mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged BRANCHES/DEV/CLOUD1-BUG-FIX to HEAD:
42432: CLOUD-795: Optimise activities feed: rollup multiple (WebDAV) document adds/deletes into a single activity git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42563 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -41,5 +41,6 @@ public interface ActivityPoster
|
|||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
String parentPath,
|
String parentPath,
|
||||||
|
FileInfo parentNodeInfo,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException;
|
FileInfo contentNodeInfo) throws WebDAVServerException;
|
||||||
}
|
}
|
||||||
|
@@ -20,15 +20,11 @@ package org.alfresco.repo.webdav;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.repo.activities.ActivityType;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.activities.ActivityService;
|
import org.alfresco.service.cmr.activities.ActivityService;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
|
||||||
import org.alfresco.util.Pair;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -40,13 +36,8 @@ import org.json.JSONObject;
|
|||||||
*/
|
*/
|
||||||
public class ActivityPosterImpl implements ActivityPoster
|
public class ActivityPosterImpl implements ActivityPoster
|
||||||
{
|
{
|
||||||
private static final String FILE_ADDED = "org.alfresco.documentlibrary.file-added";
|
|
||||||
private static final String FILE_UPDATED = "org.alfresco.documentlibrary.file-updated";
|
|
||||||
private static final String FILE_DELETED = "org.alfresco.documentlibrary.file-deleted";
|
|
||||||
private String appTool;
|
private String appTool;
|
||||||
private ActivityService activityService;
|
private ActivityService activityService;
|
||||||
private NodeService nodeService;
|
|
||||||
private PersonService personService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,12 +55,10 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
* @param nodeService
|
* @param nodeService
|
||||||
* @param personService
|
* @param personService
|
||||||
*/
|
*/
|
||||||
public ActivityPosterImpl(String appTool, ActivityService activityService, NodeService nodeService, PersonService personService)
|
public ActivityPosterImpl(String appTool, ActivityService activityService)
|
||||||
{
|
{
|
||||||
this.appTool = appTool;
|
this.appTool = appTool;
|
||||||
this.activityService = activityService;
|
this.activityService = activityService;
|
||||||
this.nodeService = nodeService;
|
|
||||||
this.personService = personService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,7 +71,7 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException
|
FileInfo contentNodeInfo) throws WebDAVServerException
|
||||||
{
|
{
|
||||||
postFileActivity(FILE_ADDED, siteId, tenantDomain, null, contentNodeInfo);
|
postFileActivity(ActivityType.FILE_ADDED, siteId, tenantDomain, null, null, contentNodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,7 +83,7 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException
|
FileInfo contentNodeInfo) throws WebDAVServerException
|
||||||
{
|
{
|
||||||
postFileActivity(FILE_UPDATED, siteId, tenantDomain, null, contentNodeInfo);
|
postFileActivity(ActivityType.FILE_UPDATED, siteId, tenantDomain, null, null, contentNodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,9 +94,10 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
String parentPath,
|
String parentPath,
|
||||||
|
FileInfo parentNodeInfo,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException
|
FileInfo contentNodeInfo) throws WebDAVServerException
|
||||||
{
|
{
|
||||||
postFileActivity(FILE_DELETED, siteId, tenantDomain, parentPath, contentNodeInfo);
|
postFileActivity(ActivityType.FILE_DELETED, siteId, tenantDomain, parentPath, parentNodeInfo.getNodeRef(), contentNodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -116,14 +106,13 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
String parentPath,
|
String parentPath,
|
||||||
|
NodeRef parentNodeRef,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException
|
FileInfo contentNodeInfo) throws WebDAVServerException
|
||||||
{
|
{
|
||||||
Pair<String, String> personName = getPersonName();
|
String fileName = contentNodeInfo.getName();
|
||||||
final String firstName = personName.getFirst();
|
NodeRef nodeRef = contentNodeInfo.getNodeRef();
|
||||||
final String lastName = personName.getSecond();
|
|
||||||
final String fileName = contentNodeInfo.getName();
|
JSONObject json = createActivityJSON(tenantDomain, parentPath, parentNodeRef, nodeRef, fileName);
|
||||||
final NodeRef nodeRef = contentNodeInfo.getNodeRef();
|
|
||||||
JSONObject json = createActivityJSON(tenantDomain, parentPath, nodeRef, firstName, lastName, fileName);
|
|
||||||
|
|
||||||
activityService.postActivity(
|
activityService.postActivity(
|
||||||
activityType,
|
activityType,
|
||||||
@@ -138,8 +127,6 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
*
|
*
|
||||||
* @param tenantDomain
|
* @param tenantDomain
|
||||||
* @param nodeRef
|
* @param nodeRef
|
||||||
* @param firstName
|
|
||||||
* @param lastName
|
|
||||||
* @param fileName
|
* @param fileName
|
||||||
* @throws WebDAVServerException
|
* @throws WebDAVServerException
|
||||||
* @return JSONObject
|
* @return JSONObject
|
||||||
@@ -147,15 +134,21 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
private JSONObject createActivityJSON(
|
private JSONObject createActivityJSON(
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
String parentPath,
|
String parentPath,
|
||||||
|
NodeRef parentNodeRef,
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
String firstName,
|
|
||||||
String lastName,
|
|
||||||
String fileName) throws WebDAVServerException
|
String fileName) throws WebDAVServerException
|
||||||
{
|
{
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
json.put("nodeRef", nodeRef);
|
json.put("nodeRef", nodeRef);
|
||||||
|
|
||||||
|
if (parentNodeRef != null)
|
||||||
|
{
|
||||||
|
// Used for deleted files.
|
||||||
|
json.put("parentNodeRef", parentNodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
if (parentPath != null)
|
if (parentPath != null)
|
||||||
{
|
{
|
||||||
// Used for deleted files.
|
// Used for deleted files.
|
||||||
@@ -167,8 +160,7 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
json.put("page", "document-details?nodeRef=" + nodeRef);
|
json.put("page", "document-details?nodeRef=" + nodeRef);
|
||||||
}
|
}
|
||||||
json.put("title", fileName);
|
json.put("title", fileName);
|
||||||
json.put("firstName", firstName);
|
|
||||||
json.put("lastName", lastName);
|
|
||||||
if (!tenantDomain.equals(TenantService.DEFAULT_DOMAIN))
|
if (!tenantDomain.equals(TenantService.DEFAULT_DOMAIN))
|
||||||
{
|
{
|
||||||
// Only used in multi-tenant setups.
|
// Only used in multi-tenant setups.
|
||||||
@@ -183,26 +175,6 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the tuple (firstName, lastName) for the current user.
|
|
||||||
*
|
|
||||||
* @return Pair<String, String>
|
|
||||||
*/
|
|
||||||
private Pair<String, String> getPersonName()
|
|
||||||
{
|
|
||||||
String firstName = "";
|
|
||||||
String lastName = "";
|
|
||||||
String userName = AuthenticationUtil.getFullyAuthenticatedUser();
|
|
||||||
NodeRef person = personService.getPerson(userName);
|
|
||||||
if (person != null)
|
|
||||||
{
|
|
||||||
firstName = (String) nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME);
|
|
||||||
lastName = (String) nodeService.getProperty(person, ContentModel.PROP_LASTNAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Pair<String, String>(firstName, lastName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAppTool(String appTool)
|
public void setAppTool(String appTool)
|
||||||
{
|
{
|
||||||
this.appTool = appTool;
|
this.appTool = appTool;
|
||||||
@@ -212,14 +184,4 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
{
|
{
|
||||||
this.activityService = activityService;
|
this.activityService = activityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNodeService(NodeService nodeService)
|
|
||||||
{
|
|
||||||
this.nodeService = nodeService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPersonService(PersonService personService)
|
|
||||||
{
|
|
||||||
this.personService = personService;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -156,7 +156,7 @@ public class DeleteMethod extends WebDAVMethod implements ActivityPostProducer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activityPoster.postFileDeleted(siteId, tenantDomain, parentPath, deletedFile);
|
activityPoster.postFileDeleted(siteId, tenantDomain, parentPath, parent, deletedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -42,7 +42,6 @@ import org.alfresco.service.cmr.repository.NodeService;
|
|||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.FileFilterMode;
|
import org.alfresco.util.FileFilterMode;
|
||||||
@@ -317,11 +316,10 @@ public class WebDAVServlet extends HttpServlet
|
|||||||
searchService = (SearchService) context.getBean("SearchService");
|
searchService = (SearchService) context.getBean("SearchService");
|
||||||
namespaceService = (NamespaceService) context.getBean("NamespaceService");
|
namespaceService = (NamespaceService) context.getBean("NamespaceService");
|
||||||
ActivityService activityService = (ActivityService) context.getBean("activityService");
|
ActivityService activityService = (ActivityService) context.getBean("activityService");
|
||||||
PersonService personService = serviceRegistry.getPersonService();
|
|
||||||
singletonCache = (SimpleCache<String, NodeRef>)context.getBean("immutableSingletonCache");
|
singletonCache = (SimpleCache<String, NodeRef>)context.getBean("immutableSingletonCache");
|
||||||
|
|
||||||
// Collaborator used by WebDAV methods to create activity posts.
|
// Collaborator used by WebDAV methods to create activity posts.
|
||||||
activityPoster = new ActivityPosterImpl("WebDAV", activityService, nodeService, personService);
|
activityPoster = new ActivityPosterImpl("WebDAV", activityService);
|
||||||
|
|
||||||
// Create the WebDAV helper
|
// Create the WebDAV helper
|
||||||
m_davHelper = (WebDAVHelper) context.getBean("webDAVHelper");
|
m_davHelper = (WebDAVHelper) context.getBean("webDAVHelper");
|
||||||
|
Reference in New Issue
Block a user