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