use of org.alfresco.repo.event.v1.model.RepoEvent in project alfresco-repository by Alfresco.
the class ChildAssociationRepoEventIT method testDeleteAssociationOneParentMultipleChildrenDifferentTransactions.
@Test
public void testDeleteAssociationOneParentMultipleChildrenDifferentTransactions() {
final NodeRef parent1NodeRef = createNode(ContentModel.TYPE_FOLDER);
final NodeRef parent2NodeRef = createNode(ContentModel.TYPE_FOLDER);
final NodeRef parent3NodeRef = createNode(ContentModel.TYPE_FOLDER);
final NodeRef childNodeRef = createNode(ContentModel.TYPE_CONTENT);
List<NodeRef> parents = Arrays.asList(parent1NodeRef, parent2NodeRef, parent3NodeRef);
checkNumOfEvents(4);
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());
resultRepoEvent = getRepoEventWithoutWait(4);
assertEquals("Wrong repo event type.", EventType.NODE_CREATED.getType(), resultRepoEvent.getType());
retryingTransactionHelper.doInTransaction(() -> nodeService.addChild(parents, childNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(TEST_NAMESPACE, GUID.generate())));
List<ChildAssociationRef> listChildAssociationRefs = retryingTransactionHelper.doInTransaction(() -> {
List<ChildAssociationRef> childAssocParent1 = nodeService.getChildAssocs(parent1NodeRef);
List<ChildAssociationRef> childAssocParent2 = nodeService.getChildAssocs(parent2NodeRef);
List<ChildAssociationRef> childAssocParent3 = nodeService.getChildAssocs(parent3NodeRef);
assertEquals(1, childAssocParent1.size());
assertEquals(1, childAssocParent2.size());
assertEquals(1, childAssocParent3.size());
return Arrays.asList(childAssocParent1.get(0), childAssocParent2.get(0), childAssocParent3.get(0));
});
for (ChildAssociationRef childAssociationRef : listChildAssociationRefs) {
retryingTransactionHelper.doInTransaction(() -> nodeService.removeChildAssociation(childAssociationRef));
}
checkNumOfEvents(10);
// 3 assoc.child.Deleted events should be created
List<RepoEvent<EventData<ChildAssociationResource>>> childAssocEvents = getFilteredEvents(EventType.CHILD_ASSOC_DELETED);
assertEquals("Wrong association events number", 3, childAssocEvents.size());
assertEquals(parent1NodeRef.getId(), getChildAssocResource(childAssocEvents.get(0)).getParent().getId());
assertEquals(childNodeRef.getId(), getChildAssocResource(childAssocEvents.get(0)).getChild().getId());
assertEquals("cm:contains", getChildAssocResource(childAssocEvents.get(0)).getAssocType());
assertEquals(parent2NodeRef.getId(), getChildAssocResource(childAssocEvents.get(1)).getParent().getId());
assertEquals(childNodeRef.getId(), getChildAssocResource(childAssocEvents.get(1)).getChild().getId());
assertEquals("cm:contains", getChildAssocResource(childAssocEvents.get(1)).getAssocType());
assertEquals(parent3NodeRef.getId(), getChildAssocResource(childAssocEvents.get(2)).getParent().getId());
assertEquals(childNodeRef.getId(), getChildAssocResource(childAssocEvents.get(2)).getChild().getId());
assertEquals("cm:contains", getChildAssocResource(childAssocEvents.get(2)).getAssocType());
}
use of org.alfresco.repo.event.v1.model.RepoEvent in project alfresco-repository by Alfresco.
the class ChildAssociationEventConsolidator 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<ChildAssociationResource>> getRepoEvent(EventInfo eventInfo) {
EventType eventType = getDerivedEvent();
DataAttributes<ChildAssociationResource> eventData = buildEventData(eventInfo, resource);
return RepoEvent.<DataAttributes<ChildAssociationResource>>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.RepoEvent in project alfresco-repository by Alfresco.
the class PeerAssociationEventConsolidator 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<PeerAssociationResource>> getRepoEvent(EventInfo eventInfo) {
EventType eventType = getDerivedEvent();
DataAttributes<PeerAssociationResource> eventData = buildEventData(eventInfo, resource);
return RepoEvent.<DataAttributes<PeerAssociationResource>>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.RepoEvent in project alfresco-repository by Alfresco.
the class UpdateRepoEventIT method testUpdateTwiceNodeTypeInTheSameTransaction.
@Test
public void testUpdateTwiceNodeTypeInTheSameTransaction() {
final NodeRef nodeRef = createNode(ContentModel.TYPE_CONTENT);
// node.Created event should be generated
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:content", nodeResource.getNodeType());
// old type
assertEquals(ContentModel.TYPE_CONTENT, nodeService.getType(nodeRef));
retryingTransactionHelper.doInTransaction(() -> {
nodeService.setType(nodeRef, ContentModel.TYPE_FOLDER);
nodeService.setType(nodeRef, ContentModel.TYPE_CONTENT);
// new type
assertEquals("Wrong node type", ContentModel.TYPE_CONTENT, nodeService.getType(nodeRef));
return null;
});
// we should have only 2 events, node.Created and node.Updated
checkNumOfEvents(2);
resultRepoEvent = getRepoEvent(2);
assertEquals("Wrong repo event type.", EventType.NODE_UPDATED.getType(), resultRepoEvent.getType());
nodeResource = getNodeResource(resultRepoEvent);
assertEquals("Incorrect node type was found", "cm:content", nodeResource.getNodeType());
NodeResource resourceBefore = getNodeResourceBefore(2);
assertEquals("Incorrect node type was found", "cm:folder", resourceBefore.getNodeType());
// assertNotNull(resourceBefore.getModifiedAt()); uncomment this when the issue will be fixed
assertNull(resourceBefore.getId());
assertNull(resourceBefore.getContent());
assertNull(resourceBefore.isFile());
assertNull(resourceBefore.isFolder());
assertNull(resourceBefore.getModifiedByUser());
assertNull(resourceBefore.getCreatedAt());
assertNull(resourceBefore.getCreatedByUser());
assertNull(resourceBefore.getProperties());
assertNull(resourceBefore.getAspectNames());
assertNull(resourceBefore.getPrimaryHierarchy());
}
use of org.alfresco.repo.event.v1.model.RepoEvent 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());
}
Aggregations