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());
}
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();
}
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);
}
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());
}
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());
}
Aggregations