Search in sources :

Example 6 with ExecutionSummary

use of org.alfresco.service.cmr.action.ExecutionSummary in project alfresco-remote-api by Alfresco.

the class RunningActionModelBuilder method buildSimpleList.

/**
 * Build a model containing a list of running actions for the given
 *  list of Running Actions
 */
protected Map<String, Object> buildSimpleList(List<ExecutionSummary> runningActions) {
    List<Map<String, Object>> models = new ArrayList<Map<String, Object>>();
    for (ExecutionSummary summary : runningActions) {
        Map<String, Object> ram = buildModel(summary);
        if (ram != null) {
            models.add(ram);
        }
    }
    // Finish up
    Map<String, Object> model = new HashMap<String, Object>();
    model.put(MODEL_DATA_LIST, models);
    return model;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExecutionSummary(org.alfresco.service.cmr.action.ExecutionSummary) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with ExecutionSummary

use of org.alfresco.service.cmr.action.ExecutionSummary in project alfresco-remote-api by Alfresco.

the class RunningActionsGet method buildModel.

@Override
protected Map<String, Object> buildModel(RunningActionModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) {
    List<ExecutionSummary> actions = null;
    // Do they want all actions, or only certain ones?
    String type = req.getParameter("type");
    String nodeRef = req.getParameter("nodeRef");
    if (type != null) {
        actions = actionTrackingService.getExecutingActions(type);
    } else if (nodeRef != null) {
        NodeRef actionNodeRef = new NodeRef(nodeRef);
        Action action = runtimeActionService.createAction(actionNodeRef);
        actions = actionTrackingService.getExecutingActions(action);
    } else {
        actions = actionTrackingService.getAllExecutingActions();
    }
    // Build the model list
    return modelBuilder.buildSimpleList(actions);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Action(org.alfresco.service.cmr.action.Action) ExecutionSummary(org.alfresco.service.cmr.action.ExecutionSummary)

Example 8 with ExecutionSummary

use of org.alfresco.service.cmr.action.ExecutionSummary in project alfresco-remote-api by Alfresco.

the class RunningReplicationActionsGet method buildModel.

@Override
protected Map<String, Object> buildModel(RunningActionModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) {
    List<ExecutionSummary> actions = null;
    // Do they want all replication actions, or only certain ones?
    String name = req.getParameter("name");
    if (name != null) {
        // Try to find a replication definition with this name
        ReplicationDefinition rd = replicationService.loadReplicationDefinition(name);
        // Look up what's running
        if (rd != null) {
            actions = actionTrackingService.getExecutingActions(rd);
        }
    } else {
        // All replication actions
        actions = actionTrackingService.getExecutingActions(ReplicationDefinitionImpl.EXECUTOR_NAME);
    }
    // Build the model list
    return modelBuilder.buildSimpleList(actions);
}
Also used : ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) ExecutionSummary(org.alfresco.service.cmr.action.ExecutionSummary)

Example 9 with ExecutionSummary

use of org.alfresco.service.cmr.action.ExecutionSummary in project alfresco-remote-api by Alfresco.

the class ReplicationModelBuilder method setStatus.

/**
 * Figures out the status that's one of:
 *    New|Running|CancelRequested|Completed|Failed|Cancelled
 * by merging data from the action tracking service.
 * Will also set the start and end dates, from either the
 *  replication definition or action tracking data, depending
 *  on the status.
 */
protected void setStatus(ReplicationDefinition replicationDefinition, Map<String, Object> model) {
    // Grab the running instance(s) of the action
    List<ExecutionSummary> executing = actionTrackingService.getExecutingActions(replicationDefinition);
    // Now get the details of that
    ExecutionDetails details = getExecutionDetails(replicationDefinition, executing);
    // Finally have the status set
    setStatus(replicationDefinition, details, model);
}
Also used : ExecutionSummary(org.alfresco.service.cmr.action.ExecutionSummary) ExecutionDetails(org.alfresco.service.cmr.action.ExecutionDetails)

Example 10 with ExecutionSummary

use of org.alfresco.service.cmr.action.ExecutionSummary in project alfresco-remote-api by Alfresco.

the class RunningActionRestApiTest method tearDown.

@Override
protected void tearDown() throws Exception {
    super.tearDown();
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    personManager.clearPeople();
    // Zap any replication definitions we created
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    for (ReplicationDefinition rd : replicationService.loadReplicationDefinitions()) {
        replicationService.deleteReplicationDefinition(rd);
    }
    AuthenticationUtil.clearCurrentSecurityContext();
    // Clear out the running actions
    for (ExecutionSummary es : actionTrackingService.getAllExecutingActions()) {
        executingActionsCache.remove(AbstractActionWebscript.getRunningId(es));
    }
    txn.commit();
}
Also used : UserTransaction(javax.transaction.UserTransaction) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) ExecutionSummary(org.alfresco.service.cmr.action.ExecutionSummary)

Aggregations

ExecutionSummary (org.alfresco.service.cmr.action.ExecutionSummary)10 ArrayList (java.util.ArrayList)3 ExecutionDetails (org.alfresco.service.cmr.action.ExecutionDetails)3 ReplicationDefinition (org.alfresco.service.cmr.replication.ReplicationDefinition)3 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Action (org.alfresco.service.cmr.action.Action)2 UserTransaction (javax.transaction.UserTransaction)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1