From: Roland Häder Date: Sun, 9 Jul 2017 10:53:03 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8301901a74c7dd30652cc25301a8879500dd7637;p=pizzaservice-war.git Please cherry-pick: - renamed bean to userConfirmationLinkController - always handle returned (mostly updated/managed) entities, then the updated data is being handled Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java index d73884a5..ec9fcc18 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java @@ -91,15 +91,6 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement */ private DialableFaxNumber faxNumber; - /** - * land-line number - */ - private DialableLandLineNumber landLineNumber; - - /** - * mobile number - */ - private DialableMobileNumber mobileNumber; /** * Event being fired when an administrator has deleted fax number @@ -114,6 +105,10 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement @Inject @Any private Event faxNumberUpdatedEvent; + /** + * land-line number + */ + private DialableLandLineNumber landLineNumber; /** * Event being fired when an administrator has deleted land-line number @@ -128,6 +123,10 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement @Inject @Any private Event landLineNumberUpdatedEvent; + /** + * mobile number + */ + private DialableMobileNumber mobileNumber; /** * Event being fired when an administrator has deleted mobile number diff --git a/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java index fe9f04a7..91e0c438 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java @@ -26,8 +26,8 @@ import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; import org.mxchange.pizzaapplication.beans.BasePizzaController; -import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionController; import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; +import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionController; /** * A web request bean for user profiles diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/confirmlink/PizzaConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/confirmlink/PizzaConfirmationLinkWebRequestBean.java index 23edfa6d..98b46a9a 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/confirmlink/PizzaConfirmationLinkWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/confirmlink/PizzaConfirmationLinkWebRequestBean.java @@ -47,7 +47,7 @@ import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; *

* @author Roland Häder */ -@Named ("confirmationLinkController") +@Named ("userConfirmationLinkController") @RequestScoped public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController implements PizzaConfirmationLinkWebRequestController { @@ -123,6 +123,9 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp @Override public void maybeConfirmUserAccount () { + // Trace message + System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: CALLED!", this.getClass().getSimpleName())); //NOI18N + // Is the confirmation key set? if (this.getConfirmationKey() == null) { // May be null if not set @@ -135,6 +138,9 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp // Now try to find the user in user list, first get the whole list List users = this.userController.allUsers(); + // Debug message + System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: users.size()={1}", this.getClass().getSimpleName(), users.size())); //NOI18N + // Get iterator from it Iterator iterator = users.iterator(); @@ -146,41 +152,49 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp // Get next user User next = iterator.next(); + // Debug message + System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: this.confirmationKey={1},next.confirmationKey={2}", this.getClass().getSimpleName(), this.getConfirmationKey(), next.getUserConfirmKey())); //NOI18N + // Same confirmation key? if (Objects.equals(this.getConfirmationKey(), next.getUserConfirmKey())) { + // Debug message + System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: next={1} - Aborting ...", this.getClass().getSimpleName(), next)); //NOI18N + // Found it, then set it and abort loop user = next; break; } } + // Debug message + System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: user={1}", this.getClass().getSimpleName(), user)); //NOI18N + // Is the user instance null? if ((null == user) || (user.getUserAccountStatus() != UserAccountStatus.UNCONFIRMED)) { // Then clear this bean and the helper this.beanHelper.setUser(null); } else { - // Set user ... - this.beanHelper.setUser(user); - - // ... and copy it to the controller - this.beanHelper.copyUserToController(); - // Try to confirm it - this.confirmUserAccount(); + this.confirmUserAccount(user); } + + // Trace message + System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: EXIT!", this.getClass().getSimpleName())); //NOI18N } /** * Tries to confirm the currently set user instance (in helper). + *

+ * @param user User instance */ - private void confirmUserAccount () { - // Get user instance - User user = this.beanHelper.getUser(); + private void confirmUserAccount (final User user) { + // Trace message + System.out.println(MessageFormat.format("{0}.confirmUserAccount: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N // Should be set if (null == user) { // Throw NPE - throw new NullPointerException("user is null"); + throw new NullPointerException("user is null"); //NOI18N } else if (user.getUserId() == null) { // Abort here throw new NullPointerException("user.userId is null"); //NOI18N @@ -196,6 +210,9 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp } else if (user.getUserConfirmKey() == null) { // Throw NPE throw new NullPointerException("user.userConfirmKey is null"); //NOI18N + } else if (user.getUserConfirmKey().isEmpty()) { + // Is empty string + throw new IllegalArgumentException("user.userConfirmKey is empty"); //NOI18N } // Updated user instance @@ -205,8 +222,14 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp // Get base URL String baseUrl = FacesUtils.generateBaseUrl(); + // Debug message + System.out.println(MessageFormat.format("{0}.confirmUserAccount: baseUrl={1}", this.getClass().getSimpleName(), baseUrl)); //NOI18N + // Confirm account updatedUser = this.userBean.confirmAccount(user, baseUrl); + + // Debug message + System.out.println(MessageFormat.format("{0}.confirmUserAccount: updatedUser={1} - Returned from EJB", this.getClass().getSimpleName(), updatedUser)); //NOI18N } catch (final UserStatusConfirmedException | UserStatusLockedException ex) { // Something unexpected happened throw new FaceletException(MessageFormat.format("Cannot confirm user account {0}", user.getUserName()), ex); //NOI18N @@ -215,8 +238,17 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp // Fire event that the user has confirmed account this.userConfirmedEvent.fire(new UserConfirmedAccountEvent(updatedUser)); + // Debug message + System.out.println(MessageFormat.format("{0}.confirmUserAccount: updatedUser={1}", this.getClass().getSimpleName(), updatedUser)); //NOI18N + // Set it again in helper this.beanHelper.setUser(updatedUser); + + // ... and copy it to the controller + this.beanHelper.copyUserToController(); + + // Trace message + System.out.println(MessageFormat.format("{0}.confirmUserAccount: EXIT!", this.getClass().getSimpleName())); //NOI18N } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionBean.java index 0410c910..6d4fe162 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionBean.java @@ -134,12 +134,15 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement throw new NullPointerException("user.userConfirmKey is null"); //NOI18N } + // Init managed user instance + User managedUser; + try { // Get base URL String baseUrl = FacesUtils.generateBaseUrl(); // Call EJB and return redirect target - this.resendLinkBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl); + managedUser = this.resendLinkBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl); } catch (final UserNotFoundException ex) { // User not found this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_NOT_FOUND"); //NOI18N @@ -150,12 +153,12 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement return ""; //NOI18N } - // Fire event - this.userResendLinkEvent.fire(new UserResendLinkAccountEvent(user)); - // Clear this bean this.clear(); + // Fire event + this.userResendLinkEvent.fire(new UserResendLinkAccountEvent(managedUser)); + // Return redirect target return "user_resend_done"; //NOI18N } diff --git a/web/guest/user/user_confirm_account.xhtml b/web/guest/user/user_confirm_account.xhtml index aeb797b4..a49b6eaa 100644 --- a/web/guest/user/user_confirm_account.xhtml +++ b/web/guest/user/user_confirm_account.xhtml @@ -10,8 +10,8 @@ - - + + @@ -24,7 +24,7 @@ - +

@@ -47,7 +47,7 @@ - +