use of org.alfresco.event.sdk.model.v1.model.ContentInfo 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);
}
use of org.alfresco.event.sdk.model.v1.model.ContentInfo in project alfresco-java-sdk by Alfresco.
the class ContentAddedFilterTest method should_testTrue_when_contentAddedEventIsSent.
@Test
public void should_testTrue_when_contentAddedEventIsSent() {
final NodeResource nodeResource = NodeResource.builder().build();
final NodeResource nodeBeforeResource = NodeResource.builder().setContent(new ContentInfo()).build();
final EventData<NodeResource> eventData = EventData.<NodeResource>builder().setResource(nodeResource).setResourceBefore(nodeBeforeResource).build();
final RepoEvent<? extends DataAttributes<? extends Resource>> repoEvent = RepoEvent.<EventData<NodeResource>>builder().setData(eventData).build();
final boolean result = contentAddedFilter.test((RepoEvent<DataAttributes<Resource>>) repoEvent);
assertThat(result).isTrue();
}
use of org.alfresco.event.sdk.model.v1.model.ContentInfo in project alfresco-java-sdk by Alfresco.
the class ContentAddedFilterTest method should_testFalse_when_eventWithContentDetailsIsSent.
@Test
public void should_testFalse_when_eventWithContentDetailsIsSent() {
final NodeResource nodeResource = NodeResource.builder().setContent(new ContentInfo("test/test", 1l, "UTF-8")).build();
final NodeResource nodeBeforeResource = NodeResource.builder().build();
final EventData<NodeResource> eventData = EventData.<NodeResource>builder().setResource(nodeResource).setResourceBefore(nodeBeforeResource).build();
final RepoEvent<? extends DataAttributes<? extends Resource>> repoEvent = RepoEvent.<EventData<NodeResource>>builder().setData(eventData).build();
final boolean result = contentAddedFilter.test((RepoEvent<DataAttributes<Resource>>) repoEvent);
assertThat(result).isFalse();
}
use of org.alfresco.event.sdk.model.v1.model.ContentInfo in project alfresco-repository by Alfresco.
the class NodeResourceHelper method getContentInfo.
public ContentInfo getContentInfo(Map<QName, Serializable> props) {
final Serializable content = props.get(ContentModel.PROP_CONTENT);
ContentInfo contentInfo = null;
if ((content instanceof ContentData)) {
ContentData cd = (ContentData) content;
contentInfo = new ContentInfo(cd.getMimetype(), cd.getSize(), cd.getEncoding());
}
return contentInfo;
}
use of org.alfresco.event.sdk.model.v1.model.ContentInfo in project alfresco-repository by Alfresco.
the class EventConsolidator method buildNodeResourceBeforeDelta.
protected NodeResource buildNodeResourceBeforeDelta(NodeResource after) {
if (after == null) {
return null;
}
Builder builder = NodeResource.builder();
Map<QName, Serializable> changedPropsBefore = getBeforeMapChanges(propertiesBefore, propertiesAfter);
if (!changedPropsBefore.isEmpty()) {
// Set only the changed properties
Map<String, Serializable> mappedProps = helper.mapToNodeProperties(changedPropsBefore);
if (!mappedProps.isEmpty()) {
builder.setProperties(mappedProps);
resourceBeforeAllFieldsNull = false;
}
String name = (String) changedPropsBefore.get(ContentModel.PROP_NAME);
if (name != null) {
builder.setName(name);
resourceBeforeAllFieldsNull = false;
}
ContentInfo contentInfo = helper.getContentInfo(changedPropsBefore);
if (contentInfo != null) {
builder.setContent(contentInfo);
resourceBeforeAllFieldsNull = false;
}
UserInfo modifier = helper.getUserInfo((String) changedPropsBefore.get(ContentModel.PROP_MODIFIER));
if (modifier != null) {
builder.setModifiedByUser(modifier);
resourceBeforeAllFieldsNull = false;
}
ZonedDateTime modifiedAt = helper.getZonedDateTime((Date) changedPropsBefore.get(ContentModel.PROP_MODIFIED));
if (modifiedAt != null) {
builder.setModifiedAt(modifiedAt);
resourceBeforeAllFieldsNull = false;
}
}
Set<String> aspectsBefore = getMappedAspectsBefore(after.getAspectNames());
if (!aspectsBefore.isEmpty()) {
builder.setAspectNames(aspectsBefore);
resourceBeforeAllFieldsNull = false;
}
if (primaryHierarchyBefore != null && !primaryHierarchyBefore.isEmpty()) {
builder.setPrimaryHierarchy(primaryHierarchyBefore);
resourceBeforeAllFieldsNull = false;
}
if (nodeTypeBefore != null) {
builder.setNodeType(helper.getQNamePrefixString(nodeTypeBefore));
resourceBeforeAllFieldsNull = false;
}
return builder.build();
}
Aggregations