use of com.enonic.xp.node.SetNodeStateResult in project xp by enonic.
the class UndoPendingDeleteContentCommand method removePendingDeleteState.
private void removePendingDeleteState(final NodeComparison nodeComparison) {
final SetNodeStateResult result = this.nodeService.setNodeState(SetNodeStateParams.create().nodeId(nodeComparison.getNodeId()).nodeState(NodeState.DEFAULT).build());
pendingDeleteUndoneContents.addAll(this.translator.fromNodes(result.getUpdatedNodes(), false));
}
use of com.enonic.xp.node.SetNodeStateResult in project xp by enonic.
the class SetNodeStateCommand method execute.
public SetNodeStateResult execute() {
final Node node = doGetById(this.params.getNodeId());
final SetNodeStateResult.Builder setNodeStateResultBuilder = SetNodeStateResult.create();
if (this.params.isRecursive()) {
setNodeStateWithChildren(node, setNodeStateResultBuilder);
} else {
setNodeState(node, setNodeStateResultBuilder);
}
return setNodeStateResultBuilder.build();
}
use of com.enonic.xp.node.SetNodeStateResult in project xp by enonic.
the class SetNodeStateCommandTest method applyRecursive.
@Test
public void applyRecursive() throws Exception {
final Node parent = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("parent").setNodeId(NodeId.from("parent")).build());
final Node child1 = createNode(CreateNodeParams.create().parent(parent.path()).name("child1").setNodeId(NodeId.from("child1")).build());
final Node child1_1 = createNode(CreateNodeParams.create().parent(child1.path()).name("child1_1").setNodeId(NodeId.from("child1_1")).build());
refresh();
final SetNodeStateResult result = SetNodeStateCommand.create().params(SetNodeStateParams.create().nodeId(parent.id()).nodeState(NodeState.PENDING_DELETE).recursive(true).build()).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
assertEquals(3, result.getUpdatedNodes().getSize());
}
use of com.enonic.xp.node.SetNodeStateResult in project xp by enonic.
the class NodeServiceImpl method setNodeState.
@Override
public SetNodeStateResult setNodeState(final SetNodeStateParams params) {
verifyContext();
final SetNodeStateResult setNodeStateResult = SetNodeStateCommand.create().params(params).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).build().execute();
if (setNodeStateResult.getUpdatedNodes().isNotEmpty()) {
this.eventPublisher.publish(NodeEvents.stateUpdated(setNodeStateResult.getUpdatedNodes()));
}
return setNodeStateResult;
}
Aggregations