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.jphone.phonenumbers.fax.DialableFaxNumber;
34 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
35 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
36 import org.mxchange.jusercore.exceptions.UserNotFoundException;
37 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
38 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
39 import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
40 import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote;
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.status.UserAccountStatus;
49 * @author Roland Häder<roland@mxchange.org>
51 @Stateless (name = "user", description = "A bean handling the user data")
52 public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean implements UserSessionBeanRemote {
57 private static final long serialVersionUID = 542_145_347_916L;
63 private UserRegistrationSessionBeanRemote registerBean;
68 public AddressbookUserSessionBean () {
72 @SuppressWarnings ("unchecked")
73 public List<User> allMemberPublicVisibleUsers () {
75 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
78 Query query = this.getEntityManager().createNamedQuery("AllMemberPublicUsers", LoginUser.class); //NOI18N
81 query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
82 query.setParameter("members", ProfileMode.MEMBERS); //NOI18N
83 query.setParameter("public", ProfileMode.PUBLIC); //NOI18N
86 List<User> users = query.getResultList();
89 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
96 @SuppressWarnings ("unchecked")
97 public List<User> allPublicUsers () {
99 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
102 Query query = this.getEntityManager().createNamedQuery("AllPublicUsers", LoginUser.class); //NOI18N
105 query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
106 query.setParameter("mode", ProfileMode.PUBLIC); //NOI18N
109 List<User> users = query.getResultList();
112 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allPublicUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
119 @SuppressWarnings ("unchecked")
120 public List<User> allUsers () {
122 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
125 Query query = this.getEntityManager().createNamedQuery("AllUsers", LoginUser.class); //NOI18N
128 List<User> users = query.getResultList();
131 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
138 public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException {
140 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
142 // Parameter must be valid
145 throw new NullPointerException("user is null"); //NOI18N
146 } else if (user.getUserId() == null) {
148 throw new NullPointerException("user.userId is null"); //NOI18N
149 } else if (user.getUserId() < 1) {
151 throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", user.getUserId())); //NOI18N
152 } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
153 // Account is already confirmed
154 throw new UserStatusConfirmedException(user);
155 } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
156 // Account is already confirmed
157 throw new UserStatusLockedException(user);
158 } else if (user.getUserConfirmKey() == null) {
160 throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
161 } else if (null == baseUrl) {
163 throw new NullPointerException("baseUrl is null"); //NOI18N
164 } else if (baseUrl.isEmpty()) {
166 throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
169 // Update user status and remove confirmation key
170 user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
171 user.setUserConfirmKey(null);
172 user.setUserUpdated(new GregorianCalendar());
174 // Update user account
175 User updatedUser = this.updateUserData(user);
178 Address emailAddress;
181 // Create email address and set
182 emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress());
183 } catch (final AddressException ex) {
185 throw new EJBException(ex);
189 this.sendEmail("Account confirmed", "account_confirmed", emailAddress, updatedUser, baseUrl); //NOI18N
192 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
194 // Return updated instance
199 public User fillUserData (final User user) {
201 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
203 // user should not be null
206 throw new NullPointerException("user is null"); //NOI18N
210 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
213 query.setParameter("userName", user.getUserName()); //NOI18N
215 // Initialize variable
216 User foundUser = null;
220 // Try to get single result
221 foundUser = (User) query.getSingleResult();
222 } catch (final NoResultException ex) {
224 this.getLoggerBeanLocal().logException(ex);
228 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: foundUser={1} - EXIT!", this.getClass().getSimpleName(), foundUser)); //NOI18N
230 // Return prepared instance
235 public User findUserById (final Long userId) throws UserNotFoundException {
237 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N
239 // Is the parameter valid?
240 if (null == userId) {
242 throw new NullPointerException("userId is null"); //NOI18N
243 } else if (userId < 1) {
245 throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
246 } else if (!this.ifUserIdExists(userId)) {
248 throw new UserNotFoundException(userId);
251 // Create query instance
252 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
255 query.setParameter("id", userId); //NOI18N
257 // Fetch the result, it should be there by now
258 User user = (User) query.getSingleResult();
261 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findUserById: user={1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N
268 public String generateRandomUserName () {
270 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName - CALLED!", this.getClass().getSimpleName())); //NOI18N
273 List<String> userList = this.getUserNameList();
276 String userName = null;
278 // Loop until a user name is found
279 while ((userName == null) || (userList.contains(userName))) {
280 // Generate random name
281 userName = UserUtils.generateRandomUserName();
285 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName: userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N
287 // Found one, so return it
292 @SuppressWarnings ("unchecked")
293 public List<String> getEmailAddressList () {
295 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: CALLED!", this.getClass().getSimpleName())); //NOI18N
298 Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N
301 List<String> emailAddressList = query.getResultList();
304 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddressList.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddressList.size())); //NOI18N
307 return emailAddressList;
311 @SuppressWarnings ("unchecked")
312 public List<String> getUserNameList () {
314 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: CALLED!", this.getClass().getSimpleName())); //NOI18N
317 Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N
320 List<String> userNameList = query.getResultList();
323 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: userNameList.size()={1} - EXIT!", this.getClass().getSimpleName(), userNameList.size())); //NOI18N
330 public boolean ifUserExists (final User user) {
332 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
334 // userId should not be null
337 throw new NullPointerException("user is null"); //NOI18N
338 } else if (user.getUserId() == null) {
340 throw new NullPointerException("user.userId is null"); //NOI18N
341 } else if (user.getUserId() < 1) {
343 throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", user.getUserId())); //NOI18N
347 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
350 query.setParameter("id", user.getUserId()); //NOI18N
354 User dummy = (User) query.getSingleResult();
357 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: dummy.id={0} found.", dummy.getUserId())); //NOI18N
358 } catch (final NoResultException ex) {
360 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: getSingleResult() returned no result: {0}", ex)); //NOI18N
362 // User name does not exist
364 } catch (final PersistenceException ex) {
365 // Something bad happened
366 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user {0} found.", user, ex)); //NOI18N
373 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: Found user {1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N
380 public boolean ifUserIdExists (final Long userId) {
382 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: userId={1} - CALLED!", this.getClass().getSimpleName(), userId)); //NOI18N
384 // userId should not be null
385 if (null == userId) {
387 throw new NullPointerException("userId is null"); //NOI18N
388 } else if (userId < 1) {
390 throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", userId)); //NOI18N
394 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
397 query.setParameter("id", userId); //NOI18N
401 User dummy = (User) query.getSingleResult();
404 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
405 } catch (final NoResultException ex) {
407 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserIdExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
409 // User name does not exist
411 } catch (final PersistenceException ex) {
412 // Something bad happened
413 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user id {0} found.", userId, ex)); //NOI18N
420 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserIdExists: Found userId={1} - EXIT!", this.getClass().getSimpleName(), userId)); //NOI18N
427 public boolean ifUserNameExists (final String userName) {
429 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: userName={1} - CALLED!", this.getClass().getSimpleName(), userName)); //NOI18N
431 // userId should not be null
432 if (null == userName) {
434 throw new NullPointerException("userName is null"); //NOI18N
435 } else if (userName.isEmpty()) {
437 throw new NullPointerException("userName is empty"); //NOI18N
441 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
444 query.setParameter("userName", userName); //NOI18N
448 User dummy = (User) query.getSingleResult();
451 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
452 } catch (final NoResultException ex) {
454 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
456 // User name does not exist
461 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: Found userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N
468 public boolean isEmailAddressRegistered (final User user) {
470 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
472 // user should not be null
475 throw new NullPointerException("user is null"); //NOI18N
479 Query query = this.getEntityManager().createNamedQuery("SearchUserByEmailAddress", LoginUser.class); //NOI18N
482 query.setParameter("emailAddress", user.getUserContact().getContactEmailAddress()); //NOI18N
486 User dummy = (User) query.getSingleResult();
489 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
490 } catch (final NoResultException ex) {
492 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
494 // Email address does not exist
496 } catch (final PersistenceException ex) {
497 // Something bad happened
498 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
505 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N
512 public boolean isUserNameRegistered (final User user) {
514 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
516 // user should not be null
519 throw new NullPointerException("user is null"); //NOI18N
523 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
526 query.setParameter("userName", user.getUserName()); //NOI18N
530 User dummy = (User) query.getSingleResult();
533 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
534 } catch (final NoResultException ex) {
536 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
538 // User name does not exist
540 } catch (final PersistenceException ex) {
541 // Something bad happened
542 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
549 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N
556 public User updateUserData (final User user) {
558 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
560 // user should not be null
563 throw new NullPointerException("user is null"); //NOI18N
564 } else if (user.getUserId() == null) {
566 throw new NullPointerException("user.userId is null"); //NOI18N
567 } else if (user.getUserId() < 1) {
569 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
570 } else if (user.getUserAccountStatus() == null) {
572 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
573 } else if (!this.ifUserExists(user)) {
574 // User does not exist
575 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
578 // Remove contact instance as this is not updated
579 user.setUserContact(null);
582 User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
585 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
588 managedUser.copyAll(user);
591 managedUser.setUserUpdated(new GregorianCalendar());
594 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: managedUser={1} - CALLED!", this.getClass().getSimpleName(), managedUser)); //NOI18N
596 // Return updated instance
601 public PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
603 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
605 // user should not be null
608 throw new NullPointerException("user is null"); //NOI18N
609 } else if (user.getUserId() == null) {
611 throw new NullPointerException("user.userId is null"); //NOI18N
612 } else if (user.getUserId() < 1) {
614 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
615 } else if (user.getUserAccountStatus() == null) {
617 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
618 } else if (user.getUserContact() == null) {
620 throw new NullPointerException("user.userContact is null"); //NOI18N
621 } else if (user.getUserContact().getContactId() == null) {
623 throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
624 } else if (user.getUserContact().getContactId() < 1) {
626 throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N
627 } else if (user.getUserContact().getContactPersonalTitle() == null) {
629 throw new NullPointerException("user.userContact.contactPersonalTitle is null"); //NOI18N
630 } else if (!this.ifUserExists(user)) {
631 // User does not exist
632 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
633 } else if (null == baseUrl) {
635 throw new NullPointerException("baseUrl is null"); //NOI18N
636 } else if (baseUrl.isEmpty()) {
638 throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
642 User updatedUser = this.updateUserData(user);
644 // Create history entry
645 PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), updatedUser);
647 // Set created timestamp
648 entry.setUserPasswordHistoryCreated(new GregorianCalendar());
651 this.getEntityManager().persist(entry);
653 // Flush it to get id number back
654 this.getEntityManager().flush();
657 Address emailAddress;
660 // Create email address and set
661 emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress());
662 } catch (final AddressException ex) {
664 throw new EJBException(ex);
667 // Send email to user
668 this.sendEmail("User password change", "user_password_change", emailAddress, user, baseUrl); //NOI18N
671 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N
678 public User updateUserPersonalData (final User user) {
680 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
682 // user should not be null
685 throw new NullPointerException("user is null"); //NOI18N
686 } else if (user.getUserId() == null) {
688 throw new NullPointerException("user.userId is null"); //NOI18N
689 } else if (user.getUserId() < 1) {
691 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
692 } else if (user.getUserAccountStatus() == null) {
694 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
695 } else if (!this.ifUserExists(user)) {
696 // User does not exist
697 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
701 User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
704 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
707 managedUser.copyAll(user);
710 managedUser.setUserUpdated(new GregorianCalendar());
711 managedUser.getUserContact().setContactUpdated(new GregorianCalendar());
713 // Get contact from it and find it
714 Contact managedContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
717 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
720 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: managedContact.contactId={0}", managedContact.getContactId())); //NOI18N
723 managedContact.copyAll(user.getUserContact());
725 // Set it back in user
726 user.setUserContact(managedContact);
729 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", user.getUserContact().getContactId()); //NOI18N
731 // Get mobile instance
732 DialableMobileNumber mobileNumber = managedContact.getContactMobileNumber();
734 // Is there a mobile instance set?
735 if (mobileNumber instanceof DialableMobileNumber) {
737 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobileNumber.phoneId={0} is being updated ...", mobileNumber.getPhoneId())); //NOI18N
740 managedContact.setContactMobileNumber(this.getManaged(mobileNumber, mobileNumber));
743 // Get mobile instance
744 DialableFaxNumber faxNumber = managedContact.getContactFaxNumber();
746 // Is there a fax instance set?
747 if (faxNumber instanceof DialableFaxNumber) {
749 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: faxNumber.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N
752 managedContact.setContactFaxNumber(this.getManaged(faxNumber, faxNumber));
755 // Get mobile instance
756 DialableLandLineNumber landLineNumber = managedContact.getContactLandLineNumber();
758 // Is there a fax instance set?
759 if (landLineNumber instanceof DialableLandLineNumber) {
761 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLineNumber.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N
764 managedContact.setContactLandLineNumber(this.getManaged(landLineNumber, landLineNumber));
768 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: entry.managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
770 // Return updated user instance