Search in sources :

Example 1 with WorkflowSession

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

the class WorkflowModelDataSourceServlet method doGet.

@Override
protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull 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) ArrayList(java.util.ArrayList) Resource(org.apache.sling.api.resource.Resource) WorkflowModel(com.adobe.granite.workflow.model.WorkflowModel) SimpleDataSource(com.adobe.granite.ui.components.ds.SimpleDataSource) DataSource(com.adobe.granite.ui.components.ds.DataSource)

Aggregations

DataSource (com.adobe.granite.ui.components.ds.DataSource)1 SimpleDataSource (com.adobe.granite.ui.components.ds.SimpleDataSource)1 WorkflowException (com.adobe.granite.workflow.WorkflowException)1 WorkflowSession (com.adobe.granite.workflow.WorkflowSession)1 WorkflowModel (com.adobe.granite.workflow.model.WorkflowModel)1 ArrayList (java.util.ArrayList)1 ServletException (javax.servlet.ServletException)1 Resource (org.apache.sling.api.resource.Resource)1