use of com.enonic.xp.index.IndexConfigDocument in project xp by enonic.
the class CreateNodeParamsFactory method produce.
public CreateNodeParams produce() {
final PropertyTree contentAsData = contentDataSerializer.toCreateNodeData(params);
final PropertySet extraDataSet = contentAsData.getPropertySet(PropertyPath.from(ContentPropertyNames.EXTRA_DATA));
final String language = contentAsData.getString(PropertyPath.from(ContentPropertyNames.LANGUAGE));
final SiteConfigs siteConfigs = new SiteConfigsDataSerializer().fromProperties(contentAsData.getPropertySet(PropertyPath.from(ContentPropertyNames.DATA))).build();
final Page page = contentAsData.hasProperty(COMPONENTS) ? contentDataSerializer.fromPageData(contentAsData.getRoot()) : null;
final ExtraDatas extraData = extraDataSet != null ? contentDataSerializer.fromExtraData(extraDataSet) : null;
final ContentIndexConfigFactory.Builder indexConfigFactoryBuilder = ContentIndexConfigFactory.create().contentTypeName(params.getType()).siteConfigs(siteConfigs).siteService(siteService).xDataService(xDataService).contentTypeService(contentTypeService);
if (page != null) {
indexConfigFactoryBuilder.page(page).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).layoutDescriptorService(layoutDescriptorService);
}
if (extraData != null) {
indexConfigFactoryBuilder.extraDatas(extraData);
}
if (!nullToEmpty(language).isBlank()) {
indexConfigFactoryBuilder.language(language);
}
final IndexConfigDocument indexConfigDocument = indexConfigFactoryBuilder.build().produce();
final CreateNodeParams.Builder builder = CreateNodeParams.create().name(resolveNodeName(params.getName())).parent(ContentNodeHelper.translateContentParentToNodeParentPath(params.getParent())).data(contentAsData).indexConfigDocument(indexConfigDocument).permissions(params.getPermissions()).inheritPermissions(params.isInheritPermissions()).childOrder(params.getChildOrder()).nodeType(ContentConstants.CONTENT_NODE_COLLECTION);
for (final CreateAttachment attachment : params.getCreateAttachments()) {
builder.attachBinary(attachment.getBinaryReference(), attachment.getByteSource());
}
return builder.build();
}
use of com.enonic.xp.index.IndexConfigDocument in project xp by enonic.
the class IndexConfigFactoryTest method default_with_alias.
@Test
public void default_with_alias() throws Exception {
IndexConfigDocument minimal = create("{\n" + " \"default\": \"minimal\"" + " }");
assertEquals(IndexConfig.MINIMAL, minimal.getConfigForPath(PropertyPath.from("my.random.path")));
IndexConfigDocument byType = create("{\n" + " \"default\": \"byType\"" + " }");
assertEquals(IndexConfig.BY_TYPE, byType.getConfigForPath(PropertyPath.from("my.random.path")));
}
use of com.enonic.xp.index.IndexConfigDocument in project xp by enonic.
the class IndexConfigFactoryTest method empty.
@Test
public void empty() throws Exception {
IndexConfigDocument config = create("{}");
assertEquals(IndexConfig.BY_TYPE, config.getConfigForPath(PropertyPath.from("my.random.path")));
}
Aggregations