use of com.enonic.xp.node.NodeIds in project xp by enonic.
the class CommitNodeHandler method execute.
@Override
public NodeCommitEntryMapper execute() {
final NodeCommitEntry nodeCommitEntry = NodeCommitEntry.create().message(message).build();
final NodeIds nodeIds = getNodeIds();
final NodeCommitEntry createdCommitEntry = nodeService.commit(nodeCommitEntry, nodeIds);
return new NodeCommitEntryMapper(createdCommitEntry);
}
use of com.enonic.xp.node.NodeIds in project xp by enonic.
the class DeleteNodeHandlerTest method mockGetNode.
private void mockGetNode() {
Mockito.when(this.nodeService.deleteById(Mockito.any())).thenReturn(NodeIds.empty());
Mockito.when(this.nodeService.deleteByPath(Mockito.any())).thenReturn(NodeIds.empty());
final NodeIds nodeIds = NodeIds.from("nodeId", "aSubNodeId");
Mockito.when(this.nodeService.deleteById(NodeId.from("nodeId"))).thenReturn(nodeIds);
Mockito.when(this.nodeService.deleteByPath(NodePath.create("/node2-path").build())).thenReturn(nodeIds);
}
use of com.enonic.xp.node.NodeIds 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.NodeIds in project xp by enonic.
the class FindContentByQueryCommand method execute.
FindContentByQueryResult execute() {
final NodeQuery nodeQuery = ContentQueryNodeQueryTranslator.translate(this.params.getContentQuery()).addQueryFilters(createFilters()).build();
final FindNodesByQueryResult result = nodeService.findByQuery(nodeQuery);
final NodeIds nodeIds = result.getNodeIds();
final Map<ContentId, HighlightedProperties> highlight = result.getNodeHits().stream().filter(nodeHit -> nodeHit.getHighlight() != null && nodeHit.getHighlight().size() > 0).collect(Collectors.toMap(hit -> ContentId.from(hit.getNodeId().toString()), NodeHit::getHighlight));
final Nodes foundNodes = this.nodeService.getByIds(nodeIds);
Contents contents = this.translator.fromNodes(foundNodes, true);
return FindContentByQueryResult.create().contents(contents).aggregations(result.getAggregations()).hits(result.getHits()).totalHits(result.getTotalHits()).highlight(highlight).build();
}
use of com.enonic.xp.node.NodeIds in project xp by enonic.
the class GetContentByIdsCommand method doExecute.
private Contents doExecute() {
final NodeIds nodeIds = getAsNodeIds(this.params.getIds());
final Nodes nodes = nodeService.getByIds(nodeIds);
return this.translator.fromNodes(nodes, true);
}
Aggregations