use of org.alfresco.service.cmr.action.ExecutionDetails in project alfresco-remote-api by Alfresco.
the class RunningActionDelete method buildModel.
@Override
protected Map<String, Object> buildModel(RunningActionModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) {
// Which action did they ask for?
String actionTrackingId = req.getServiceMatch().getTemplateVars().get("action_tracking_id");
// Check it exists
ExecutionSummary action = getSummaryFromKey(actionTrackingId);
if (action == null) {
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No Running Action found with that tracking id");
}
ExecutionDetails details = actionTrackingService.getExecutionDetails(action);
if (details == null) {
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No Running Action found with that tracking id");
}
// Request the cancel
actionTrackingService.requestActionCancellation(action);
// Report it as having been cancelled
status.setCode(Status.STATUS_NO_CONTENT);
status.setMessage("Action cancellation requested");
status.setRedirect(true);
return null;
}
use of org.alfresco.service.cmr.action.ExecutionDetails in project alfresco-remote-api by Alfresco.
the class ReplicationModelBuilder method buildSimpleList.
/**
* Build a model containing a list of simple definitions for the given
* list of Replication Definitions.
*/
protected Map<String, Object> buildSimpleList(List<ReplicationDefinition> replicationDefinitions, Comparator<Map<String, Object>> sorter) {
List<Map<String, Object>> models = new ArrayList<Map<String, Object>>();
// have some Replication Definitions to render
if (replicationDefinitions.size() > 0) {
List<ExecutionSummary> executing = actionTrackingService.getExecutingActions(replicationDefinitions.get(0).getActionDefinitionName());
for (ReplicationDefinition rd : replicationDefinitions) {
// Get the executing detail(s) for this definition
ExecutionDetails details = getExecutionDetails(rd, executing);
// Set the core details
Map<String, Object> rdm = new HashMap<String, Object>();
rdm.put(DEFINITION_NAME, rd.getReplicationName());
rdm.put(DEFINITION_ENABLED, rd.isEnabled());
// Do the status
setStatus(rd, details, rdm);
// In the summary form, we don't need end time or details
rdm.remove(DEFINITION_ENDED_AT);
rdm.remove(DEFINITION_RUNNING_ACTION_ID);
// Add to the list of finished models
models.add(rdm);
}
}
// Sort the entries
if (sorter != null) {
Collections.sort(models, sorter);
}
// Finish up
Map<String, Object> model = new HashMap<String, Object>();
model.put(MODEL_DATA_LIST, models);
return model;
}
use of org.alfresco.service.cmr.action.ExecutionDetails in project alfresco-remote-api by Alfresco.
the class RunningActionModelBuilder method buildModel.
/**
* Build a model for a single action
*/
private Map<String, Object> buildModel(ExecutionSummary summary) {
if (summary == null) {
return null;
}
// Get the details, if we can
ExecutionDetails details = actionTrackingService.getExecutionDetails(summary);
// between getting the list and now
if (details != null) {
Map<String, Object> ram = new HashMap<String, Object>();
ram.put(ACTION_ID, summary.getActionId());
ram.put(ACTION_TYPE, summary.getActionType());
ram.put(ACTION_INSTANCE, summary.getExecutionInstance());
ram.put(ACTION_KEY, AbstractActionWebscript.getRunningId(summary));
ram.put(ACTION_NODE_REF, details.getPersistedActionRef());
ram.put(ACTION_RUNNING_ON, details.getRunningOn());
ram.put(ACTION_CANCEL_REQUESTED, details.isCancelRequested());
if (details.getStartedAt() != null) {
ram.put(ACTION_STARTED_AT, ISO8601DateFormat.format(details.getStartedAt()));
} else {
ram.put(ACTION_STARTED_AT, null);
}
return ram;
}
return null;
}
use of org.alfresco.service.cmr.action.ExecutionDetails 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);
}
use of org.alfresco.service.cmr.action.ExecutionDetails in project alfresco-remote-api by Alfresco.
the class RunningActionRestApiTest method setUp.
@SuppressWarnings("unchecked")
@Override
protected void setUp() throws Exception {
super.setUp();
ApplicationContext appContext = getServer().getApplicationContext();
nodeService = (NodeService) appContext.getBean("NodeService");
replicationService = (ReplicationService) appContext.getBean("ReplicationService");
actionTrackingService = (ActionTrackingService) appContext.getBean("actionTrackingService");
repositoryHelper = (Repository) appContext.getBean("repositoryHelper");
transactionService = (TransactionService) appContext.getBean("transactionService");
executingActionsCache = (SimpleCache<String, ExecutionDetails>) appContext.getBean("executingActionsCache");
MutableAuthenticationService authenticationService = (MutableAuthenticationService) appContext.getBean("AuthenticationService");
PersonService personService = (PersonService) appContext.getBean("PersonService");
personManager = new TestPersonManager(authenticationService, personService, nodeService);
UserTransaction txn = transactionService.getUserTransaction();
txn.begin();
personManager.createPerson(USER_NORMAL);
// Ensure we start with no replication definitions
// (eg another test left them behind)
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
for (ReplicationDefinition rd : replicationService.loadReplicationDefinitions()) {
replicationService.deleteReplicationDefinition(rd);
}
txn.commit();
// Grab a reference to the data dictionary
dataDictionary = nodeService.getChildByName(repositoryHelper.getCompanyHome(), ContentModel.ASSOC_CONTAINS, "Data Dictionary");
AuthenticationUtil.clearCurrentSecurityContext();
}
Aggregations