use of com.enonic.xp.content.ContentIds in project xp by enonic.
the class ContentServiceImplTest_resolveRequiredDependencies method resolve_empty.
@Test
public void resolve_empty() throws Exception {
content1 = createContent(ContentPath.ROOT);
content2 = createContent(content1.getPath());
content3 = createContent(content2.getPath());
refresh();
final ContentIds result = this.contentService.resolveRequiredDependencies(ResolveRequiredDependenciesParams.create().contentIds(ContentIds.empty()).target(WS_OTHER).build());
assertTrue(result.getSize() == 0);
}
use of com.enonic.xp.content.ContentIds in project xp by enonic.
the class QueryContentHandler method convert.
private ContentsResultMapper convert(final FindContentIdsByQueryResult findQueryResult) {
final ContentIds contentIds = findQueryResult.getContentIds();
final Contents contents;
if (contentIds.isEmpty()) {
contents = Contents.empty();
} else {
contents = this.contentService.getByIds(new GetContentByIdsParams(contentIds));
}
return new ContentsResultMapper(contents, findQueryResult.getTotalHits(), findQueryResult.getAggregations(), findQueryResult.getHighlight(), findQueryResult.getSort(), findQueryResult.getScore());
}
use of com.enonic.xp.content.ContentIds in project xp by enonic.
the class GetOutboundDependenciesHandler method doExecute.
@Override
protected Object doExecute() {
validate();
ContentIds contentIds;
if (this.key.startsWith("/")) {
final Content content = contentService.getByPath(ContentPath.from(this.key));
contentIds = contentService.getOutboundDependencies(content.getId());
} else {
contentIds = contentService.getOutboundDependencies(ContentId.from(key));
}
return contentIds.stream().map(ContentId::toString).collect(Collectors.toList());
}
use of com.enonic.xp.content.ContentIds 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.ContentIds in project xp by enonic.
the class PublishContentCommand method pushAndDelete.
private void pushAndDelete(final CompareContentResults results) {
NodeIds.Builder pushNodesIds = NodeIds.create();
NodeIds.Builder deletedNodesIds = NodeIds.create();
for (CompareContentResult compareResult : results) {
if (compareResult.getCompareStatus() == CompareStatus.PENDING_DELETE) {
deletedNodesIds.add(NodeId.from(compareResult.getContentId()));
} else {
pushNodesIds.add(NodeId.from(compareResult.getContentId()));
}
}
final ContentIds pushContentsIds = ContentIds.from(pushNodesIds.build().stream().map((n) -> ContentId.from(n.toString())).toArray(ContentId[]::new));
final boolean validContents = checkIfAllContentsValid(pushContentsIds);
if (validContents) {
doPushNodes(pushNodesIds.build());
} else {
this.resultBuilder.setFailed(pushContentsIds);
}
doDeleteNodes(deletedNodesIds.build());
}
Aggregations