use of com.day.cq.workflow.exec.Workflow in project acs-aem-commons by Adobe-Consulting-Services.
the class AEMWorkflowRunnerImpl method forceTerminate.
@SuppressWarnings("squid:S00112")
@Override
public void forceTerminate(Workspace workspace, Payload payload) throws Exception {
final WorkflowSession workflowSession = workflowService.getWorkflowSession(payload.getResourceResolver().adaptTo(Session.class));
Workflow workflow = null;
fail(workspace, payload);
try {
workflow = payload.getWorkflow();
if (workflow != null) {
if (workflow.isActive()) {
workflowSession.terminateWorkflow(workflow);
log.info("Force Terminated workflow [ {} ]", workflow.getId());
payload.setStatus(Status.FORCE_TERMINATED);
if (workspace.getConfig().isPurgeWorkflow()) {
purge(payload);
}
} else {
log.warn("Trying to force terminate an inactive workflow [ {} ]", workflow.getId());
}
} else {
payload.setStatus(Status.FORCE_TERMINATED);
}
} catch (WorkflowException e) {
throw new Exception(e);
}
}
use of com.day.cq.workflow.exec.Workflow in project acs-aem-commons by Adobe-Consulting-Services.
the class AEMWorkflowRunnerImpl method purge.
private void purge(Payload payload) throws PersistenceException, WorkflowException {
Workflow workflow = payload.getWorkflow();
if (workflow != null) {
ResourceResolver resourceResolver = payload.getResourceResolver();
final Resource resource = resourceResolver.getResource(workflow.getId());
if (resource != null) {
try {
String path = resource.getPath();
resource.adaptTo(Node.class).remove();
log.info("Purging working instance [ {} ]", path);
} catch (RepositoryException e) {
throw new PersistenceException("Unable to purge workflow instance node.", e);
}
} else {
log.warn("Could not find workflow instance at [ {} ] to purge.", workflow.getId());
}
}
}
Aggregations