Source:
public JobDetail demoteContent( @PathParam("env_id") @Verify(Environment.class) String envId, @QueryParam("content") String[] contentIds, @QueryParam("lazy_regen") @DefaultValue("true") Boolean lazyRegen) { Environment e = lookupEnvironment(envId); Map<String, EnvironmentContent> demotedContent = new HashMap<String, EnvironmentContent>(); for (String contentId : contentIds) { EnvironmentContent envContent = envContentCurator.lookupByEnvironmentAndContent(e, contentId); if (envContent == null) { throw new NotFoundException(i18n.tr("Content does not exist in environment: {0}", contentId)); } demotedContent.put(contentId, envContent); } try { envContentCurator.bulkDelete(new ArrayList<EnvironmentContent>(demotedContent.values())); } catch (RollbackException hibernateException) { if (rdbmsExceptionTranslator.isUpdateHadNoEffectException(hibernateException)) { log.info("Concurrent content demotion will cause this request to fail.", hibernateException); throw new NotFoundException( i18n.tr("One of the content does not exist in the environment anymore: {0}", demotedContent.values())); } else { throw hibernateException; } } Set<String> demotedContentIds = new HashSet<String>(demotedContent.keySet()); JobDataMap map = new JobDataMap(); map.put(RegenEnvEntitlementCertsJob.ENV, e); map.put(RegenEnvEntitlementCertsJob.CONTENT, demotedContentIds); map.put(RegenEnvEntitlementCertsJob.LAZY_REGEN, lazyRegen); JobDetail detail = newJob(RegenEnvEntitlementCertsJob.class) .withIdentity("regen_entitlement_cert_of_env" + Util.generateUUID()) .usingJobData(map) .build(); return detail; }

Target:
public JobDetail demoteContent( @PathParam("env_id") @Verify(Environment.class) String envId, @QueryParam("content") String[] contentIds, @QueryParam("lazy_regen") @DefaultValue("true") Boolean lazyRegen) { Environment e = lookupEnvironment(envId); Map<String, EnvironmentContent> demotedContent = new HashMap<String, EnvironmentContent>(); for (String contentId : contentIds) { EnvironmentContent envContent = envContentCurator.lookupByEnvironmentAndContent(e, contentId); if (envContent == null) { throw new NotFoundException(i18n.tr("Content does not exist in environment: {0}", contentId)); } demotedContent.put(contentId, envContent); } try { envContentCurator.bulkDeleteTransactional( new ArrayList<EnvironmentContent>(demotedContent.values())); } catch (RollbackException hibernateException) { if (rdbmsExceptionTranslator.isUpdateHadNoEffectException(hibernateException)) { log.info("Concurrent content demotion will cause this request to fail.", hibernateException); throw new NotFoundException( i18n.tr("One of the content does not exist in the environment anymore: {0}", demotedContent.values())); } else { throw hibernateException; } } Set<String> demotedContentIds = new HashSet<String>(demotedContent.keySet()); JobDataMap map = new JobDataMap(); map.put(RegenEnvEntitlementCertsJob.ENV, e); map.put(RegenEnvEntitlementCertsJob.CONTENT, demotedContentIds); map.put(RegenEnvEntitlementCertsJob.LAZY_REGEN, lazyRegen); JobDetail detail = newJob(RegenEnvEntitlementCertsJob.class) .withIdentity("regen_entitlement_cert_of_env" + Util.generateUUID()) .usingJobData(map) .build(); return detail; }