use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class RenameNodeCommand method execute.
public MoveNodeResult execute() {
final NodeId nodeId = params.getNodeId();
final Node nodeToBeRenamed = doGetById(nodeId);
if (nodeToBeRenamed == null) {
throw new NodeNotFoundException("cannot rename node with id [" + nodeId + "]");
}
if (nodeToBeRenamed.isRoot()) {
throw new OperationNotPermittedException("Not allowed to rename root-node");
}
final NodePath parentPath = nodeToBeRenamed.parentPath().asAbsolute();
return MoveNodeCommand.create(this).id(params.getNodeId()).newParent(parentPath).newNodeName(params.getNewNodeName()).processor(params.getProcessor()).build().execute();
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class SetActiveVersionCommand method execute.
public NodeVersionId execute() {
final InternalContext context = InternalContext.from(ContextAccessor.current());
final Node node = this.nodeStorageService.get(nodeId, nodeVersionId, context);
if (node == null) {
throw new NodeNotFoundException("Cannot find nodeVersion [" + this.nodeVersionId + "] in branch " + context.getBranch().getValue());
}
if (!node.id().equals(nodeId)) {
throw new NodeNotFoundException("NodeVersionId [" + nodeVersionId + "] not a version of Node with id [" + nodeId + "]");
}
NodePermissionsResolver.requireContextUserPermissionOrAdmin(REQUIRED_PERMISSION, node);
this.nodeStorageService.updateVersion(node, nodeVersionId, context);
return nodeVersionId;
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class RepositoryServiceImpl method pushRootNode.
private void pushRootNode(final Repository currentRepo, final Branch branch) {
final Context context = ContextAccessor.current();
final InternalContext internalContext = InternalContext.create(context).branch(RepositoryConstants.MASTER_BRANCH).build();
final Node rootNode = this.nodeStorageService.get(Node.ROOT_UUID, internalContext);
if (rootNode == null) {
throw new NodeNotFoundException("Cannot find root-node in repository [" + currentRepo + "]");
}
this.nodeStorageService.push(rootNode, branch, internalContext);
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class NodeStorageServiceImpl method updateMetadata.
@Override
public Node updateMetadata(final Node node, final InternalContext context) {
final NodeBranchEntry nodeBranchEntry = this.branchService.get(node.id(), context);
if (nodeBranchEntry == null) {
throw new NodeNotFoundException("Cannot find node with id: " + node.id() + " in branch " + context.getBranch());
}
final NodeVersionId nodeVersionId = nodeBranchEntry.getVersionId();
final NodeVersionKey nodeVersionKey = nodeBranchEntry.getNodeVersionKey();
final StoreBranchMetadataParams storeBranchMetadataParams = StoreBranchMetadataParams.create().node(node).nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionKey).context(context).build();
storeBranchMetadata(storeBranchMetadataParams);
indexNode(node, nodeVersionId, context);
return Node.create(node).nodeVersionId(nodeVersionId).build();
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class NodeStorageServiceImpl method updateVersion.
@Override
public void updateVersion(final Node node, final NodeVersionId nodeVersionId, final InternalContext context) {
// TODO Check
final NodeVersionMetadata nodeVersionMetadata = this.versionService.getVersion(node.id(), nodeVersionId, context);
if (nodeVersionMetadata == null) {
throw new NodeNotFoundException("Cannot find node version with id: " + nodeVersionId);
}
this.branchService.store(NodeBranchEntry.create().nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionMetadata.getNodeVersionKey()).nodeId(node.id()).nodeState(node.getNodeState()).timestamp(node.getTimestamp()).nodePath(node.path()).build(), context);
this.indexDataService.store(node, context);
}
Aggregations