Search in sources :

Example 11 with TreeFilteringResourceVisitor

use of com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor in project acs-aem-commons by Adobe-Consulting-Services.

the class ControlledProcessManagerImpl method getInactiveProcesses.

@Override
public Collection<ProcessInstance> getInactiveProcesses() {
    ArrayList<ProcessInstance> processes = new ArrayList();
    try (ResourceResolver rr = getServiceResourceResolver()) {
        Resource tree = rr.getResource(ProcessInstanceImpl.BASE_PATH);
        TreeFilteringResourceVisitor visitor = new TreeFilteringResourceVisitor();
        visitor.setLeafVisitor((r, l) -> {
            if (!activeProcesses.containsKey(r.getName())) {
                processes.add(r.adaptTo(ArchivedProcessInstance.class));
            }
        });
        visitor.accept(tree);
    } catch (LoginException ex) {
        LOG.error("Error getting inactive process list", ex);
    }
    return processes;
}
Also used : TreeFilteringResourceVisitor(com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Resource(org.apache.sling.api.resource.Resource) LoginException(org.apache.sling.api.resource.LoginException) ArchivedProcessInstance(com.adobe.acs.commons.mcp.model.impl.ArchivedProcessInstance) ProcessInstance(com.adobe.acs.commons.mcp.ProcessInstance) ArchivedProcessInstance(com.adobe.acs.commons.mcp.model.impl.ArchivedProcessInstance)

Aggregations

TreeFilteringResourceVisitor (com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor)11 Resource (org.apache.sling.api.resource.Resource)6 ProcessInstance (com.adobe.acs.commons.mcp.ProcessInstance)5 List (java.util.List)5 Map (java.util.Map)5 LoginException (org.apache.sling.api.resource.LoginException)5 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)5 ActionManager (com.adobe.acs.commons.fam.ActionManager)4 Actions (com.adobe.acs.commons.fam.actions.Actions)4 ProcessDefinition (com.adobe.acs.commons.mcp.ProcessDefinition)4 FormField (com.adobe.acs.commons.mcp.form.FormField)4 PathfieldComponent (com.adobe.acs.commons.mcp.form.PathfieldComponent)4 RadioComponent (com.adobe.acs.commons.mcp.form.RadioComponent)4 SimpleFilteringResourceVisitor (com.adobe.acs.commons.util.visitors.SimpleFilteringResourceVisitor)4 HashMap (java.util.HashMap)4 Level (java.util.logging.Level)4 Logger (java.util.logging.Logger)4 Pattern (java.util.regex.Pattern)4 RepositoryException (javax.jcr.RepositoryException)4 Session (javax.jcr.Session)4