Search in sources :

Example 1 with WorkflowRemovalStatus

use of com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus in project acs-aem-commons by Adobe-Consulting-Services.

the class StatusServlet method doGet.

@Override
public final void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    try {
        if (workflowInstanceRemover.getStatus() != null) {
            response.getWriter().write(workflowInstanceRemover.getStatus().getJSON().toString());
        } else {
            WorkflowRemovalStatus workflowStatus = new WorkflowRemovalStatus(request.getResourceResolver());
            workflowStatus.setRunning(false);
            response.getWriter().write(workflowStatus.getJSON().toString());
        }
    } catch (Exception e) {
        log.error("Unable to create Workflow Removal status", e);
        response.setStatus(SlingHttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        response.getWriter().write(e.getMessage());
    }
}
Also used : WorkflowRemovalStatus(com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 2 with WorkflowRemovalStatus

use of com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus in project acs-aem-commons by Adobe-Consulting-Services.

the class WorkflowInstanceRemoverImpl method internalForceQuit.

private void internalForceQuit() {
    WorkflowRemovalStatus removalStatus = this.status.get();
    removalStatus.setRunning(false);
    removalStatus.setForceQuitAt(Calendar.getInstance());
    this.status.set(removalStatus);
    // Reset force quit flag
    this.forceQuit.set(false);
}
Also used : WorkflowRemovalStatus(com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus)

Example 3 with WorkflowRemovalStatus

use of com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus in project acs-aem-commons by Adobe-Consulting-Services.

the class WorkflowInstanceRemoverImpl method start.

private void start(final ResourceResolver resourceResolver) throws PersistenceException, WorkflowRemovalException, InterruptedException {
    // Ensure forceQuit does not have a left-over value when starting a new run
    this.forceQuit.set(false);
    boolean running = false;
    WorkflowRemovalStatus localStatus = this.getStatus();
    if (localStatus != null) {
        running = localStatus.isRunning();
    }
    if (running) {
        log.warn("Unable to start workflow instance removal; Workflow removal already running.");
        throw new WorkflowRemovalException("Workflow removal already started by " + this.getStatus().getInitiatedBy());
    } else {
        this.status.set(new WorkflowRemovalStatus(resourceResolver));
        log.info("Starting workflow instance removal");
    }
}
Also used : WorkflowRemovalStatus(com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus) WorkflowRemovalException(com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalException)

Example 4 with WorkflowRemovalStatus

use of com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus in project acs-aem-commons by Adobe-Consulting-Services.

the class WorkflowInstanceRemoverImpl method batchComplete.

private void batchComplete(final ResourceResolver resourceResolver, final int checked, final int count) throws PersistenceException, InterruptedException {
    this.save(resourceResolver);
    WorkflowRemovalStatus removalStatus = this.status.get();
    removalStatus.setChecked(checked);
    removalStatus.setRemoved(count);
    this.status.set(removalStatus);
}
Also used : WorkflowRemovalStatus(com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus)

Example 5 with WorkflowRemovalStatus

use of com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus in project acs-aem-commons by Adobe-Consulting-Services.

the class WorkflowInstanceRemoverImpl method error.

private void error() throws PersistenceException, InterruptedException {
    WorkflowRemovalStatus removalStatus = this.status.get();
    removalStatus.setRunning(false);
    removalStatus.setErredAt(Calendar.getInstance());
    this.status.set(removalStatus);
}
Also used : WorkflowRemovalStatus(com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus)

Aggregations

WorkflowRemovalStatus (com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalStatus)7 IOException (java.io.IOException)2 ServletException (javax.servlet.ServletException)2 WorkflowRemovalException (com.adobe.acs.commons.workflow.bulk.removal.WorkflowRemovalException)1