use of com.enonic.xp.branch.Branch in project xp by enonic.
the class GetActiveContentVersionsParamsTest method testEquals.
@Test
public void testEquals() {
Branch branch = Branch.create().value("branchName").build();
Branches branches = Branches.from(branch);
GetActiveContentVersionsParams params = GetActiveContentVersionsParams.create().contentId(contentId).branches(branches).build();
assertEquals(params, params);
assertEquals(params.getContentId(), contentId);
assertEquals(params.getBranches().getSet(), branches.getSet());
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class DeleteContentCommand method getCompareStatus.
private CompareStatus getCompareStatus(final NodeId nodeToDelete) {
final Context context = ContextAccessor.current();
final Branch currentBranch = context.getBranch();
final NodeComparison compare;
if (currentBranch.equals(ContentConstants.BRANCH_DRAFT)) {
compare = this.nodeService.compare(nodeToDelete, ContentConstants.BRANCH_MASTER);
} else {
compare = this.nodeService.compare(nodeToDelete, ContentConstants.BRANCH_DRAFT);
}
return compare.getCompareStatus();
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class GetActiveContentVersionsCommand method execute.
public GetActiveContentVersionsResult execute() {
this.nodeService.refresh(RefreshMode.STORAGE);
final NodeId nodeId = NodeId.from(contentId.toString());
final GetActiveNodeVersionsResult activeNodeVersions = this.nodeService.getActiveVersions(GetActiveNodeVersionsParams.create().nodeId(nodeId).branches(this.branches).build());
final ContentVersionFactory contentVersionFactory = new ContentVersionFactory(this.nodeService);
final GetActiveContentVersionsResult.Builder builder = GetActiveContentVersionsResult.create();
final ImmutableMap<Branch, NodeVersionMetadata> nodeVersionsMap = activeNodeVersions.getNodeVersions();
for (final Branch branch : nodeVersionsMap.keySet()) {
final NodeVersionMetadata nodeVersionMetadata = nodeVersionsMap.get(branch);
builder.add(ActiveContentVersionEntry.from(branch, contentVersionFactory.create(nodeVersionMetadata)));
}
return builder.build();
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class UnpublishContentCommand method removePendingDeleteFromDraft.
private void removePendingDeleteFromDraft(final UnpublishContentsResult result) {
final Branch currentBranch = ContextAccessor.current().getBranch();
if (!currentBranch.equals(ContentConstants.BRANCH_DRAFT)) {
final Context draftContext = ContextBuilder.from(ContextAccessor.current()).branch(ContentConstants.BRANCH_DRAFT).build();
draftContext.callWith(() -> {
final Nodes draftNodes = this.nodeService.getByIds(NodeIds.from(result.getUnpublishedContents().asStrings()));
for (final Node draftNode : draftNodes) {
if (draftNode.getNodeState().value().equalsIgnoreCase(ContentState.PENDING_DELETE.toString())) {
this.nodeService.deleteById(draftNode.id());
}
}
return null;
});
}
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepoDumper method dumpBranch.
private void dumpBranch(final BranchDumpResult.Builder dumpResult, Consumer<NodeId> nodeIdsAccumulator) {
final Node rootNode = this.nodeService.getRoot();
final FindNodesByParentResult children = this.nodeService.findByParent(FindNodesByParentParams.create().parentId(rootNode.id()).recursive(true).childOrder(ChildOrder.from("_path asc")).build());
final Branch branch = ContextAccessor.current().getBranch();
this.listener.dumpingBranch(repository.getId(), branch, children.getTotalHits() + 1);
LOG.info("Dumping repository [{}], branch [{}]", repository.getId(), branch);
doDumpNode(rootNode.id(), dumpResult);
nodeIdsAccumulator.accept(rootNode.id());
for (final NodeId child : children.getNodeIds()) {
doDumpNode(child, dumpResult);
nodeIdsAccumulator.accept(child);
}
}
Aggregations