]> git.mxchange.org Git - jjobs-mailer-ejb.git/commitdiff
addressbook-user-ejb has been merged into addressbook-ejb:
authorRoland Haeder <roland@mxchange.org>
Tue, 8 Mar 2016 21:04:32 +0000 (22:04 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 8 Mar 2016 21:04:55 +0000 (22:04 +0100)
- updated project files
- added jcore.jar
- updated jar(s)

lib/jcontacts-business-core.jar
lib/jcontacts-core.jar
lib/jcore.jar [new file with mode: 0644]
lib/jphone-core.jar
nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/project.properties
nbproject/project.xml
src/java/org/mxchange/jusercore/model/login/UserLoginSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jusercore/model/register/UserRegistrationSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jusercore/model/user/UserSessionBean.java [new file with mode: 0644]

index 38f7bec9b70f927a6c77d80bf420e15e01e2b9eb..fcaadf8ccb43000591b17665bdb1e7b4d4824515 100644 (file)
Binary files a/lib/jcontacts-business-core.jar and b/lib/jcontacts-business-core.jar differ
index a9baa32fa6cfb062f87ed9a9ccba1ebe106e8244..e905316a232cc3f743e47c1d041b3c782fa666f1 100644 (file)
Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ
diff --git a/lib/jcore.jar b/lib/jcore.jar
new file mode 100644 (file)
index 0000000..23ef19d
Binary files /dev/null and b/lib/jcore.jar differ
index 4a792881003d7be6485b4aba1e0a4aa6cf1d4c0e..221f558c88c722e38e98a8f00c55f365f4cf1498 100644 (file)
Binary files a/lib/jphone-core.jar and b/lib/jphone-core.jar differ
index 12a05fda0a9f1ac414f793c6078b29a471d78913..a38545049b8021aa7e7b427f5f6bfbc3844b3f62 100644 (file)
@@ -826,6 +826,7 @@ exists or setup the property manually. For example like this:
     </target>
     <target depends="compile,-library-inclusion-in-archive-weblogic,-library-inclusion-in-archive-by-user" name="library-inclusion-in-archive"/>
     <target if="is.jars.in.ejbjar" name="-library-inclusion-in-archive-by-user">
+        <copyfiles files="${file.reference.jcore.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.jcoreee.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.jcore-logger-lib.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.jcountry-core.jar}" todir="${build.classes.dir}"/>
@@ -837,6 +838,7 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${reference.addressbook-lib.jar}" todir="${build.classes.dir}"/>
     </target>
     <target if="is.server.weblogic" name="-library-inclusion-in-archive-weblogic">
+        <basename file="${file.reference.jcore.jar}" property="manifest.file.reference.jcore.jar"/>
         <basename file="${file.reference.jcoreee.jar}" property="manifest.file.reference.jcoreee.jar"/>
         <basename file="${file.reference.jcore-logger-lib.jar}" property="manifest.file.reference.jcore-logger-lib.jar"/>
         <basename file="${file.reference.jcountry-core.jar}" property="manifest.file.reference.jcountry-core.jar"/>
@@ -847,19 +849,21 @@ exists or setup the property manually. For example like this:
         <basename file="${file.reference.juser-lib.jar}" property="manifest.file.reference.juser-lib.jar"/>
         <basename file="${reference.addressbook-lib.jar}" property="manifest.reference.addressbook-lib.jar"/>
         <manifest file="${build.ear.classes.dir}/META-INF/MANIFEST.MF" mode="update">
-            <attribute name="Extension-List" value="jar-1 jar-2 jar-3 jar-4 jar-5 jar-6 jar-7 jar-8 jar-9 "/>
-            <attribute name="jar-1-Extension-Name" value="${manifest.file.reference.jcoreee.jar}"/>
-            <attribute name="jar-2-Extension-Name" value="${manifest.file.reference.jcore-logger-lib.jar}"/>
-            <attribute name="jar-3-Extension-Name" value="${manifest.file.reference.jcountry-core.jar}"/>
-            <attribute name="jar-4-Extension-Name" value="${manifest.file.reference.jphone-core.jar}"/>
-            <attribute name="jar-5-Extension-Name" value="${manifest.file.reference.jcontacts-core.jar}"/>
-            <attribute name="jar-6-Extension-Name" value="${manifest.file.reference.jcontacts-business-core.jar}"/>
-            <attribute name="jar-7-Extension-Name" value="${manifest.file.reference.juser-core.jar}"/>
-            <attribute name="jar-8-Extension-Name" value="${manifest.file.reference.juser-lib.jar}"/>
-            <attribute name="jar-9-Extension-Name" value="${manifest.reference.addressbook-lib.jar}"/>
+            <attribute name="Extension-List" value="jar-1 jar-2 jar-3 jar-4 jar-5 jar-6 jar-7 jar-8 jar-9 jar-10 "/>
+            <attribute name="jar-1-Extension-Name" value="${manifest.file.reference.jcore.jar}"/>
+            <attribute name="jar-2-Extension-Name" value="${manifest.file.reference.jcoreee.jar}"/>
+            <attribute name="jar-3-Extension-Name" value="${manifest.file.reference.jcore-logger-lib.jar}"/>
+            <attribute name="jar-4-Extension-Name" value="${manifest.file.reference.jcountry-core.jar}"/>
+            <attribute name="jar-5-Extension-Name" value="${manifest.file.reference.jphone-core.jar}"/>
+            <attribute name="jar-6-Extension-Name" value="${manifest.file.reference.jcontacts-core.jar}"/>
+            <attribute name="jar-7-Extension-Name" value="${manifest.file.reference.jcontacts-business-core.jar}"/>
+            <attribute name="jar-8-Extension-Name" value="${manifest.file.reference.juser-core.jar}"/>
+            <attribute name="jar-9-Extension-Name" value="${manifest.file.reference.juser-lib.jar}"/>
+            <attribute name="jar-10-Extension-Name" value="${manifest.reference.addressbook-lib.jar}"/>
         </manifest>
     </target>
     <target depends="compile" name="library-inclusion-in-manifest">
+        <copyfiles files="${file.reference.jcore.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcoreee.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcore-logger-lib.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcountry-core.jar}" todir="${dist.ear.dir}/lib"/>
index 8c017634f01b74bdd51cb6c9f3683d4e8aad66ce..5217369d60343188665bc432d767b2a7b1a3b2bb 100644 (file)
@@ -3,6 +3,6 @@ build.xml.script.CRC32=7d41e0fd
 build.xml.stylesheet.CRC32=5910fda3@1.51.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=67e811b4
-nbproject/build-impl.xml.script.CRC32=db1e22fc
+nbproject/build-impl.xml.data.CRC32=73853deb
+nbproject/build-impl.xml.script.CRC32=b9ae5896
 nbproject/build-impl.xml.stylesheet.CRC32=6096d939@1.55.1
index 08b86a3370ab397d7cd03d9b24c6dadcc4cd7bca..4e968a24fe7d20a0d0e919e25c77b89dc8ef15f0 100644 (file)
@@ -24,6 +24,7 @@ excludes=
 file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar
 file.reference.jcontacts-core.jar=lib/jcontacts-core.jar
 file.reference.jcore-logger-lib.jar=lib/jcore-logger-lib.jar
+file.reference.jcore.jar=lib/jcore.jar
 file.reference.jcoreee.jar=lib/jcoreee.jar
 file.reference.jcountry-core.jar=lib/jcountry-core.jar
 file.reference.jphone-core.jar=lib/jphone-core.jar
@@ -44,6 +45,7 @@ jar.compress=false
 jar.name=addressbook-ejb.jar
 jars.in.ejbjar=false
 javac.classpath=\
+    ${file.reference.jcore.jar}:\
     ${file.reference.jcoreee.jar}:\
     ${file.reference.jcore-logger-lib.jar}:\
     ${file.reference.jcountry-core.jar}:\
@@ -93,6 +95,7 @@ source.encoding=UTF-8
 source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/
 source.reference.jcontacts-core.jar=../jcontacts-core/src/
 source.reference.jcore-logger-lib.jar=../jcore-logger-lib/src/
+source.reference.jcore.jar=../jcore/src/
 source.reference.jcoreee.jar=../jcoreee/src/
 source.reference.jcountry-core.jar=../jcountry-core/src/
 source.reference.jphone-core.jar=../jphone-core/src/
index e8cc12d503bfec6ff2153b185f306f309fe59c1d..7e8512459863a4acb7c235e8189d3a594a860f0b 100644 (file)
@@ -5,6 +5,7 @@
         <data xmlns="http://www.netbeans.org/ns/j2ee-ejbjarproject/3">
             <name>addressbook-ejb</name>
             <minimum-ant-version>1.6.5</minimum-ant-version>
+            <included-library dirs="200">file.reference.jcore.jar</included-library>
             <included-library dirs="200">file.reference.jcoreee.jar</included-library>
             <included-library dirs="200">file.reference.jcore-logger-lib.jar</included-library>
             <included-library dirs="200">file.reference.jcountry-core.jar</included-library>
diff --git a/src/java/org/mxchange/jusercore/model/login/UserLoginSessionBean.java b/src/java/org/mxchange/jusercore/model/login/UserLoginSessionBean.java
new file mode 100644 (file)
index 0000000..9983247
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.login;
+
+import java.text.MessageFormat;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jusercore.container.login.LoginContainer;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
+import org.mxchange.jusercore.exceptions.UserStatusLockedException;
+import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
+import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+import org.mxchange.jusercore.model.user.UserUtils;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+
+/**
+ * A session bean for user logins
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Stateless (name = "login", mappedName = "ejb/stateless-addressbook-login", description = "A bean handling the user login for Addressbook project")
+public class UserLoginSessionBean extends BaseDatabaseBean implements UserLoginSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 21_785_978_127_581_965L;
+
+       /**
+        * Registration bean
+        */
+       @EJB
+       private UserRegistrationSessionBeanRemote registerBean;
+
+       /**
+        * User bean
+        */
+       @EJB
+       private UserSessionBeanRemote userBean;
+
+       @Override
+       public User validateUserAccountStatus (final LoginContainer container) throws UserNotFoundException, UserStatusLockedException, UserStatusUnconfirmedException, UserPasswordMismatchException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("loginUser: container={0} - CALLED!", container)); //NOI18N
+
+               // Check some beans
+               assert (this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N
+               assert (this.registerBean instanceof UserRegistrationSessionBeanRemote) : "this.registerBean is not set"; //NOI18N
+
+               // user should not be null
+               if (null == container) {
+                       // Abort here
+                       throw new NullPointerException("container is null"); //NOI18N
+               } else if (container.getUser() == null) {
+                       // NPE again
+                       throw new NullPointerException("container.user is null"); //NOI18N
+               } else if (container.getUserPassword() == null) {
+                       // And yet again NPE
+                       throw new NullPointerException("container.userPassword is null"); //NOI18N
+               } else if (container.getUserPassword().isEmpty()) {
+                       // Empty password is not allowed, hardcoded.
+                       throw new IllegalArgumentException("container.userPassword is empty"); //NOI18N
+               }
+
+               // Is the account there?
+               if (!this.registerBean.isUserNameRegistered(container.getUser())) {
+                       // Not registered
+                       throw new UserNotFoundException(container.getUser());
+               }
+
+               // Get user instance from persistance
+               User updatedUser = this.userBean.fillUserData(container.getUser());
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("loginUser: updatedUser={0}", updatedUser)); //NOI18N
+
+               // Is the user account unconfirmed?
+               if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.UNCONFIRMED)) {
+                       // Is unconfirmed
+                       throw new UserStatusUnconfirmedException(container.getUser());
+               } else if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.LOCKED)) {
+                       // Is locked
+                       throw new UserStatusLockedException(container.getUser());
+               } else if (!this.isPasswordMatching(container, updatedUser)) {
+                       // Not matcing passwords
+                       throw new UserPasswordMismatchException(container.getUser());
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("loginUser: updatedUser={0} - EXIT!", updatedUser)); //NOI18N
+
+               // Return it
+               return updatedUser;
+       }
+
+       /**
+        * Checks if password matches of both instances. Both user instances must
+        * not match, the first one is the one from the calling bean/controller, the
+        * second is the from database.
+        * <p>
+        * @param container   Container instance holding the user instance and
+        *                    unencrypted password
+        * @param updatedUser User instance found for given user name
+        * <p>
+        * @return Whether the password matches
+        */
+       private boolean isPasswordMatching (final LoginContainer container, final User updatedUser) {
+               // First math both instances
+               if (null == container) {
+                       // Throw NPE
+                       throw new NullPointerException("container is null"); //NOI18N
+               } else if (null == updatedUser) {
+                       // Throw NPE
+                       throw new NullPointerException("updatedUser is null"); //NOI18N
+               } else if (container.getUser().equals(updatedUser)) {
+                       // Both same instance!
+                       throw new IllegalArgumentException(MessageFormat.format("container.user matches updatedUser: {0}", container.getUser())); //NOI18N
+               }
+
+               // Is it the same same password?
+               return UserUtils.ifPasswordMatches(container, updatedUser);
+       }
+}
diff --git a/src/java/org/mxchange/jusercore/model/register/UserRegistrationSessionBean.java b/src/java/org/mxchange/jusercore/model/register/UserRegistrationSessionBean.java
new file mode 100644 (file)
index 0000000..5eb8c7e
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.register;
+
+import java.text.MessageFormat;
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
+import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+
+/**
+ * A session bean for user registration
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Stateless (name = "register", mappedName = "ejb/stateless-addressbook-register", description = "A bean handling the user registration")
+public class UserRegistrationSessionBean extends BaseDatabaseBean implements UserRegistrationSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 12_348_958_986_818_627L;
+
+       /**
+        * User bean
+        */
+       @EJB
+       private UserSessionBeanRemote userBean;
+
+       @Override
+       public boolean isEmailAddressRegistered (final User user) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isEmailAddressRegistered: user={0} - CALLED!", user)); //NOI18N
+
+               // Check bean
+               assert(this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N
+
+               // user should not be null
+               if (null == user) {
+                       // Abort here
+                       throw new NullPointerException("user is null"); //NOI18N
+               }
+
+               // Call other bean
+               return this.userBean.isEmailAddressReqistered(user);
+       }
+
+       @Override
+       public boolean isUserNameRegistered (final User user) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserNameRegistered: user={0} - CALLED!", user)); //NOI18N
+
+               // Check bean
+               assert(this.userBean instanceof UserSessionBeanRemote) : "this.userBean is not set"; //NOI18N
+
+               // user should not be null
+               if (null == user) {
+                       // Abort here
+                       throw new NullPointerException("user is null"); //NOI18N
+               }
+
+               // Call other bean
+               return this.userBean.isUserNameReqistered(user);
+       }
+
+       @Override
+       public User registerUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("registerUser: user={0} - CALLED!", user)); //NOI18N
+
+               // user should not be null
+               if (null == user) {
+                       // Abort here
+                       throw new NullPointerException("user is null"); //NOI18N
+               }
+
+               // Check if user is registered
+               if (this.isUserNameRegistered(user)) {
+                       // Abort here
+                       throw new UserNameAlreadyRegisteredException(user);
+               } else if (this.isEmailAddressRegistered(user)) {
+                       // Abort here
+                       throw new EmailAddressAlreadyRegisteredException(user);
+               }
+
+               // Persist it
+               this.getEntityManager().persist(user);
+
+               // Flush to get id back
+               this.getEntityManager().flush();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("registerUser: user={0},user.id={1} - EXIT!", user, user.getUserId())); //NOI18N
+
+               // Return it
+               return user;
+       }
+}
diff --git a/src/java/org/mxchange/jusercore/model/user/UserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/UserSessionBean.java
new file mode 100644 (file)
index 0000000..af59b8e
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.user;
+
+import java.text.MessageFormat;
+import java.util.GregorianCalendar;
+import java.util.List;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.PersistenceException;
+import javax.persistence.Query;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+
+/**
+ * A user bean
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Stateless (name = "user", mappedName = "ejb/stateless-addressbook-user", description = "A bean handling the user data")
+public class UserSessionBean extends BaseDatabaseBean implements UserSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_916L;
+
+       /**
+        * Default constructor
+        */
+       public UserSessionBean () {
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<User> allMemberPublicVisibleUsers () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("allMemberPublicVisibleUsers: CALLED!"); //NOI18N
+
+               // Get named query
+               Query query = this.getEntityManager().createNamedQuery("AllMemberPublicUsers", List.class); //NOI18N
+
+               // Set parameters
+               query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
+               query.setParameter("members", ProfileMode.MEMBERS); //NOI18N
+               query.setParameter("public", ProfileMode.PUBLIC); //NOI18N
+
+               // Get result
+               List<User> users = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allMemberPublicVisibleUsers: users.size()={0} - EXIT!", users.size())); //NOI18N
+
+               // Return full list
+               return users;
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<User> allPublicUsers () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace("allPublicUsers: CALLED!"); //NOI18N
+
+               // Get named query
+               Query query = this.getEntityManager().createNamedQuery("AllPublicUsers", List.class); //NOI18N
+
+               // Set parameters
+               query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
+               query.setParameter("mode", ProfileMode.PUBLIC); //NOI18N
+
+               // Get result
+               List<User> users = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allPublicUsers: users.size()={0} - EXIT!", users.size())); //NOI18N
+
+               // Return full list
+               return users;
+       }
+
+       @Override
+       public User fillUserData (final User user) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("fillUserData: user={0} - CALLED!", user)); //NOI18N
+
+               // user should not be null
+               if (null == user) {
+                       // Abort here
+                       throw new NullPointerException("user is null"); //NOI18N
+               }
+
+               // Try to locate it
+               Query query = this.getEntityManager().createNamedQuery("SearchUserName", LoginUser.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("param", user.getUserName()); //NOI18N
+
+               // Initialize variable
+               User foundUser = null;
+
+               // Try it
+               try {
+                       // Try to get single result
+                       foundUser = (User) query.getSingleResult();
+               } catch (final NoResultException ex) {
+                       // Log it
+                       this.getLoggerBeanLocal().logException(ex);
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("fillUserData: foundUser={0} - EXIT!", foundUser)); //NOI18N
+
+               // Return prepared instance
+               return foundUser;
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<String> getEmailAddressList () {
+               // Get query
+               Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N
+
+               // Get result list
+               List<String> emailAddressList = query.getResultList();
+
+               // Return it
+               return emailAddressList;
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<String> getUserNameList () {
+               // Get query
+               Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N
+
+               // Get result list
+               List<String> userNameList = query.getResultList();
+
+               // Return it
+               return userNameList;
+       }
+
+       @Override
+       public boolean ifUserIdExists (final Long userId) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserIdExists: userId={0} - CALLED!", userId)); //NOI18N
+
+               // userId should not be null
+               if (null == userId) {
+                       // Abort here
+                       throw new NullPointerException("userId is null"); //NOI18N
+               } else if (userId < 1) {
+                       // Invalid number
+                       throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", userId)); //NOI18N
+               }
+
+               // Generate query
+               Query query = this.getEntityManager().createNamedQuery("SearchUserId", LoginUser.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("id", userId); //NOI18N
+
+               // Try this
+               try {
+                       User dummy = (User) query.getSingleResult();
+
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserIdExists: dummy.id={0} found.", dummy.getUserId())); //NOI18N
+               } catch (final NoResultException ex) {
+                       // Log it
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserIdExists: getSingleResult() returned no result: {0}", ex)); //NOI18N
+
+                       // User name does not exist
+                       return false;
+               } catch (final PersistenceException ex) {
+                       // Something bad happened
+                       this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user id {0} found.", userId, ex)); //NOI18N
+
+                       // Throw again
+                       throw ex;
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserIdExists: Found user id {0} - EXIT!", userId)); //NOI18N
+
+               // Found it
+               return true;
+       }
+
+       @Override
+       public boolean isEmailAddressReqistered (final User user) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isEmailAddressReqistered: user={0} - CALLED!", user)); //NOI18N
+
+               // user should not be null
+               if (null == user) {
+                       // Abort here
+                       throw new NullPointerException("user is null"); //NOI18N
+               }
+
+               // Generate query
+               Query query = this.getEntityManager().createNamedQuery("SearchEmailAddress", LoginUser.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("param", user.getUserContact().getContactEmailAddress()); //NOI18N
+
+               // Search for it
+               try {
+                       User dummy = (User) query.getSingleResult();
+
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("isEmailAddressReqistered: dummy.id={0} found.", dummy.getUserId())); //NOI18N
+               } catch (final NoResultException ex) {
+                       // Log it
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("isEmailAddressReqistered: getSingleResult() returned no result: {0}", ex)); //NOI18N
+
+                       // Email address does not exist
+                       return false;
+               } catch (final PersistenceException ex) {
+                       // Something bad happened
+                       this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
+
+                       // Throw again
+                       throw ex;
+               }
+
+               // Found it
+               return true;
+       }
+
+       @Override
+       public boolean isUserNameReqistered (final User user) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserNameReqistered: user={0} - CALLED!", user)); //NOI18N
+
+               // user should not be null
+               if (null == user) {
+                       // Abort here
+                       throw new NullPointerException("user is null"); //NOI18N
+               }
+
+               // Generate query
+               Query query = this.getEntityManager().createNamedQuery("SearchUserName", LoginUser.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("param", user.getUserName()); //NOI18N
+
+               // Try this
+               try {
+                       User dummy = (User) query.getSingleResult();
+
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserNameReqistered: dummy.id={0} found.", dummy.getUserId())); //NOI18N
+               } catch (final NoResultException ex) {
+                       // Log it
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserNameReqistered: getSingleResult() returned no result: {0}", ex)); //NOI18N
+
+                       // User name does not exist
+                       return false;
+               } catch (final PersistenceException ex) {
+                       // Something bad happened
+                       this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
+
+                       // Throw again
+                       throw ex;
+               }
+
+               // Found it
+               return true;
+       }
+
+       @Override
+       public void updateUserPersonalData (final User user) {
+               // user should not be null
+               if (null == user) {
+                       // Abort here
+                       throw new NullPointerException("user is null"); //NOI18N
+               } else if (user.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("user.userId is null");
+               } else if (user.getUserId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId()));
+               } else if (!this.ifUserIdExists(user.getUserId())) {
+                       // User does not exist
+                       throw new PersistenceException(MessageFormat.format("User with id {0} does not exist.", user.getUserId()));
+               }
+
+               // Find the instance
+               User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
+
+               // Should be found!
+               assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
+
+               // Merge user
+               User detachedUser = this.getEntityManager().merge(foundUser);
+
+               // Should be found!
+               assert (detachedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", user.getUserId()); //NOI18N
+
+               // Strange things needs to be logged
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: user.userAccountStatus={0},foundUser.userAccountStatus={1},user.userContact.phoneId={2},detachedUser.userContact.phoneId={3}", user.getUserAccountStatus(), detachedUser.getUserAccountStatus(), user.getUserContact().getContactLandLineNumber().getPhoneId(), detachedUser.getUserContact().getContactLandLineNumber().getPhoneId())); //NOI18N
+
+               // Copy all data
+               detachedUser.copyAll(user);
+
+               // Set as updated
+               detachedUser.setUserUpdated(new GregorianCalendar());
+               detachedUser.getUserContact().setContactUpdated(new GregorianCalendar());
+       }
+}