2 * Copyright (C) 2016 Roland Haeder
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.jjobs.database.BaseJobsDatabaseBean;
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 Haeder<roland@mxchange.org>
51 @Stateless (name = "user", description = "A bean handling the user data")
52 public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSessionBeanRemote {
57 private static final long serialVersionUID = 542_145_347_916L;
63 private UserRegistrationSessionBeanRemote registerBean;
68 public JobsUserSessionBean () {
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("param", 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("param", 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("param", 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("param", 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
579 User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
582 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
585 managedUser.copyAll(user);
588 managedUser.setUserUpdated(new GregorianCalendar());
591 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: managedUser={1} - CALLED!", this.getClass().getSimpleName(), managedUser)); //NOI18N
593 // Return updated instance
598 public PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
600 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
602 // user should not be null
605 throw new NullPointerException("user is null"); //NOI18N
606 } else if (user.getUserId() == null) {
608 throw new NullPointerException("user.userId is null"); //NOI18N
609 } else if (user.getUserId() < 1) {
611 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
612 } else if (user.getUserName() == null) {
614 throw new NullPointerException("user.userName is null"); //NOI18N
615 } else if (user.getUserName().isEmpty()) {
617 throw new IllegalArgumentException("user.userName is empty"); //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().getContactGender() == null) {
632 throw new NullPointerException("user.userContact.contactGender 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 managedUser = this.updateUserData(user);
647 // Create history entry
648 PasswordHistory entry = new UserPasswordHistory();
650 // Set all data here to avoid user instance become detached again
651 entry.setUserPasswordHistoryPasswordHash(managedUser.getUserEncryptedPassword());
652 entry.setUserPasswordHistoryUser(this.getManagedUser(user));
653 entry.setUserPasswordHistoryCreated(new GregorianCalendar());
656 this.getEntityManager().persist(entry);
658 // Flush it to get id number back
659 this.getEntityManager().flush();
662 Address emailAddress;
665 // Create email address and set
666 emailAddress = new InternetAddress(managedUser.getUserContact().getContactEmailAddress());
667 } catch (final AddressException ex) {
669 throw new EJBException(ex);
672 // Send email to user
673 this.sendEmail("User password change", "user_password_change", emailAddress, user, baseUrl); //NOI18N
676 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N
683 public User updateUserPersonalData (final User user) {
685 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
687 // user should not be null
690 throw new NullPointerException("user is null"); //NOI18N
691 } else if (user.getUserId() == null) {
693 throw new NullPointerException("user.userId is null"); //NOI18N
694 } else if (user.getUserId() < 1) {
696 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
697 } else if (user.getUserAccountStatus() == null) {
699 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
700 } else if (!this.ifUserExists(user)) {
701 // User does not exist
702 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
706 User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
709 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
712 managedUser.copyAll(user);
715 managedUser.setUserUpdated(new GregorianCalendar());
716 managedUser.getUserContact().setContactUpdated(new GregorianCalendar());
718 // Get contact from it and find it
719 Contact managedContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
722 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
725 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: managedContact.contactId={0}", managedContact.getContactId())); //NOI18N
728 managedContact.copyAll(user.getUserContact());
730 // Set it back in user
731 user.setUserContact(managedContact);
734 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", user.getUserContact().getContactId()); //NOI18N
736 // Get mobile instance
737 DialableMobileNumber mobileNumber = managedContact.getContactMobileNumber();
739 // Is there a mobile instance set?
740 if (mobileNumber instanceof DialableMobileNumber) {
742 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobileNumber.phoneId={0} is being updated ...", mobileNumber.getPhoneId())); //NOI18N
745 managedContact.setContactMobileNumber(this.getManaged(mobileNumber, mobileNumber));
748 // Get mobile instance
749 DialableFaxNumber faxNumber = managedContact.getContactFaxNumber();
751 // Is there a fax instance set?
752 if (faxNumber instanceof DialableFaxNumber) {
754 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: faxNumber.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N
757 managedContact.setContactFaxNumber(this.getManaged(faxNumber, faxNumber));
760 // Get mobile instance
761 DialableLandLineNumber landLineNumber = managedContact.getContactLandLineNumber();
763 // Is there a fax instance set?
764 if (landLineNumber instanceof DialableLandLineNumber) {
766 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLineNumber.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N
769 managedContact.setContactLandLineNumber(this.getManaged(landLineNumber, landLineNumber));
773 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: entry.managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
775 // Return updated user instance