+ // The email address should not be empty as the JSF validates this
+ if (this.getEmailAddress() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.emailAddress is null"); //NOI18N
+ }
+
+ // Init user instance
+ User user;
+
+ try {
+ // Is the email address really not used?
+ user = this.userController.lookupUserByEmailAddress(this.getEmailAddress());
+ } catch (final UserEmailAddressNotFoundException ex) {
+ // Always clear bean
+ this.clear();
+
+ // Not found, should not happen as the registered validator should find it
+ this.showFacesMessage("form_resend_link:", "ERROR_USER_EMAIL_ADDRESS_NOT_FOUND"); //NOI18N
+ return ""; //NOI18N
+ }
+
+ // Is the user account already confirmed?
+ if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
+ // Always clear bean
+ this.clear();
+
+ // Then abort here
+ this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_STATUS_ALREADY_CONFIRMED"); //NOI18N
+ return ""; //NOI18N
+ } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
+ // Always clear bean
+ this.clear();
+
+ // User account is locked
+ this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_STATUS_LOCKED"); //NOI18N
+ return ""; //NOI18N
+ } else if (user.getUserConfirmKey() == null) {
+ // Status is UNCONFIRMED but confirmation key is NULL
+ throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
+ }
+
+ try {
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // Call EJB and return redirect target
+ this.emailBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
+ } catch (final UserNotFoundException ex) {
+ // User not found
+ this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_NOT_FOUND"); //NOI18N
+ return ""; //NOI18N
+ } catch (final UserStatusLockedException | UserStatusConfirmedException ex) {
+ // Output message, this should not happen as the confirmation key is being removed
+ this.showFacesMessage("form_resend_link:resendEmailAddress", ex); //NOI18N
+ return ""; //NOI18N
+ }
+
+ // Fire event
+ this.userResendLinkEvent.fire(new UserResendLinkAccountEvent(user));
+
+ // Clear this bean
+ this.clear();
+
+ // Return redirect target
+ return "user_resend_done"; //NOI18N