use of com.enonic.xp.data.PropertySet 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.data.PropertySet in project xp by enonic.
the class ContentOutboundDependenciesIdsResolver method resolveOutboundDependenciesIds.
private ContentIds resolveOutboundDependenciesIds(final ContentId contentId) {
final Content content = this.contentService.getById(contentId);
final ContentIds.Builder contentIds = ContentIds.create();
final PropertySet contentPageData = new PropertyTree().getRoot();
if (content.getPage() != null) {
contentDataSerializer.toPageData(content.getPage(), contentPageData);
}
final Stream<Property> extraDataDependencies = content.hasExtraData() ? content.getAllExtraData().stream().flatMap(extraData -> extraData.getData().getProperties(ValueTypes.REFERENCE).stream()) : Stream.empty();
Stream.of(content.getData().getProperties(ValueTypes.REFERENCE).stream(), contentPageData.getProperties(ValueTypes.REFERENCE).stream(), extraDataDependencies).flatMap(s -> s).forEach(property -> {
final String value = property.getValue().toString();
if (!contentId.toString().equals(value) && !nullToEmpty(value).isBlank()) {
contentIds.add(ContentId.from(value));
}
});
if (content.getProcessedReferences() != null && content.getProcessedReferences().getSize() > 0) {
contentIds.addAll(content.getProcessedReferences());
}
return contentIds.build();
}
use of com.enonic.xp.data.PropertySet in project xp by enonic.
the class ContentAuditLogSupportImpl method doSetActiveContentVersion.
private void doSetActiveContentVersion(final ContentId contentId, final ContentVersionId versionId, final Context rootContext) {
final PropertyTree data = new PropertyTree();
final PropertySet paramsSet = data.addSet("params");
final PropertySet resultSet = data.addSet("result");
paramsSet.addString("contentId", nullToNull(contentId));
paramsSet.addString("versionId", nullToNull(versionId));
resultSet.addString("contentId", nullToNull(contentId));
resultSet.addString("versionId", nullToNull(versionId));
log("system.content.setActiveContentVersion", data, contentId, rootContext);
}
use of com.enonic.xp.data.PropertySet in project xp by enonic.
the class ContentAuditLogSupportImpl method doReorderChildren.
private void doReorderChildren(final ReorderChildContentsParams params, final ReorderChildContentsResult result, final Context rootContext) {
final PropertyTree data = new PropertyTree();
final PropertySet paramsSet = data.addSet("params");
final PropertySet resultSet = data.addSet("result");
paramsSet.addString("contentId", nullToNull(params.getContentId()));
paramsSet.addBoolean("silent", params.isSilent());
resultSet.addLong("size", (long) result.getMovedChildren());
log("system.content.reorderChildren", data, params.getContentId(), rootContext);
}
use of com.enonic.xp.data.PropertySet in project xp by enonic.
the class ContentAuditLogSupportImpl method doCreateMedia.
private void doCreateMedia(final CreateMediaParams params, final Content content, final Context rootContext) {
final PropertyTree data = new PropertyTree();
final PropertySet paramsSet = data.addSet("params");
final PropertySet resultSet = data.addSet("result");
paramsSet.addString("artist", params.getArtist());
paramsSet.addString("caption", params.getCaption());
paramsSet.addString("copyright", params.getCopyright());
paramsSet.addString("mimeType", params.getMimeType());
paramsSet.addString("name", params.getName());
paramsSet.addString("tags", params.getTags());
paramsSet.addDouble("focalX", params.getFocalX());
paramsSet.addDouble("focalY", params.getFocalY());
paramsSet.addString("parent", nullToNull(params.getParent()));
addContent(resultSet, content);
log("system.content.create", data, content.getPath(), rootContext);
}
Aggregations