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:
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:
@@ -78,6 +78,7 @@ function postActivity()
|
|||||||
|
|
||||||
switch (String(type).toLowerCase())
|
switch (String(type).toLowerCase())
|
||||||
{
|
{
|
||||||
|
case "file-created":
|
||||||
case "file-added":
|
case "file-added":
|
||||||
case "file-updated":
|
case "file-updated":
|
||||||
case "file-liked":
|
case "file-liked":
|
||||||
@@ -93,6 +94,7 @@ function postActivity()
|
|||||||
case "files-added":
|
case "files-added":
|
||||||
case "files-deleted":
|
case "files-deleted":
|
||||||
case "files-updated":
|
case "files-updated":
|
||||||
|
case "folders-deleted":
|
||||||
data.title = json.get("fileCount");
|
data.title = json.get("fileCount");
|
||||||
strParams = "?path=" + json.get("path");
|
strParams = "?path=" + json.get("path");
|
||||||
if (parentNodeRef != null)
|
if (parentNodeRef != null)
|
||||||
@@ -102,6 +104,8 @@ function postActivity()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "file-deleted":
|
case "file-deleted":
|
||||||
|
case "folder-added":
|
||||||
|
case "folder-deleted":
|
||||||
data.title = json.get("fileName");
|
data.title = json.get("fileName");
|
||||||
data.nodeRef = nodeRef;
|
data.nodeRef = nodeRef;
|
||||||
strParams = "?path=" + json.get("path");
|
strParams = "?path=" + json.get("path");
|
||||||
|
@@ -25,19 +25,21 @@ import org.alfresco.service.cmr.model.FileInfo;
|
|||||||
*
|
*
|
||||||
* @author Matt Ward
|
* @author Matt Ward
|
||||||
*/
|
*/
|
||||||
|
// TODO consolidate with ActivityPost for OpenCMIS
|
||||||
public interface ActivityPoster
|
public interface ActivityPoster
|
||||||
{
|
{
|
||||||
void postFileAdded(
|
void postFileFolderAdded(
|
||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException;
|
String path,
|
||||||
|
FileInfo nodeInfo) throws WebDAVServerException;
|
||||||
|
|
||||||
void postFileUpdated(
|
void postFileFolderUpdated(
|
||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException;
|
FileInfo nodeInfo) throws WebDAVServerException;
|
||||||
|
|
||||||
void postFileDeleted(
|
void postFileFolderDeleted(
|
||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
String parentPath,
|
String parentPath,
|
||||||
|
@@ -34,6 +34,7 @@ import org.json.JSONObject;
|
|||||||
* @see ActivityPoster
|
* @see ActivityPoster
|
||||||
* @author Matt Ward
|
* @author Matt Ward
|
||||||
*/
|
*/
|
||||||
|
// TODO consolidate with ActivityPost for OpenCMIS
|
||||||
public class ActivityPosterImpl implements ActivityPoster
|
public class ActivityPosterImpl implements ActivityPoster
|
||||||
{
|
{
|
||||||
private String appTool;
|
private String appTool;
|
||||||
@@ -66,53 +67,57 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void postFileAdded(
|
public void postFileFolderAdded(
|
||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException
|
String path,
|
||||||
|
FileInfo nodeInfo) throws WebDAVServerException
|
||||||
{
|
{
|
||||||
postFileActivity(ActivityType.FILE_ADDED, siteId, tenantDomain, null, null, contentNodeInfo);
|
postFileFolderActivity(nodeInfo.isFolder() ? ActivityType.FOLDER_ADDED : ActivityType.FILE_ADDED, siteId, tenantDomain, path, null, nodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void postFileUpdated(
|
public void postFileFolderUpdated(
|
||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException
|
FileInfo nodeInfo) throws WebDAVServerException
|
||||||
{
|
{
|
||||||
postFileActivity(ActivityType.FILE_UPDATED, siteId, tenantDomain, null, null, contentNodeInfo);
|
if (! nodeInfo.isFolder())
|
||||||
|
{
|
||||||
|
postFileFolderActivity(ActivityType.FILE_UPDATED, siteId, tenantDomain, null, null, nodeInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void postFileDeleted(
|
public void postFileFolderDeleted(
|
||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
String parentPath,
|
String parentPath,
|
||||||
FileInfo parentNodeInfo,
|
FileInfo parentNodeInfo,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException
|
FileInfo nodeInfo) throws WebDAVServerException
|
||||||
{
|
{
|
||||||
postFileActivity(ActivityType.FILE_DELETED, siteId, tenantDomain, parentPath, parentNodeInfo.getNodeRef(), contentNodeInfo);
|
postFileFolderActivity(nodeInfo.isFolder() ? ActivityType.FOLDER_DELETED : ActivityType.FILE_DELETED, siteId, tenantDomain, parentPath, parentNodeInfo.getNodeRef(), nodeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void postFileActivity(
|
private void postFileFolderActivity(
|
||||||
String activityType,
|
String activityType,
|
||||||
String siteId,
|
String siteId,
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
String parentPath,
|
String path,
|
||||||
NodeRef parentNodeRef,
|
NodeRef parentNodeRef,
|
||||||
FileInfo contentNodeInfo) throws WebDAVServerException
|
FileInfo contentNodeInfo) throws WebDAVServerException
|
||||||
{
|
{
|
||||||
String fileName = contentNodeInfo.getName();
|
String fileName = contentNodeInfo.getName();
|
||||||
NodeRef nodeRef = contentNodeInfo.getNodeRef();
|
NodeRef nodeRef = contentNodeInfo.getNodeRef();
|
||||||
|
|
||||||
JSONObject json = createActivityJSON(tenantDomain, parentPath, parentNodeRef, nodeRef, fileName);
|
JSONObject json = createActivityJSON(tenantDomain, path, parentNodeRef, nodeRef, fileName);
|
||||||
|
|
||||||
activityService.postActivity(
|
activityService.postActivity(
|
||||||
activityType,
|
activityType,
|
||||||
@@ -133,7 +138,7 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
*/
|
*/
|
||||||
private JSONObject createActivityJSON(
|
private JSONObject createActivityJSON(
|
||||||
String tenantDomain,
|
String tenantDomain,
|
||||||
String parentPath,
|
String path,
|
||||||
NodeRef parentNodeRef,
|
NodeRef parentNodeRef,
|
||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
String fileName) throws WebDAVServerException
|
String fileName) throws WebDAVServerException
|
||||||
@@ -149,10 +154,10 @@ public class ActivityPosterImpl implements ActivityPoster
|
|||||||
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
|
||||||
{
|
{
|
||||||
|
@@ -108,14 +108,14 @@ public class DeleteMethod extends WebDAVMethod implements ActivityPostProducer
|
|||||||
String siteId = getSiteId();
|
String siteId = getSiteId();
|
||||||
NodeRef deletedNodeRef = fileInfo.getNodeRef();
|
NodeRef deletedNodeRef = fileInfo.getNodeRef();
|
||||||
FileInfo parentFile = getDAVHelper().getParentNodeForPath(getRootNodeRef(), getPath(), getServletPath());
|
FileInfo parentFile = getDAVHelper().getParentNodeForPath(getRootNodeRef(), getPath(), getServletPath());
|
||||||
boolean hidden = getNodeService().hasAspect(deletedNodeRef, ContentModel.ASPECT_HIDDEN);
|
boolean hidden = fileInfo.isHidden();
|
||||||
// Delete it
|
// Delete it
|
||||||
fileFolderService.delete(deletedNodeRef);
|
fileFolderService.delete(deletedNodeRef);
|
||||||
// Don't post activity data for hidden files, resource forks etc.
|
// Don't post activity data for hidden files, resource forks etc.
|
||||||
if (!hidden)
|
if (!hidden)
|
||||||
{
|
{
|
||||||
postActivity(parentFile, fileInfo, siteId);
|
postActivity(parentFile, fileInfo, siteId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ public class DeleteMethod extends WebDAVMethod implements ActivityPostProducer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activityPoster.postFileDeleted(siteId, tenantDomain, parentPath, parent, deletedFile);
|
activityPoster.postFileFolderDeleted(siteId, tenantDomain, parentPath, parent, deletedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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
|
||||||
*
|
*
|
||||||
@@ -25,14 +25,18 @@ import org.alfresco.service.cmr.model.FileFolderService;
|
|||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
|
import org.alfresco.service.cmr.webdav.WebDavService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the WebDAV MKCOL method
|
* Implements the WebDAV MKCOL method
|
||||||
*
|
*
|
||||||
* @author gavinc
|
* @author gavinc
|
||||||
*/
|
*/
|
||||||
public class MkcolMethod extends WebDAVMethod
|
public class MkcolMethod extends WebDAVMethod implements ActivityPostProducer
|
||||||
{
|
{
|
||||||
|
private ActivityPoster activityPoster;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
@@ -124,9 +128,60 @@ public class MkcolMethod extends WebDAVMethod
|
|||||||
String folderName = getPath().substring(lastPos + 1);
|
String folderName = getPath().substring(lastPos + 1);
|
||||||
|
|
||||||
// Create the new folder node
|
// Create the new folder node
|
||||||
fileFolderService.create(parentNodeRef, folderName, ContentModel.TYPE_FOLDER);
|
FileInfo fileInfo = fileFolderService.create(parentNodeRef, folderName, ContentModel.TYPE_FOLDER);
|
||||||
|
|
||||||
|
// Don't post activity data for hidden folder
|
||||||
|
if (!fileInfo.isHidden())
|
||||||
|
{
|
||||||
|
postActivity(fileInfo);
|
||||||
|
}
|
||||||
|
|
||||||
// Return a success status
|
// Return a success status
|
||||||
m_response.setStatus(HttpServletResponse.SC_CREATED);
|
m_response.setStatus(HttpServletResponse.SC_CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a folder added activity post.
|
||||||
|
*
|
||||||
|
* @throws WebDAVServerException
|
||||||
|
*/
|
||||||
|
private void postActivity(FileInfo fileInfo) throws WebDAVServerException
|
||||||
|
{
|
||||||
|
WebDavService davService = getDAVHelper().getServiceRegistry().getWebDavService();
|
||||||
|
if (!davService.activitiesEnabled())
|
||||||
|
{
|
||||||
|
// Don't post activities if this behaviour is disabled.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String siteId = getSiteId();
|
||||||
|
String tenantDomain = getTenantDomain();
|
||||||
|
|
||||||
|
// Check there is enough information to publish site activity.
|
||||||
|
if (!siteId.equals(WebDAVHelper.EMPTY_SITE_ID))
|
||||||
|
{
|
||||||
|
SiteService siteService = getServiceRegistry().getSiteService();
|
||||||
|
NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
|
||||||
|
String path = "/";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
path = getDAVHelper().getPathFromNode(documentLibrary, fileInfo.getNodeRef());
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException error)
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("No " + SiteService.DOCUMENT_LIBRARY + " container found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
activityPoster.postFileFolderAdded(siteId, tenantDomain, path, fileInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setActivityPoster(ActivityPoster activityPoster)
|
||||||
|
{
|
||||||
|
this.activityPoster = activityPoster;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -363,12 +363,14 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
|
|||||||
if (!getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN))
|
if (!getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN))
|
||||||
{
|
{
|
||||||
if (isCreated())
|
if (isCreated())
|
||||||
{
|
{
|
||||||
activityPoster.postFileAdded(siteId, tenantDomain, contentNodeInfo);
|
// file added
|
||||||
|
activityPoster.postFileFolderAdded(siteId, tenantDomain, null, contentNodeInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
activityPoster.postFileUpdated(siteId, tenantDomain, contentNodeInfo);
|
// file updated
|
||||||
|
activityPoster.postFileFolderUpdated(siteId, tenantDomain, contentNodeInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user