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());
}
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;
}
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;
}
Aggregations