use of com.adobe.acs.commons.workflow.bulk.execution.model.Workspace in project acs-aem-commons by Adobe-Consulting-Services.
the class BulkWorkflowEngineImpl method stopping.
@Override
public void stopping(Config config) throws PersistenceException {
Workspace workspace = config.getWorkspace();
workspace.getRunner().stopping(workspace);
workspace.commit();
}
use of com.adobe.acs.commons.workflow.bulk.execution.model.Workspace in project acs-aem-commons by Adobe-Consulting-Services.
the class BulkWorkflowEngineImpl method complete.
public void complete(Config config) throws PersistenceException {
Workspace workspace = config.getWorkspace();
scheduler.unschedule(workspace.getJobName());
workspace.getRunner().complete(workspace);
workspace.commit();
}
use of com.adobe.acs.commons.workflow.bulk.execution.model.Workspace in project acs-aem-commons by Adobe-Consulting-Services.
the class StatusServlet method doGet.
@Override
@SuppressWarnings({ "squid:S3776", "squid:S1192" })
protected final void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy hh:mm:ss aaa");
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
Config config = request.getResource().adaptTo(Config.class);
Workspace workspace = config.getWorkspace();
final JSONObject json = new JSONObject();
try {
json.put("initialized", workspace.isInitialized());
json.put("status", workspace.getStatus());
if (workspace.getSubStatus() != null) {
json.put("subStatus", workspace.getSubStatus());
}
json.put("runnerType", config.getRunnerType());
json.put("queryType", config.getQueryType());
json.put("queryStatement", config.getQueryStatement());
json.put("workflowModel", StringUtils.removeEnd(config.getWorkflowModelId(), "/jcr:content/model"));
json.put("batchSize", config.getBatchSize());
json.put("autoThrottle", config.isAutoThrottle());
json.put("purgeWorkflow", config.isPurgeWorkflow());
json.put("interval", config.getInterval());
json.put("retryCount", config.getRetryCount());
json.put("timeout", config.getTimeout());
json.put("throttle", config.getThrottle());
json.put("message", workspace.getMessage());
if (config.isUserEventData()) {
json.put("userEventData", config.getUserEventData());
}
ActionManager actionManager = actionManagerFactory.getActionManager(workspace.getActionManagerName());
if (actionManager != null && !Status.COMPLETED.equals(workspace.getStatus())) {
// If Complete, then look to JCR for final accounts as ActionManager may be gone
addActionManagerTrackedCounts(workspace.getActionManagerName(), json);
for (com.adobe.acs.commons.fam.Failure failure : actionManager.getFailureList()) {
JSONObject failureJSON = new JSONObject();
failureJSON.put(Failure.PN_PAYLOAD_PATH, failure.getNodePath());
failureJSON.put(Failure.PN_FAILED_AT, sdf.format(failure.getTime().getTime()));
json.accumulate("failures", failureJSON);
}
} else {
addWorkspaceTrackedCounts(workspace, json);
// Failures
for (Failure failure : workspace.getFailures()) {
json.accumulate("failures", failure.toJSON());
}
}
// Times
if (workspace.getStartedAt() != null) {
json.put("startedAt", sdf.format(workspace.getStartedAt().getTime()));
json.put("timeTakenInMillis", (Calendar.getInstance().getTime().getTime() - workspace.getStartedAt().getTime().getTime()));
}
if (workspace.getStoppedAt() != null) {
json.put("stoppedAt", sdf.format(workspace.getStoppedAt().getTime()));
json.put("timeTakenInMillis", (workspace.getStoppedAt().getTime().getTime() - workspace.getStartedAt().getTime().getTime()));
}
if (workspace.getCompletedAt() != null) {
json.put("completedAt", sdf.format(workspace.getCompletedAt().getTime()));
json.put("timeTakenInMillis", (workspace.getCompletedAt().getTime().getTime() - workspace.getStartedAt().getTime().getTime()));
}
if (AEMWorkflowRunnerImpl.class.getName().equals(config.getRunnerType())) {
for (Payload payload : config.getWorkspace().getActivePayloads()) {
json.accumulate("activePayloads", payload.toJSON());
}
}
json.put("systemStats", getSystemStats());
response.getWriter().write(json.toString());
} catch (JSONException e) {
log.error("Could not collect Bulk Workflow status due to: {}", e);
JSONErrorUtil.sendJSONError(response, SlingHttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Could not collect Bulk Workflow status.", e.getMessage());
}
}
use of com.adobe.acs.commons.workflow.bulk.execution.model.Workspace in project acs-aem-commons by Adobe-Consulting-Services.
the class BulkWorkflowEngineImpl method start.
@Override
public final void start(Config config) throws PersistenceException {
Workspace workspace = config.getWorkspace();
workspace.getRunner().start(workspace);
Runnable job = workspace.getRunner().getRunnable(config);
ScheduleOptions options = workspace.getRunner().getOptions(config);
if (options != null) {
scheduler.schedule(job, options);
} else {
job.run();
}
workspace.commit();
}
use of com.adobe.acs.commons.workflow.bulk.execution.model.Workspace in project acs-aem-commons by Adobe-Consulting-Services.
the class BulkWorkflowEngineImpl method stop.
@Override
public void stop(Config config) throws PersistenceException {
Workspace workspace = config.getWorkspace();
scheduler.unschedule(workspace.getJobName());
workspace.getRunner().stop(workspace);
workspace.commit();
}
Aggregations