Search in sources :

Example 1 with UpdateNodeParams

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

the class ReprocessContentCommand method revertModifiedTime.

private Content revertModifiedTime(final Content content, final Instant modifiedTime) {
    final UpdateNodeParams update = UpdateNodeParams.create().id(NodeId.from(content.getId())).editor((node) -> node.data.getRoot().setInstant(MODIFIED_TIME, modifiedTime)).build();
    this.nodeService.update(update);
    return this.getContent(content.getId());
}
Also used : PartDescriptorService(com.enonic.xp.region.PartDescriptorService) Media(com.enonic.xp.content.Media) UpdateMediaParams(com.enonic.xp.content.UpdateMediaParams) Content(com.enonic.xp.content.Content) Attachment(com.enonic.xp.attachment.Attachment) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) Instant(java.time.Instant) NodeId(com.enonic.xp.node.NodeId) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) ContentId(com.enonic.xp.content.ContentId) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) ReprocessContentParams(com.enonic.xp.content.ReprocessContentParams) MediaInfoService(com.enonic.xp.media.MediaInfoService) ContentDataSerializer(com.enonic.xp.core.impl.content.serializer.ContentDataSerializer) MODIFIED_TIME(com.enonic.xp.content.ContentPropertyNames.MODIFIED_TIME) ByteSource(com.google.common.io.ByteSource) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams)

Example 2 with UpdateNodeParams

use of com.enonic.xp.node.UpdateNodeParams 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 3 with UpdateNodeParams

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

the class UpdateIssueCommand method doExecute.

private Issue doExecute() {
    Issue editedIssue = editIssue(params.getEditor(), getIssue(params.getId()));
    final UpdateNodeParams updateNodeParams = UpdateNodeParamsFactory.create(editedIssue);
    final Node updatedNode = this.nodeService.update(updateNodeParams);
    nodeService.refresh(RefreshMode.SEARCH);
    return IssueNodeTranslator.fromNode(updatedNode);
}
Also used : EditableIssue(com.enonic.xp.issue.EditableIssue) Issue(com.enonic.xp.issue.Issue) PublishRequestIssue(com.enonic.xp.issue.PublishRequestIssue) EditablePublishRequestIssue(com.enonic.xp.issue.EditablePublishRequestIssue) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) Node(com.enonic.xp.node.Node)

Example 4 with UpdateNodeParams

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

the class GetActiveNodeVersionsCommandTest method updateNode.

private void updateNode(final Node node, Context context) {
    UpdateNodeParams updateNodeParams = UpdateNodeParams.create().id(node.id()).editor(toBeEdited -> toBeEdited.data.setString("myString", "edit")).build();
    context.runWith(() -> UpdateNodeCommand.create().params(updateNodeParams).indexServiceInternal(this.indexServiceInternal).binaryService(this.binaryService).storageService(this.storageService).searchService(this.searchService).build().execute());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) Node(com.enonic.xp.node.Node) NodePath(com.enonic.xp.node.NodePath) Branches(com.enonic.xp.branch.Branches) GetActiveNodeVersionsResult(com.enonic.xp.node.GetActiveNodeVersionsResult) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) Test(org.junit.jupiter.api.Test) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Context(com.enonic.xp.context.Context) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NodeIds(com.enonic.xp.node.NodeIds) PropertyTree(com.enonic.xp.data.PropertyTree) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams)

Example 5 with UpdateNodeParams

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

the class UpdateNodeCommandTest method unreferred_binary_attachment_ignored.

@Test
public void unreferred_binary_attachment_ignored() throws Exception {
    final PropertyTree data = new PropertyTree();
    final BinaryReference binaryRef = BinaryReference.from("my-car.jpg");
    data.setBinaryReference("my-image", binaryRef);
    final CreateNodeParams params = CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").data(data).attachBinary(binaryRef, ByteSource.wrap("my-car-image-source".getBytes())).build();
    final Node node = createNode(params);
    final UpdateNodeParams updateNodeParams = UpdateNodeParams.create().editor(toBeEdited -> {
        final PropertyTree nodeData = toBeEdited.data;
        nodeData.addString("newValue", "hepp");
    }).attachBinary(BinaryReference.from("unreferred binary"), ByteSource.wrap("nothing to see here".getBytes())).id(node.id()).build();
    final Node updatedNode = updateNode(updateNodeParams);
    assertEquals(1, updatedNode.getAttachedBinaries().getSize());
}
Also used : BinaryReference(com.enonic.xp.util.BinaryReference) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) Node(com.enonic.xp.node.Node) NodePath(com.enonic.xp.node.NodePath) StandardCharsets(java.nio.charset.StandardCharsets) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) Test(org.junit.jupiter.api.Test) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) ByteStreams(com.google.common.io.ByteStreams) NodeBinaryReferenceException(com.enonic.xp.node.NodeBinaryReferenceException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ByteSource(com.google.common.io.ByteSource) PropertyTree(com.enonic.xp.data.PropertyTree) PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) BinaryReference(com.enonic.xp.util.BinaryReference) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) Test(org.junit.jupiter.api.Test)

Aggregations

UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)31 Node (com.enonic.xp.node.Node)24 PropertyTree (com.enonic.xp.data.PropertyTree)13 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)11 Test (org.junit.jupiter.api.Test)11 BinaryReference (com.enonic.xp.util.BinaryReference)10 NodePath (com.enonic.xp.node.NodePath)8 ByteSource (com.google.common.io.ByteSource)6 NodeIds (com.enonic.xp.node.NodeIds)4 User (com.enonic.xp.security.User)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Content (com.enonic.xp.content.Content)3 Context (com.enonic.xp.context.Context)3 NodeBinaryReferenceException (com.enonic.xp.node.NodeBinaryReferenceException)3 NodeId (com.enonic.xp.node.NodeId)3 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)3 PrincipalKey (com.enonic.xp.security.PrincipalKey)3 PrincipalNotFoundException (com.enonic.xp.security.PrincipalNotFoundException)3