Source:
private String startBulkCaseBookPDFJob(String studyOid, String siteOid, String participantId, HttpServletRequest request, UserAccountBean userAccountBean, String format, String margin, String landscape) { Study site = null; Study study = null; if(siteOid !=null) { site = studyDao.findByOcOID(siteOid); } if(studyOid != null) { study = studyDao.findByOcOID(studyOid); } UserAccount userAccount = uAccountDao.findById(userAccountBean.getId()); StudySubject ss = studySubjectDao.findByLabelAndStudyOrParentStudy(participantId, study); String studySubjectIdentifier = ss.getOcOid(); String fullFinalFilePathName = this.getMergedPDFcasebookFileName(studyOid, participantId); int index= fullFinalFilePathName.lastIndexOf("\\"); String fileName = fullFinalFilePathName.substring(index + 1); JobDetail jobDetail = userService.persistJobCreated(study, site, userAccount, JobType.PARTICIPANT_PDF_CASEBOOK, fileName); jobDetail.setLogPath(fileName); ServletContext servletContext = request.getServletContext(); String accessToken = (String) request.getSession().getAttribute("accessToken"); servletContext.setAttribute("accessToken", accessToken); servletContext.setAttribute("studyID", study.getStudyId()+""); List<String> permissionTagsString =permissionService.getPermissionTagsList((StudyBean)request.getSession().getAttribute("study"),request); CompletableFuture<Object> future = CompletableFuture.supplyAsync(() -> { try { String userAccountID = userAccountBean.getId() +""; this.studyParticipantService.startCaseBookPDFJob(jobDetail,studyOid, studySubjectIdentifier, servletContext, userAccountID, fullFinalFilePathName,format, margin, landscape,permissionTagsString); } catch (Exception e) { logger.error("Exception is thrown while processing CaseBook PDF: " + e); return e.getMessage(); } return null; }); return jobDetail.getUuid(); }

Target:
private String startBulkCaseBookPDFJob(String studyOid, String siteOid, String participantId, HttpServletRequest request, UserAccountBean userAccountBean, String format, String margin, String landscape) { Study site = null; Study study = null; if(siteOid !=null) { site = studyDao.findByOcOID(siteOid); } if(studyOid != null) { study = studyDao.findByOcOID(studyOid); } UserAccount userAccount = uAccountDao.findById(userAccountBean.getId()); StudySubject ss = studySubjectDao.findByLabelAndStudyOrParentStudy(participantId, study); String studySubjectIdentifier = ss.getOcOid(); String fullFinalFilePathName = this.getMergedPDFcasebookFileName(studyOid, participantId); int index= fullFinalFilePathName.lastIndexOf("\\"); String fileName = fullFinalFilePathName.substring(index + 1); JobDetail jobDetail = userService.persistJobCreated(study, site, userAccount, JobType.PARTICIPANT_PDF_CASEBOOK, fileName); jobDetail.setLogPath(fileName); ServletContext servletContext = request.getServletContext(); String accessToken = (String) request.getSession().getAttribute("accessToken"); servletContext.setAttribute("accessToken", accessToken); servletContext.setAttribute("studyID", study.getStudyId()+""); Locale local = LocaleResolver.resolveLocale(request); List<String> permissionTagsString =permissionService.getPermissionTagsList((StudyBean)request.getSession().getAttribute("study"),request); CompletableFuture<Object> future = CompletableFuture.supplyAsync(() -> { try { ResourceBundleProvider.updateLocale(local); String userAccountID = userAccountBean.getId() +""; this.studyParticipantService.startCaseBookPDFJob(jobDetail,studyOid, studySubjectIdentifier, servletContext, userAccountID, fullFinalFilePathName,format, margin, landscape,permissionTagsString); } catch (Exception e) { logger.error("Exception is thrown while processing CaseBook PDF: " + e); return e.getMessage(); } return null; }); return jobDetail.getUuid(); }