new Object[] {
submittedRegistrant.getFirstName(), submittedRegistrant.getLastName(),
submittedRegistrant.getEmailAddress(), submittedRegistrant.getCaptchaText()
});
LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
long creatorUserId = liferayFacesContext.getUser().getUserId();
long companyId = liferayFacesContext.getCompanyId();
Locale locale = liferayFacesContext.getLocale();
try {
boolean active = true;
boolean autoScreenName = false;
boolean sendEmail = true;
RegistrantServiceUtil.add(creatorUserId, companyId, locale, submittedRegistrant, active, autoScreenName,
sendEmail);
String key = "thank-you-for-registering";
liferayFacesContext.addGlobalInfoMessage(key, submittedRegistrant.getEmailAddress());
submittedRegistrant.clearProperties();
}
catch (DuplicateUserScreenNameException e) {
liferayFacesContext.addGlobalErrorMessage("the-screen-name-you-requested-is-already-taken");
}
catch (DuplicateUserEmailAddressException e) {
liferayFacesContext.addGlobalErrorMessage("the-email-address-you-requested-is-already-taken");
}
catch (UserPasswordException e) {
switch (e.getType()) {
case UserPasswordException.PASSWORD_ALREADY_USED: {
liferayFacesContext.addGlobalErrorMessage(
"that-password-has-already-been-used-please-enter-in-a-different-password");
break;
}
case UserPasswordException.PASSWORD_CONTAINS_TRIVIAL_WORDS: {
liferayFacesContext.addGlobalErrorMessage(
"that-password-uses-common-words-please-enter-in-a-password-that-is-harder-to-guess-i-e-contains-a-mix-of-numbers-and-letters");
break;
}
case UserPasswordException.PASSWORD_INVALID: {
liferayFacesContext.addGlobalErrorMessage(
"that-password-is-invalid-please-enter-in-a-different-password");
break;
}
case UserPasswordException.PASSWORD_LENGTH: {
try {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
PasswordPolicy passwordPolicy = company.getDefaultUser().getPasswordPolicy();
liferayFacesContext.addGlobalErrorMessage(
"that-password-is-too-short-or-too-long-please-make-sure-your-password-is-between-x-and-512-characters",
new Object[] { String.valueOf(passwordPolicy.getMinLength()) });
}
catch (Exception e1) {
logger.error(e.getMessage(), e);
liferayFacesContext.addGlobalUnexpectedErrorMessage();
}
break;
}
case UserPasswordException.PASSWORD_NOT_CHANGEABLE: {
liferayFacesContext.addGlobalErrorMessage("your-password-cannot-be-changed");
break;
}
case UserPasswordException.PASSWORD_SAME_AS_CURRENT: {
liferayFacesContext.addGlobalErrorMessage(
"your-new-password-cannot-be-the-same-as-your-old-password-please-enter-in-a-different-password");
break;
}
case UserPasswordException.PASSWORD_TOO_TRIVIAL: {
liferayFacesContext.addGlobalErrorMessage("that-password-is-too-trivial");
break;
}
case UserPasswordException.PASSWORD_TOO_YOUNG: {
try {
Company company = CompanyLocalServiceUtil.getCompany(companyId);
PasswordPolicy passwordPolicy = company.getDefaultUser().getPasswordPolicy();
liferayFacesContext.addGlobalErrorMessage(
"you-cannot-change-your-password-yet-please-wait-at-least-x-before-changing-your-password-again",
new Object[] { String.valueOf(passwordPolicy.getMinAge() * 1000) });
}
catch (Exception e1) {
logger.error(e.getMessage(), e);
liferayFacesContext.addGlobalUnexpectedErrorMessage();
}
break;
}
case UserPasswordException.PASSWORDS_DO_NOT_MATCH: {
liferayFacesContext.addGlobalErrorMessage(
"the-passwords-you-entered-do-not-match-each-other-please-re-enter-your-password");
break;
}
default: {
break;
}
}
}
catch (Exception e) {
logger.error(e.getMessage(), e);
liferayFacesContext.addGlobalUnexpectedErrorMessage();
}
}