use of com.enonic.xp.node.NodeId in project xp by enonic.
the class CompareContentCommand method execute.
public CompareContentResult execute() {
final NodeId nodeId = NodeId.from(contentId.toString());
final NodeComparison compareResult = this.nodeService.compare(nodeId, this.target);
return CompareResultTranslator.translate(compareResult);
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class DeleteContentCommand method doDeleteContent.
private DeleteContentsResult doDeleteContent(NodeId nodeToDelete) {
final CompareStatus rootNodeStatus = getCompareStatus(nodeToDelete);
final DeleteContentsResult.Builder result = DeleteContentsResult.create();
if (rootNodeStatus == CompareStatus.NEW) {
// Root node is new, just delete all children
final NodeIds nodes = this.nodeService.deleteById(nodeToDelete, this);
result.addDeleted(ContentIds.from(nodes.getAsStrings()));
} else if (this.params.isDeleteOnline()) {
deleteNodeInDraftAndMaster(nodeToDelete, result);
} else {
this.nodeService.setNodeState(SetNodeStateParams.create().nodeId(nodeToDelete).nodeState(NodeState.PENDING_DELETE).build());
result.addPending(ContentId.from(nodeToDelete.toString()));
this.nodesDeleted(1);
final NodeIds children = getDirectChildren(nodeToDelete);
for (final NodeId child : children) {
final DeleteContentsResult childDeleteResult = this.doDeleteContent(child);
result.addDeleted(childDeleteResult.getDeletedContents());
result.addPending(childDeleteResult.getPendingContents());
}
}
return result.build();
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class DuplicateContentCommand method doExecute.
private DuplicateContentsResult doExecute() {
final NodeId sourceNodeId = NodeId.from(params.getContentId());
final Node sourceNode = nodeService.getById(sourceNodeId);
if (sourceNode == null) {
throw new IllegalArgumentException(String.format("Content with id [%s] not found", params.getContentId()));
}
final DuplicateNodeParams duplicateNodeParams = DuplicateNodeParams.create().duplicateListener(this).nodeId(sourceNodeId).dataProcessor(new DuplicateContentProcessor()).includeChildren(params.getIncludeChildren()).build();
final Node duplicatedNode = nodeService.duplicate(duplicateNodeParams);
final Content duplicatedContent = translator.fromNode(duplicatedNode, true);
final ContentIds childrenIds = params.getIncludeChildren() ? getAllChildren(duplicatedContent) : ContentIds.empty();
return DuplicateContentsResult.create().setSourceContentPath(ContentNodeHelper.translateNodePathToContentPath(sourceNode.path())).setContentName(duplicatedContent.getDisplayName()).addDuplicated(duplicatedContent.getId()).addDuplicated(childrenIds).build();
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class FindContentByParentCommand method setNodePathOrIdAsIdentifier.
private void setNodePathOrIdAsIdentifier(final FindNodesByParentParams.Builder findNodesParam) {
if (params.getParentPath() == null && params.getParentId() == null) {
final NodePath parentPath = ContentNodeHelper.getContentRoot();
findNodesParam.parentPath(parentPath);
} else if (params.getParentPath() != null) {
final NodePath parentPath = ContentNodeHelper.translateContentPathToNodePath(params.getParentPath());
findNodesParam.parentPath(parentPath);
} else {
final NodeId parentId = NodeId.from(params.getParentId().toString());
findNodesParam.parentId(parentId);
}
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class FindContentIdsByParentCommand method setNodePathOrIdAsIdentifier.
private void setNodePathOrIdAsIdentifier(final FindNodesByParentParams.Builder findNodesParam) {
if (params.getParentPath() == null && params.getParentId() == null) {
final NodePath parentPath = ContentNodeHelper.getContentRoot();
findNodesParam.parentPath(parentPath);
} else if (params.getParentPath() != null) {
final NodePath parentPath = ContentNodeHelper.translateContentPathToNodePath(params.getParentPath());
findNodesParam.parentPath(parentPath);
} else {
final NodeId parentId = NodeId.from(params.getParentId().toString());
findNodesParam.parentId(parentId);
}
}
Aggregations