Search in sources :

Example 6 with WorkflowSession

use of com.day.cq.workflow.WorkflowSession in project acs-aem-commons by Adobe-Consulting-Services.

the class InitServlet method getFormJSONObject.

/**
 * Get the JSON data to populate the Workflow Removal form.
 *
 * @param resourceResolver
 * @return
 * @throws WorkflowException
 * @throws JSONException
 */
private JSONObject getFormJSONObject(final ResourceResolver resourceResolver) throws WorkflowException, JSONException {
    final JSONObject json = new JSONObject();
    final WorkflowSession workflowSession = workflowService.getWorkflowSession(resourceResolver.adaptTo(Session.class));
    final WorkflowModel[] workflowModels = workflowSession.getModels();
    for (final WorkflowModel workflowModel : workflowModels) {
        final JSONObject jsonWorkflow = new JSONObject();
        jsonWorkflow.put("title", workflowModel.getTitle());
        jsonWorkflow.put("id", workflowModel.getId());
        json.accumulate("workflowModels", jsonWorkflow);
    }
    json.put("statuses", new JSONArray(Arrays.asList(WORKFLOW_STATUSES)));
    return json;
}
Also used : JSONObject(org.apache.sling.commons.json.JSONObject) WorkflowSession(com.day.cq.workflow.WorkflowSession) JSONArray(org.apache.sling.commons.json.JSONArray) WorkflowModel(com.day.cq.workflow.model.WorkflowModel) Session(javax.jcr.Session) WorkflowSession(com.day.cq.workflow.WorkflowSession)

Aggregations

WorkflowSession (com.day.cq.workflow.WorkflowSession)6 Session (javax.jcr.Session)5 WorkflowException (com.day.cq.workflow.WorkflowException)4 WorkflowModel (com.day.cq.workflow.model.WorkflowModel)2 PersistenceException (org.apache.sling.api.resource.PersistenceException)2 ContentVisitor (com.adobe.acs.commons.util.visitors.ContentVisitor)1 ResourceRunnable (com.adobe.acs.commons.util.visitors.ResourceRunnable)1 SyntheticWorkItem (com.adobe.acs.commons.workflow.synthetic.impl.cq.SyntheticWorkItem)1 SyntheticWorkflowSession (com.adobe.acs.commons.workflow.synthetic.impl.cq.SyntheticWorkflowSession)1 SyntheticCompleteWorkflowException (com.adobe.acs.commons.workflow.synthetic.impl.cq.exceptions.SyntheticCompleteWorkflowException)1 SyntheticTerminateWorkflowException (com.adobe.acs.commons.workflow.synthetic.impl.cq.exceptions.SyntheticTerminateWorkflowException)1 Workflow (com.day.cq.workflow.exec.Workflow)1 JsonObject (com.google.gson.JsonObject)1 Date (java.util.Date)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 RepositoryException (javax.jcr.RepositoryException)1 Resource (org.apache.sling.api.resource.Resource)1 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)1 JSONArray (org.apache.sling.commons.json.JSONArray)1 JSONException (org.apache.sling.commons.json.JSONException)1