Search in sources :

Example 1 with UnpublishContentsResult

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

the class UnpublishContentHandler method execute.

public List<String> execute() {
    final Branch targetBranch = ContentConstants.BRANCH_MASTER;
    final Context context = ContextBuilder.from(ContextAccessor.current()).branch(targetBranch).build();
    final List<ContentId> contentIds = context.callWith(this::resolveContentIds);
    final UnpublishContentParams unpublishContentParams = UnpublishContentParams.create().contentIds(ContentIds.from(contentIds)).unpublishBranch(targetBranch).includeChildren(true).build();
    final UnpublishContentsResult result = this.contentService.unpublishContent(unpublishContentParams);
    return result.getUnpublishedContents().stream().map(ContentId::toString).collect(Collectors.toList());
}
Also used : BeanContext(com.enonic.xp.script.bean.BeanContext) Context(com.enonic.xp.context.Context) Branch(com.enonic.xp.branch.Branch) UnpublishContentParams(com.enonic.xp.content.UnpublishContentParams) UnpublishContentsResult(com.enonic.xp.content.UnpublishContentsResult) ContentId(com.enonic.xp.content.ContentId)

Example 2 with UnpublishContentsResult

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

the class UnpublishContentCommand method unpublish.

private UnpublishContentsResult unpublish() {
    final ContentIds.Builder contentBuilder = ContentIds.create();
    for (final ContentId contentId : this.params.getContentIds()) {
        recursiveUnpublish(NodeId.from(contentId), this.params.isIncludeChildren(), contentBuilder);
    }
    final ContentIds contentIds = contentBuilder.build();
    final Context draftContext = ContextBuilder.from(ContextAccessor.current()).branch(ContentConstants.BRANCH_DRAFT).build();
    draftContext.callWith(() -> removePublishInfo(contentIds));
    final UnpublishContentsResult.Builder resultBuilder = UnpublishContentsResult.create().addUnpublished(contentIds);
    if (contentIds.getSize() == 1) {
        draftContext.callWith(() -> {
            resultBuilder.setContentPath(this.getContent(contentIds.first()).getPath());
            return null;
        });
    }
    final UnpublishContentsResult result = resultBuilder.build();
    removePendingDeleteFromDraft(result);
    return result;
}
Also used : Context(com.enonic.xp.context.Context) UnpublishContentsResult(com.enonic.xp.content.UnpublishContentsResult) ContentIds(com.enonic.xp.content.ContentIds) ContentId(com.enonic.xp.content.ContentId)

Example 3 with UnpublishContentsResult

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

the class ContentServiceImpl method unpublishContent.

@Override
public UnpublishContentsResult unpublishContent(final UnpublishContentParams params) {
    final UnpublishContentsResult result = UnpublishContentCommand.create().params(params).nodeService(this.nodeService).contentTypeService(this.contentTypeService).translator(this.translator).eventPublisher(this.eventPublisher).build().execute();
    contentAuditLogSupport.unpublishContent(params, result);
    return result;
}
Also used : UnpublishContentsResult(com.enonic.xp.content.UnpublishContentsResult)

Aggregations

UnpublishContentsResult (com.enonic.xp.content.UnpublishContentsResult)3 ContentId (com.enonic.xp.content.ContentId)2 Context (com.enonic.xp.context.Context)2 Branch (com.enonic.xp.branch.Branch)1 ContentIds (com.enonic.xp.content.ContentIds)1 UnpublishContentParams (com.enonic.xp.content.UnpublishContentParams)1 BeanContext (com.enonic.xp.script.bean.BeanContext)1