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)
75027: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 71711: Raises a ContentReadEvent when content is downloaded via cmis git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@75355 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -173,6 +173,7 @@
|
|||||||
<property name="searchService" ref="SearchService" />
|
<property name="searchService" ref="SearchService" />
|
||||||
<property name="dictionaryService" ref="DictionaryService" />
|
<property name="dictionaryService" ref="DictionaryService" />
|
||||||
<property name="behaviourFilter" ref="policyBehaviourFilter" />
|
<property name="behaviourFilter" ref="policyBehaviourFilter" />
|
||||||
|
<property name="eventPublisher" ref="eventPublisher" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="OpenCMISQueryService" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
<bean id="OpenCMISQueryService" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
|
||||||
|
@@ -49,6 +49,9 @@ import javax.xml.datatype.DatatypeFactory;
|
|||||||
|
|
||||||
import org.alfresco.cmis.CMISDictionaryModel;
|
import org.alfresco.cmis.CMISDictionaryModel;
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.events.types.ContentReadEvent;
|
||||||
|
import org.alfresco.events.types.ContentReadRangeEvent;
|
||||||
|
import org.alfresco.events.types.Event;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.opencmis.ActivityPosterImpl.ActivityInfo;
|
import org.alfresco.opencmis.ActivityPosterImpl.ActivityInfo;
|
||||||
import org.alfresco.opencmis.dictionary.CMISActionEvaluator;
|
import org.alfresco.opencmis.dictionary.CMISActionEvaluator;
|
||||||
@@ -71,6 +74,8 @@ import org.alfresco.opencmis.search.CMISResultSetColumn;
|
|||||||
import org.alfresco.opencmis.search.CMISResultSetRow;
|
import org.alfresco.opencmis.search.CMISResultSetRow;
|
||||||
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
|
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
|
||||||
import org.alfresco.repo.cache.SimpleCache;
|
import org.alfresco.repo.cache.SimpleCache;
|
||||||
|
import org.alfresco.repo.events.EventPreparator;
|
||||||
|
import org.alfresco.repo.events.EventPublisher;
|
||||||
import org.alfresco.repo.model.filefolder.GetChildrenCannedQuery;
|
import org.alfresco.repo.model.filefolder.GetChildrenCannedQuery;
|
||||||
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
import org.alfresco.repo.model.filefolder.HiddenAspect;
|
||||||
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
|
import org.alfresco.repo.model.filefolder.HiddenAspect.Visibility;
|
||||||
@@ -224,6 +229,7 @@ import org.springframework.context.ApplicationEvent;
|
|||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.event.ApplicationContextEvent;
|
import org.springframework.context.event.ApplicationContextEvent;
|
||||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bridge connecting Alfresco and OpenCMIS.
|
* Bridge connecting Alfresco and OpenCMIS.
|
||||||
@@ -312,6 +318,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
|||||||
private ActionService actionService;
|
private ActionService actionService;
|
||||||
private ThumbnailService thumbnailService;
|
private ThumbnailService thumbnailService;
|
||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
private EventPublisher eventPublisher;
|
||||||
|
|
||||||
private ActivityPoster activityPoster;
|
private ActivityPoster activityPoster;
|
||||||
|
|
||||||
@@ -556,6 +563,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
|||||||
return contentService;
|
return contentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the event publisher
|
||||||
|
*/
|
||||||
|
public void setEventPublisher(EventPublisher eventPublisher)
|
||||||
|
{
|
||||||
|
this.eventPublisher = eventPublisher;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the rendition service.
|
* Sets the rendition service.
|
||||||
*/
|
*/
|
||||||
@@ -1640,23 +1655,26 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.setMimeType(contentReader.getMimetype());
|
result.setMimeType(contentReader.getMimetype());
|
||||||
|
long contentSize = contentReader.getSize();
|
||||||
|
|
||||||
if ((offset == null) && (length == null))
|
if ((offset == null) && (length == null))
|
||||||
{
|
{
|
||||||
result.setStream(contentReader.getContentInputStream());
|
result.setStream(contentReader.getContentInputStream());
|
||||||
result.setLength(BigInteger.valueOf(contentReader.getSize()));
|
result.setLength(BigInteger.valueOf(contentSize));
|
||||||
|
publishReadEvent(streamNodeRef, result.getMimeType(), contentSize, contentReader.getEncoding(), null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
long off = (offset == null ? 0 : offset.longValue());
|
long off = (offset == null ? 0 : offset.longValue());
|
||||||
long len = (length == null ? contentReader.getSize() : length.longValue());
|
long len = (length == null ? contentSize : length.longValue());
|
||||||
if (off + len > contentReader.getSize())
|
if (off + len > contentSize)
|
||||||
{
|
{
|
||||||
len = contentReader.getSize() - off;
|
len = contentReader.getSize() - off;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.setStream(new RangeInputStream(contentReader.getContentInputStream(), off, len));
|
result.setStream(new RangeInputStream(contentReader.getContentInputStream(), off, len));
|
||||||
result.setLength(BigInteger.valueOf(len));
|
result.setLength(BigInteger.valueOf(len));
|
||||||
|
publishReadEvent(streamNodeRef, result.getMimeType(), contentSize, contentReader.getEncoding(), off+" - "+len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -1682,6 +1700,40 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies listeners that a read has taken place.
|
||||||
|
*
|
||||||
|
* @param streamNodeRef
|
||||||
|
* @param type
|
||||||
|
* @param mimeType
|
||||||
|
* @param contentSize
|
||||||
|
* @param encoding
|
||||||
|
* @param string
|
||||||
|
*/
|
||||||
|
protected void publishReadEvent(final NodeRef nodeRef, final String mimeType, final long contentSize, final String encoding, final String range)
|
||||||
|
{
|
||||||
|
final QName nodeType = nodeRef==null?null:nodeService.getType(nodeRef);
|
||||||
|
|
||||||
|
eventPublisher.publishEvent(new EventPreparator(){
|
||||||
|
@Override
|
||||||
|
public Event prepareEvent(String user, String networkId, String transactionId)
|
||||||
|
{
|
||||||
|
if (StringUtils.hasText(range))
|
||||||
|
{
|
||||||
|
return new ContentReadRangeEvent(user, networkId, transactionId,
|
||||||
|
nodeRef.getId(), null, nodeType.toString(), Client.cmis, mimeType, contentSize, encoding, range);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new ContentReadEvent(ContentReadEvent.DOWNLOAD, user, networkId, transactionId,
|
||||||
|
nodeRef.getId(), null, nodeType.toString(), Client.cmis, mimeType, contentSize, encoding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void appendContent(CMISNodeInfo nodeInfo, ContentStream contentStream, boolean isLastChunk) throws IOException
|
public void appendContent(CMISNodeInfo nodeInfo, ContentStream contentStream, boolean isLastChunk) throws IOException
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = nodeInfo.getNodeRef();
|
NodeRef nodeRef = nodeInfo.getNodeRef();
|
||||||
|
Reference in New Issue
Block a user