if (Researcher.findResearchersByEmailEquals(dto.getEmail()).getResultList().size() != 0) {
result.rejectValue("email", "researcher.error.email", "There is already an account under that email address. If you forgot your password use the forgot password link from the login page to get help.");
}
Researcher researcher = copyFormDataFromDtoToResearcher(dto, new Researcher());
researcher.setPassword(dto.getPassword());
Set<ConstraintViolation<Researcher>> violatedConstraints = Validation.buildDefaultValidatorFactory().getValidator().validate(researcher);
for (ConstraintViolation<Researcher> constraint : violatedConstraints) {
result.rejectValue(constraint.getPropertyPath().toString(), "researcher.error." + constraint.getPropertyPath(), constraint.getMessage());
}
if (!result.hasErrors()) {
uploadProfilePictureIfEntered(dto, researcher);
researcher.setSalt(getRandomSalt());
researcher.setPassword(getHashedPassword(dto.getPassword(), researcher.getSalt()));
researcher.persist();
String message = generateMessage(accountCreatedMessage, new Object[] {researcher.getEmail(), applicationUrl});
messageSender.sendMessage("Community Profile Database Account Created", researcher.getEmail(), message);
}
}