Search in sources :

Example 1 with CompareStatus

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();
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) CompareStatus(com.enonic.xp.content.CompareStatus) NodeId(com.enonic.xp.node.NodeId) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult)

Example 2 with CompareStatus

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);
}
Also used : NodeComparison(com.enonic.xp.node.NodeComparison) CompareStatus(com.enonic.xp.content.CompareStatus) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 3 with 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();
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Context(com.enonic.xp.context.Context) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeComparison(com.enonic.xp.node.NodeComparison) NodeId(com.enonic.xp.node.NodeId) CompareStatus(com.enonic.xp.content.CompareStatus) NodeComparisons(com.enonic.xp.node.NodeComparisons) HashSet(java.util.HashSet)

Aggregations

CompareStatus (com.enonic.xp.content.CompareStatus)3 NodeComparison (com.enonic.xp.node.NodeComparison)2 NodeId (com.enonic.xp.node.NodeId)2 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)1 Context (com.enonic.xp.context.Context)1 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)1 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)1 NodeComparisons (com.enonic.xp.node.NodeComparisons)1 NodeIds (com.enonic.xp.node.NodeIds)1 InternalContext (com.enonic.xp.repo.impl.InternalContext)1 HashSet (java.util.HashSet)1