Search in sources :

Example 1 with ContentReadRangeEvent

use of org.alfresco.sync.events.types.ContentReadRangeEvent in project alfresco-repository by Alfresco.

the class CMISConnector method publishReadEvent.

/**
 * Notifies listeners that a read has taken place.
 *
 * @param nodeRef NodeRef
 * @param name String
 * @param mimeType String
 * @param contentSize long
 * @param encoding String
 * @param range String
 */
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);
    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.asType(ClientType.cmis), name, mimeType, contentSize, encoding, range);
            } else {
                return new ContentEventImpl(ContentEvent.DOWNLOAD, user, networkId, transactionId, nodeRef.getId(), null, nodeType.toString(), Client.asType(ClientType.cmis), name, mimeType, contentSize, encoding);
            }
        }
    });
}
Also used : EventPreparator(org.alfresco.sync.repo.events.EventPreparator) ContentReadRangeEvent(org.alfresco.sync.events.types.ContentReadRangeEvent) QName(org.alfresco.service.namespace.QName) Event(org.alfresco.sync.events.types.Event) ApplicationEvent(org.springframework.context.ApplicationEvent) ApplicationContextEvent(org.springframework.context.event.ApplicationContextEvent) ContentReadRangeEvent(org.alfresco.sync.events.types.ContentReadRangeEvent) ContentEvent(org.alfresco.sync.events.types.ContentEvent) PropertyString(org.apache.chemistry.opencmis.commons.data.PropertyString) ContentEventImpl(org.alfresco.sync.events.types.ContentEventImpl)

Aggregations

QName (org.alfresco.service.namespace.QName)1 ContentEvent (org.alfresco.sync.events.types.ContentEvent)1 ContentEventImpl (org.alfresco.sync.events.types.ContentEventImpl)1 ContentReadRangeEvent (org.alfresco.sync.events.types.ContentReadRangeEvent)1 Event (org.alfresco.sync.events.types.Event)1 EventPreparator (org.alfresco.sync.repo.events.EventPreparator)1 PropertyString (org.apache.chemistry.opencmis.commons.data.PropertyString)1 ApplicationEvent (org.springframework.context.ApplicationEvent)1 ApplicationContextEvent (org.springframework.context.event.ApplicationContextEvent)1