Search in sources :

Example 1 with ProcessDefinitionFactory

use of com.adobe.acs.commons.mcp.ProcessDefinitionFactory in project acs-aem-commons by Adobe-Consulting-Services.

the class AvailableProcessDefinitions method activate.

@Override
@SuppressWarnings("checkstyle:parametername")
public void activate() throws Exception {
    SlingScriptHelper sling = getSlingScriptHelper();
    User user = sling.getRequest().getResourceResolver().adaptTo(User.class);
    ProcessDefinitionFactory[] allDefinitionFactories = sling.getServices(ProcessDefinitionFactory.class, null);
    definitions = Stream.of(allDefinitionFactories).filter(o -> o.isAllowed(user)).collect(Collectors.toMap(ProcessDefinitionFactory::getName, o -> o, (a, b) -> a, TreeMap::new));
    String processDefinitionName = get("processDefinition", String.class);
    if (StringUtils.isEmpty(processDefinitionName)) {
        processDefinitionName = getRequest().getParameter("processDefinition");
    }
    if (StringUtils.isNotEmpty(processDefinitionName) && definitions.containsKey(processDefinitionName)) {
        Class clazz = definitions.get(processDefinitionName).createProcessDefinition().getClass();
        fieldComponents = AnnotatedFieldDeserializer.getFormFields(clazz, sling);
    }
}
Also used : User(org.apache.jackrabbit.api.security.user.User) ProcessDefinitionFactory(com.adobe.acs.commons.mcp.ProcessDefinitionFactory) SlingScriptHelper(org.apache.sling.api.scripting.SlingScriptHelper) TreeMap(java.util.TreeMap)

Aggregations

ProcessDefinitionFactory (com.adobe.acs.commons.mcp.ProcessDefinitionFactory)1 TreeMap (java.util.TreeMap)1 User (org.apache.jackrabbit.api.security.user.User)1 SlingScriptHelper (org.apache.sling.api.scripting.SlingScriptHelper)1