use of com.enonic.xp.content.EditableSite 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.EditableSite in project xp by enonic.
the class HtmlAreaContentProcessorTest method site_config_data.
@Test
public void site_config_data() throws IOException {
final ContentType contentType = ContentType.create().name(ContentTypeName.site()).superType(ContentTypeName.folder()).form(Form.create().build()).build();
Mockito.when(contentTypeService.getByName(GetContentTypeParams.from(contentType.getName()))).thenReturn(contentType);
Mockito.when(siteService.getDescriptor(ApplicationKey.SYSTEM)).thenReturn(SiteDescriptor.create().form(Form.create().addFormItem(Input.create().name("htmlData").label("htmlData").inputType(InputTypeName.HTML_AREA).build()).build()).build());
final PropertyTree data = new PropertyTree();
data.addProperty("htmlData", ValueFactory.newString("<img alt=\"Dictyophorus_spumans01.jpg\" data-src=\"image://image-id\"/>"));
final EditableSite editableSite = new EditableSite(Site.create().name("myContentName").type(ContentTypeName.site()).parentPath(ContentPath.ROOT).data(new PropertyTree()).siteConfigs(SiteConfigs.create().add(SiteConfig.create().config(data).application(ApplicationKey.SYSTEM).build()).build()).build());
result.getEditor().edit(editableSite);
assertEquals(1, editableSite.processedReferences.build().getSize());
assertTrue(editableSite.processedReferences.build().contains(ContentId.from("image-id")));
}
use of com.enonic.xp.content.EditableSite in project xp by enonic.
the class HtmlAreaContentProcessorTest method extra_data.
@Test
public void extra_data() throws IOException {
final XDataName xDataName = XDataName.from("xDataName");
final XData xData = XData.create().name(xDataName).addFormItem(Input.create().name("htmlData").label("htmlData").inputType(InputTypeName.HTML_AREA).build()).build();
final ContentType contentType = ContentType.create().name(contentTypeName).superType(ContentTypeName.folder()).xData(XDataNames.from(xDataName)).build();
Mockito.when(contentTypeService.getByName(GetContentTypeParams.from(ContentTypeName.site()))).thenReturn(contentType);
Mockito.when(xDataService.getByNames(XDataNames.from(xDataName))).thenReturn(XDatas.from(xData));
final PropertyTree data = new PropertyTree();
data.addProperty("htmlData", ValueFactory.newString("<img alt=\"Dictyophorus_spumans01.jpg\" data-src=\"image://image-id\"/>"));
final EditableSite editableSite = new EditableSite(Site.create().name("myContentName").type(ContentTypeName.site()).parentPath(ContentPath.ROOT).data(new PropertyTree()).extraDatas(ExtraDatas.create().add(new ExtraData(XDataName.from("xDataName"), data)).build()).build());
result.getEditor().edit(editableSite);
assertEquals(1, editableSite.processedReferences.build().getSize());
assertTrue(editableSite.processedReferences.build().contains(ContentId.from("image-id")));
}
Aggregations