use of org.alfresco.sync.events.types.Event in project alfresco-repository by Alfresco.
the class EventsServiceImpl method nodeTagged.
@Override
public void nodeTagged(final NodeRef nodeRef, final String tag) {
NodeInfo nodeInfo = getNodeInfo(nodeRef, NodeTaggedEvent.EVENT_TYPE);
if (nodeInfo.checkNodeInfo()) {
String username = AuthenticationUtil.getFullyAuthenticatedUser();
String networkId = TenantUtil.getCurrentDomain();
String name = nodeInfo.getName();
String objectId = nodeInfo.getNodeId();
String siteId = nodeInfo.getSiteId();
String txnId = AlfrescoTransactionSupport.getTransactionId();
List<String> nodePaths = nodeInfo.getPaths();
List<List<String>> pathNodeIds = nodeInfo.getParentNodeIds();
long timestamp = System.currentTimeMillis();
Long modificationTime = nodeInfo.getModificationTimestamp();
String nodeType = nodeInfo.getType().toPrefixString(namespaceService);
Set<String> aspects = nodeInfo.getAspectsAsStrings();
Map<String, Serializable> properties = nodeInfo.getProperties();
Client alfrescoClient = getAlfrescoClient(nodeInfo.getClient());
Event event = new NodeTaggedEvent(nextSequenceNumber(), name, txnId, timestamp, networkId, siteId, objectId, nodeType, nodePaths, pathNodeIds, username, modificationTime, tag, alfrescoClient, aspects, properties);
sendEvent(event);
}
}
use of org.alfresco.sync.events.types.Event in project alfresco-repository by Alfresco.
the class EventsServiceImpl method nodeCheckedOut.
public void nodeCheckedOut(NodeRef workingCopyNodeRef) {
NodeInfo workingCopyNodeInfo = getNodeInfo(workingCopyNodeRef, NodeCheckedOutEvent.EVENT_TYPE);
if (workingCopyNodeInfo.checkNodeInfo()) {
String username = AuthenticationUtil.getFullyAuthenticatedUser();
String networkId = TenantUtil.getCurrentDomain();
String name = workingCopyNodeInfo.getName();
String objectId = workingCopyNodeInfo.getNodeId();
String siteId = workingCopyNodeInfo.getSiteId();
String txnId = AlfrescoTransactionSupport.getTransactionId();
List<String> nodePaths = workingCopyNodeInfo.getPaths();
List<List<String>> pathNodeIds = workingCopyNodeInfo.getParentNodeIds();
long timestamp = System.currentTimeMillis();
Long modificationTime = workingCopyNodeInfo.getModificationTimestamp();
String nodeType = workingCopyNodeInfo.getType().toPrefixString(namespaceService);
Client alfrescoClient = getAlfrescoClient(workingCopyNodeInfo.getClient());
String workingCopyNodeId = workingCopyNodeInfo.getNodeId();
Set<String> aspects = workingCopyNodeInfo.getAspectsAsStrings();
Map<String, Serializable> properties = workingCopyNodeInfo.getProperties();
Event event = new NodeCheckedOutEvent(nextSequenceNumber(), workingCopyNodeId, name, txnId, timestamp, networkId, siteId, objectId, nodeType, nodePaths, pathNodeIds, username, modificationTime, alfrescoClient, aspects, properties);
sendEvent(event);
}
}
use of org.alfresco.sync.events.types.Event in project alfresco-repository by Alfresco.
the class EventsServiceImpl method authorityAddedToGroup.
@Override
public void authorityAddedToGroup(String parentGroup, String childAuthority) {
if (includeEventType(AuthorityAddedToGroupEvent.EVENT_TYPE)) {
String username = AuthenticationUtil.getFullyAuthenticatedUser();
String networkId = TenantUtil.getCurrentDomain();
String txnId = AlfrescoTransactionSupport.getTransactionId();
long timestamp = System.currentTimeMillis();
Client client = getAlfrescoClient(ClientUtil.from(FileFilterMode.getClient()));
Event event = AuthorityAddedToGroupEvent.builder().parentGroup(parentGroup).authorityName(childAuthority).seqNumber(nextSequenceNumber()).txnId(txnId).networkId(networkId).timestamp(timestamp).username(username).client(client).build();
sendEvent(event);
}
}
use of org.alfresco.sync.events.types.Event in project alfresco-repository by Alfresco.
the class AbstractEventsService method afterRollback.
@Override
public void afterRollback() {
String txnId = AlfrescoTransactionSupport.getTransactionId();
long timestamp = System.currentTimeMillis();
String networkId = TenantUtil.getCurrentDomain();
String username = AuthenticationUtil.getFullyAuthenticatedUser();
Client alfrescoClient = getAlfrescoClient(null);
Event event = new TransactionRolledBackEvent(nextSequenceNumber(), txnId, networkId, timestamp, username, alfrescoClient);
if (logger.isDebugEnabled()) {
logger.debug("sendEvent " + event);
}
try {
messageProducer.send(event);
} catch (MessagingException e) {
// throw new AlfrescoRuntimeException("Failed to send event", e);
// TODO just log for now. How to deal with no running ActiveMQ?
logger.error("Failed to send event " + event, e);
} finally {
TxnEvents events = (TxnEvents) AlfrescoTransactionSupport.getResource(EVENTS_KEY);
if (events != null) {
events.clear();
}
}
}
use of org.alfresco.sync.events.types.Event in project alfresco-repository by Alfresco.
the class AbstractEventsService method afterCommit.
@Override
public void afterCommit() {
if (sendEventsBeforeCommit) {
if (!shouldSendCommitEvent()) {
return;
}
// send txn committed event
String txnId = AlfrescoTransactionSupport.getTransactionId();
long timestamp = System.currentTimeMillis();
String networkId = TenantUtil.getCurrentDomain();
String username = AuthenticationUtil.getFullyAuthenticatedUser();
Client alfrescoClient = getAlfrescoClient(null);
final Event event = new TransactionCommittedEvent(nextSequenceNumber(), txnId, networkId, timestamp, username, alfrescoClient);
if (logger.isDebugEnabled()) {
logger.debug("sendEvent " + event);
}
// Need to execute this in another read txn because Camel/JMS expects it (the config now seems to
// require a txn)
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
messageProducer.send(event);
return null;
}
}, true, false);
} else {
// send all events
final TxnEvents transactionEvents = (TxnEvents) AlfrescoTransactionSupport.getResource(EVENTS_KEY);
if (transactionEvents != null) {
List<Event> filteredEvents = filterEventsBeforeSend(transactionEvents.getEvents());
updateTransactionEvents(transactionEvents, filteredEvents);
transactionEvents.sendEvents();
}
}
}
Aggregations