Search in sources :

Example 1 with JobCanceledException

use of org.opencastproject.util.JobCanceledException in project opencast by opencast.

the class WorkflowOperationWorker method execute.

/**
 * Executes the workflow operation logic.
 */
public WorkflowInstance execute() {
    WorkflowOperationInstance operation = workflow.getCurrentOperation();
    try {
        WorkflowOperationResult result = null;
        switch(operation.getState()) {
            case INSTANTIATED:
            case RETRY:
                result = start();
                break;
            case PAUSED:
                result = resume();
                break;
            default:
                throw new IllegalStateException("Workflow operation '" + operation + "' is in unexpected state '" + operation.getState() + "'");
        }
        if (result == null || Action.CONTINUE.equals(result.getAction()) || Action.SKIP.equals(result.getAction())) {
            if (handler != null) {
                handler.destroy(workflow, null);
            }
        }
        workflow = service.handleOperationResult(workflow, result);
        return workflow;
    } catch (JobCanceledException e) {
        logger.info(e.getMessage());
        return workflow;
    } catch (WorkflowOperationAbortedException e) {
        // Don't log it as error because it was aborted by the user
        logger.info("Workflow operation '" + operation + "' aborted by user");
    } catch (Exception e) {
        Throwable t = e.getCause();
        if (t != null) {
            logger.error("Workflow operation '" + operation + "' failed", t);
        } else {
            logger.error("Workflow operation '" + operation + "' failed", e);
        }
        // the associated job shares operation's id
        service.getServiceRegistry().incident().unhandledException(operation.getId(), Severity.FAILURE, e);
    }
    try {
        workflow = service.handleOperationException(workflow, operation);
    } catch (Exception e2) {
        logger.error("Error handling workflow operation '{}' failure: {}", operation, e2.getMessage(), e2);
    }
    return workflow;
}
Also used : WorkflowOperationInstance(org.opencastproject.workflow.api.WorkflowOperationInstance) WorkflowOperationResult(org.opencastproject.workflow.api.WorkflowOperationResult) JobCanceledException(org.opencastproject.util.JobCanceledException) UnauthorizedException(org.opencastproject.security.api.UnauthorizedException) WorkflowException(org.opencastproject.workflow.api.WorkflowException) JobCanceledException(org.opencastproject.util.JobCanceledException) WorkflowOperationAbortedException(org.opencastproject.workflow.api.WorkflowOperationAbortedException) WorkflowOperationException(org.opencastproject.workflow.api.WorkflowOperationException) WorkflowOperationAbortedException(org.opencastproject.workflow.api.WorkflowOperationAbortedException)

Aggregations

UnauthorizedException (org.opencastproject.security.api.UnauthorizedException)1 JobCanceledException (org.opencastproject.util.JobCanceledException)1 WorkflowException (org.opencastproject.workflow.api.WorkflowException)1 WorkflowOperationAbortedException (org.opencastproject.workflow.api.WorkflowOperationAbortedException)1 WorkflowOperationException (org.opencastproject.workflow.api.WorkflowOperationException)1 WorkflowOperationInstance (org.opencastproject.workflow.api.WorkflowOperationInstance)1 WorkflowOperationResult (org.opencastproject.workflow.api.WorkflowOperationResult)1