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