if (last.length() == 0)
result.addError("last_name");
// Check if the email address is all ready being used.
EPerson potentialDupicate = EPerson.findByEmail(context,email);
if (potentialDupicate != null)
{
// special error that the front end knows about.
result.addError("eperson_email_key");
}
// No errors, so we try to create the EPerson from the data provided
if (result.getErrors() == null)
{
EPerson newPerson = AuthenticationUtil.createNewEperson(objectModel,email);
newPerson.setFirstName(first);
newPerson.setLastName(last);
newPerson.setMetadata("phone", phone);
newPerson.setCanLogIn(login);
newPerson.setRequireCertificate(certificate);
newPerson.setSelfRegistered(false);
newPerson.update();
context.commit();
// success
result.setContinue(true);
result.setOutcome(true);
result.setMessage(T_add_eperson_success_notice);
result.setParameter("epersonID", newPerson.getID());
}
return result;
}