Search in sources :

Example 1 with NodeName

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());
}
Also used : NodeName(com.enonic.xp.node.NodeName) ValidationErrors(com.enonic.xp.content.ValidationErrors) Content(com.enonic.xp.content.Content) RenameNodeParams(com.enonic.xp.node.RenameNodeParams) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId)

Example 2 with NodeName

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();
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) NodeName(com.enonic.xp.node.NodeName) Node(com.enonic.xp.node.Node) OperationNotPermittedException(com.enonic.xp.node.OperationNotPermittedException) NodePath(com.enonic.xp.node.NodePath)

Aggregations

Node (com.enonic.xp.node.Node)2 NodeName (com.enonic.xp.node.NodeName)2 Content (com.enonic.xp.content.Content)1 ValidationErrors (com.enonic.xp.content.ValidationErrors)1 NodeId (com.enonic.xp.node.NodeId)1 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)1 NodePath (com.enonic.xp.node.NodePath)1 OperationNotPermittedException (com.enonic.xp.node.OperationNotPermittedException)1 RenameNodeParams (com.enonic.xp.node.RenameNodeParams)1