]> git.mxchange.org Git - jaddressbook-share-lib.git/commitdiff
organized members and formatted project
authorRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 14:38:53 +0000 (16:38 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 14:38:53 +0000 (16:38 +0200)
src/org/mxchange/addressbook/validator/user/UserIdValidator.java

index 943c0b34d55a717084102bce56823fd12e429a10..a449dee7ac1e9e66716f486faa7a0de5958048e8 100644 (file)
@@ -40,6 +40,11 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
 @FacesValidator (value = "UserIdValidator")
 public class UserIdValidator extends BaseLongValidator implements Validator {
 
+       /**
+        * Cached user status
+        */
+       private static final Set<Long> cachedStatus = new TreeSet<>();
+
        /**
         * Serial number
         */
@@ -52,9 +57,32 @@ public class UserIdValidator extends BaseLongValidator implements Validator {
        private UserSessionBeanRemote userBean;
 
        /**
-        * Cached user status
+        * Event fired when the user registration is complete
+        * <p>
+        * @param event User registration event
         */
-       private static final Set<Long> cachedStatus = new TreeSet<>();
+       public void afterRegistration (final @Observes UserRegisteredEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.user is null"); //NOI18N
+               } else if (event.getUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.user.userId is null"); //NOI18N
+               } else if (event.getUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUser(), event.getUser().getUserId())); //NOI18N
+               }
+
+               // Get user instance
+               User registeredUser = event.getUser();
+
+               // Update cache
+               UserIdValidator.cachedStatus.add(registeredUser.getUserId());
+       }
 
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
@@ -94,32 +122,4 @@ public class UserIdValidator extends BaseLongValidator implements Validator {
                // Trace message
                //this.getLogger().logTrace("validate: EXIT!"); //NOI18N
        }
-
-       /**
-        * Event fired when the user registration is complete
-        * <p>
-        * @param event User registration event
-        */
-       public void afterRegistration (final @Observes UserRegisteredEvent event) {
-               // event should not be null
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getUser() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.user is null"); //NOI18N
-               } else if (event.getUser().getUserId() == null) {
-                       // userId is null
-                       throw new NullPointerException("event.user.userId is null"); //NOI18N
-               } else if (event.getUser().getUserId() < 1) {
-                       // Not avalid id
-                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUser(), event.getUser().getUserId())); //NOI18N
-               }
-
-               // Get user instance
-               User registeredUser = event.getUser();
-
-               // Update cache
-               UserIdValidator.cachedStatus.add(registeredUser.getUserId());
-       }
 }