mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/CLOUD1-BUG-FIX to HEAD:
42884: ALF-1059 / CLOUD-469: Post activities for folder(s) add + delete git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42891 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,13 +27,14 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
*
|
*
|
||||||
* @author sglover
|
* @author sglover
|
||||||
*/
|
*/
|
||||||
|
// TODO consolidate with ActivityPost for WebDAV
|
||||||
public interface ActivityPoster
|
public interface ActivityPoster
|
||||||
{
|
{
|
||||||
void postFileAdded(FileInfo fileInfo);
|
void postFileFolderAdded(FileInfo fileInfo);
|
||||||
|
|
||||||
void postFileUpdated(NodeRef nodeRef);
|
void postFileFolderUpdated(boolean isFolder, NodeRef nodeRef);
|
||||||
|
|
||||||
void postFileDeleted(ActivityInfo activityInfo);
|
void postFileFolderDeleted(ActivityInfo activityInfo);
|
||||||
|
|
||||||
ActivityInfo getActivityInfo(NodeRef nodeRef);
|
ActivityInfo getActivityInfo(NodeRef nodeRef);
|
||||||
}
|
}
|
||||||
|
@@ -48,6 +48,7 @@ import org.springframework.beans.factory.InitializingBean;
|
|||||||
* @see ActivityPoster
|
* @see ActivityPoster
|
||||||
* @author sglover
|
* @author sglover
|
||||||
*/
|
*/
|
||||||
|
// TODO consolidate with ActivityPost for WebDAV
|
||||||
public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||||
{
|
{
|
||||||
private static final String APP_TOOL = "CMIS";
|
private static final String APP_TOOL = "CMIS";
|
||||||
@@ -165,18 +166,37 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void postFileAdded(FileInfo fileInfo)
|
public void postFileFolderAdded(FileInfo fileInfo)
|
||||||
{
|
{
|
||||||
if(activitiesEnabled && !fileInfo.isHidden())
|
if(activitiesEnabled && !fileInfo.isHidden())
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = fileInfo.getNodeRef();
|
NodeRef nodeRef = fileInfo.getNodeRef();
|
||||||
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
||||||
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
|
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
|
||||||
|
|
||||||
if(siteId != null && !siteId.equals(""))
|
if(siteId != null && !siteId.equals(""))
|
||||||
{
|
{
|
||||||
// post only for nodes within sites
|
// post only for nodes within sites
|
||||||
NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||||
postFileActivity(ActivityType.FILE_ADDED, null, parentNodeRef, nodeRef, siteId, fileInfo.getName());
|
|
||||||
|
String path = null;
|
||||||
|
if (fileInfo.isFolder())
|
||||||
|
{
|
||||||
|
NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
|
||||||
|
path = "/";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
path = getPathFromNode(documentLibrary, nodeRef);
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException error)
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("No " + SiteService.DOCUMENT_LIBRARY + " container found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
postFileFolderActivity((fileInfo.isFolder() ? ActivityType.FOLDER_ADDED : ActivityType.FILE_ADDED), path, parentNodeRef, nodeRef, siteId, fileInfo.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +205,7 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void postFileUpdated(NodeRef nodeRef)
|
public void postFileFolderUpdated(boolean isFolder, NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
if(activitiesEnabled && hiddenAspect.getVisibility(Client.cmis, nodeRef) == Visibility.Visible)
|
if(activitiesEnabled && hiddenAspect.getVisibility(Client.cmis, nodeRef) == Visibility.Visible)
|
||||||
{
|
{
|
||||||
@@ -195,7 +215,11 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
{
|
{
|
||||||
// post only for nodes within sites
|
// post only for nodes within sites
|
||||||
String fileName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
String fileName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||||
postFileActivity(ActivityType.FILE_UPDATED, null, null, nodeRef, siteId, fileName);
|
|
||||||
|
if (!isFolder)
|
||||||
|
{
|
||||||
|
postFileFolderActivity(ActivityType.FILE_UPDATED, null, null, nodeRef, siteId, fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,24 +228,27 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void postFileDeleted(ActivityInfo activityInfo)
|
public void postFileFolderDeleted(ActivityInfo activityInfo)
|
||||||
{
|
{
|
||||||
if(activitiesEnabled && activityInfo.getSiteId() != null)
|
if(activitiesEnabled && activityInfo.getSiteId() != null)
|
||||||
{
|
{
|
||||||
// post only for nodes within sites
|
// post only for nodes within sites
|
||||||
postFileActivity(ActivityType.FILE_DELETED, activityInfo.getParentPath(), activityInfo.getParentNodeRef(), activityInfo.getNodeRef(),
|
postFileFolderActivity((activityInfo.isFolder() ? ActivityType.FOLDER_DELETED : ActivityType.FILE_DELETED), activityInfo.getParentPath(), activityInfo.getParentNodeRef(), activityInfo.getNodeRef(),
|
||||||
activityInfo.getSiteId(), activityInfo.getFileName());
|
activityInfo.getSiteId(), activityInfo.getFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActivityInfo getActivityInfo(NodeRef nodeRef)
|
public ActivityInfo getActivityInfo(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
|
||||||
String fileName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
|
||||||
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
SiteInfo siteInfo = siteService.getSite(nodeRef);
|
||||||
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
|
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
|
||||||
if(siteId != null && !siteId.equals(""))
|
if(siteId != null && !siteId.equals(""))
|
||||||
{
|
{
|
||||||
|
NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||||
|
FileInfo fileInfo = fileFolderService.getFileInfo(nodeRef);
|
||||||
|
String name = fileInfo.getName();
|
||||||
|
boolean isFolder = fileInfo.isFolder();
|
||||||
|
|
||||||
NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
|
NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
|
||||||
String parentPath = "/";
|
String parentPath = "/";
|
||||||
try
|
try
|
||||||
@@ -236,7 +263,7 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ActivityInfo(nodeRef, parentPath, parentNodeRef, siteId, fileName);
|
return new ActivityInfo(nodeRef, parentPath, parentNodeRef, siteId, name, isFolder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -244,15 +271,15 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postFileActivity(
|
private void postFileFolderActivity(
|
||||||
String activityType,
|
String activityType,
|
||||||
String parentPath,
|
String path,
|
||||||
NodeRef parentNodeRef,
|
NodeRef parentNodeRef,
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
String siteId,
|
String siteId,
|
||||||
String fileName)
|
String name)
|
||||||
{
|
{
|
||||||
JSONObject json = createActivityJSON(getCurrentTenantDomain(), parentPath, parentNodeRef, nodeRef, fileName);
|
JSONObject json = createActivityJSON(getCurrentTenantDomain(), path, parentNodeRef, nodeRef, name);
|
||||||
|
|
||||||
activityService.postActivity(
|
activityService.postActivity(
|
||||||
activityType,
|
activityType,
|
||||||
@@ -273,7 +300,7 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
*/
|
*/
|
||||||
private JSONObject createActivityJSON(
|
private JSONObject createActivityJSON(
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
String parentPath,
|
String path,
|
||||||
NodeRef parentNodeRef,
|
NodeRef parentNodeRef,
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
String fileName)
|
String fileName)
|
||||||
@@ -289,10 +316,10 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
json.put("parentNodeRef", parentNodeRef);
|
json.put("parentNodeRef", parentNodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentPath != null)
|
if (path != null)
|
||||||
{
|
{
|
||||||
// Used for deleted files.
|
// Used for deleted files and folders (added or deleted)
|
||||||
json.put("page", "documentlibrary?path=" + parentPath);
|
json.put("page", "documentlibrary?path=" + path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -322,9 +349,10 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
private NodeRef parentNodeRef;
|
private NodeRef parentNodeRef;
|
||||||
private String siteId;
|
private String siteId;
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
private boolean isFolder;
|
||||||
|
|
||||||
public ActivityInfo(NodeRef nodeRef, String parentPath, NodeRef parentNodeRef,
|
public ActivityInfo(NodeRef nodeRef, String parentPath, NodeRef parentNodeRef,
|
||||||
String siteId, String fileName)
|
String siteId, String fileName, boolean isFolder)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.nodeRef = nodeRef;
|
this.nodeRef = nodeRef;
|
||||||
@@ -332,6 +360,7 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
this.parentNodeRef = parentNodeRef;
|
this.parentNodeRef = parentNodeRef;
|
||||||
this.siteId = siteId;
|
this.siteId = siteId;
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
|
this.isFolder = isFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeRef getNodeRef()
|
public NodeRef getNodeRef()
|
||||||
@@ -358,5 +387,10 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
|||||||
{
|
{
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFolder()
|
||||||
|
{
|
||||||
|
return isFolder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1085,13 +1085,17 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
connector.checkChildObjectType(parentInfo, type.getTypeId());
|
connector.checkChildObjectType(parentInfo, type.getTypeId());
|
||||||
|
|
||||||
// run transaction
|
// run transaction
|
||||||
NodeRef nodeRef = connector.getFileFolderService().create(
|
FileInfo fileInfo = connector.getFileFolderService().create(
|
||||||
parentInfo.getNodeRef(), name, type.getAlfrescoClass()).getNodeRef();
|
parentInfo.getNodeRef(), name, type.getAlfrescoClass());
|
||||||
|
NodeRef nodeRef = fileInfo.getNodeRef();
|
||||||
|
|
||||||
|
|
||||||
connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
|
connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
|
||||||
connector.applyPolicies(nodeRef, type, policies);
|
connector.applyPolicies(nodeRef, type, policies);
|
||||||
connector.applyACL(nodeRef, type, addAces, removeAces);
|
connector.applyACL(nodeRef, type, addAces, removeAces);
|
||||||
|
|
||||||
|
connector.getActivityPoster().postFileFolderAdded(fileInfo);
|
||||||
|
|
||||||
return nodeRef.toString();
|
return nodeRef.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1175,7 +1179,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
|
|
||||||
String objectId = connector.createObjectId(nodeRef);
|
String objectId = connector.createObjectId(nodeRef);
|
||||||
|
|
||||||
connector.getActivityPoster().postFileAdded(fileInfo);
|
connector.getActivityPoster().postFileFolderAdded(fileInfo);
|
||||||
|
|
||||||
return objectId;
|
return objectId;
|
||||||
}
|
}
|
||||||
@@ -1223,7 +1227,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
connector.applyACL(nodeRef, type, addAces, removeAces);
|
connector.applyACL(nodeRef, type, addAces, removeAces);
|
||||||
connector.applyVersioningState(nodeRef, versioningState);
|
connector.applyVersioningState(nodeRef, versioningState);
|
||||||
|
|
||||||
connector.getActivityPoster().postFileAdded(fileInfo);
|
connector.getActivityPoster().postFileFolderAdded(fileInfo);
|
||||||
|
|
||||||
return connector.createObjectId(nodeRef);
|
return connector.createObjectId(nodeRef);
|
||||||
}
|
}
|
||||||
@@ -1369,7 +1373,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
|
|
||||||
objectId.setValue(connector.createObjectId(nodeRef));
|
objectId.setValue(connector.createObjectId(nodeRef));
|
||||||
|
|
||||||
connector.getActivityPoster().postFileUpdated(nodeRef);
|
connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1395,7 +1399,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
|
|
||||||
connector.getNodeService().setProperty(nodeRef, ContentModel.PROP_CONTENT, null);
|
connector.getNodeService().setProperty(nodeRef, ContentModel.PROP_CONTENT, null);
|
||||||
|
|
||||||
connector.getActivityPoster().postFileUpdated(nodeRef);
|
connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
|
||||||
|
|
||||||
objectId.setValue(connector.createObjectId(nodeRef));
|
objectId.setValue(connector.createObjectId(nodeRef));
|
||||||
}
|
}
|
||||||
@@ -1480,7 +1484,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
|||||||
getObjectInfo(repositoryId, objectId.getValue(), "*", IncludeRelationships.NONE);
|
getObjectInfo(repositoryId, objectId.getValue(), "*", IncludeRelationships.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
connector.getActivityPoster().postFileUpdated(nodeRef);
|
connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -754,7 +754,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
|||||||
// post activity after removal of the node
|
// post activity after removal of the node
|
||||||
if(postActivity && activityInfo != null)
|
if(postActivity && activityInfo != null)
|
||||||
{
|
{
|
||||||
activityPoster.postFileDeleted(activityInfo);
|
activityPoster.postFileFolderDeleted(activityInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,4 +42,13 @@ public interface ActivityType
|
|||||||
public static final String FILES_ADDED = "org.alfresco.documentlibrary.files-added";
|
public static final String FILES_ADDED = "org.alfresco.documentlibrary.files-added";
|
||||||
public static final String FILES_UPDATED = "org.alfresco.documentlibrary.files-updated";
|
public static final String FILES_UPDATED = "org.alfresco.documentlibrary.files-updated";
|
||||||
public static final String FILES_DELETED = "org.alfresco.documentlibrary.files-deleted";
|
public static final String FILES_DELETED = "org.alfresco.documentlibrary.files-deleted";
|
||||||
|
|
||||||
|
public static final String FOLDER_ADDED = "org.alfresco.documentlibrary.folder-added";
|
||||||
|
public static final String FOLDER_DELETED = "org.alfresco.documentlibrary.folder-deleted";
|
||||||
|
|
||||||
|
public static final String FOLDERS_ADDED = "org.alfresco.documentlibrary.folders-added";
|
||||||
|
public static final String FOLDERS_DELETED = "org.alfresco.documentlibrary.folders-deleted";
|
||||||
|
|
||||||
|
public static final String FILE_LIKED = "org.alfresco.documentlibrary.file-liked";
|
||||||
|
public static final String FOLDER_LIKED = "org.alfresco.documentlibrary.folder-liked";
|
||||||
}
|
}
|
||||||
|
@@ -153,6 +153,9 @@ public class PostLookup
|
|||||||
rollupTypes.put(ActivityType.FILE_ADDED, ActivityType.FILES_ADDED);
|
rollupTypes.put(ActivityType.FILE_ADDED, ActivityType.FILES_ADDED);
|
||||||
rollupTypes.put(ActivityType.FILE_UPDATED, ActivityType.FILES_UPDATED);
|
rollupTypes.put(ActivityType.FILE_UPDATED, ActivityType.FILES_UPDATED);
|
||||||
rollupTypes.put(ActivityType.FILE_DELETED, ActivityType.FILES_DELETED);
|
rollupTypes.put(ActivityType.FILE_DELETED, ActivityType.FILES_DELETED);
|
||||||
|
|
||||||
|
rollupTypes.put(ActivityType.FOLDER_ADDED, ActivityType.FOLDERS_ADDED);
|
||||||
|
rollupTypes.put(ActivityType.FOLDER_DELETED, ActivityType.FOLDERS_DELETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute() throws JobExecutionException
|
public void execute() throws JobExecutionException
|
||||||
|
Reference in New Issue
Block a user