Search in sources :

Example 6 with WorkflowException

use of com.adobe.granite.workflow.WorkflowException in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class WorkflowModelDataSourceServlet method doGet.

@Override
protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) throws ServletException, IOException {
    try {
        WorkflowSession workflowSession = request.getResourceResolver().adaptTo(WorkflowSession.class);
        ArrayList<Resource> resources = new ArrayList<>();
        if (workflowSession != null) {
            WorkflowModel[] models = workflowSession.getModels();
            for (WorkflowModel model : models) {
                resources.add(new WorkflowModelResource(model, request.getResourceResolver()));
            }
        }
        SimpleDataSource dataSource = new SimpleDataSource(resources.iterator());
        request.setAttribute(DataSource.class.getName(), dataSource);
    } catch (WorkflowException e) {
        throw new ServletException(e);
    }
}
Also used : ServletException(javax.servlet.ServletException) SimpleDataSource(com.adobe.granite.ui.components.ds.SimpleDataSource) WorkflowSession(com.adobe.granite.workflow.WorkflowSession) WorkflowException(com.adobe.granite.workflow.WorkflowException) Resource(org.apache.sling.api.resource.Resource) ArrayList(java.util.ArrayList) WorkflowModel(com.adobe.granite.workflow.model.WorkflowModel) SimpleDataSource(com.adobe.granite.ui.components.ds.SimpleDataSource) DataSource(com.adobe.granite.ui.components.ds.DataSource)

Aggregations

WorkflowException (com.adobe.granite.workflow.WorkflowException)6 Resource (org.apache.sling.api.resource.Resource)4 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)4 WorkflowModel (com.adobe.granite.workflow.model.WorkflowModel)3 WorkflowSession (com.adobe.granite.workflow.WorkflowSession)2 Asset (com.day.cq.dam.api.Asset)2 ArrayList (java.util.ArrayList)2 AudioException (com.adobe.acs.commons.dam.audio.impl.AudioException)1 DataSource (com.adobe.granite.ui.components.ds.DataSource)1 SimpleDataSource (com.adobe.granite.ui.components.ds.SimpleDataSource)1 WorkItem (com.adobe.granite.workflow.exec.WorkItem)1 Workflow (com.adobe.granite.workflow.exec.Workflow)1 WorkflowData (com.adobe.granite.workflow.exec.WorkflowData)1 WorkItemFilter (com.adobe.granite.workflow.exec.filter.WorkItemFilter)1 HierarchyNodeInheritanceValueMap (com.day.cq.commons.inherit.HierarchyNodeInheritanceValueMap)1 InheritanceValueMap (com.day.cq.commons.inherit.InheritanceValueMap)1 ReplicationActionType (com.day.cq.replication.ReplicationActionType)1 Serializable (java.io.Serializable)1 RepositoryException (javax.jcr.RepositoryException)1 ServletException (javax.servlet.ServletException)1