2 * Copyright (C) 2016, 2017 Roland Häder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jusercore.model.user;
19 import java.text.MessageFormat;
20 import java.util.GregorianCalendar;
21 import java.util.List;
23 import javax.ejb.EJBException;
24 import javax.ejb.Stateless;
25 import javax.mail.Address;
26 import javax.mail.internet.AddressException;
27 import javax.mail.internet.InternetAddress;
28 import javax.persistence.NoResultException;
29 import javax.persistence.PersistenceException;
30 import javax.persistence.Query;
31 import org.mxchange.jcontacts.contact.Contact;
32 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
33 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
34 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
35 import org.mxchange.jusercore.exceptions.UserNotFoundException;
36 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
37 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
38 import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
39 import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
40 import org.mxchange.jusercore.model.user.password_history.UserPasswordHistory;
41 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
42 import org.mxchange.jusercore.model.user.register.UserRegistrationSessionBeanRemote;
43 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
44 import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
49 * @author Roland Häder<roland@mxchange.org>
51 @Stateless (name = "user", description = "A bean handling the user data")
52 public class PizzaUserSessionBean extends BasePizzaDatabaseBean implements UserSessionBeanRemote {
57 private static final long serialVersionUID = 542_145_347_916L;
63 private UserRegistrationSessionBeanRemote registerBean;
68 public PizzaUserSessionBean () {
69 // Call super constructor
74 @SuppressWarnings ("unchecked")
75 public List<User> allMemberPublicVisibleUsers () {
77 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
80 Query query = this.getEntityManager().createNamedQuery("AllMemberPublicUsers", LoginUser.class); //NOI18N
83 query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
84 query.setParameter("members", ProfileMode.MEMBERS); //NOI18N
85 query.setParameter("public", ProfileMode.PUBLIC); //NOI18N
88 List<User> users = query.getResultList();
91 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
98 @SuppressWarnings ("unchecked")
99 public List<User> allPublicUsers () {
101 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
104 Query query = this.getEntityManager().createNamedQuery("AllPublicUsers", LoginUser.class); //NOI18N
107 query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
108 query.setParameter("mode", ProfileMode.PUBLIC); //NOI18N
111 List<User> users = query.getResultList();
114 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
121 @SuppressWarnings ("unchecked")
122 public List<User> allUsers () {
124 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
127 Query query = this.getEntityManager().createNamedQuery("AllUsers", LoginUser.class); //NOI18N
130 List<User> users = query.getResultList();
133 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
140 public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException {
142 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
144 // Parameter must be valid
147 throw new NullPointerException("user is null"); //NOI18N
148 } else if (user.getUserId() == null) {
150 throw new NullPointerException("user.userId is null"); //NOI18N
151 } else if (user.getUserId() < 1) {
153 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
154 } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
155 // Account is already confirmed
156 throw new UserStatusConfirmedException(user);
157 } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
158 // Account is already confirmed
159 throw new UserStatusLockedException(user);
160 } else if (user.getUserConfirmKey() == null) {
162 throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
163 } else if (null == baseUrl) {
165 throw new NullPointerException("baseUrl is null"); //NOI18N
166 } else if (baseUrl.isEmpty()) {
168 throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
171 // Update user status and remove confirmation key
172 user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
173 user.setUserConfirmKey(null);
174 user.setUserUpdated(new GregorianCalendar());
176 // Update user account
177 User updatedUser = this.updateUserData(user);
180 Address emailAddress;
183 // Create email address and set
184 emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress());
185 } catch (final AddressException ex) {
187 throw new EJBException(ex);
191 this.sendEmail("User account confirmed", "user_account_confirmed", emailAddress, updatedUser, baseUrl, null); //NOI18N
194 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
196 // Return updated instance
201 public User fillUserData (final User user) {
203 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
205 // user should not be null
208 throw new NullPointerException("user is null"); //NOI18N
212 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
215 query.setParameter("userName", user.getUserName()); //NOI18N
217 // Initialize variable
218 User foundUser = null;
222 // Try to get single result
223 foundUser = (User) query.getSingleResult();
224 } catch (final NoResultException ex) {
226 this.getLoggerBeanLocal().logException(ex);
230 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: foundUser={1} - EXIT!", this.getClass().getSimpleName(), foundUser)); //NOI18N
232 // Return prepared instance
237 public User findUserById (final Long userId) throws UserNotFoundException {
239 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N
241 // Is the parameter valid?
242 if (null == userId) {
244 throw new NullPointerException("userId is null"); //NOI18N
245 } else if (userId < 1) {
247 throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid", userId)); //NOI18N
248 } else if (!this.ifUserIdExists(userId)) {
250 throw new UserNotFoundException(userId);
253 // Create query instance
254 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
257 query.setParameter("id", userId); //NOI18N
259 // Fetch the result, it should be there by now
260 User user = (User) query.getSingleResult();
263 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: user={1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N
270 public String generateRandomUserName () {
272 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName - CALLED!", this.getClass().getSimpleName())); //NOI18N
275 List<String> userList = this.getUserNameList();
278 String userName = null;
280 // Loop until a user name is found
281 while ((userName == null) || (userList.contains(userName))) {
282 // Generate random name
283 userName = UserUtils.generateRandomUserName();
287 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName: userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N
289 // Found one, so return it
294 @SuppressWarnings ("unchecked")
295 public List<String> getEmailAddressList () {
297 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: CALLED!", this.getClass().getSimpleName())); //NOI18N
300 Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N
303 List<String> emailAddressList = query.getResultList();
306 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddressList.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddressList.size())); //NOI18N
309 return emailAddressList;
313 @SuppressWarnings ("unchecked")
314 public List<String> getUserNameList () {
316 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: CALLED!", this.getClass().getSimpleName())); //NOI18N
319 Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N
322 List<String> userNameList = query.getResultList();
325 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: userNameList.size()={1} - EXIT!", this.getClass().getSimpleName(), userNameList.size())); //NOI18N
332 public boolean ifUserExists (final User user) {
334 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
336 // userId should not be null
339 throw new NullPointerException("user is null"); //NOI18N
340 } else if (user.getUserId() == null) {
342 throw new NullPointerException("user.userId is null"); //NOI18N
343 } else if (user.getUserId() < 1) {
345 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
349 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
352 query.setParameter("id", user.getUserId()); //NOI18N
356 User dummy = (User) query.getSingleResult();
359 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: dummy.userId={0} found.", dummy.getUserId())); //NOI18N
360 } catch (final NoResultException ex) {
362 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: getSingleResult() returned no result: {0}", ex)); //NOI18N
364 // User name does not exist
366 } catch (final PersistenceException ex) {
367 // Something bad happened
368 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user {0} found.", user, ex)); //NOI18N
375 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: Found user {1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N
382 public boolean ifUserIdExists (final Long userId) {
384 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N
386 // userId should not be null
387 if (null == userId) {
389 throw new NullPointerException("userId is null"); //NOI18N
390 } else if (userId < 1) {
392 throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid", userId)); //NOI18N
396 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
399 query.setParameter("id", userId); //NOI18N
403 User dummy = (User) query.getSingleResult();
406 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
407 } catch (final NoResultException ex) {
409 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
411 // User name does not exist
413 } catch (final PersistenceException ex) {
414 // Something bad happened
415 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user id {0} found.", userId, ex)); //NOI18N
422 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: Found userId={1} - EXIT!", this.getClass().getSimpleName(), userId)); //NOI18N
429 public boolean ifUserNameExists (final String userName) {
431 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: userName={1} - CALLED!", this.getClass().getSimpleName(), userName)); //NOI18N
433 // userId should not be null
434 if (null == userName) {
436 throw new NullPointerException("userName is null"); //NOI18N
437 } else if (userName.isEmpty()) {
439 throw new NullPointerException("userName is empty"); //NOI18N
443 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
446 query.setParameter("userName", userName); //NOI18N
450 User dummy = (User) query.getSingleResult();
453 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
454 } catch (final NoResultException ex) {
456 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
458 // User name does not exist
463 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: Found userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N
470 public boolean isEmailAddressRegistered (final User user) {
472 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
474 // user should not be null
477 throw new NullPointerException("user is null"); //NOI18N
481 Query query = this.getEntityManager().createNamedQuery("SearchUserByEmailAddress", LoginUser.class); //NOI18N
484 query.setParameter("emailAddress", user.getUserContact().getContactEmailAddress()); //NOI18N
488 User dummy = (User) query.getSingleResult();
491 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
492 } catch (final NoResultException ex) {
494 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
496 // Email address does not exist
498 } catch (final PersistenceException ex) {
499 // Something bad happened
500 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
507 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N
514 public boolean isUserNameRegistered (final User user) {
516 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
518 // user should not be null
521 throw new NullPointerException("user is null"); //NOI18N
525 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
528 query.setParameter("userName", user.getUserName()); //NOI18N
532 User dummy = (User) query.getSingleResult();
535 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
536 } catch (final NoResultException ex) {
538 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
540 // User name does not exist
542 } catch (final PersistenceException ex) {
543 // Something bad happened
544 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
551 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N
558 public User updateUserData (final User user) {
560 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
562 // user should not be null
565 throw new NullPointerException("user is null"); //NOI18N
566 } else if (user.getUserId() == null) {
568 throw new NullPointerException("user.userId is null"); //NOI18N
569 } else if (user.getUserId() < 1) {
571 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
572 } else if (user.getUserAccountStatus() == null) {
574 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
575 } else if (!this.ifUserExists(user)) {
576 // User does not exist
577 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
581 User updatedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
584 assert (updatedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
587 updatedUser.copyAll(user);
590 updatedUser.setUserUpdated(new GregorianCalendar());
593 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
595 // Return updated instance
600 public PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
602 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
604 // user should not be null
607 throw new NullPointerException("user is null"); //NOI18N
608 } else if (user.getUserId() == null) {
610 throw new NullPointerException("user.userId is null"); //NOI18N
611 } else if (user.getUserId() < 1) {
613 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
614 } else if (user.getUserName() == null) {
616 throw new NullPointerException("user.userName is null"); //NOI18N
617 } else if (user.getUserName().isEmpty()) {
619 throw new IllegalArgumentException("user.userName is empty"); //NOI18N
620 } else if (user.getUserAccountStatus() == null) {
622 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
623 } else if (user.getUserContact() == null) {
625 throw new NullPointerException("user.userContact is null"); //NOI18N
626 } else if (user.getUserContact().getContactId() == null) {
628 throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
629 } else if (user.getUserContact().getContactId() < 1) {
631 throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N
632 } else if (user.getUserContact().getContactPersonalTitle() == null) {
634 throw new NullPointerException("user.userContact.contactPersonalTitle is null"); //NOI18N
635 } else if (!this.ifUserExists(user)) {
636 // User does not exist
637 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
638 } else if (null == baseUrl) {
640 throw new NullPointerException("baseUrl is null"); //NOI18N
641 } else if (baseUrl.isEmpty()) {
643 throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
647 User updatedUser = this.updateUserData(user);
649 // Create history entry
650 PasswordHistory entry = new UserPasswordHistory(updatedUser.getUserEncryptedPassword(), updatedUser);
652 // Set created timestamp
653 entry.setUserPasswordHistoryCreated(new GregorianCalendar());
655 // Merge user to make sure it is not re-persisted
656 User mergedUser = this.getEntityManager().merge(updatedUser);
657 entry.setUserPasswordHistoryUser(mergedUser);
660 this.getEntityManager().persist(entry);
662 // Flush it to get id number back
663 this.getEntityManager().flush();
666 Address emailAddress;
669 // Create email address and set
670 emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress());
671 } catch (final AddressException ex) {
673 throw new EJBException(ex);
676 // Send email to user
677 this.sendEmail("User password change", "user_password_change", emailAddress, updatedUser, baseUrl, null); //NOI18N
680 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N
687 public User updateUserPersonalData (final User user) {
689 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
691 // user should not be null
694 throw new NullPointerException("user is null"); //NOI18N
695 } else if (user.getUserId() == null) {
697 throw new NullPointerException("user.userId is null"); //NOI18N
698 } else if (user.getUserId() < 1) {
700 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
701 } else if (user.getUserAccountStatus() == null) {
703 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
704 } else if (!this.ifUserExists(user)) {
705 // User does not exist
706 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
710 User updatedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
713 assert (updatedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
716 updatedUser.copyAll(user);
719 updatedUser.setUserUpdated(new GregorianCalendar());
720 updatedUser.getUserContact().setContactUpdated(new GregorianCalendar());
722 // Get contact from it and find it
723 Contact managedContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
726 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
729 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: managedContact.contactId={0}", managedContact.getContactId())); //NOI18N
732 managedContact.copyAll(user.getUserContact());
734 // Set it back in user
735 user.setUserContact(managedContact);
738 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", user.getUserContact().getContactId()); //NOI18N
740 // Get mobile instance
741 DialableMobileNumber mobileNumber = managedContact.getContactMobileNumber();
743 // Is there a mobile instance set?
744 if (mobileNumber instanceof DialableMobileNumber) {
746 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobileNumber.phoneId={0} is being updated ...", mobileNumber.getPhoneId())); //NOI18N
749 managedContact.setContactMobileNumber(this.getManaged(mobileNumber, mobileNumber));
752 // Get mobile instance
753 DialableFaxNumber faxNumber = managedContact.getContactFaxNumber();
755 // Is there a fax instance set?
756 if (faxNumber instanceof DialableFaxNumber) {
758 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: faxNumber.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N
761 managedContact.setContactFaxNumber(this.getManaged(faxNumber, faxNumber));
764 // Get mobile instance
765 DialableLandLineNumber landLineNumber = managedContact.getContactLandLineNumber();
767 // Is there a fax instance set?
768 if (landLineNumber instanceof DialableLandLineNumber) {
770 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLineNumber.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N
773 managedContact.setContactLandLineNumber(this.getManaged(landLineNumber, landLineNumber));
777 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: entry.updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
779 // Return updated user instance