]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Tue, 6 Oct 2015 13:39:07 +0000 (15:39 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 6 Oct 2015 13:39:07 +0000 (15:39 +0200)
- new exception caught and renamed one
- updated jars
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jcontacts-core.jar
lib/juser-core.jar
lib/juser-lib.jar
src/java/org/mxchange/addressbook/beans/register/UserRegisterWebBean.java
src/java/org/mxchange/addressbook/beans/user/UserWebBean.java
src/java/org/mxchange/addressbook/beans/user/UserWebController.java

index 5fd68dc8f80098600ff320c77eef156f7e79d9d2..ceeaa29af8efe058726733354565e73674c2bba6 100644 (file)
Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ
index 30c2eb8281ea781cce326a635f5476b122507439..bacd4604eea1d39d40cef3cc12fc6e84825e17ef 100644 (file)
Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ
index 83cf0feae10030f1352a1c89e12ac9e5838a4d95..bc0d93d984b186468f94b648e07df11bb22b1189 100644 (file)
Binary files a/lib/juser-lib.jar and b/lib/juser-lib.jar differ
index 77cfa372479665e6910af999e64e218a7818a176..24dddcb4d669e9ae779ac50e1be58c67006a1be7 100644 (file)
@@ -24,7 +24,8 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.user.UserWebController;
-import org.mxchange.jusercore.exceptions.UserAlreadyRegisteredException;
+import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
+import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
 import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote;
 import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
@@ -75,6 +76,15 @@ public class UserRegisterWebBean implements UserRegisterWebController {
                // Get user instance
                User user = this.userController.createUserInstance();
 
+               // Is the user already used?
+               if (this.userController.isUserNameRegistered(user.getUserName())) {
+                       // User name is already used
+                       throw new FaceletException(new UserNameAlreadyRegisteredException(user));
+               } else if (this.userController.isEmailAddressRegistered(user.getUserContact().getEmailAddress())) {
+                       // Email address has already been taken
+                       throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
+               }
+
                // For debugging/programming only:
                user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
 
@@ -87,7 +97,7 @@ public class UserRegisterWebBean implements UserRegisterWebController {
 
                        // All fine, redirect to proper page
                        return "register_done"; //NOI18N
-               } catch (final UserAlreadyRegisteredException ex) {
+               } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
                        // Continue to throw
                        throw new FaceletException(ex);
                }
index 5b0bdc271cc96b67360847ad9dabb111138d6c84..de5c6e0561f674aa1fb060b6efa8a92ebe79d4b4 100644 (file)
@@ -17,6 +17,8 @@
 package org.mxchange.addressbook.beans.user;
 
 import java.util.Date;
+import java.util.List;
+import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
@@ -45,7 +47,6 @@ public class UserWebBean implements UserWebController {
        private static final long serialVersionUID = 542_145_347_916L;
 
        /////////////////////// Properties /////////////////////
-
        /**
         * Birth day
         */
@@ -136,6 +137,16 @@ public class UserWebBean implements UserWebController {
         */
        private Integer zipCode;
 
+       /**
+        * Email address list
+        */
+       private List<String> emailAddressList;
+
+       /**
+        * User name list
+        */
+       private List<String> userNameList;
+
        /**
         * Default constructor
         */
@@ -156,6 +167,25 @@ public class UserWebBean implements UserWebController {
                }
        }
 
+       @Override
+       public boolean isEmailAddressRegistered (String emailAddress) {
+               return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(emailAddress)));
+       }
+
+       @Override
+       public boolean isUserNameRegistered (final String userName) {
+               return ((this.userNameList instanceof List) && (this.userNameList.contains(userName)));
+       }
+
+       @PostConstruct
+       public void init () {
+               // Get full user name list for reducing EJB calls
+               this.userNameList = this.userBean.getUserNameList();
+
+               // Get full email address list for reducing EJB calls
+               this.emailAddressList = this.userBean.getEmailAddressList();
+       }
+
        @Override
        public void copyUser (final User user) {
                // Copy all fields:
@@ -216,7 +246,7 @@ public class UserWebBean implements UserWebController {
 
        @Override
        public Date getBirthday () {
-               return birthday;
+               return this.birthday;
        }
 
        @Override
index 7bef48a487796cd31909dda3fe22ddfdaa3fdc0c..cc7c9d16d15a0a928c19d9452a6f3ffbd9023f0c 100644 (file)
@@ -42,6 +42,22 @@ public interface UserWebController extends Serializable {
         */
        public User createUserInstance ();
 
+       /**
+        * Checks whether given user name is used
+        * <p>
+        * @param userName User name to check
+        * @return Whether it is already used
+        */
+       public boolean isUserNameRegistered (final String userName);
+
+       /**
+        * Checks whether given email address is used
+        * <p>
+        * @param emailAddress Email address to check
+        * @return Whether it is already used
+        */
+       public boolean isEmailAddressRegistered (final String emailAddress);
+
        /**
         * Getter for birth day
         * <p>