use of org.craftercms.studio.api.v1.dal.ItemState in project studio by craftercms.
the class ObjectStateServiceImpl method getChangeSet.
@Override
@ValidateParams
public List<ItemState> getChangeSet(@ValidateStringParam(name = "site") String site) {
Map<String, Object> params = new HashMap<String, Object>();
List<String> statesValues = new ArrayList<String>();
for (State state : State.IN_PROGRESS_STATES) {
statesValues.add(state.name());
}
params.put("states", statesValues);
params.put("site", site);
List<ItemState> objects = itemStateMapper.getObjectStateByStates(params);
return objects;
}
use of org.craftercms.studio.api.v1.dal.ItemState in project studio by craftercms.
the class ObjectStateServiceImpl method isUpdatedOrSubmitted.
@Override
@ValidateParams
public boolean isUpdatedOrSubmitted(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path) {
path = FilenameUtils.normalize(path, true);
ItemState state = getObjectState(site, path);
if (state != null) {
return State.isUpdateOrSubmitted(State.valueOf(state.getState()));
} else {
return false;
}
}
use of org.craftercms.studio.api.v1.dal.ItemState 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.dal.ItemState in project studio by craftercms.
the class WorkflowServiceImpl method handleReferences.
protected void handleReferences(String site, SubmitPackage submitpackage, DmDependencyTO dmDependencyTO, boolean isNotScheduled, SubmitPackage dependencyPackage, String approver, Set<String> rescheduledUris, Set<String> processedUris) {
if (!processedUris.contains(dmDependencyTO.getUri())) {
ItemMetadata properties = objectMetadataManager.getProperties(site, dmDependencyTO.getUri());
ZonedDateTime scheduledDate = null;
if (properties != null) {
scheduledDate = properties.getLaunchDate();
}
ItemState state = objectStateService.getObjectState(site, dmDependencyTO.getUri());
if (state != null) {
if (!State.isSubmitted(State.valueOf(state.getState())) && scheduledDate != null && scheduledDate.equals(dmDependencyTO.getScheduledDate())) {
if (objectStateService.isScheduled(site, dmDependencyTO.getUri())) {
return;
} else {
submitpackage.addToPackage(dmDependencyTO);
}
}
}
if (!dmDependencyTO.isReference()) {
submitpackage.addToPackage(dmDependencyTO);
}
if (isRescheduleRequest(dmDependencyTO, site)) {
rescheduledUris.add(dmDependencyTO.getUri());
}
processedUris.add(dmDependencyTO.getUri());
}
}
use of org.craftercms.studio.api.v1.dal.ItemState 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());
}
}
}
}
Aggregations