use of com.enonic.xp.content.processor.ProcessUpdateResult in project xp by enonic.
the class HtmlAreaContentProcessor method processUpdate.
@Override
public ProcessUpdateResult processUpdate(final ProcessUpdateParams params) {
final CreateAttachments createAttachments = params.getCreateAttachments();
final ContentEditor editor;
editor = editable -> {
final ContentIds.Builder processedIds = ContentIds.create();
final ContentType contentType = contentTypeService.getByName(GetContentTypeParams.from(editable.source.getType()));
processContentData(editable.data, contentType, processedIds);
processExtraData(editable.extraDatas, processedIds);
processPageData(editable.page, processedIds);
if (editable instanceof EditableSite) {
processSiteConfigData(((EditableSite) editable).siteConfigs, processedIds);
}
editable.processedReferences = processedIds;
};
return new ProcessUpdateResult(createAttachments, editor);
}
use of com.enonic.xp.content.processor.ProcessUpdateResult in project xp by enonic.
the class UpdateContentCommand method runContentProcessors.
private Content runContentProcessors(final Content originalContent, Content editedContent, final ContentType contentType) {
for (final ContentProcessor contentProcessor : this.contentProcessors) {
if (contentProcessor.supports(contentType)) {
final ProcessUpdateResult result = contentProcessor.processUpdate(ProcessUpdateParams.create().contentType(contentType).mediaInfo(mediaInfo).createAttachments(params.getCreateAttachments()).originalContent(originalContent).editedContent(editedContent).modifier(getCurrentUser()).build());
editedContent = updateContentWithProcessedData(editedContent, result);
}
}
return editedContent;
}
use of com.enonic.xp.content.processor.ProcessUpdateResult in project xp by enonic.
the class ImageContentProcessorTest method testProcessUpdate.
@Test
public void testProcessUpdate() throws IOException {
Mockito.when(contentService.getBinary(Mockito.any(), Mockito.any())).thenReturn(this.loadImage("cat-small.jpg"));
final ProcessUpdateParams processUpdateParams = ProcessUpdateParams.create().contentType(ContentType.create().name(ContentTypeName.imageMedia()).superType(ContentTypeName.imageMedia()).build()).build();
final ProcessUpdateResult result = this.imageContentProcessor.processUpdate(processUpdateParams);
final PropertyTree data = new PropertyTree();
data.addProperty(ContentPropertyNames.MEDIA, ValueFactory.newString("MyImage.jpg"));
final EditableContent editableContent = new EditableContent(Media.create().name("myContentName").type(ContentTypeName.imageMedia()).parentPath(ContentPath.ROOT).data(data).addExtraData(new ExtraData(MediaInfo.IMAGE_INFO_METADATA_NAME, new PropertyTree())).attachments(Attachments.from(Attachment.create().mimeType("image/jpg").name("MyImage.jpg").build())).build());
result.getEditor().edit(editableContent);
assertNotNull(editableContent.extraDatas.first().getData().getLong("pixelSize", 0));
assertNotNull(editableContent.extraDatas.first().getData().getLong("imageHeight", 0));
assertNotNull(editableContent.extraDatas.first().getData().getLong("imageWidth", 0));
assertNotNull(editableContent.extraDatas.first().getData().getLong("byteSize", 0));
}
use of com.enonic.xp.content.processor.ProcessUpdateResult in project xp by enonic.
the class ProjectAccessSiteProcessorTest method testProcessUpdateWithNoRightsAndNoChanges.
@Test
public void testProcessUpdateWithNoRightsAndNoChanges() {
final Context context = ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.create().user(TEST_USER).build()).build();
context.runWith(() -> {
final ProcessUpdateParams params = createProcessUpdateParams("white", "white");
final ProcessUpdateResult result = this.projectAccessSiteProcessor.processUpdate(params);
assertNull(result);
});
}
use of com.enonic.xp.content.processor.ProcessUpdateResult in project xp by enonic.
the class ProjectAccessSiteProcessorTest method testProcessUpdateWithNoChanges.
@Test
public void testProcessUpdateWithNoChanges() {
final Context context = ContextBuilder.from(ContextAccessor.current()).authInfo(AuthenticationInfo.create().user(TEST_USER).principals(RoleKeys.ADMIN).build()).build();
context.runWith(() -> {
final ProcessUpdateParams params = createProcessUpdateParams("white", "white");
final ProcessUpdateResult result = this.projectAccessSiteProcessor.processUpdate(params);
assertNull(result);
});
}
Aggregations