Source:
private SurveillanceUploadResult processUploadAsJob(final String data) throws EntityCreationException, EntityRetrievalException { SurveillanceUploadResult result = new SurveillanceUploadResult(); UserDTO currentUser = null; try { currentUser = userManager.getById(Util.getCurrentUser().getId()); } catch (final UserRetrievalException ex) { LOGGER.error("Error finding user with ID " + Util.getCurrentUser().getId() + ": " + ex.getMessage()); result.setJobStatus(SurveillanceUploadResult.UNAUTHORIZED); return result; } if (currentUser == null) { LOGGER.error("No user with ID " + Util.getCurrentUser().getId() + " could be found in the system."); result.setJobStatus(SurveillanceUploadResult.UNAUTHORIZED); return result; } JobTypeDTO jobType = null; List<JobTypeDTO> jobTypes = jobManager.getAllJobTypes(); for (JobTypeDTO jt : jobTypes) { if (jt.getName().equalsIgnoreCase(allowedJobType.getName())) { jobType = jt; } } JobDTO toCreate = new JobDTO(); toCreate.setData(data); toCreate.setUser(currentUser); toCreate.setJobType(jobType); JobDTO insertedJob = jobManager.createJob(toCreate); JobDTO createdJob = jobManager.getJobById(insertedJob.getId()); try { boolean isStarted = jobManager.start(createdJob); if (!isStarted) { result.setJob(new Job(createdJob)); result.setJobStatus(SurveillanceUploadResult.NOT_STARTED); return result; } else { createdJob = jobManager.getJobById(insertedJob.getId()); } } catch (final EntityRetrievalException ex) { LOGGER.error("Could not mark job " + createdJob.getId() + " as started."); result.setJob(new Job(createdJob)); result.setJobStatus(SurveillanceUploadResult.ERROR); return result; } result.setJob(new Job(createdJob)); result.setJobStatus(SurveillanceUploadResult.SUCCESS); return result; }

Target:
private SurveillanceUploadResult processUploadAsJob(final String data) throws EntityCreationException, EntityRetrievalException { SurveillanceUploadResult result = new SurveillanceUploadResult(); UserDTO currentUser = null; try { currentUser = userManager.getById(Util.getCurrentUser().getId()); } catch (final UserRetrievalException ex) { LOGGER.error("Error finding user with ID " + Util.getCurrentUser().getId() + ": " + ex.getMessage()); result.setJobStatus(SurveillanceUploadResult.UNAUTHORIZED); return result; } if (currentUser == null) { LOGGER.error("No user with ID " + Util.getCurrentUser().getId() + " could be found in the system."); result.setJobStatus(SurveillanceUploadResult.UNAUTHORIZED); return result; } JobTypeDTO jobType = null; List<JobTypeDTO> jobTypes = jobManager.getAllJobTypes(); for (JobTypeDTO jt : jobTypes) { if (jt.getName().equalsIgnoreCase(allowedJobType.getName())) { jobType = jt; } } JobDTO toCreate = new JobDTO(); toCreate.setData(data); toCreate.setUser(currentUser); toCreate.setJobType(jobType); JobDTO insertedJob = jobManager.createJob(toCreate); JobDTO createdJob = jobManager.getJobById(insertedJob.getId()); try { boolean isStarted = jobManager.start(createdJob); if (!isStarted) { result.setJob(new Job(createdJob)); result.setJobStatus(SurveillanceUploadResult.NOT_STARTED); return result; } else { createdJob = jobManager.getJobById(insertedJob.getId()); } } catch (final EntityRetrievalException ex) { LOGGER.error("Could not mark job " + createdJob.getId() + " as started."); result.setJob(new Job(createdJob)); result.setJobStatus(SurveillanceUploadResult.ERROR); return result; } result.setJob(new Job(createdJob)); result.setJobStatus(SurveillanceUploadResult.STARTED); return result; }