use of com.enonic.xp.node.Node in project xp by enonic.
the class HasUnpublishedChildrenCommand method execute.
public boolean execute() {
final Node parentNode = doGetById(parent);
if (parentNode == null) {
return false;
}
final SearchResult result = nodeSearchService.query(NodeVersionDiffQuery.create().source(ContextAccessor.current().getBranch()).target(target).nodePath(parentNode.path()).size(0).excludes(ExcludeEntries.create().add(new ExcludeEntry(parentNode.path(), false)).build()).build(), SingleRepoStorageSource.create(ContextAccessor.current().getRepositoryId(), SingleRepoStorageSource.Type.VERSION));
return result.getTotalHits() > 0;
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class MoveNodeCommand method execute.
public MoveNodeResult execute() {
final Node existingNode = doGetById(nodeId);
if (existingNode == null) {
throw new NodeNotFoundException("cannot move node with id [" + nodeId + "]");
}
if (existingNode.isRoot()) {
throw new OperationNotPermittedException("Not allowed to move root-node");
}
final NodeName newNodeName = resolveNodeName(existingNode);
final NodePath newParentPath = resolvePath(existingNode);
if (noChanges(existingNode, newParentPath, newNodeName)) {
return result.build();
}
checkNotMovedToSelfOrChild(existingNode, newParentPath, newNodeName);
checkContextUserPermissionOrAdmin(existingNode, newParentPath);
verifyNoExistingAtNewPath(newParentPath, newNodeName);
doMoveNode(newParentPath, newNodeName, nodeId);
RefreshCommand.create().refreshMode(RefreshMode.ALL).indexServiceInternal(this.indexServiceInternal).build().execute();
return result.build();
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class MoveNodeCommand method checkContextUserPermissionOrAdmin.
private void checkContextUserPermissionOrAdmin(final Node existingSourceNode, final NodePath newParentPath) {
NodePermissionsResolver.requireContextUserPermissionOrAdmin(Permission.MODIFY, existingSourceNode);
final Node newParentNode = GetNodeByPathCommand.create(this).nodePath(newParentPath).build().execute();
if (newParentNode == null) {
throw new NodeNotFoundException("Cannot move node to parent with path '" + newParentPath + "', does not exist");
}
NodePermissionsResolver.requireContextUserPermissionOrAdmin(Permission.CREATE, newParentNode);
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class NodeServiceImpl method getById.
@Override
public Node getById(final NodeId id) {
final Trace trace = Tracer.newTrace("node.getById");
if (trace == null) {
return executeGetById(id);
}
return Tracer.trace(trace, () -> {
trace.put("id", id);
final Node node = executeGetById(id);
trace.put("path", node.path());
return node;
});
}
use of com.enonic.xp.node.Node in project xp by enonic.
the class NodeServiceImpl method executeGetById.
private Node executeGetById(final NodeId id) {
verifyContext();
final Node node = doGetById(id);
if (node == null) {
throw new NodeNotFoundException("Node with id " + id + " not found in branch " + ContextAccessor.current().getBranch().getValue());
}
return node;
}
Aggregations