use of com.enonic.xp.content.CompareStatus 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.content.CompareStatus in project xp by enonic.
the class AbstractCompareNodeCommand method doCompareNodeVersions.
NodeComparison doCompareNodeVersions(final Context context, final NodeId nodeId) {
final NodeBranchEntry sourceWsVersion = nodeStorageService.getBranchNodeVersion(nodeId, InternalContext.from(context));
final NodeBranchEntry targetWsVersion = nodeStorageService.getBranchNodeVersion(nodeId, InternalContext.create(context).branch(this.target).build());
final CompareStatus compareStatus = CompareStatusResolver.create().source(sourceWsVersion).target(targetWsVersion).storageService(this.nodeStorageService).build().resolve();
return new NodeComparison(sourceWsVersion, targetWsVersion, compareStatus);
}
use of com.enonic.xp.content.CompareStatus in project xp by enonic.
the class CompareNodesCommand method execute.
public NodeComparisons execute() {
Set<NodeId> allNodeIds = new HashSet<>();
final Context context = ContextAccessor.current();
final NodeComparisons.Builder builder = NodeComparisons.create();
final NodeBranchEntries sourceVersions = nodeStorageService.getBranchNodeVersions(nodeIds, false, InternalContext.from(context));
final NodeBranchEntries targetVersions = nodeStorageService.getBranchNodeVersions(nodeIds, false, InternalContext.create(context).branch(this.target).build());
allNodeIds.addAll(sourceVersions.getKeys());
allNodeIds.addAll(targetVersions.getKeys());
for (final NodeId id : allNodeIds) {
final CompareStatus compareStatus = CompareStatusResolver.create().source(sourceVersions.get(id)).target(targetVersions.get(id)).storageService(this.nodeStorageService).build().resolve();
builder.add(new NodeComparison(sourceVersions.get(id), targetVersions.get(id), compareStatus));
}
return builder.build();
}
Aggregations