JobRequest request = getJobRequest(ctx);
JobResult result = approvalService.requestApproval(request);
// save job
logger.debug( "--- job {} ---, status: {}", result.getJobId(), result.getStatus());
JobResultManager jobMgr = getJobManager(ctx);
result.setLastModified(System.currentTimeMillis());
jobMgr.putJob(result);
// if approved, process
if( JobStatus.APPROVED.equals(result.getStatus()) ) {
try {
result = internalExecute(ctx, request);
} catch( Exception e ) {
result.setStatus(JobStatus.SERVER_ERROR);
result.setResult("Request failed because of " + e.getClass().getSimpleName() + ": " + e.getMessage());
logger.error("{} [{}] failed because of thrown {}: {}",
request.getClass().getSimpleName(), request.getJobId(),
e.getClass().getSimpleName(), e.getMessage(), e);
}
// save job
logger.debug( "--- job {} ---, status: {}", result.getJobId(), result.getStatus());
result.setLastModified(System.currentTimeMillis());
jobMgr.putJob(result);
}
return getEmptyResult();
}