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 () {
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("userId is not valid: {0}", 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("Account confirmed", "account_confirmed", emailAddress, updatedUser, baseUrl); //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("userId is not valid: {0}", 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.id={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 is not valid: {0}", 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
580 // Remove contact instance as this is not updated
581 user.setUserContact(null);
584 User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
587 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
590 managedUser.copyAll(user);
593 managedUser.setUserUpdated(new GregorianCalendar());
596 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: managedUser={1} - CALLED!", this.getClass().getSimpleName(), managedUser)); //NOI18N
598 // Return updated instance
603 public PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
605 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
607 // user should not be null
610 throw new NullPointerException("user is null"); //NOI18N
611 } else if (user.getUserId() == null) {
613 throw new NullPointerException("user.userId is null"); //NOI18N
614 } else if (user.getUserId() < 1) {
616 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
617 } else if (user.getUserAccountStatus() == null) {
619 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
620 } else if (user.getUserContact() == null) {
622 throw new NullPointerException("user.userContact is null"); //NOI18N
623 } else if (user.getUserContact().getContactId() == null) {
625 throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
626 } else if (user.getUserContact().getContactId() < 1) {
628 throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N
629 } else if (user.getUserContact().getContactPersonalTitle() == null) {
631 throw new NullPointerException("user.userContact.contactPersonalTitle is null"); //NOI18N
632 } else if (!this.ifUserExists(user)) {
633 // User does not exist
634 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
635 } else if (null == baseUrl) {
637 throw new NullPointerException("baseUrl is null"); //NOI18N
638 } else if (baseUrl.isEmpty()) {
640 throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
644 User updatedUser = this.updateUserData(user);
646 // Create history entry
647 PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), updatedUser);
649 // Set created timestamp
650 entry.setUserPasswordHistoryCreated(new GregorianCalendar());
653 this.getEntityManager().persist(entry);
655 // Flush it to get id number back
656 this.getEntityManager().flush();
659 Address emailAddress;
662 // Create email address and set
663 emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress());
664 } catch (final AddressException ex) {
666 throw new EJBException(ex);
669 // Send email to user
670 this.sendEmail("User password change", "user_password_change", emailAddress, user, baseUrl); //NOI18N
673 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N
680 public User updateUserPersonalData (final User user) {
682 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
684 // user should not be null
687 throw new NullPointerException("user is null"); //NOI18N
688 } else if (user.getUserId() == null) {
690 throw new NullPointerException("user.userId is null"); //NOI18N
691 } else if (user.getUserId() < 1) {
693 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
694 } else if (user.getUserAccountStatus() == null) {
696 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
697 } else if (!this.ifUserExists(user)) {
698 // User does not exist
699 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
703 User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
706 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
709 managedUser.copyAll(user);
712 managedUser.setUserUpdated(new GregorianCalendar());
713 managedUser.getUserContact().setContactUpdated(new GregorianCalendar());
715 // Get contact from it and find it
716 Contact managedContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
719 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
722 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: managedContact.contactId={0}", managedContact.getContactId())); //NOI18N
725 managedContact.copyAll(user.getUserContact());
727 // Set it back in user
728 user.setUserContact(managedContact);
731 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", user.getUserContact().getContactId()); //NOI18N
733 // Get mobile instance
734 DialableMobileNumber mobileNumber = managedContact.getContactMobileNumber();
736 // Is there a mobile instance set?
737 if (mobileNumber instanceof DialableMobileNumber) {
739 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobileNumber.phoneId={0} is being updated ...", mobileNumber.getPhoneId())); //NOI18N
742 managedContact.setContactMobileNumber(this.getManaged(mobileNumber, mobileNumber));
745 // Get mobile instance
746 DialableFaxNumber faxNumber = managedContact.getContactFaxNumber();
748 // Is there a fax instance set?
749 if (faxNumber instanceof DialableFaxNumber) {
751 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: faxNumber.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N
754 managedContact.setContactFaxNumber(this.getManaged(faxNumber, faxNumber));
757 // Get mobile instance
758 DialableLandLineNumber landLineNumber = managedContact.getContactLandLineNumber();
760 // Is there a fax instance set?
761 if (landLineNumber instanceof DialableLandLineNumber) {
763 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLineNumber.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N
766 managedContact.setContactLandLineNumber(this.getManaged(landLineNumber, landLineNumber));
770 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: entry.managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
772 // Return updated user instance