use of com.enonic.xp.node.NodeName in project xp by enonic.
the class RenameContentCommand method doExecute.
private Content doExecute() {
final NodeId nodeId = NodeId.from(params.getContentId());
final NodeName nodeName = NodeName.from(params.getNewName().toString());
final RenameNodeParams.Builder builder = RenameNodeParams.create().nodeId(nodeId).nodeName(nodeName);
if (params.stopInherit()) {
builder.processor(new RenameContentProcessor());
}
final Node node = nodeService.rename(builder.build());
final Content content = translator.fromNode(node, false);
final ValidationErrors validationErrors = validateContent(content);
if (content.isValid() == validationErrors.hasErrors() || !validationErrors.equals(content.getValidationErrors())) {
return updateValidState(content);
}
return getContent(params.getContentId());
}
use of com.enonic.xp.node.NodeName 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();
}
Aggregations