Search in sources :

Example 1 with ActionManager

use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.

the class ActionManagerFactoryImpl method purgeCompletedTasks.

@Override
public void purgeCompletedTasks() {
    for (Iterator<ActionManager> taskIterator = tasks.values().iterator(); taskIterator.hasNext(); ) {
        ActionManager task = taskIterator.next();
        if (task.isComplete() || taskRunner.getActiveCount() == 0) {
            task.closeAllResolvers();
            taskIterator.remove();
        }
    }
}
Also used : ActionManager(com.adobe.acs.commons.fam.ActionManager)

Example 2 with ActionManager

use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.

the class BrokenLinksTest method getControlledProcessManager.

private ControlledProcessManager getControlledProcessManager() throws LoginException {
    ActionManager am = getActionManager();
    ActionManagerFactory amf = mock(ActionManagerFactoryImpl.class);
    when(amf.createTaskManager(any(), any(), anyInt())).thenReturn(am);
    ControlledProcessManager cpm = mock(ControlledProcessManager.class);
    when(cpm.getActionManagerFactory()).thenReturn(amf);
    when(cpm.getServiceResourceResolver()).thenReturn(getMockResolver());
    return cpm;
}
Also used : ActionManager(com.adobe.acs.commons.fam.ActionManager) ControlledProcessManager(com.adobe.acs.commons.mcp.ControlledProcessManager) ActionManagerFactory(com.adobe.acs.commons.fam.ActionManagerFactory)

Example 3 with ActionManager

use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.

the class ActionManagerTest method deferredStatsCounterTest.

@Test
public void deferredStatsCounterTest() throws LoginException, Exception {
    ResourceResolver rr = getMockResolver();
    ActionManager manager = getActionManager();
    assertEquals(0, manager.getAddedCount());
    manager.deferredWithResolver(resolver -> {
    });
    assertEquals(1, manager.getAddedCount());
    assertEquals(1, manager.getCompletedCount());
    manager.deferredWithResolver(resolver -> {
    });
    assertEquals(2, manager.getAddedCount());
    assertEquals(2, manager.getSuccessCount());
    assertEquals(2, manager.getCompletedCount());
    assertEquals(0, manager.getErrorCount());
    assertEquals(0, manager.getRemainingCount());
    assertTrue(manager.isComplete());
}
Also used : ActionManager(com.adobe.acs.commons.fam.ActionManager) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Test(org.junit.Test)

Example 4 with ActionManager

use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.

the class ActionManagerTest method closeAllResolversTest.

@Test
public void closeAllResolversTest() throws LoginException, Exception {
    ResourceResolver rr = getMockResolver();
    ActionManager manager = getActionManager();
    manager.deferredWithResolver(resolver -> {
    });
    manager.deferredWithResolver(resolver -> {
    });
    manager.deferredWithResolver(resolver -> {
    });
    manager.deferredWithResolver(resolver -> {
    });
    manager.closeAllResolvers();
    verify(rr, atLeast(5)).close();
}
Also used : ActionManager(com.adobe.acs.commons.fam.ActionManager) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Test(org.junit.Test)

Example 5 with ActionManager

use of com.adobe.acs.commons.fam.ActionManager in project acs-aem-commons by Adobe-Consulting-Services.

the class PageRelocatorTest method getControlledProcessManager.

private ControlledProcessManager getControlledProcessManager() throws LoginException {
    ActionManager am = getActionManager();
    ActionManagerFactory amf = mock(ActionManagerFactoryImpl.class);
    when(amf.createTaskManager(any(), any(), anyInt())).thenReturn(am);
    ControlledProcessManager cpm = mock(ControlledProcessManager.class);
    when(cpm.getActionManagerFactory()).thenReturn(amf);
    when(cpm.getServiceResourceResolver()).thenReturn(getMockResolver());
    return cpm;
}
Also used : ActionManager(com.adobe.acs.commons.fam.ActionManager) ControlledProcessManager(com.adobe.acs.commons.mcp.ControlledProcessManager) ActionManagerFactory(com.adobe.acs.commons.fam.ActionManagerFactory)

Aggregations

ActionManager (com.adobe.acs.commons.fam.ActionManager)15 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)9 ProcessInstance (com.adobe.acs.commons.mcp.ProcessInstance)5 LoginException (org.apache.sling.api.resource.LoginException)5 PersistenceException (org.apache.sling.api.resource.PersistenceException)5 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 TreeFilteringResourceVisitor (com.adobe.acs.commons.util.visitors.TreeFilteringResourceVisitor)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)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