Search in sources :

Example 1 with NodeAccessException

use of com.enonic.xp.node.NodeAccessException in project xp by enonic.

the class ArchiveContentCommand method execute.

ArchiveContentsResult execute() {
    params.validate();
    try {
        final ArchiveContentsResult archivedContents = doExecute();
        this.nodeService.refresh(RefreshMode.ALL);
        return archivedContents;
    } catch (MoveNodeException e) {
        throw new ArchiveContentException(e.getMessage(), ContentNodeHelper.translateNodePathToContentPath(e.getPath()));
    } catch (NodeAccessException e) {
        throw new ContentAccessException(e);
    }
}
Also used : MoveNodeException(com.enonic.xp.node.MoveNodeException) NodeAccessException(com.enonic.xp.node.NodeAccessException) ArchiveContentException(com.enonic.xp.archive.ArchiveContentException) ArchiveContentsResult(com.enonic.xp.archive.ArchiveContentsResult) ContentAccessException(com.enonic.xp.content.ContentAccessException)

Example 2 with NodeAccessException

use of com.enonic.xp.node.NodeAccessException in project xp by enonic.

the class ContentServiceImpl method setChildOrder.

@Override
public Content setChildOrder(final SetContentChildOrderParams params) {
    try {
        final SetNodeChildOrderParams.Builder builder = SetNodeChildOrderParams.create().nodeId(NodeId.from(params.getContentId())).childOrder(params.getChildOrder());
        if (params.stopInherit()) {
            builder.processor(new SetContentChildOrderProcessor());
        }
        final Node node = nodeService.setChildOrder(builder.build());
        final Content content = translator.fromNode(node, true);
        contentAuditLogSupport.setChildOrder(params, content);
        return content;
    } catch (NodeAccessException e) {
        throw new ContentAccessException(e);
    }
}
Also used : NodeAccessException(com.enonic.xp.node.NodeAccessException) SetNodeChildOrderParams(com.enonic.xp.node.SetNodeChildOrderParams) Content(com.enonic.xp.content.Content) Node(com.enonic.xp.node.Node) ContentAccessException(com.enonic.xp.content.ContentAccessException)

Example 3 with NodeAccessException

use of com.enonic.xp.node.NodeAccessException in project xp by enonic.

the class MoveContentCommand method execute.

MoveContentsResult execute() {
    params.validate();
    try {
        final MoveContentsResult movedContents = doExecute();
        this.nodeService.refresh(RefreshMode.ALL);
        return movedContents;
    } catch (MoveNodeException e) {
        throw new MoveContentException(e.getMessage(), ContentPath.from(e.getPath().toString()));
    } catch (NodeAlreadyExistAtPathException e) {
        throw new ContentAlreadyExistsException(ContentPath.from(e.getNode().toString()), e.getRepositoryId(), e.getBranch());
    } catch (NodeAccessException e) {
        throw new ContentAccessException(e);
    }
}
Also used : MoveNodeException(com.enonic.xp.node.MoveNodeException) NodeAccessException(com.enonic.xp.node.NodeAccessException) MoveContentException(com.enonic.xp.content.MoveContentException) MoveContentsResult(com.enonic.xp.content.MoveContentsResult) ContentAlreadyExistsException(com.enonic.xp.content.ContentAlreadyExistsException) NodeAlreadyExistAtPathException(com.enonic.xp.node.NodeAlreadyExistAtPathException) ContentAccessException(com.enonic.xp.content.ContentAccessException)

Example 4 with NodeAccessException

use of com.enonic.xp.node.NodeAccessException in project xp by enonic.

the class UpdateContentCommand method execute.

Content execute() {
    params.validate();
    validateCreateAttachments(params.getCreateAttachments());
    try {
        return doExecute();
    } catch (NodeAccessException e) {
        throw new ContentAccessException(e);
    }
}
Also used : NodeAccessException(com.enonic.xp.node.NodeAccessException) ContentAccessException(com.enonic.xp.content.ContentAccessException)

Example 5 with NodeAccessException

use of com.enonic.xp.node.NodeAccessException in project xp by enonic.

the class AbstractDeleteNodeCommand method deleteNodeWithChildren.

NodeBranchEntries deleteNodeWithChildren(final Node node, final Context context, final DeleteNodeListener deleteNodeListener) {
    if (node.isRoot() && !allowDeleteRootNode) {
        throw new OperationNotPermittedException("Not allowed to delete root-node");
    }
    doRefresh();
    final NodeBranchEntries nodesToBeDeleted = newResolveNodesToDelete(node);
    final NodeIds nodeIds = NodeIds.from(nodesToBeDeleted.getKeys());
    final boolean allHasPermissions = NodesHasPermissionResolver.create(this).nodeIds(nodeIds).permission(Permission.DELETE).build().execute();
    if (!allHasPermissions) {
        throw new NodeAccessException(context.getAuthInfo().getUser(), node.path(), Permission.DELETE);
    }
    for (final List<NodeId> keysBatch : Iterables.partition(nodeIds, BATCH_SIZE)) {
        this.nodeStorageService.delete(NodeIds.from(keysBatch), InternalContext.from(context));
        if (deleteNodeListener != null) {
            deleteNodeListener.nodesDeleted(keysBatch.size());
        }
    }
    doRefresh();
    return nodesToBeDeleted;
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeAccessException(com.enonic.xp.node.NodeAccessException) NodeIds(com.enonic.xp.node.NodeIds) NodeId(com.enonic.xp.node.NodeId) OperationNotPermittedException(com.enonic.xp.node.OperationNotPermittedException)

Aggregations

NodeAccessException (com.enonic.xp.node.NodeAccessException)11 ContentAccessException (com.enonic.xp.content.ContentAccessException)7 Node (com.enonic.xp.node.Node)5 MoveNodeException (com.enonic.xp.node.MoveNodeException)3 ContentAlreadyExistsException (com.enonic.xp.content.ContentAlreadyExistsException)2 NodeAlreadyExistAtPathException (com.enonic.xp.node.NodeAlreadyExistAtPathException)2 Test (org.junit.jupiter.api.Test)2 ArchiveContentException (com.enonic.xp.archive.ArchiveContentException)1 ArchiveContentsResult (com.enonic.xp.archive.ArchiveContentsResult)1 RestoreContentException (com.enonic.xp.archive.RestoreContentException)1 RestoreContentsResult (com.enonic.xp.archive.RestoreContentsResult)1 Content (com.enonic.xp.content.Content)1 CreateContentParams (com.enonic.xp.content.CreateContentParams)1 CreateContentTranslatorParams (com.enonic.xp.content.CreateContentTranslatorParams)1 DeleteContentsResult (com.enonic.xp.content.DeleteContentsResult)1 MoveContentException (com.enonic.xp.content.MoveContentException)1 MoveContentsResult (com.enonic.xp.content.MoveContentsResult)1 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)1 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)1 NodeId (com.enonic.xp.node.NodeId)1