use of com.enonic.xp.content.processor.ProcessCreateResult in project xp by enonic.
the class CreateContentCommand method runContentProcessors.
private CreateContentParams runContentProcessors(final CreateContentParams createContentParams, final ContentType contentType) {
CreateContentParams processedParams = createContentParams;
for (final ContentProcessor contentProcessor : this.contentProcessors) {
if (contentProcessor.supports(contentType)) {
final ProcessCreateResult result = contentProcessor.processCreate(new ProcessCreateParams(processedParams, mediaInfo));
processedParams = CreateContentParams.create(result.getCreateContentParams()).build();
}
}
return processedParams;
}
use of com.enonic.xp.content.processor.ProcessCreateResult in project xp by enonic.
the class ImageContentProcessorTest method testProcessCreateWithExtraData.
@Test
public void testProcessCreateWithExtraData() throws IOException {
final Form.Builder form = Form.create();
form.addFormItem(createTextLine("shutterTime", "Exposure Time").occurrences(0, 1).build());
form.addFormItem(createTextLine("altitude", "Gps Altitude").occurrences(0, 1).build());
final XData xDataInfo = createXData(MediaInfo.IMAGE_INFO_METADATA_NAME, "Extra Info", form.build());
Mockito.when(this.xDataService.getFromContentType(Mockito.any())).thenReturn(XDatas.from(xDataInfo));
final CreateContentParams params = createContentParams(createAttachments());
final ProcessCreateParams processCreateParams = new ProcessCreateParams(params, MediaInfo.create().addMetadata("exposure time", "1").addMetadata("gps altitude ", "2").build());
final ProcessCreateResult result = this.imageContentProcessor.processCreate(processCreateParams);
final ExtraData extraData = result.getCreateContentParams().getExtraDatas().first();
assertEquals(xDataInfo.getName(), extraData.getName());
assertEquals(extraData.getData().getString("shutterTime", 0), "1");
assertEquals(extraData.getData().getString("altitude", 0), "2");
assertEquals(13, extraData.getData().getLong(MediaInfo.MEDIA_INFO_BYTE_SIZE, 0));
}
Aggregations