Search in sources :

Example 1 with ContentAccessException

use of com.enonic.xp.content.ContentAccessException 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 ContentAccessException

use of com.enonic.xp.content.ContentAccessException 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 ContentAccessException

use of com.enonic.xp.content.ContentAccessException 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 ContentAccessException

use of com.enonic.xp.content.ContentAccessException 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 ContentAccessException

use of com.enonic.xp.content.ContentAccessException in project xp by enonic.

the class CreateContentCommand method doExecute.

private Content doExecute() {
    final ContentType contentType = contentTypeService.getByName(new GetContentTypeParams().contentTypeName(params.getType()));
    validateContentType(contentType);
    formDefaultValuesProcessor.setDefaultValues(contentType.getForm(), params.getData());
    // TODO apply default values to xData
    CreateContentParams processedParams = runContentProcessors(this.params, contentType);
    validateBlockingChecks(processedParams);
    final CreateContentTranslatorParams createContentTranslatorParams = createContentTranslatorParams(processedParams);
    final CreateNodeParams createNodeParams = CreateNodeParamsFactory.create(createContentTranslatorParams).contentTypeService(this.contentTypeService).pageDescriptorService(this.pageDescriptorService).xDataService(this.xDataService).partDescriptorService(this.partDescriptorService).layoutDescriptorService(this.layoutDescriptorService).contentDataSerializer(this.contentDataSerializer).siteService(this.siteService).build().produce();
    try {
        final Node createdNode = nodeService.create(createNodeParams);
        if (params.isRefresh()) {
            nodeService.refresh(RefreshMode.SEARCH);
        }
        return translator.fromNode(createdNode, false);
    } catch (NodeAlreadyExistAtPathException e) {
        throw new ContentAlreadyExistsException(ContentPath.from(createContentTranslatorParams.getParent(), createContentTranslatorParams.getName().toString()), e.getRepositoryId(), e.getBranch());
    } catch (NodeAccessException e) {
        throw new ContentAccessException(e);
    }
}
Also used : GetContentTypeParams(com.enonic.xp.schema.content.GetContentTypeParams) NodeAccessException(com.enonic.xp.node.NodeAccessException) ContentType(com.enonic.xp.schema.content.ContentType) CreateContentTranslatorParams(com.enonic.xp.content.CreateContentTranslatorParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Node(com.enonic.xp.node.Node) ContentAlreadyExistsException(com.enonic.xp.content.ContentAlreadyExistsException) NodeAlreadyExistAtPathException(com.enonic.xp.node.NodeAlreadyExistAtPathException) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) ContentAccessException(com.enonic.xp.content.ContentAccessException)

Aggregations

ContentAccessException (com.enonic.xp.content.ContentAccessException)7 NodeAccessException (com.enonic.xp.node.NodeAccessException)7 MoveNodeException (com.enonic.xp.node.MoveNodeException)3 ContentAlreadyExistsException (com.enonic.xp.content.ContentAlreadyExistsException)2 Node (com.enonic.xp.node.Node)2 NodeAlreadyExistAtPathException (com.enonic.xp.node.NodeAlreadyExistAtPathException)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 SetNodeChildOrderParams (com.enonic.xp.node.SetNodeChildOrderParams)1 ContentType (com.enonic.xp.schema.content.ContentType)1 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)1