From: Roland Haeder Date: Tue, 8 Mar 2016 21:04:32 +0000 (+0100) Subject: addressbook-user-ejb has been merged into addressbook-ejb: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2df78299e45b9058fcb03ac6d5a27f63c18ae7a2;p=addressbook-ejb.git addressbook-user-ejb has been merged into addressbook-ejb: - updated project files - added jcore.jar - updated jar(s) --- diff --git a/lib/jcontacts-business-core.jar b/lib/jcontacts-business-core.jar index 38f7bec..fcaadf8 100644 Binary files a/lib/jcontacts-business-core.jar and b/lib/jcontacts-business-core.jar differ diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar index a9baa32..e905316 100644 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 index 0000000..23ef19d Binary files /dev/null and b/lib/jcore.jar differ diff --git a/lib/jphone-core.jar b/lib/jphone-core.jar index 4a79288..221f558 100644 Binary files a/lib/jphone-core.jar and b/lib/jphone-core.jar differ diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 12a05fd..a385450 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -826,6 +826,7 @@ exists or setup the property manually. For example like this: + @@ -837,6 +838,7 @@ exists or setup the property manually. For example like this: + @@ -847,19 +849,21 @@ exists or setup the property manually. For example like this: - - - - - - - - - - + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 8c01763..5217369 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -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 diff --git a/nbproject/project.properties b/nbproject/project.properties index 08b86a3..4e968a2 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -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/ diff --git a/nbproject/project.xml b/nbproject/project.xml index e8cc12d..7e85124 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -5,6 +5,7 @@ addressbook-ejb 1.6.5 + file.reference.jcore.jar file.reference.jcoreee.jar file.reference.jcore-logger-lib.jar file.reference.jcountry-core.jar 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 index 0000000..9983247 --- /dev/null +++ b/src/java/org/mxchange/jusercore/model/login/UserLoginSessionBean.java @@ -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 . + */ +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 + *

+ * @author Roland Haeder + */ +@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. + *

+ * @param container Container instance holding the user instance and + * unencrypted password + * @param updatedUser User instance found for given user name + *

+ * @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 index 0000000..5eb8c7e --- /dev/null +++ b/src/java/org/mxchange/jusercore/model/register/UserRegistrationSessionBean.java @@ -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 . + */ +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 + *

+ * @author Roland Haeder + */ +@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 index 0000000..af59b8e --- /dev/null +++ b/src/java/org/mxchange/jusercore/model/user/UserSessionBean.java @@ -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 . + */ +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 + *

+ * @author Roland Haeder + */ +@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 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 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 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 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 getEmailAddressList () { + // Get query + Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N + + // Get result list + List emailAddressList = query.getResultList(); + + // Return it + return emailAddressList; + } + + @Override + @SuppressWarnings ("unchecked") + public List getUserNameList () { + // Get query + Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N + + // Get result list + List 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()); + } +}