Search in sources :

Example 81 with PropertySet

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();
}
Also used : SiteConfigsDataSerializer(com.enonic.xp.site.SiteConfigsDataSerializer) Page(com.enonic.xp.page.Page) SiteConfigs(com.enonic.xp.site.SiteConfigs) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) ExtraDatas(com.enonic.xp.content.ExtraDatas) IndexConfigDocument(com.enonic.xp.index.IndexConfigDocument) ContentIndexConfigFactory(com.enonic.xp.core.impl.content.index.ContentIndexConfigFactory)

Example 82 with PropertySet

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();
}
Also used : ContentId(com.enonic.xp.content.ContentId) ContentService(com.enonic.xp.content.ContentService) Property(com.enonic.xp.data.Property) Stream(java.util.stream.Stream) ContentIds(com.enonic.xp.content.ContentIds) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) PropertySet(com.enonic.xp.data.PropertySet) Content(com.enonic.xp.content.Content) ContentDataSerializer(com.enonic.xp.core.impl.content.serializer.ContentDataSerializer) ValueTypes(com.enonic.xp.data.ValueTypes) PropertyTree(com.enonic.xp.data.PropertyTree) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ContentIds(com.enonic.xp.content.ContentIds) PropertySet(com.enonic.xp.data.PropertySet) Property(com.enonic.xp.data.Property)

Example 83 with PropertySet

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);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 84 with PropertySet

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);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 85 with PropertySet

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);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)225 PropertyTree (com.enonic.xp.data.PropertyTree)150 Test (org.junit.jupiter.api.Test)69 Content (com.enonic.xp.content.Content)30 Node (com.enonic.xp.node.Node)20 CreateContentParams (com.enonic.xp.content.CreateContentParams)12 ContentId (com.enonic.xp.content.ContentId)11 Property (com.enonic.xp.data.Property)11 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)10 PrincipalKey (com.enonic.xp.security.PrincipalKey)9 ContentQuery (com.enonic.xp.content.ContentQuery)7 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 ExtraDatas (com.enonic.xp.content.ExtraDatas)6 Form (com.enonic.xp.form.Form)6 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)6 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)5 ContentPropertyNames (com.enonic.xp.content.ContentPropertyNames)5 ExtraData (com.enonic.xp.content.ExtraData)5 PropertyPath (com.enonic.xp.data.PropertyPath)5 Page (com.enonic.xp.page.Page)5