]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
fixed 2nd parameter, it can be easily generated within a JSF application
authorRoland Häder <roland@mxchange.org>
Wed, 18 May 2016 12:50:42 +0000 (14:50 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 21 May 2016 10:34:57 +0000 (12:34 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/beans/email_address/PizzaEmailChangeWebSessionBean.java
src/java/org/mxchange/pizzaapplication/beans/register/PizzaUserRegisterWebSessionBean.java
src/java/org/mxchange/pizzaapplication/beans/resendlink/PizzaResendLinkWebSessionBean.java

index 960c5bc110301550e8415b14729b56f31cba58a5..ec382e601190e1efe804452bc36402c2dd3ad561 100644 (file)
@@ -27,6 +27,7 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcoreee.utils.FacesUtils;
 import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
 import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress;
 import org.mxchange.jusercore.model.email_address.EmailAddressChange;
@@ -88,7 +89,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen
                        this.emailBean = (EmailChangeSessionBeanRemote) context.lookup("java:global/addressbook-ejb/email-change!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N
 
                        // Init list
-                       this.emailAddresses = this.emailBean.allQueuedAddressesAsList();
+                       this.emailAddresses = this.emailBean.allQueuedAddresses();
                } catch (final NamingException e) {
                        // Throw again
                        throw new FaceletException(e);
@@ -132,8 +133,11 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen
                // Create change object, to save EJB calls, the hash is not generated here
                ChangeableEmailAddress emailChange = new EmailAddressChange(user, this.getEmailAddress());
 
+               // Get base URL
+               String baseUrl = FacesUtils.generateBaseUrl();
+
                // Call EJB
-               this.emailBean.enqueueEmailAddressForChange(emailChange);
+               this.emailBean.enqueueEmailAddressForChange(emailChange, baseUrl);
 
                // Unset all so the user is forced to re-enter it
                this.clear();
index 7f736a07165a2fe6149fbf0b036851394704dc90..72cf1eb58e8e939812d3c100d9b0e214dc2b625e 100644 (file)
@@ -29,6 +29,7 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jcoreee.utils.FacesUtils;
 import org.mxchange.jusercore.events.registration.RegisteredUserEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
 import org.mxchange.jusercore.exceptions.DataRepeatMismatchException;
@@ -151,8 +152,11 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme
                }
 
                try {
+                       // Get base URL
+                       String baseUrl = FacesUtils.generateBaseUrl();
+
                        // Call bean
-                       User registeredUser = this.registerBean.registerUser(user);
+                       User registeredUser = this.registerBean.registerUser(user, baseUrl);
 
                        // The id number should be set
                        assert (registeredUser.getUserId() instanceof Long) : "registeredUser.userId is null after registerUser() was called."; //NOI18N
index cbb7b4da84657b506289a580c926b621e08edf1b..25c9b591249eb8d6175340e9781b59a6c854b3d9 100644 (file)
  */
 package org.mxchange.pizzaapplication.beans.resendlink;
 
+import java.text.MessageFormat;
+import java.util.Locale;
 import javax.enterprise.context.SessionScoped;
+import javax.faces.context.FacesContext;
 import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
 import javax.inject.Named;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
+import org.mxchange.jcoreee.utils.FacesUtils;
+import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
+import org.mxchange.jusercore.model.user.User;
 import org.mxchange.pizzaapplication.beans.BasePizzaController;
+import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController;
 
 /**
  * A web session bean for resending confirmation link
@@ -48,6 +56,12 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement
         */
        private ResendLinkSessionBeanRemote emailBean;
 
+       /**
+        * User controller
+        */
+       @Inject
+       private PizzaUserWebSessionController userController;
+
        /**
         * Default constructor
         */
@@ -67,7 +81,34 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement
 
        @Override
        public String doResendLink () {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+               // 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) {
+                       // Not found, should not happen as the registeredvalidator should find it
+                       throw new FaceletException(MessageFormat.format("this.emailAddress={0} should be resolveable into User instance.", this.getEmailAddress()), ex); //NOI18N
+               }
+
+               // Get locale from faces context
+               Locale locale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
+
+               // Get base URL
+               String baseUrl = FacesUtils.generateBaseUrl();
+
+               // Call EJB and return redirect target
+               String redirectTarget = this.emailBean.resendConfirmationLink(user, locale, baseUrl);
+
+               // Return redirect target
+               return redirectTarget;
        }
 
        @Override