Source:
public ValidationResult processNewRegistration(UserRegistration userRegistration, Boolean sendEmail) { Objects.requireNonNull(userRegistration); ValidationResult validationResult = validateRegistration(userRegistration); if (validationResult.valid()) { UserRegistration existing = (userRegistration.getRegistrationId() != null && !userRegistration.getRegistrationId().isEmpty()) ? persistenceService.findById(UserRegistration.class, userRegistration.getRegistrationId()) : null; if (existing != null) { existing.updateFields(userRegistration); userRegistration = existing; } else { userRegistration.setRegistrationId(persistenceService.generateId()); userRegistration.populateBaseCreateFields(); } if (sendEmail) { userRegistration.setVerificationCode(generateRandomString(8)); if (StringUtils.isNotBlank(userRegistration.getEmail())) { Map data = new HashMap(); String subject = "Email Verification Code"; data.put("verificationCode", userRegistration.getVerificationCode()); data.put("replyName", PropertiesManager.getValue(PropertiesManager.KEY_MAIL_REPLY_NAME)); data.put("replyAddress", PropertiesManager.getValue(PropertiesManager.KEY_MAIL_REPLY_ADDRESS)); data.put("title", subject); Email email = MailManager.newTemplateEmail(MailManager.Templates.EMAIL_VERIFICATION.toString(), data); email.setSubject(subject); email.addRecipient(userRegistration.getFirstName(), userRegistration.getEmail(), Message.RecipientType.TO); MailManager.send(email); } else { LOG.log(Level.WARNING, "Email is setup as the feedback handler however the configure properties doesn't have a email added defined for property: " + PropertiesManager.KEY_FEEDBACK_EMAIL); } } persistenceService.persist(userRegistration); } return validationResult; }

Target:
public ValidationResult processNewRegistration(UserRegistration userRegistration, Boolean sendEmail) { Objects.requireNonNull(userRegistration); ValidationResult validationResult = validateRegistration(userRegistration); if (validationResult.valid()) { UserRegistration existing = (userRegistration.getRegistrationId() != null && !userRegistration.getRegistrationId().isEmpty()) ? persistenceService.findById(UserRegistration.class, userRegistration.getRegistrationId()) : null; if (existing != null) { existing.updateFields(userRegistration); userRegistration = existing; } else { userRegistration.setRegistrationId(persistenceService.generateId()); userRegistration.populateBaseCreateFields(); } if (sendEmail) { userRegistration.setVerificationCode(generateRandomString(8)); if (StringUtils.isNotBlank(userRegistration.getEmail())) { Map data = new HashMap(); String subject = "Email Verification Code"; data.put("verificationCode", userRegistration.getVerificationCode()); data.put("replyName", PropertiesManager.getValue(PropertiesManager.KEY_MAIL_REPLY_NAME)); data.put("replyAddress", PropertiesManager.getValue(PropertiesManager.KEY_MAIL_REPLY_ADDRESS)); data.put("title", subject); Email email = MailManager.newTemplateEmail(MailManager.Templates.EMAIL_VERIFICATION.toString(), data); email.setSubject(subject); email.addRecipient(userRegistration.getFirstName(), userRegistration.getEmail(), Message.RecipientType.TO); MailManager.send(email); } else { LOG.log(Level.WARNING, "Missing email address unable to send verification code"); } } persistenceService.persist(userRegistration); } return validationResult; }