Source:
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { JobDataMap map = jobExecutionContext.getJobDetail().getJobDataMap(); User userToDelete = (User) map.get("userToDelete"); User replacementUser = (User) map.get("replacementUser"); User user = (User) map.get("user"); Boolean respectFrontEndRoles = (Boolean) map.get("respectFrontEndRoles"); String errorMessage = null; try { String startMessage = MessageFormat.format(LanguageUtil.get(user, "com.dotmarketing.business.UserAPI.delete.start"), userToDelete.getUserId() + "/" + userToDelete.getFullName(), replacementUser.getUserId() + "/" + replacementUser.getFullName()); String finishMessage = MessageFormat.format(LanguageUtil.get(user, "com.dotmarketing.business.UserAPI.delete.success"), userToDelete.getUserId() + "/" + userToDelete.getFullName()); errorMessage = MessageFormat.format(LanguageUtil.get(user, "com.dotmarketing.business.UserAPI.delete.error"), userToDelete.getUserId() + "/" + userToDelete.getFullName()); notfAPI.info(startMessage, user.getUserId()); HibernateUtil.startTransaction(); uAPI.delete(userToDelete, replacementUser, user, respectFrontEndRoles); HibernateUtil.closeAndCommitTransaction(); notfAPI.info(finishMessage, user.getUserId()); } catch (Exception e) { try { HibernateUtil.rollbackTransaction(); userToDelete.setDeleteDate(null); userToDelete.setDeleteInProgress(false); uAPI.save(userToDelete, user, false); } catch (DotDataException | DotSecurityException e1) { Logger.error(this, "Error in rollback transaction", e); } Logger.error(this, String.format("Unable to delete user '%s'.", userToDelete.getUserId() + "/" + userToDelete.getFullName()), e); notfAPI.error(errorMessage, user.getUserId()); } finally { try { HibernateUtil.closeSession(); } catch (DotHibernateException e) { Logger.warn(this, "exception while calling HibernateUtil.closeSession()", e); } } }

Target:
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { JobDataMap map = jobExecutionContext.getJobDetail().getJobDataMap(); User userToDelete = (User) map.get("userToDelete"); User replacementUser = (User) map.get("replacementUser"); User user = (User) map.get("user"); Boolean respectFrontEndRoles = (Boolean) map.get("respectFrontEndRoles"); String errorMessage = null; try { String startMessage = MessageFormat.format(LanguageUtil.get(user, "com.dotmarketing.business.UserAPI.delete.start"), userToDelete.getUserId() + "/" + userToDelete.getFullName(), replacementUser.getUserId() + "/" + replacementUser.getFullName()); String finishMessage = MessageFormat.format(LanguageUtil.get(user, "com.dotmarketing.business.UserAPI.delete.success"), userToDelete.getUserId() + "/" + userToDelete.getFullName()); errorMessage = MessageFormat.format(LanguageUtil.get(user, "com.dotmarketing.business.UserAPI.delete.error"), userToDelete.getUserId() + "/" + userToDelete.getFullName()); notfAPI.info(startMessage, user.getUserId()); HibernateUtil.startTransaction(); uAPI.delete(userToDelete, replacementUser, user, respectFrontEndRoles); HibernateUtil.closeAndCommitTransaction(); notfAPI.info(finishMessage, user.getUserId()); } catch (Exception e) { try { HibernateUtil.rollbackTransaction(); userToDelete.setDeleteDate(null); userToDelete.setDeleteInProgress(false); uAPI.save(userToDelete, user, false); } catch (DotDataException | DotSecurityException e1) { Logger.error(this, "Error in rollback transaction", e); } Logger.error(this, String.format("Unable to delete user '%s'.", userToDelete.getUserId() + "/" + userToDelete.getFullName()), e); notfAPI.error(errorMessage, user.getUserId()); } finally { try { HibernateUtil.closeSession(); } catch (DotHibernateException e) { Logger.warn(this, "exception while calling HibernateUtil.closeSession()", e); } finally { DbConnectionFactory.closeConnection(); } } }