Search in sources :

Example 1 with GetPublishStatusesParams

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();
}
Also used : DuplicateContentParams(com.enonic.xp.content.DuplicateContentParams) QueryParser(com.enonic.xp.query.parser.QueryParser) FindContentIdsByQueryResult(com.enonic.xp.content.FindContentIdsByQueryResult) ArchiveContentsResult(com.enonic.xp.archive.ArchiveContentsResult) PublishContentResult(com.enonic.xp.content.PublishContentResult) ContextAccessor(com.enonic.xp.context.ContextAccessor) NodeService(com.enonic.xp.node.NodeService) ProjectService(com.enonic.xp.project.ProjectService) CreateSiteParams(com.enonic.xp.site.CreateSiteParams) ReferencePolicy(org.osgi.service.component.annotations.ReferencePolicy) LayoutDescriptorService(com.enonic.xp.region.LayoutDescriptorService) PushContentParams(com.enonic.xp.content.PushContentParams) ReorderChildNodesResult(com.enonic.xp.node.ReorderChildNodesResult) ArchiveContentParams(com.enonic.xp.archive.ArchiveContentParams) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ContentValidator(com.enonic.xp.content.ContentValidator) FindContentByQueryParams(com.enonic.xp.content.FindContentByQueryParams) EventPublisher(com.enonic.xp.event.EventPublisher) Node(com.enonic.xp.node.Node) FindContentVersionsResult(com.enonic.xp.content.FindContentVersionsResult) ResolvePublishDependenciesParams(com.enonic.xp.content.ResolvePublishDependenciesParams) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) ContentVersionId(com.enonic.xp.content.ContentVersionId) RestoreContentParams(com.enonic.xp.archive.RestoreContentParams) ReorderChildParams(com.enonic.xp.content.ReorderChildParams) PageDescriptorService(com.enonic.xp.page.PageDescriptorService) Component(org.osgi.service.component.annotations.Component) Tracer(com.enonic.xp.trace.Tracer) MediaInfoService(com.enonic.xp.media.MediaInfoService) MoveContentsResult(com.enonic.xp.content.MoveContentsResult) ByteSource(com.google.common.io.ByteSource) ContentAccessException(com.enonic.xp.content.ContentAccessException) ContentPath(com.enonic.xp.content.ContentPath) SetActiveContentVersionResult(com.enonic.xp.content.SetActiveContentVersionResult) Content(com.enonic.xp.content.Content) IOException(java.io.IOException) ReorderChildNodeParams(com.enonic.xp.node.ReorderChildNodeParams) FindContentIdsByParentResult(com.enonic.xp.content.FindContentIdsByParentResult) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) PublishStatus(com.enonic.xp.content.PublishStatus) ContentIds(com.enonic.xp.content.ContentIds) RenameContentParams(com.enonic.xp.content.RenameContentParams) GetActiveContentVersionsResult(com.enonic.xp.content.GetActiveContentVersionsResult) MoveContentParams(com.enonic.xp.content.MoveContentParams) NodeAccessException(com.enonic.xp.node.NodeAccessException) UnmodifiableIterator(com.google.common.collect.UnmodifiableIterator) GetActiveContentVersionParams(com.enonic.xp.content.GetActiveContentVersionParams) DeleteContentsResult(com.enonic.xp.content.DeleteContentsResult) GetPublishStatusesParams(com.enonic.xp.content.GetPublishStatusesParams) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) FindContentPathsByQueryParams(com.enonic.xp.content.FindContentPathsByQueryParams) ImportContentParams(com.enonic.xp.content.ImportContentParams) LoggerFactory(org.slf4j.LoggerFactory) ImportContentResult(com.enonic.xp.content.ImportContentResult) ContentTypeService(com.enonic.xp.schema.content.ContentTypeService) GetPublishStatusesResult(com.enonic.xp.content.GetPublishStatusesResult) Trace(com.enonic.xp.trace.Trace) ApplyContentPermissionsParams(com.enonic.xp.content.ApplyContentPermissionsParams) FindContentPathsByQueryResult(com.enonic.xp.content.FindContentPathsByQueryResult) ContentId(com.enonic.xp.content.ContentId) ApplyContentPermissionsResult(com.enonic.xp.content.ApplyContentPermissionsResult) FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) DuplicateContentsResult(com.enonic.xp.content.DuplicateContentsResult) CompareContentsParams(com.enonic.xp.content.CompareContentsParams) ContentDependencies(com.enonic.xp.content.ContentDependencies) ContextBuilder(com.enonic.xp.context.ContextBuilder) FormDefaultValuesProcessor(com.enonic.xp.form.FormDefaultValuesProcessor) BinaryReference(com.enonic.xp.util.BinaryReference) SiteService(com.enonic.xp.site.SiteService) Predicate(java.util.function.Predicate) ContentProcessor(com.enonic.xp.content.processor.ContentProcessor) Instant(java.time.Instant) AccessControlList(com.enonic.xp.security.acl.AccessControlList) ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) NodeId(com.enonic.xp.node.NodeId) List(java.util.List) Site(com.enonic.xp.site.Site) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) ReorderChildContentsResult(com.enonic.xp.content.ReorderChildContentsResult) Contents(com.enonic.xp.content.Contents) FindContentByQueryResult(com.enonic.xp.content.FindContentByQueryResult) GetActiveContentVersionsParams(com.enonic.xp.content.GetActiveContentVersionsParams) ContentDataSerializer(com.enonic.xp.core.impl.content.serializer.ContentDataSerializer) UnpublishContentsResult(com.enonic.xp.content.UnpublishContentsResult) CompareContentResults(com.enonic.xp.content.CompareContentResults) CreateContentParams(com.enonic.xp.content.CreateContentParams) RefreshMode(com.enonic.xp.node.RefreshMode) ContentService(com.enonic.xp.content.ContentService) SiteConfigsDataSerializer(com.enonic.xp.site.SiteConfigsDataSerializer) ResolveRequiredDependenciesParams(com.enonic.xp.content.ResolveRequiredDependenciesParams) RestoreContentsResult(com.enonic.xp.archive.RestoreContentsResult) ContentValidityParams(com.enonic.xp.content.ContentValidityParams) ReorderChildNodesParams(com.enonic.xp.node.ReorderChildNodesParams) DeleteContentParams(com.enonic.xp.content.DeleteContentParams) CompareContentResult(com.enonic.xp.content.CompareContentResult) ContentVersion(com.enonic.xp.content.ContentVersion) SetNodeChildOrderParams(com.enonic.xp.node.SetNodeChildOrderParams) ContentPaths(com.enonic.xp.content.ContentPaths) NodeVersionId(com.enonic.xp.node.NodeVersionId) FindContentVersionsParams(com.enonic.xp.content.FindContentVersionsParams) UndoPendingDeleteContentParams(com.enonic.xp.content.UndoPendingDeleteContentParams) Activate(org.osgi.service.component.annotations.Activate) HasUnpublishedChildrenParams(com.enonic.xp.content.HasUnpublishedChildrenParams) XDataService(com.enonic.xp.schema.xdata.XDataService) PropertyTree(com.enonic.xp.data.PropertyTree) PartDescriptorService(com.enonic.xp.region.PartDescriptorService) Logger(org.slf4j.Logger) ContentPropertyNames(com.enonic.xp.content.ContentPropertyNames) UpdateMediaParams(com.enonic.xp.content.UpdateMediaParams) UnpublishContentParams(com.enonic.xp.content.UnpublishContentParams) NodePath(com.enonic.xp.node.NodePath) ContentPublishInfo(com.enonic.xp.content.ContentPublishInfo) Branches(com.enonic.xp.branch.Branches) ApplicationKey(com.enonic.xp.app.ApplicationKey) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) ContentQuery(com.enonic.xp.content.ContentQuery) ReprocessContentParams(com.enonic.xp.content.ReprocessContentParams) GetPublishStatusResult(com.enonic.xp.content.GetPublishStatusResult) CompareContentParams(com.enonic.xp.content.CompareContentParams) ContentValidityResult(com.enonic.xp.content.ContentValidityResult) Modified(org.osgi.service.component.annotations.Modified) ReorderChildContentsParams(com.enonic.xp.content.ReorderChildContentsParams) SetContentChildOrderParams(com.enonic.xp.content.SetContentChildOrderParams) ActiveContentVersionEntry(com.enonic.xp.content.ActiveContentVersionEntry) Reference(org.osgi.service.component.annotations.Reference) CreateMediaParams(com.enonic.xp.content.CreateMediaParams) InputStream(java.io.InputStream) GetContentByIdsParams(com.enonic.xp.content.GetContentByIdsParams) Contents(com.enonic.xp.content.Contents) GetPublishStatusesResult(com.enonic.xp.content.GetPublishStatusesResult) Instant(java.time.Instant) ContentPublishInfo(com.enonic.xp.content.ContentPublishInfo) GetPublishStatusResult(com.enonic.xp.content.GetPublishStatusResult)

Aggregations

ApplicationKey (com.enonic.xp.app.ApplicationKey)1 ArchiveContentParams (com.enonic.xp.archive.ArchiveContentParams)1 ArchiveContentsResult (com.enonic.xp.archive.ArchiveContentsResult)1 RestoreContentParams (com.enonic.xp.archive.RestoreContentParams)1 RestoreContentsResult (com.enonic.xp.archive.RestoreContentsResult)1 Branches (com.enonic.xp.branch.Branches)1 ActiveContentVersionEntry (com.enonic.xp.content.ActiveContentVersionEntry)1 ApplyContentPermissionsParams (com.enonic.xp.content.ApplyContentPermissionsParams)1 ApplyContentPermissionsResult (com.enonic.xp.content.ApplyContentPermissionsResult)1 CompareContentParams (com.enonic.xp.content.CompareContentParams)1 CompareContentResult (com.enonic.xp.content.CompareContentResult)1 CompareContentResults (com.enonic.xp.content.CompareContentResults)1 CompareContentsParams (com.enonic.xp.content.CompareContentsParams)1 Content (com.enonic.xp.content.Content)1 ContentAccessException (com.enonic.xp.content.ContentAccessException)1 ContentDependencies (com.enonic.xp.content.ContentDependencies)1 ContentId (com.enonic.xp.content.ContentId)1 ContentIds (com.enonic.xp.content.ContentIds)1 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)1 ContentPath (com.enonic.xp.content.ContentPath)1