mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
82375: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 76480: Re-worked download activity posting following Kev's changes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@83218 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,4 +25,17 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="activitiesPoster" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
||||
<property name="sourceApplicationContextFactory">
|
||||
<ref bean="ActivitiesFeed"/>
|
||||
</property>
|
||||
<property name="sourceBeanName">
|
||||
<value>ffActivitiesPoster</value>
|
||||
</property>
|
||||
<property name="interfaces">
|
||||
<list>
|
||||
<value>org.alfresco.service.cmr.activities.ActivityPoster</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
|
@@ -115,7 +115,7 @@
|
||||
</bean>
|
||||
|
||||
<bean id="cmisActivityPoster" class="org.alfresco.opencmis.ActivityPosterImpl">
|
||||
<property name="activityService" ref="activityService" />
|
||||
<property name="poster" ref="activitiesPoster" />
|
||||
<property name="siteService" ref="SiteService" />
|
||||
<property name="tenantService" ref="tenantService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
|
@@ -26,6 +26,10 @@
|
||||
<property name="maxFeedItems" value="${activities.feed.max.size}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="ffActivitiesPoster" class="org.alfresco.service.cmr.activities.FileFolderActivityPosterImpl">
|
||||
<property name="activityService" ref="activityService" />
|
||||
</bean>
|
||||
|
||||
<!-- cleans out-of-date feed entries -->
|
||||
<bean id="feedCleaner" class="org.alfresco.repo.activities.feed.cleanup.FeedCleaner" init-method="init">
|
||||
<property name="feedDAO" ref="feedDAO"/>
|
||||
|
@@ -20,14 +20,13 @@ package org.alfresco.opencmis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.Client;
|
||||
import org.alfresco.repo.Client.ClientType;
|
||||
import org.alfresco.repo.activities.ActivityType;
|
||||
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.activities.ActivityService;
|
||||
import org.alfresco.service.cmr.activities.ActivityPoster;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileFolderServiceType;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
@@ -40,26 +39,23 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* OpenCMIS methods may use an instance of this class to post activity data.
|
||||
*
|
||||
* @see ActivityPoster
|
||||
* @see CmisActivityPoster
|
||||
* @author sglover
|
||||
*/
|
||||
// TODO consolidate with ActivityPost for WebDAV
|
||||
public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||
public class ActivityPosterImpl implements CmisActivityPoster, InitializingBean
|
||||
{
|
||||
private static final String APP_TOOL = "CMIS";
|
||||
public static final char PathSeperatorChar = '/';
|
||||
|
||||
// Logging
|
||||
private static Log logger = LogFactory.getLog(ActivityPoster.class);
|
||||
private static Log logger = LogFactory.getLog(CmisActivityPoster.class);
|
||||
|
||||
private ActivityService activityService;
|
||||
private ActivityPoster poster;
|
||||
private SiteService siteService;
|
||||
private TenantService tenantService;
|
||||
private NodeService nodeService;
|
||||
@@ -100,16 +96,16 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setActivityService(ActivityService activityService)
|
||||
{
|
||||
this.activityService = activityService;
|
||||
}
|
||||
|
||||
public void setActivitiesEnabled(boolean activitiesEnabled)
|
||||
{
|
||||
this.activitiesEnabled = activitiesEnabled;
|
||||
}
|
||||
|
||||
public void setPoster(ActivityPoster poster)
|
||||
{
|
||||
this.poster = poster;
|
||||
}
|
||||
|
||||
private final String getPathFromNode(NodeRef rootNodeRef, NodeRef nodeRef) throws FileNotFoundException
|
||||
{
|
||||
// Check if the nodes are valid, or equal
|
||||
@@ -147,7 +143,7 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
PropertyCheck.mandatory(this, "activityService", activityService);
|
||||
PropertyCheck.mandatory(this, "poster", poster);
|
||||
PropertyCheck.mandatory(this, "siteService", siteService);
|
||||
PropertyCheck.mandatory(this, "tenantService", tenantService);
|
||||
PropertyCheck.mandatory(this, "nodeService", nodeService);
|
||||
@@ -209,7 +205,9 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||
}
|
||||
}
|
||||
FileInfo fileInfo = fileFolderService.getFileInfo(nodeRef);
|
||||
postFileFolderActivity((isFolder ? ActivityType.FOLDER_ADDED : ActivityType.FILE_ADDED), path, parentNodeRef, nodeRef, siteId, name, fileInfo);
|
||||
poster.postFileFolderActivity((isFolder ? ActivityType.FOLDER_ADDED : ActivityType.FILE_ADDED), path, getCurrentTenantDomain(),
|
||||
siteId, parentNodeRef, nodeRef, name, APP_TOOL, Client.asType(ClientType.cmis), fileInfo);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,7 +230,8 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||
if (!isFolder)
|
||||
{
|
||||
FileInfo fileInfo = fileFolderService.getFileInfo(nodeRef);
|
||||
postFileFolderActivity(ActivityType.FILE_UPDATED, null, null, nodeRef, siteId, fileName, fileInfo);
|
||||
poster.postFileFolderActivity(ActivityType.FILE_UPDATED, null, getCurrentTenantDomain(),
|
||||
siteId, null, nodeRef, fileName, APP_TOOL, Client.asType(ClientType.cmis), fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,9 +245,8 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||
{
|
||||
if(activitiesEnabled && activityInfo.getSiteId() != null)
|
||||
{
|
||||
// post only for nodes within sites
|
||||
postFileFolderActivity((activityInfo.isFolder() ? ActivityType.FOLDER_DELETED : ActivityType.FILE_DELETED), activityInfo.getParentPath(), activityInfo.getParentNodeRef(), activityInfo.getNodeRef(),
|
||||
activityInfo.getSiteId(), activityInfo.getFileName(), null);
|
||||
poster.postFileFolderActivity((activityInfo.isFolder() ? ActivityType.FOLDER_DELETED : ActivityType.FILE_DELETED), activityInfo.getParentPath(), getCurrentTenantDomain(),
|
||||
activityInfo.getSiteId(), activityInfo.getParentNodeRef(), activityInfo.getNodeRef(), activityInfo.getFileName(), APP_TOOL, Client.asType(ClientType.cmis), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,80 +283,6 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||
}
|
||||
}
|
||||
|
||||
private void postFileFolderActivity(
|
||||
String activityType,
|
||||
String path,
|
||||
NodeRef parentNodeRef,
|
||||
NodeRef nodeRef,
|
||||
String siteId,
|
||||
String name,
|
||||
FileInfo fileInfo)
|
||||
{
|
||||
JSONObject json = createActivityJSON(getCurrentTenantDomain(), path, parentNodeRef, nodeRef, name);
|
||||
|
||||
activityService.postActivity(
|
||||
activityType,
|
||||
siteId,
|
||||
APP_TOOL,
|
||||
json.toString(),
|
||||
Client.asType(ClientType.cmis),
|
||||
fileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create JSON suitable for create, modify or delete activity posts. Returns a new JSONObject
|
||||
* containing appropriate key/value pairs.
|
||||
*
|
||||
* @param tenantDomain
|
||||
* @param nodeRef
|
||||
* @param fileName
|
||||
* @throws WebDAVServerException
|
||||
* @return JSONObject
|
||||
*/
|
||||
private JSONObject createActivityJSON(
|
||||
String tenantDomain,
|
||||
String path,
|
||||
NodeRef parentNodeRef,
|
||||
NodeRef nodeRef,
|
||||
String fileName)
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
try
|
||||
{
|
||||
json.put("nodeRef", nodeRef);
|
||||
|
||||
if (parentNodeRef != null)
|
||||
{
|
||||
// Used for deleted files.
|
||||
json.put("parentNodeRef", parentNodeRef);
|
||||
}
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
// Used for deleted files and folders (added or deleted)
|
||||
json.put("page", "documentlibrary?path=" + path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Used for added or modified files.
|
||||
json.put("page", "document-details?nodeRef=" + nodeRef);
|
||||
}
|
||||
json.put("title", fileName);
|
||||
|
||||
if (!tenantDomain.equals(TenantService.DEFAULT_DOMAIN))
|
||||
{
|
||||
// Only used in multi-tenant setups.
|
||||
json.put("tenantDomain", tenantDomain);
|
||||
}
|
||||
}
|
||||
catch (JSONException error)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("", error);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public static class ActivityInfo
|
||||
{
|
||||
private NodeRef nodeRef;
|
||||
|
@@ -321,7 +321,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private EventPublisher eventPublisher;
|
||||
|
||||
private ActivityPoster activityPoster;
|
||||
private CmisActivityPoster activityPoster;
|
||||
|
||||
private BehaviourFilter behaviourFilter;
|
||||
|
||||
@@ -376,12 +376,12 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
public void setActivityPoster(ActivityPoster activityPoster)
|
||||
public void setActivityPoster(CmisActivityPoster activityPoster)
|
||||
{
|
||||
this.activityPoster = activityPoster;
|
||||
}
|
||||
|
||||
public ActivityPoster getActivityPoster()
|
||||
public CmisActivityPoster getActivityPoster()
|
||||
{
|
||||
return activityPoster;
|
||||
}
|
||||
|
@@ -26,8 +26,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
*
|
||||
* @author sglover
|
||||
*/
|
||||
// TODO consolidate with ActivityPost for WebDAV
|
||||
public interface ActivityPoster
|
||||
public interface CmisActivityPoster
|
||||
{
|
||||
void postFileFolderAdded(NodeRef nodeRef);
|
||||
|
@@ -0,0 +1,33 @@
|
||||
package org.alfresco.service.cmr.activities;
|
||||
|
||||
import org.alfresco.repo.Client;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* A consolidated services for posting file folder activities.
|
||||
*
|
||||
* @author Gethin James
|
||||
*/
|
||||
public interface ActivityPoster
|
||||
{
|
||||
|
||||
public static final String DOWNLOADED = "org.alfresco.documentlibrary.file-downloaded";
|
||||
/**
|
||||
* Posts file folder activity.
|
||||
* @param activityType required
|
||||
* @param path optional
|
||||
* @param tenantDomain optional
|
||||
* @param siteId required
|
||||
* @param parentNodeRef optional
|
||||
* @param nodeRef required
|
||||
* @param fileName required
|
||||
* @param appTool required
|
||||
* @param client required
|
||||
* @param fileInfo optional
|
||||
*/
|
||||
void postFileFolderActivity(String activityType, String path, String tenantDomain,
|
||||
String siteId, NodeRef parentNodeRef, NodeRef nodeRef, String fileName,
|
||||
String appTool, Client client, FileInfo fileInfo);
|
||||
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
package org.alfresco.service.cmr.activities;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.Client;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* A consolidated services for posting file folder activities.
|
||||
* Some code was moved from webdav.ActivityPosterImpl and
|
||||
* opencmis.ActivityPosterImpl.
|
||||
*
|
||||
* @author Gethin James
|
||||
*/
|
||||
public class FileFolderActivityPosterImpl implements ActivityPoster
|
||||
{
|
||||
private ActivityService activityService;
|
||||
|
||||
@Override
|
||||
public void postFileFolderActivity(
|
||||
String activityType,
|
||||
String path,
|
||||
String tenantDomain,
|
||||
String siteId,
|
||||
NodeRef parentNodeRef,
|
||||
NodeRef nodeRef,
|
||||
String fileName,
|
||||
String appTool,
|
||||
Client client,
|
||||
FileInfo fileInfo)
|
||||
{
|
||||
|
||||
JSONObject json;
|
||||
try
|
||||
{
|
||||
json = createActivityJSON(tenantDomain, path, parentNodeRef, nodeRef, fileName);
|
||||
}
|
||||
catch (JSONException jsonError)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unabled to create activities json", jsonError);
|
||||
}
|
||||
|
||||
activityService.postActivity(
|
||||
activityType,
|
||||
siteId,
|
||||
appTool,
|
||||
json.toString(),
|
||||
client,
|
||||
fileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create JSON suitable for create, modify or delete activity posts.
|
||||
*
|
||||
* @param tenantDomain
|
||||
* @param path
|
||||
* @param parentNodeRef
|
||||
* @param nodeRef
|
||||
* @param fileName
|
||||
* @throws JSONException
|
||||
* @return JSONObject
|
||||
*/
|
||||
protected JSONObject createActivityJSON(
|
||||
String tenantDomain,
|
||||
String path,
|
||||
NodeRef parentNodeRef,
|
||||
NodeRef nodeRef,
|
||||
String fileName) throws JSONException
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
json.put("nodeRef", nodeRef);
|
||||
|
||||
if (parentNodeRef != null)
|
||||
{
|
||||
// Used for deleted files.
|
||||
json.put("parentNodeRef", parentNodeRef);
|
||||
}
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
// Used for deleted files and folders (added or deleted)
|
||||
json.put("page", "documentlibrary?path=" + path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Used for added or modified files.
|
||||
json.put("page", "document-details?nodeRef=" + nodeRef);
|
||||
}
|
||||
json.put("title", fileName);
|
||||
|
||||
if (tenantDomain!= null && !tenantDomain.equals(TenantService.DEFAULT_DOMAIN))
|
||||
{
|
||||
// Only used in multi-tenant setups.
|
||||
json.put("tenantDomain", tenantDomain);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public void setActivityService(ActivityService activityService)
|
||||
{
|
||||
this.activityService = activityService;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user