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)
75088: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 73976: Improvements to activities post events for ACE-1707 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@75416 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
<property name="tenantService" ref="tenantService"/>
|
||||
<property name="userNamesAreCaseSensitive" value="${user.name.caseSensitive}"/>
|
||||
<property name="eventPublisher" ref="eventPublisher" />
|
||||
<property name="fileFolderService" ref="FileFolderService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="activityService" class="org.alfresco.repo.activities.ActivityServiceImpl">
|
||||
|
@@ -35,6 +35,7 @@ import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -290,12 +291,15 @@ public class ActivityPosterImpl implements ActivityPoster, InitializingBean
|
||||
String name)
|
||||
{
|
||||
JSONObject json = createActivityJSON(getCurrentTenantDomain(), path, parentNodeRef, nodeRef, name);
|
||||
FileInfo fileInfo = fileFolderService.getFileInfo(nodeRef);
|
||||
|
||||
activityService.postActivity(
|
||||
activityType,
|
||||
siteId,
|
||||
APP_TOOL,
|
||||
json.toString());
|
||||
json.toString(),
|
||||
Client.cmis,
|
||||
fileInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1662,7 +1662,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
{
|
||||
result.setStream(contentReader.getContentInputStream());
|
||||
result.setLength(BigInteger.valueOf(contentSize));
|
||||
publishReadEvent(streamNodeRef, result.getMimeType(), contentSize, contentReader.getEncoding(), null);
|
||||
publishReadEvent(streamNodeRef, info.getName(), result.getMimeType(), contentSize, contentReader.getEncoding(), null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1675,7 +1675,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
|
||||
result.setStream(new RangeInputStream(contentReader.getContentInputStream(), off, len));
|
||||
result.setLength(BigInteger.valueOf(len));
|
||||
publishReadEvent(streamNodeRef, result.getMimeType(), contentSize, contentReader.getEncoding(), off+" - "+len);
|
||||
publishReadEvent(streamNodeRef, info.getName(), result.getMimeType(), contentSize, contentReader.getEncoding(), off+" - "+len);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -1711,7 +1711,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
* @param encoding
|
||||
* @param string
|
||||
*/
|
||||
protected void publishReadEvent(final NodeRef nodeRef, final String mimeType, final long contentSize, final String encoding, final String range)
|
||||
protected void publishReadEvent(final NodeRef nodeRef, final String name, final String mimeType, final long contentSize, final String encoding, final String range)
|
||||
{
|
||||
final QName nodeType = nodeRef==null?null:nodeService.getType(nodeRef);
|
||||
|
||||
@@ -1722,12 +1722,12 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
if (StringUtils.hasText(range))
|
||||
{
|
||||
return new ContentReadRangeEvent(user, networkId, transactionId,
|
||||
nodeRef.getId(), null, nodeType.toString(), Client.cmis, mimeType, contentSize, encoding, range);
|
||||
nodeRef.getId(), null, nodeType.toString(), Client.cmis, name, mimeType, contentSize, encoding, range);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ContentEventImpl(ContentEvent.DOWNLOAD, user, networkId, transactionId,
|
||||
nodeRef.getId(), null, nodeType.toString(), Client.cmis, mimeType, contentSize, encoding);
|
||||
nodeRef.getId(), null, nodeType.toString(), Client.cmis, name, mimeType, contentSize, encoding);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -32,8 +32,12 @@ import org.alfresco.repo.events.EventPublisher;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.activities.ActivityPostService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONException;
|
||||
@@ -54,6 +58,8 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
private ActivityPostDAO postDAO;
|
||||
private TenantService tenantService;
|
||||
private EventPublisher eventPublisher;
|
||||
private FileFolderService fileFolderService;
|
||||
|
||||
private int estGridSize = 1;
|
||||
|
||||
private boolean userNamesAreCaseSensitive = false;
|
||||
@@ -83,12 +89,29 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
this.eventPublisher = eventPublisher;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.activities.ActivityService#postActivity(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void postActivity(String activityType, String siteId, String appTool, String activityData)
|
||||
{
|
||||
postActivity(activityType, siteId, appTool, activityData, ActivityPostEntity.STATUS.PENDING, getCurrentUser(), null);
|
||||
postActivity(activityType, siteId, appTool, activityData, ActivityPostEntity.STATUS.PENDING, getCurrentUser(), null, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void postActivity(String activityType, String siteId, String appTool, String activityData, Client client)
|
||||
{
|
||||
postActivity(activityType, siteId, appTool, activityData, ActivityPostEntity.STATUS.PENDING, getCurrentUser(), client, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postActivity(String activityType, String siteId, String appTool, String jsonActivityData, Client client, FileInfo contentNodeInfo)
|
||||
{
|
||||
postActivity(activityType, siteId, appTool, jsonActivityData, ActivityPostEntity.STATUS.PENDING, getCurrentUser(), client, contentNodeInfo);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -96,7 +119,7 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
*/
|
||||
public void postActivity(String activityType, String siteId, String appTool, String activityData, String userId)
|
||||
{
|
||||
postActivity(activityType, siteId, appTool, activityData, ActivityPostEntity.STATUS.PENDING, userId, null);
|
||||
postActivity(activityType, siteId, appTool, activityData, ActivityPostEntity.STATUS.PENDING, userId,null, null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -109,7 +132,7 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{").append("\""+PostLookup.JSON_NODEREF_LOOKUP+"\":\"").append(nodeRef.toString()).append("\"").append("}");
|
||||
|
||||
postActivity(activityType, siteId, appTool, sb.toString(), ActivityPostEntity.STATUS.PENDING, getCurrentUser(), nodeRef);
|
||||
postActivity(activityType, siteId, appTool, sb.toString(), ActivityPostEntity.STATUS.PENDING, getCurrentUser(),null, null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -124,7 +147,7 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
.append("\"name\":\"").append(name).append("\"")
|
||||
.append("}");
|
||||
|
||||
postActivity(activityType, siteId, appTool, sb.toString(), ActivityPostEntity.STATUS.PENDING, getCurrentUser(),nodeRef);
|
||||
postActivity(activityType, siteId, appTool, sb.toString(), ActivityPostEntity.STATUS.PENDING, getCurrentUser(),null,null);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -145,12 +168,14 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
.append("\""+PostLookup.JSON_NODEREF_PARENT+"\":\"").append(parentNodeRef.toString()).append("\"")
|
||||
.append("}");
|
||||
|
||||
postActivity(activityType, siteId, appTool, sb.toString(), ActivityPostEntity.STATUS.PENDING, getCurrentUser(), nodeRef);
|
||||
postActivity(activityType, siteId, appTool, sb.toString(), ActivityPostEntity.STATUS.PENDING, getCurrentUser(), null,null);
|
||||
}
|
||||
|
||||
private void postActivity(final String activityType, String siteId, String appTool, String activityData, ActivityPostEntity.STATUS status, String userId, NodeRef nodeRef)
|
||||
private void postActivity(final String activityType, String siteId, String appTool, String activityData, ActivityPostEntity.STATUS status, String userId, final Client client, final FileInfo contentNodeInfo)
|
||||
{
|
||||
|
||||
NodeRef nodeRef = null;
|
||||
|
||||
try
|
||||
{
|
||||
// optional - default to empty string
|
||||
@@ -198,7 +223,7 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
jo.put(PostLookup.JSON_TENANT_DOMAIN, tenantService.getCurrentUserDomain());
|
||||
activityData = jo.toString();
|
||||
}
|
||||
checkNodeRef(jo);
|
||||
nodeRef = checkNodeRef(jo);
|
||||
|
||||
// ALF-10362 - belts-and-braces (note: Share sets "title" from cm:name)
|
||||
if (jo.has(PostLookup.JSON_TITLE))
|
||||
@@ -244,8 +269,8 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
final Date postDate = new Date();
|
||||
final ActivityPostEntity activityPost = new ActivityPostEntity();
|
||||
final String network = tenantService.getName(siteId);
|
||||
final String nodeId = nodeRef!=null?nodeRef.toString():null;
|
||||
final String site = siteId;
|
||||
final NodeRef finalNodeRef = nodeRef;
|
||||
|
||||
//MNT-9104 If username contains uppercase letters the action of joining a site will not be displayed in "My activities"
|
||||
if (! userNamesAreCaseSensitive)
|
||||
@@ -263,11 +288,47 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
activityPost.setLastModified(postDate);
|
||||
|
||||
eventPublisher.publishEvent(new EventPreparator(){
|
||||
|
||||
@Override
|
||||
public Event prepareEvent(String user, String networkId, String transactionId)
|
||||
{
|
||||
return new ActivityEvent(activityType, transactionId, networkId, postDate.getTime(), user, nodeId,
|
||||
site, null, null, activityPost.getActivityData());
|
||||
String filename = null, nodeType = null, mime = null, encoding = null;
|
||||
long size = 0l;
|
||||
String nodeId = finalNodeRef!=null?finalNodeRef.getId():null;
|
||||
FileInfo fileInfo = contentNodeInfo;
|
||||
|
||||
//Get content info if available
|
||||
if (fileInfo == null && finalNodeRef !=null)
|
||||
{
|
||||
fileInfo = fileFolderService.getFileInfo(finalNodeRef);
|
||||
}
|
||||
|
||||
//Use content info
|
||||
if (fileInfo != null)
|
||||
{
|
||||
if (nodeId == null)
|
||||
{
|
||||
nodeId = fileInfo.getNodeRef().getId();
|
||||
}
|
||||
filename = fileInfo.getName();
|
||||
nodeType = fileInfo.getType().toString();
|
||||
|
||||
if (!fileInfo.isFolder())
|
||||
{
|
||||
//It's a file so get more info
|
||||
ContentData contentData = fileInfo.getContentData();
|
||||
if (contentData!=null)
|
||||
{
|
||||
mime = contentData.getMimetype();
|
||||
size = contentData.getSize();
|
||||
encoding = contentData.getEncoding();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new ActivityEvent(activityType, transactionId, networkId, user, nodeId,
|
||||
site, nodeType, client, activityPost.getActivityData(), filename, mime, size, encoding);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -323,7 +384,7 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
* @param activityPost
|
||||
* @throws JSONException
|
||||
*/
|
||||
private void checkNodeRef(JSONObject jo) throws JSONException
|
||||
private NodeRef checkNodeRef(JSONObject jo) throws JSONException
|
||||
{
|
||||
String nodeRefStr = null;
|
||||
try
|
||||
@@ -331,12 +392,14 @@ public class ActivityPostServiceImpl implements ActivityPostService
|
||||
if (jo.has(PostLookup.JSON_NODEREF))
|
||||
{
|
||||
nodeRefStr = jo.getString(PostLookup.JSON_NODEREF);
|
||||
new NodeRef(nodeRefStr);
|
||||
return new NodeRef(nodeRefStr);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid node ref: " + nodeRefStr);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -40,6 +40,7 @@ import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.activities.ActivityPostService;
|
||||
import org.alfresco.service.cmr.activities.ActivityService;
|
||||
import org.alfresco.service.cmr.activities.FeedControl;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -49,6 +50,7 @@ import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.json.JSONObject;
|
||||
@@ -194,6 +196,21 @@ public class ActivityServiceImpl implements ActivityService, InitializingBean
|
||||
activityPostService.postActivity(activityType, siteId, appTool, nodeRef, name, typeQName, parentNodeRef);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void postActivity(String activityType, String siteId, String appTool, String jsonActivityData, Client client)
|
||||
{
|
||||
// delegate
|
||||
activityPostService.postActivity(activityType, siteId, appTool, jsonActivityData, client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postActivity(String activityType, String siteId, String appTool, String jsonActivityData, Client client, FileInfo contentNodeInfo)
|
||||
{
|
||||
// delegate
|
||||
activityPostService.postActivity(activityType, siteId, appTool, jsonActivityData, client, contentNodeInfo);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.activities.ActivityService#getUserFeedEntries(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
|
@@ -26,6 +26,7 @@ import org.alfresco.service.cmr.activities.ActivityService;
|
||||
import org.alfresco.service.cmr.activities.FeedControl;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
@@ -72,7 +73,7 @@ public final class Activity extends BaseScopableProcessorExtension
|
||||
*/
|
||||
public void postActivity(String activityType, String siteId, String appTool, String jsonActivityData)
|
||||
{
|
||||
activityService.postActivity(activityType, siteId, appTool, jsonActivityData);
|
||||
activityService.postActivity(activityType, siteId, appTool, jsonActivityData, Client.webclient);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,7 +20,6 @@ package org.alfresco.repo.quickshare;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -63,8 +62,8 @@ import org.alfresco.service.cmr.thumbnail.ThumbnailService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.EqualsHelper;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -250,9 +249,9 @@ public class QuickShareServiceImpl implements QuickShareService, NodeServicePoli
|
||||
@Override
|
||||
public Event prepareEvent(String user, String networkId, String transactionId)
|
||||
{
|
||||
return new ActivityEvent("quickshare", transactionId, networkId, new Date().getTime(),
|
||||
user, nodeRef.getId(),
|
||||
null, typeQName.toString(), Client.webclient, sb.toString());
|
||||
return new ActivityEvent("quickshare", transactionId, networkId, user, nodeRef.getId(),
|
||||
null, typeQName.toString(), Client.webclient, sb.toString(),
|
||||
null, null, 0l, null);
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -18,8 +18,10 @@
|
||||
*/
|
||||
package org.alfresco.service.cmr.activities;
|
||||
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.FileFilterMode.Client;
|
||||
|
||||
public interface ActivityPostService
|
||||
{
|
||||
@@ -38,6 +40,27 @@ public interface ActivityPostService
|
||||
*/
|
||||
public void postActivity(String activityType, String siteId, String appTool, String jsonActivityData);
|
||||
|
||||
/**
|
||||
* Post a custom activity type
|
||||
*
|
||||
* @param activityType - required
|
||||
* @param siteId - optional, if null will be stored as empty string
|
||||
* @param appTool - optional, if null will be stored as empty string
|
||||
* @param jsonActivityData - required
|
||||
*/
|
||||
public void postActivity(String activityType, String siteId, String appTool, String jsonActivityData, Client client);
|
||||
|
||||
/**
|
||||
* Post a custom activity type
|
||||
*
|
||||
* @param activityType - required
|
||||
* @param siteId - optional, if null will be stored as empty string
|
||||
* @param appTool - optional, if null will be stored as empty string
|
||||
* @param jsonActivityData - required
|
||||
* @param contentNodeInfo FileInfo
|
||||
*/
|
||||
public void postActivity(String activityType, String siteId, String appTool, String jsonActivityData, Client client, FileInfo contentNodeInfo);
|
||||
|
||||
/**
|
||||
* Post a custom activity type
|
||||
*
|
||||
|
Reference in New Issue
Block a user