Search in sources :

Example 11 with ItemState

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;
}
Also used : HashMap(java.util.HashMap) State(org.craftercms.studio.api.v1.service.objectstate.State) ItemState(org.craftercms.studio.api.v1.dal.ItemState) ItemState(org.craftercms.studio.api.v1.dal.ItemState) ArrayList(java.util.ArrayList) ValidateParams(org.craftercms.commons.validation.annotations.param.ValidateParams)

Example 12 with ItemState

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;
    }
}
Also used : ItemState(org.craftercms.studio.api.v1.dal.ItemState) ValidateParams(org.craftercms.commons.validation.annotations.param.ValidateParams)

Example 13 with ItemState

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());
    }
}
Also used : ItemState(org.craftercms.studio.api.v1.dal.ItemState) State(org.craftercms.studio.api.v1.service.objectstate.State)

Example 14 with ItemState

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());
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ItemState(org.craftercms.studio.api.v1.dal.ItemState) ItemMetadata(org.craftercms.studio.api.v1.dal.ItemMetadata)

Example 15 with ItemState

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

Aggregations

ItemState (org.craftercms.studio.api.v1.dal.ItemState)25 ValidateParams (org.craftercms.commons.validation.annotations.param.ValidateParams)19 HashMap (java.util.HashMap)12 ContentItemTO (org.craftercms.studio.api.v1.to.ContentItemTO)7 ArrayList (java.util.ArrayList)5 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)5 State (org.craftercms.studio.api.v1.service.objectstate.State)5 ContentNotFoundException (org.craftercms.studio.api.v1.exception.ContentNotFoundException)3 RetryingOperation (org.craftercms.studio.api.v2.annotation.RetryingOperation)3 InputStream (java.io.InputStream)2 Map (java.util.Map)2 CryptoException (org.craftercms.commons.crypto.CryptoException)2 EntitlementException (org.craftercms.commons.entitlements.exception.EntitlementException)2 PreviewEventContext (org.craftercms.studio.api.v1.ebus.PreviewEventContext)2 DocumentException (org.dom4j.DocumentException)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ZonedDateTime (java.time.ZonedDateTime)1