Search in sources :

Example 1 with DataAttributes

use of org.alfresco.event.sdk.model.v1.model.DataAttributes in project alfresco-java-sdk by Alfresco.

the class NodeMovedFilter method checkPrimaryHierarchy.

private boolean checkPrimaryHierarchy(final RepoEvent<DataAttributes<Resource>> event) {
    final NodeResource nodeResourceBefore = (NodeResource) event.getData().getResourceBefore();
    final List<String> primaryHierarchy = nodeResourceBefore.getPrimaryHierarchy();
    return primaryHierarchy != null && !primaryHierarchy.isEmpty();
}
Also used : NodeResource(org.alfresco.event.sdk.model.v1.model.NodeResource)

Example 2 with DataAttributes

use of org.alfresco.event.sdk.model.v1.model.DataAttributes in project alfresco-java-sdk by Alfresco.

the class NodeTypeChangedFilter method checkNodeType.

private boolean checkNodeType(final RepoEvent<DataAttributes<Resource>> event) {
    final NodeResource nodeResourceBefore = (NodeResource) event.getData().getResourceBefore();
    final String nodeTypeBefore = nodeResourceBefore.getNodeType();
    final String nodeTypeAfter = ((NodeResource) event.getData().getResource()).getNodeType();
    return nodeTypeBefore != null && nodeTypeAfter != null && !nodeTypeAfter.equals(nodeTypeBefore);
}
Also used : NodeResource(org.alfresco.event.sdk.model.v1.model.NodeResource)

Example 3 with DataAttributes

use of org.alfresco.event.sdk.model.v1.model.DataAttributes in project alfresco-java-sdk by Alfresco.

the class ContentChangedFilter method checkContent.

private boolean checkContent(final RepoEvent<DataAttributes<Resource>> event) {
    final NodeResource nodeResourceBefore = (NodeResource) event.getData().getResourceBefore();
    final ContentInfo contentInfo = nodeResourceBefore.getContent();
    return contentInfo != null && (contentInfo.getEncoding() != null || contentInfo.getMimeType() != null || contentInfo.getSizeInBytes() != null);
}
Also used : NodeResource(org.alfresco.event.sdk.model.v1.model.NodeResource) ContentInfo(org.alfresco.event.sdk.model.v1.model.ContentInfo)

Example 4 with DataAttributes

use of org.alfresco.event.sdk.model.v1.model.DataAttributes in project alfresco-java-sdk by Alfresco.

the class NodeMovedHandler method handleEvent.

@Override
public void handleEvent(final RepoEvent<DataAttributes<Resource>> repoEvent) {
    final NodeResource nodeResource = (NodeResource) repoEvent.getData().getResource();
    final NodeResource beforeNodeResource = (NodeResource) repoEvent.getData().getResourceBefore();
    final String name = nodeResource.getName();
    final String currentPrimaryHierarchy = String.join(COMMA, nodeResource.getPrimaryHierarchy());
    final String previousPrimaryHierarchy = String.join(COMMA, beforeNodeResource.getPrimaryHierarchy());
    LOGGER.info("The node {} has been moved from the hierarchy path [{}] to the new hierarchy path [{}] in the repository!", name, previousPrimaryHierarchy, currentPrimaryHierarchy);
}
Also used : NodeResource(org.alfresco.event.sdk.model.v1.model.NodeResource)

Example 5 with DataAttributes

use of org.alfresco.event.sdk.model.v1.model.DataAttributes in project alfresco-java-sdk by Alfresco.

the class TitleModifiedHandler method handleEvent.

@Override
public void handleEvent(final RepoEvent<DataAttributes<Resource>> repoEvent) {
    final NodeResource nodeResource = (NodeResource) repoEvent.getData().getResource();
    final NodeResource beforeNodeResource = (NodeResource) repoEvent.getData().getResourceBefore();
    final String name = nodeResource.getName();
    final String previousTitle = (String) beforeNodeResource.getProperties().getOrDefault(CM_TITLE, "");
    final String currentTitle = (String) nodeResource.getProperties().getOrDefault(CM_TITLE, "");
    LOGGER.info("The title of the node {} has changed from '{}' to '{}'!", name, previousTitle, currentTitle);
}
Also used : NodeResource(org.alfresco.event.sdk.model.v1.model.NodeResource)

Aggregations

NodeResource (org.alfresco.event.sdk.model.v1.model.NodeResource)58 EventData (org.alfresco.event.sdk.model.v1.model.EventData)54 Test (org.junit.Test)54 DataAttributes (org.alfresco.event.sdk.model.v1.model.DataAttributes)52 Serializable (java.io.Serializable)6 HashMap (java.util.HashMap)6 ContentInfo (org.alfresco.event.sdk.model.v1.model.ContentInfo)5 PeerAssociationResource (org.alfresco.event.sdk.model.v1.model.PeerAssociationResource)3 GenericMessage (org.springframework.messaging.support.GenericMessage)2 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1