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.addressbook.database.BaseAddressbookDatabaseBean;
32 import org.mxchange.jcontacts.contact.Contact;
33 import org.mxchange.jcontacts.contact.ContactUtils;
34 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
35 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
36 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
37 import org.mxchange.jusercore.exceptions.UserNotFoundException;
38 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
39 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
40 import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
41 import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
42 import org.mxchange.jusercore.model.user.password_history.UserPasswordHistory;
43 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
44 import org.mxchange.jusercore.model.user.register.UserRegistrationSessionBeanRemote;
45 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
50 * @author Roland Häder<roland@mxchange.org>
52 @Stateless (name = "user", description = "A bean handling the user data")
53 public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean implements UserSessionBeanRemote {
58 private static final long serialVersionUID = 542_145_347_916L;
64 private UserRegistrationSessionBeanRemote registerBean;
69 public AddressbookUserSessionBean () {
70 // Call super constructor
75 @SuppressWarnings ("unchecked")
76 public List<User> allMemberPublicVisibleUsers () {
78 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
81 Query query = this.getEntityManager().createNamedQuery("AllMemberPublicUsers", LoginUser.class); //NOI18N
84 query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
85 query.setParameter("members", ProfileMode.MEMBERS); //NOI18N
86 query.setParameter("public", ProfileMode.PUBLIC); //NOI18N
89 List<User> users = query.getResultList();
92 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
99 @SuppressWarnings ("unchecked")
100 public List<User> allPublicUsers () {
102 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
105 Query query = this.getEntityManager().createNamedQuery("AllPublicUsers", LoginUser.class); //NOI18N
108 query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
109 query.setParameter("mode", ProfileMode.PUBLIC); //NOI18N
112 List<User> users = query.getResultList();
115 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
122 @SuppressWarnings ("unchecked")
123 public List<User> allUsers () {
125 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
128 Query query = this.getEntityManager().createNamedQuery("AllUsers", LoginUser.class); //NOI18N
131 List<User> users = query.getResultList();
134 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
141 public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException {
143 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
145 // Parameter must be valid
148 throw new NullPointerException("user is null"); //NOI18N
149 } else if (user.getUserId() == null) {
151 throw new NullPointerException("user.userId is null"); //NOI18N
152 } else if (user.getUserId() < 1) {
154 throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", user.getUserId())); //NOI18N
155 } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
156 // Account is already confirmed
157 throw new UserStatusConfirmedException(user);
158 } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
159 // Account is already confirmed
160 throw new UserStatusLockedException(user);
161 } else if (user.getUserConfirmKey() == null) {
163 throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
164 } else if (null == baseUrl) {
166 throw new NullPointerException("baseUrl is null"); //NOI18N
167 } else if (baseUrl.isEmpty()) {
169 throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
172 // Update user status and remove confirmation key
173 user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
174 user.setUserConfirmKey(null);
175 user.setUserUpdated(new GregorianCalendar());
177 // Update user account
178 User updatedUser = this.updateUserData(user);
181 Address emailAddress;
184 // Create email address and set
185 emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress());
186 } catch (final AddressException ex) {
188 throw new EJBException(ex);
192 this.sendEmail("User account confirmed", "user_account_confirmed", emailAddress, updatedUser, baseUrl, null); //NOI18N
195 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
197 // Return updated instance
202 public User fillUserData (final User user) {
204 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
206 // user should not be null
209 throw new NullPointerException("user is null"); //NOI18N
213 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
216 query.setParameter("userName", user.getUserName()); //NOI18N
218 // Initialize variable
219 User foundUser = null;
223 // Try to get single result
224 foundUser = (User) query.getSingleResult();
225 } catch (final NoResultException ex) {
227 this.getLoggerBeanLocal().logException(ex);
231 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: foundUser={1} - EXIT!", this.getClass().getSimpleName(), foundUser)); //NOI18N
233 // Return prepared instance
238 public User findUserById (final Long userId) throws UserNotFoundException {
240 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N
242 // Is the parameter valid?
243 if (null == userId) {
245 throw new NullPointerException("userId is null"); //NOI18N
246 } else if (userId < 1) {
248 throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
249 } else if (!this.ifUserIdExists(userId)) {
251 throw new UserNotFoundException(userId);
254 // Create query instance
255 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
258 query.setParameter("id", userId); //NOI18N
260 // Fetch the result, it should be there by now
261 User user = (User) query.getSingleResult();
264 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: user={1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N
271 public String generateRandomUserName () {
273 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName - CALLED!", this.getClass().getSimpleName())); //NOI18N
276 List<String> userList = this.getUserNameList();
279 String userName = null;
281 // Loop until a user name is found
282 while ((userName == null) || (userList.contains(userName))) {
283 // Generate random name
284 userName = UserUtils.generateRandomUserName();
288 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName: userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N
290 // Found one, so return it
295 @SuppressWarnings ("unchecked")
296 public List<String> getEmailAddressList () {
298 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: CALLED!", this.getClass().getSimpleName())); //NOI18N
301 Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N
304 List<String> emailAddressList = query.getResultList();
307 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddressList.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddressList.size())); //NOI18N
310 return emailAddressList;
314 @SuppressWarnings ("unchecked")
315 public List<String> getUserNameList () {
317 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: CALLED!", this.getClass().getSimpleName())); //NOI18N
320 Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N
323 List<String> userNameList = query.getResultList();
326 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: userNameList.size()={1} - EXIT!", this.getClass().getSimpleName(), userNameList.size())); //NOI18N
333 public boolean ifUserExists (final User user) {
335 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
337 // userId should not be null
340 throw new NullPointerException("user is null"); //NOI18N
341 } else if (user.getUserId() == null) {
343 throw new NullPointerException("user.userId is null"); //NOI18N
344 } else if (user.getUserId() < 1) {
346 throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", user.getUserId())); //NOI18N
350 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
353 query.setParameter("id", user.getUserId()); //NOI18N
357 User dummy = (User) query.getSingleResult();
360 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: dummy.id={0} found.", dummy.getUserId())); //NOI18N
361 } catch (final NoResultException ex) {
363 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: getSingleResult() returned no result: {0}", ex)); //NOI18N
365 // User name does not exist
367 } catch (final PersistenceException ex) {
368 // Something bad happened
369 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user {0} found.", user, ex)); //NOI18N
376 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: Found user {1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N
383 public boolean ifUserIdExists (final Long userId) {
385 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N
387 // userId should not be null
388 if (null == userId) {
390 throw new NullPointerException("userId is null"); //NOI18N
391 } else if (userId < 1) {
393 throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", userId)); //NOI18N
397 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
400 query.setParameter("id", userId); //NOI18N
404 User dummy = (User) query.getSingleResult();
407 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
408 } catch (final NoResultException ex) {
410 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
412 // User name does not exist
414 } catch (final PersistenceException ex) {
415 // Something bad happened
416 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user id {0} found.", userId, ex)); //NOI18N
423 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: Found userId={1} - EXIT!", this.getClass().getSimpleName(), userId)); //NOI18N
430 public boolean ifUserNameExists (final String userName) {
432 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: userName={1} - CALLED!", this.getClass().getSimpleName(), userName)); //NOI18N
434 // userId should not be null
435 if (null == userName) {
437 throw new NullPointerException("userName is null"); //NOI18N
438 } else if (userName.isEmpty()) {
440 throw new NullPointerException("userName is empty"); //NOI18N
444 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
447 query.setParameter("userName", userName); //NOI18N
451 User dummy = (User) query.getSingleResult();
454 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
455 } catch (final NoResultException ex) {
457 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
459 // User name does not exist
464 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: Found userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N
471 public boolean isEmailAddressRegistered (final User user) {
473 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
475 // user should not be null
478 throw new NullPointerException("user is null"); //NOI18N
482 Query query = this.getEntityManager().createNamedQuery("SearchUserByEmailAddress", LoginUser.class); //NOI18N
485 query.setParameter("emailAddress", user.getUserContact().getContactEmailAddress()); //NOI18N
489 User dummy = (User) query.getSingleResult();
492 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
493 } catch (final NoResultException ex) {
495 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
497 // Email address does not exist
499 } catch (final PersistenceException ex) {
500 // Something bad happened
501 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
508 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N
515 public boolean isUserNameRegistered (final User user) {
517 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
519 // user should not be null
522 throw new NullPointerException("user is null"); //NOI18N
526 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
529 query.setParameter("userName", user.getUserName()); //NOI18N
533 User dummy = (User) query.getSingleResult();
536 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
537 } catch (final NoResultException ex) {
539 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
541 // User name does not exist
543 } catch (final PersistenceException ex) {
544 // Something bad happened
545 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
552 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N
559 public User updateUserData (final User user) {
561 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
563 // user should not be null
566 throw new NullPointerException("user is null"); //NOI18N
567 } else if (user.getUserId() == null) {
569 throw new NullPointerException("user.userId is null"); //NOI18N
570 } else if (user.getUserId() < 1) {
572 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
573 } else if (user.getUserAccountStatus() == null) {
575 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
576 } else if (!this.ifUserExists(user)) {
577 // User does not exist
578 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
581 // Remove contact instance as this is not updated
582 user.setUserContact(null);
585 User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
588 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
591 UserUtils.copyAll(user, managedUser);
594 managedUser.setUserUpdated(new GregorianCalendar());
597 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: managedUser={1} - CALLED!", this.getClass().getSimpleName(), managedUser)); //NOI18N
599 // Return updated instance
604 public PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
606 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
608 // user should not be null
611 throw new NullPointerException("user is null"); //NOI18N
612 } else if (user.getUserId() == null) {
614 throw new NullPointerException("user.userId is null"); //NOI18N
615 } else if (user.getUserId() < 1) {
617 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
618 } else if (user.getUserAccountStatus() == null) {
620 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
621 } else if (user.getUserContact() == null) {
623 throw new NullPointerException("user.userContact is null"); //NOI18N
624 } else if (user.getUserContact().getContactId() == null) {
626 throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
627 } else if (user.getUserContact().getContactId() < 1) {
629 throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N
630 } else if (user.getUserContact().getContactPersonalTitle() == null) {
632 throw new NullPointerException("user.userContact.contactPersonalTitle is null"); //NOI18N
633 } else if (!this.ifUserExists(user)) {
634 // User does not exist
635 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
636 } else if (null == baseUrl) {
638 throw new NullPointerException("baseUrl is null"); //NOI18N
639 } else if (baseUrl.isEmpty()) {
641 throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
645 User updatedUser = this.updateUserData(user);
647 // Create history entry
648 PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), updatedUser);
650 // Set created timestamp
651 entry.setUserPasswordHistoryCreated(new GregorianCalendar());
654 this.getEntityManager().persist(entry);
656 // Flush it to get id number back
657 this.getEntityManager().flush();
660 Address emailAddress;
663 // Create email address and set
664 emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress());
665 } catch (final AddressException ex) {
667 throw new EJBException(ex);
670 // Send email to user
671 this.sendEmail("User password change", "user_password_change", emailAddress, user, baseUrl, null); //NOI18N
674 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N
681 public User updateUserPersonalData (final User user) {
683 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
685 // user should not be null
688 throw new NullPointerException("user is null"); //NOI18N
689 } else if (user.getUserId() == null) {
691 throw new NullPointerException("user.userId is null"); //NOI18N
692 } else if (user.getUserId() < 1) {
694 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
695 } else if (user.getUserAccountStatus() == null) {
697 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
698 } else if (!this.ifUserExists(user)) {
699 // User does not exist
700 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
704 User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
707 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
710 UserUtils.copyAll(user, managedUser);
713 managedUser.setUserUpdated(new GregorianCalendar());
714 managedUser.getUserContact().setContactUpdated(new GregorianCalendar());
716 // Get contact from it and find it
717 Contact managedContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
720 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
723 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: managedContact.contactId={0}", managedContact.getContactId())); //NOI18N
726 ContactUtils.copyAll(user.getUserContact(), managedContact);
728 // Set it back in user
729 user.setUserContact(managedContact);
732 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", user.getUserContact().getContactId()); //NOI18N
734 // Get mobile instance
735 DialableMobileNumber mobileNumber = managedContact.getContactMobileNumber();
737 // Is there a mobile instance set?
738 if (mobileNumber instanceof DialableMobileNumber) {
740 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobileNumber.phoneId={0} is being updated ...", mobileNumber.getPhoneId())); //NOI18N
743 managedContact.setContactMobileNumber(this.getManaged(mobileNumber, mobileNumber));
746 // Get mobile instance
747 DialableFaxNumber faxNumber = managedContact.getContactFaxNumber();
749 // Is there a fax instance set?
750 if (faxNumber instanceof DialableFaxNumber) {
752 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: faxNumber.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N
755 managedContact.setContactFaxNumber(this.getManaged(faxNumber, faxNumber));
758 // Get mobile instance
759 DialableLandLineNumber landLineNumber = managedContact.getContactLandLineNumber();
761 // Is there a fax instance set?
762 if (landLineNumber instanceof DialableLandLineNumber) {
764 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLineNumber.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N
767 managedContact.setContactLandLineNumber(this.getManaged(landLineNumber, landLineNumber));
771 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: entry.managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
773 // Return updated user instance