Search in sources :

Example 1 with GoLiveQueue

use of org.craftercms.studio.api.v1.to.GoLiveQueue in project studio by craftercms.

the class WorkflowServiceImpl method addToQueue.

protected void addToQueue(String site, GoLiveQueue queue, GoLiveQueue inProcessQueue, ContentItemTO item, ItemState itemState) throws ServiceLayerException {
    if (item != null) {
        State state = State.valueOf(itemState.getState());
        // add only submitted items to go live Q.
        if (State.isSubmitted(state)) {
            queue.add(item);
        }
        if (inProcessQueue != null) {
            if (!State.isLive(state)) {
                inProcessQueue.add(item);
                inProcessQueue.add(item.getPath(), item);
            }
        }
    } else {
        objectStateService.deleteObjectState(itemState.getObjectId());
    }
}
Also used : ItemState(org.craftercms.studio.api.v1.dal.ItemState) State(org.craftercms.studio.api.v1.service.objectstate.State)

Example 2 with GoLiveQueue

use of org.craftercms.studio.api.v1.to.GoLiveQueue in project studio by craftercms.

the class WorkflowServiceImpl method fillQueue.

@Override
@ValidateParams
public void fillQueue(@ValidateStringParam(name = "site") String site, GoLiveQueue goLiveQueue, GoLiveQueue inProcessQueue) throws ServiceLayerException {
    List<ItemState> changeSet = objectStateService.getSubmittedItems(site);
    // regular categories specified in the configuration
    if (changeSet != null) {
        // add all content items from each task if task is the review task
        for (ItemState state : changeSet) {
            try {
                if (contentService.contentExists(state.getSite(), state.getPath())) {
                    ContentItemTO item = contentService.getContentItem(state.getSite(), state.getPath(), 0);
                    Set<String> permissions = securityService.getUserPermissions(site, item.getUri(), securityService.getCurrentUser(), Collections.<String>emptyList());
                    if (permissions.contains(StudioConstants.PERMISSION_VALUE_PUBLISH)) {
                        addToQueue(site, goLiveQueue, inProcessQueue, item, state);
                    }
                } else {
                    _cancelWorkflow(site, state.getPath());
                    objectStateService.deleteObjectStateForPath(site, state.getPath());
                    objectMetadataManager.deleteObjectMetadata(site, state.getPath());
                }
            } catch (Exception e) {
                logger.error("Could not warm cache for [" + state.getSite() + " : " + state.getPath() + "] " + e.getMessage());
            }
        }
    }
}
Also used : ContentItemTO(org.craftercms.studio.api.v1.to.ContentItemTO) ItemState(org.craftercms.studio.api.v1.dal.ItemState) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) ContentNotFoundException(org.craftercms.studio.api.v1.exception.ContentNotFoundException) JSONException(net.sf.json.JSONException) DeploymentException(org.craftercms.studio.api.v1.service.deployment.DeploymentException) ValidateParams(org.craftercms.commons.validation.annotations.param.ValidateParams)

Example 3 with GoLiveQueue

use of org.craftercms.studio.api.v1.to.GoLiveQueue in project studio by craftercms.

the class WorkflowServiceImpl method getGoLiveItems.

protected List<ContentItemTO> getGoLiveItems(final String site, final DmContentItemComparator comparator) throws ServiceLayerException {
    List<String> displayPatterns = servicesConfig.getDisplayInWidgetPathPatterns(site);
    List<ContentItemTO> categoryItems = getCategoryItems(site);
    GoLiveQueue queue = new GoLiveQueue();
    fillQueue(site, queue, null);
    Set<ContentItemTO> queueItems = queue.getQueue();
    ContentItemTO.ChildFilter childFilter = new GoLiveQueueChildFilter(queue);
    GoLiveQueueOrganizer goLiveQueueOrganizer = new GoLiveQueueOrganizer(contentService, childFilter);
    for (ContentItemTO queueItem : queueItems) {
        if (queueItem.getLastEditDate() != null) {
            queueItem.setEventDate(queueItem.getLastEditDate());
        }
        goLiveQueueOrganizer.addToGoLiveItems(site, queueItem, categoryItems, comparator, false, displayPatterns);
    }
    return categoryItems;
}
Also used : ContentItemTO(org.craftercms.studio.api.v1.to.ContentItemTO) GoLiveQueueChildFilter(org.craftercms.studio.api.v1.to.GoLiveQueueChildFilter) GoLiveQueueOrganizer(org.craftercms.studio.impl.v1.util.GoLiveQueueOrganizer) GoLiveQueue(org.craftercms.studio.api.v1.to.GoLiveQueue)

Aggregations

ItemState (org.craftercms.studio.api.v1.dal.ItemState)2 ContentItemTO (org.craftercms.studio.api.v1.to.ContentItemTO)2 JSONException (net.sf.json.JSONException)1 ValidateParams (org.craftercms.commons.validation.annotations.param.ValidateParams)1 ContentNotFoundException (org.craftercms.studio.api.v1.exception.ContentNotFoundException)1 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)1 DeploymentException (org.craftercms.studio.api.v1.service.deployment.DeploymentException)1 State (org.craftercms.studio.api.v1.service.objectstate.State)1 GoLiveQueue (org.craftercms.studio.api.v1.to.GoLiveQueue)1 GoLiveQueueChildFilter (org.craftercms.studio.api.v1.to.GoLiveQueueChildFilter)1 GoLiveQueueOrganizer (org.craftercms.studio.impl.v1.util.GoLiveQueueOrganizer)1