use of com.enonic.xp.content.GetPublishStatusesParams in project xp by enonic.
the class ContentServiceImpl method getPublishStatuses.
@Override
public GetPublishStatusesResult getPublishStatuses(final GetPublishStatusesParams params) {
final GetContentByIdsParams getContentByIdsParams = new GetContentByIdsParams(params.getContentIds());
final Instant now = Instant.now();
final Contents contents = ContextBuilder.from(ContextAccessor.current()).branch(params.getTarget()).attribute("ignorePublishTimes", Boolean.TRUE).build().callWith(() -> this.getByIds(getContentByIdsParams));
final GetPublishStatusesResult.Builder getPublishStatusesResult = GetPublishStatusesResult.create();
contents.stream().map(content -> {
final ContentPublishInfo publishInfo = content.getPublishInfo();
if (publishInfo != null) {
if (publishInfo.getTo() != null && publishInfo.getTo().compareTo(now) < 0) {
return new GetPublishStatusResult(content.getId(), PublishStatus.EXPIRED);
}
if (publishInfo.getFrom() != null && publishInfo.getFrom().compareTo(now) > 0) {
return new GetPublishStatusResult(content.getId(), PublishStatus.PENDING);
}
}
return new GetPublishStatusResult(content.getId(), PublishStatus.ONLINE);
}).forEach(getPublishStatusesResult::add);
return getPublishStatusesResult.build();
}
Aggregations