Search in sources :

Example 1 with NodeEditor

use of com.enonic.xp.node.NodeEditor in project xp by enonic.

the class UpdateNodeParamsFactory method produce.

public UpdateNodeParams produce() {
    final Content editedContent = params.getEditedContent();
    final CreateAttachments createAttachments = params.getCreateAttachments();
    final NodeEditor nodeEditor = toNodeEditor(params);
    final UpdateNodeParams.Builder builder = UpdateNodeParams.create().id(NodeId.from(editedContent.getId())).editor(nodeEditor);
    if (createAttachments != null) {
        for (final CreateAttachment createAttachment : createAttachments) {
            builder.attachBinary(createAttachment.getBinaryReference(), createAttachment.getByteSource());
        }
    }
    return builder.build();
}
Also used : CreateAttachments(com.enonic.xp.attachment.CreateAttachments) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) Content(com.enonic.xp.content.Content) NodeEditor(com.enonic.xp.node.NodeEditor) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams)

Example 2 with NodeEditor

use of com.enonic.xp.node.NodeEditor in project xp by enonic.

the class UpdateNodeParamsFactory method toNodeEditor.

private NodeEditor toNodeEditor(final UpdateContentTranslatorParams params) {
    final Content content = params.getEditedContent();
    final PropertyTree nodeData = contentDataSerializer.toUpdateNodeData(params);
    final ContentIndexConfigFactory indexConfigFactory = ContentIndexConfigFactory.create().contentTypeService(contentTypeService).pageDescriptorService(pageDescriptorService).partDescriptorService(partDescriptorService).layoutDescriptorService(layoutDescriptorService).siteService(this.siteService).xDataService(this.xDataService).contentTypeName(content.getType()).page(content.getPage()).siteConfigs(content.isSite() ? ((Site) content).getSiteConfigs() : null).extraDatas(content.getAllExtraData()).language(content.getLanguage() != null ? content.getLanguage().getLanguage() : null).build();
    return editableNode -> {
        editableNode.indexConfigDocument = indexConfigFactory.produce();
        editableNode.data = nodeData;
        editableNode.manualOrderValue = content.getManualOrderValue();
        editableNode.permissions = content.getPermissions();
        editableNode.inheritPermissions = content.inheritsPermissions();
    };
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) SiteService(com.enonic.xp.site.SiteService) Content(com.enonic.xp.content.Content) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) NodeId(com.enonic.xp.node.NodeId) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) Site(com.enonic.xp.site.Site) CreateAttachments(com.enonic.xp.attachment.CreateAttachments) CreateAttachment(com.enonic.xp.attachment.CreateAttachment) ContentDataSerializer(com.enonic.xp.core.impl.content.serializer.ContentDataSerializer) Preconditions(com.google.common.base.Preconditions) ContentIndexConfigFactory(com.enonic.xp.core.impl.content.index.ContentIndexConfigFactory) UpdateContentTranslatorParams(com.enonic.xp.content.UpdateContentTranslatorParams) NodeEditor(com.enonic.xp.node.NodeEditor) XDataService(com.enonic.xp.schema.xdata.XDataService) PropertyTree(com.enonic.xp.data.PropertyTree) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ContentIndexConfigFactory(com.enonic.xp.core.impl.content.index.ContentIndexConfigFactory)

Example 3 with NodeEditor

use of com.enonic.xp.node.NodeEditor in project xp by enonic.

the class ModifyNodeHandlerTest method getEditedNode.

private EditableNode getEditedNode(final Node node) {
    final NodeEditor editor = updateCaptor.getValue().getEditor();
    assertNotNull(editor);
    final EditableNode editableNode = new EditableNode(node);
    editor.edit(editableNode);
    return editableNode;
}
Also used : NodeEditor(com.enonic.xp.node.NodeEditor) EditableNode(com.enonic.xp.node.EditableNode)

Aggregations

NodeEditor (com.enonic.xp.node.NodeEditor)3 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)2 CreateAttachments (com.enonic.xp.attachment.CreateAttachments)2 Content (com.enonic.xp.content.Content)2 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)2 UpdateContentTranslatorParams (com.enonic.xp.content.UpdateContentTranslatorParams)1 ContentIndexConfigFactory (com.enonic.xp.core.impl.content.index.ContentIndexConfigFactory)1 ContentDataSerializer (com.enonic.xp.core.impl.content.serializer.ContentDataSerializer)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 EditableNode (com.enonic.xp.node.EditableNode)1 NodeId (com.enonic.xp.node.NodeId)1 PageDescriptorService (com.enonic.xp.page.PageDescriptorService)1 LayoutDescriptorService (com.enonic.xp.region.LayoutDescriptorService)1 PartDescriptorService (com.enonic.xp.region.PartDescriptorService)1 ContentTypeService (com.enonic.xp.schema.content.ContentTypeService)1 XDataService (com.enonic.xp.schema.xdata.XDataService)1 Site (com.enonic.xp.site.Site)1 SiteService (com.enonic.xp.site.SiteService)1 Preconditions (com.google.common.base.Preconditions)1