use of org.alfresco.repo.event.v1.model.EventData in project alfresco-repository by Alfresco.
the class UpdateRepoEventIT method testCreateAndUpdateNodeTypeInTheSameTransaction.
@Test
public void testCreateAndUpdateNodeTypeInTheSameTransaction() {
retryingTransactionHelper.doInTransaction(() -> {
final NodeRef nodeRef = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName(TEST_NAMESPACE, GUID.generate()), ContentModel.TYPE_CONTENT).getChildRef();
// old type
assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(nodeRef));
nodeService.setType(nodeRef, ContentModel.TYPE_FOLDER);
// new type
assertEquals(ContentModel.TYPE_FOLDER, nodeService.getType(nodeRef));
return null;
});
// we should have only 1 event, node.Created
checkNumOfEvents(1);
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEvent(1);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
NodeResource nodeResource = getNodeResource(resultRepoEvent);
assertEquals("Incorrect node type was found", "cm:folder", nodeResource.getNodeType());
}
use of org.alfresco.repo.event.v1.model.EventData in project alfresco-repository by Alfresco.
the class EventConsolidator method getRepoEvent.
/**
* Builds and returns the {@link RepoEvent} instance.
*
* @param eventInfo the object holding the event information
* @return the {@link RepoEvent} instance
*/
public RepoEvent<DataAttributes<NodeResource>> getRepoEvent(EventInfo eventInfo) {
NodeResource resource = buildNodeResource();
EventType eventType = getDerivedEvent();
DataAttributes<NodeResource> eventData = buildEventData(eventInfo, resource, eventType);
return RepoEvent.<DataAttributes<NodeResource>>builder().setId(eventInfo.getId()).setSource(eventInfo.getSource()).setTime(eventInfo.getTimestamp()).setType(eventType.getType()).setData(eventData).setDataschema(EventJSONSchema.getSchemaV1(eventType)).build();
}
use of org.alfresco.repo.event.v1.model.EventData in project alfresco-repository by Alfresco.
the class PeerAssociationRepoEventIT method testAddAndRemovePeerAssociationSameTransaction.
@Test
public void testAddAndRemovePeerAssociationSameTransaction() {
final NodeRef content1NodeRef = createNode(ContentModel.TYPE_CONTENT);
final NodeRef content2NodeRef = createNode(ContentModel.TYPE_CONTENT);
checkNumOfEvents(2);
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(1);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
resultRepoEvent = getRepoEventWithoutWait(2);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
// Create peer association
retryingTransactionHelper.doInTransaction(() -> {
nodeService.createAssociation(content1NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL);
nodeService.removeAssociation(content1NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL);
return null;
});
List<AssociationRef> peerAssociationRefs = retryingTransactionHelper.doInTransaction(() -> nodeService.getSourceAssocs(content2NodeRef, ContentModel.ASSOC_ORIGINAL));
assertEquals(0, peerAssociationRefs.size());
checkNumOfEvents(2);
}
use of org.alfresco.repo.event.v1.model.EventData in project alfresco-repository by Alfresco.
the class PeerAssociationRepoEventIT method testAddPeerAssociation.
@Test
public void testAddPeerAssociation() {
final NodeRef content1NodeRef = createNode(ContentModel.TYPE_CONTENT);
final NodeRef content2NodeRef = createNode(ContentModel.TYPE_CONTENT);
checkNumOfEvents(2);
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(1);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
resultRepoEvent = getRepoEventWithoutWait(2);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
retryingTransactionHelper.doInTransaction(() -> nodeService.createAssociation(content1NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL));
List<AssociationRef> peerAssociationRefs = retryingTransactionHelper.doInTransaction(() -> nodeService.getSourceAssocs(content2NodeRef, ContentModel.ASSOC_ORIGINAL));
assertEquals(1, peerAssociationRefs.size());
checkNumOfEvents(4);
final RepoEvent<EventData<PeerAssociationResource>> peerAssocRepoEvent = getFilteredEvent(EventType.PEER_ASSOC_CREATED, 0);
assertEquals("Wrong repo event type.", EventType.PEER_ASSOC_CREATED.getType(), peerAssocRepoEvent.getType());
assertNotNull("Repo event ID is not available. ", peerAssocRepoEvent.getId());
assertNotNull("Source is not available", peerAssocRepoEvent.getSource());
assertEquals("Repo event source is not available. ", "/" + descriptorService.getCurrentRepositoryDescriptor().getId(), peerAssocRepoEvent.getSource().toString());
assertNotNull("Repo event creation time is not available. ", peerAssocRepoEvent.getTime());
assertEquals("Repo event datacontenttype", "application/json", peerAssocRepoEvent.getDatacontenttype());
assertNotNull(peerAssocRepoEvent.getDataschema());
assertEquals(EventJSONSchema.PEER_ASSOC_CREATED_V1.getSchema(), peerAssocRepoEvent.getDataschema());
final EventData<PeerAssociationResource> nodeResourceEventData = getEventData(peerAssocRepoEvent);
// EventData attributes
assertNotNull("Event data group ID is not available. ", nodeResourceEventData.getEventGroupId());
assertNull("resourceBefore property is not available", nodeResourceEventData.getResourceBefore());
final PeerAssociationResource peerAssociationResource = getPeerAssocResource(peerAssocRepoEvent);
assertEquals("Wrong source", content1NodeRef.getId(), peerAssociationResource.getSource().getId());
assertEquals("Wrong target", content2NodeRef.getId(), peerAssociationResource.getTarget().getId());
assertEquals("Wrong assoc type", "cm:original", peerAssociationResource.getAssocType());
}
use of org.alfresco.repo.event.v1.model.EventData in project alfresco-repository by Alfresco.
the class PeerAssociationRepoEventIT method testAddMultiplePeerAssociationSameTransaction.
@Test
public void testAddMultiplePeerAssociationSameTransaction() {
final NodeRef content1NodeRef = createNode(ContentModel.TYPE_CONTENT);
final NodeRef content2NodeRef = createNode(ContentModel.TYPE_CONTENT);
final NodeRef content3NodeRef = createNode(ContentModel.TYPE_CONTENT);
checkNumOfEvents(3);
RepoEvent<EventData<NodeResource>> resultRepoEvent = getRepoEventWithoutWait(1);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
resultRepoEvent = getRepoEventWithoutWait(2);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
resultRepoEvent = getRepoEventWithoutWait(3);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
retryingTransactionHelper.doInTransaction(() -> {
nodeService.createAssociation(content1NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL);
nodeService.createAssociation(content3NodeRef, content2NodeRef, ContentModel.ASSOC_ORIGINAL);
return null;
});
List<AssociationRef> peerAssociationRefs = retryingTransactionHelper.doInTransaction(() -> nodeService.getSourceAssocs(content2NodeRef, ContentModel.ASSOC_ORIGINAL));
assertEquals(2, peerAssociationRefs.size());
checkNumOfEvents(7);
List<RepoEvent<EventData<PeerAssociationResource>>> peerAssocRepoEvent = getFilteredEvents(EventType.PEER_ASSOC_CREATED);
// we should have 2 assoc.peer.Created events
assertEquals("Wrong association events number", 2, peerAssocRepoEvent.size());
}
Aggregations