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.Date;
21 import java.util.List;
23 import javax.ejb.EJBException;
24 import javax.ejb.Stateless;
25 import javax.persistence.NoResultException;
26 import javax.persistence.PersistenceException;
27 import javax.persistence.Query;
28 import org.mxchange.jcontacts.model.contact.Contact;
29 import org.mxchange.jcontacts.model.contact.ContactUtils;
30 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
31 import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
32 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
33 import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
34 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
35 import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
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.user.password_history.PasswordHistory;
41 import org.mxchange.jusercore.model.user.password_history.UserPasswordHistory;
42 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
43 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
44 import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote;
45 import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean;
50 * @author Roland Häder<roland@mxchange.org>
52 @Stateless (name = "user", description = "A bean handling the user data")
53 public class PizzaUserSessionBean extends BasePizzaEnterpriseBean implements UserSessionBeanRemote {
58 private static final long serialVersionUID = 542_145_347_916L;
64 private UserRegistrationSessionBeanRemote registerBean;
69 public PizzaUserSessionBean () {
70 // Call super constructor
71 super("jms/pizzaservice-queue-factory", "jms/pizzaservice-email-queue"); //NOI18N
75 @SuppressWarnings ("unchecked")
76 public List<User> allMemberPublicVisibleUsers () {
78 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMemberPublicVisibleUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
81 final 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 final 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 final Query query = this.getEntityManager().createNamedQuery("AllPublicUsers", LoginUser.class); //NOI18N
108 query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
109 query.setParameter("mode", ProfileMode.PUBLIC); //NOI18N
112 final 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<String> allUserNames () {
125 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: CALLED!", this.getClass().getSimpleName())); //NOI18N
128 final Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N
131 final List<String> userNameList = query.getResultList();
134 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getUserNameList: userNameList.size()={1} - EXIT!", this.getClass().getSimpleName(), userNameList.size())); //NOI18N
141 @SuppressWarnings ("unchecked")
142 public List<User> allUsers () {
144 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: CALLED!", this.getClass().getSimpleName())); //NOI18N
147 final Query query = this.getEntityManager().createNamedQuery("AllUsers", LoginUser.class); //NOI18N
150 final List<User> users = query.getResultList();
153 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsers: users.size()={1} - EXIT!", this.getClass().getSimpleName(), users.size())); //NOI18N
160 public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException {
162 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
164 // Parameter must be valid
167 throw new NullPointerException("user is null"); //NOI18N
168 } else if (user.getUserId() == null) {
170 throw new NullPointerException("user.userId is null"); //NOI18N
171 } else if (user.getUserId() < 1) {
173 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
174 } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
175 // Account is already confirmed
176 throw new UserStatusConfirmedException(user);
177 } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
178 // Account is already confirmed
179 throw new UserStatusLockedException(user);
180 } else if (user.getUserConfirmKey() == null) {
182 throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
183 } else if (null == baseUrl) {
185 throw new NullPointerException("baseUrl is null"); //NOI18N
186 } else if (baseUrl.isEmpty()) {
188 throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
191 // Update user account
192 final User managedUser = this.updateUserData(user);
194 // Update user status and remove confirmation key
195 managedUser.setUserAccountStatus(UserAccountStatus.CONFIRMED);
196 managedUser.setUserConfirmKey(null);
197 managedUser.setUserUpdated(new Date());
200 this.sendEmail("User account confirmed", "user_account_confirmed", managedUser, baseUrl, null); //NOI18N
203 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
205 // Return updated instance
210 public User fillUserData (final User user) throws UserNotFoundException {
212 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
214 // user should not be null
217 throw new NullPointerException("user is null"); //NOI18N
218 } else if (user.getUserName() == null) {
220 throw new NullPointerException("user.userName is null");
221 } else if (user.getUserName().isEmpty()) {
223 throw new IllegalArgumentException("user.userName is empty");
224 } else if (!this.ifUserExists(user)) {
225 // User does not exist
226 throw new UserNotFoundException(user);
230 final Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
233 query.setParameter("userName", user.getUserName()); //NOI18N
235 // Initialize variable
236 final User foundUser;
240 // Try to get single result
241 foundUser = (User) query.getSingleResult();
242 } catch (final NoResultException ex) {
244 this.getLoggerBeanLocal().logException(ex);
249 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.fillUserData: foundUser={1} - EXIT!", this.getClass().getSimpleName(), foundUser)); //NOI18N
251 // Return prepared instance
256 public String generateRandomUserName () {
258 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName - CALLED!", this.getClass().getSimpleName())); //NOI18N
261 final List<String> userList = this.allUserNames();
264 String userName = null;
266 // Loop until a user name is found
267 while ((userName == null) || (userList.contains(userName))) {
268 // Generate random name
269 userName = UserUtils.generateRandomUserName();
273 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.generateRandomUserName: userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N
275 // Found one, so return it
280 @SuppressWarnings ("unchecked")
281 public List<String> getEmailAddressList () {
283 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: CALLED!", this.getClass().getSimpleName())); //NOI18N
286 final Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N
289 final List<String> emailAddressList = query.getResultList();
292 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.getEmailAddressList: emailAddressList.size()={1} - EXIT!", this.getClass().getSimpleName(), emailAddressList.size())); //NOI18N
295 return emailAddressList;
299 public boolean ifUserExists (final User user) {
301 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
303 // userId should not be null
306 throw new NullPointerException("user is null"); //NOI18N
307 } else if (user.getUserId() == null) {
309 throw new NullPointerException("user.userId is null"); //NOI18N
310 } else if (user.getUserId() < 1) {
312 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
316 final Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
319 query.setParameter("id", user.getUserId()); //NOI18N
323 // Try to get single result
324 final User dummy = (User) query.getSingleResult();
327 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: dummy.userId={0} found.", dummy.getUserId())); //NOI18N
328 } catch (final NoResultException ex) {
330 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: getSingleResult() returned no result: {0}", ex)); //NOI18N
332 // User name does not exist
334 } catch (final PersistenceException ex) {
335 // Something bad happened
336 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user {0} found.", user, ex)); //NOI18N
343 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserExists: Found user {1} - EXIT!", this.getClass().getSimpleName(), user)); //NOI18N
350 public boolean ifUserNameExists (final String userName) {
352 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: userName={1} - CALLED!", this.getClass().getSimpleName(), userName)); //NOI18N
354 // userId should not be null
355 if (null == userName) {
357 throw new NullPointerException("userName is null"); //NOI18N
358 } else if (userName.isEmpty()) {
360 throw new NullPointerException("userName is empty"); //NOI18N
364 final Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
367 query.setParameter("userName", userName); //NOI18N
371 // Try to get single result
372 final User dummy = (User) query.getSingleResult();
375 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
376 } catch (final NoResultException ex) {
378 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserNameExists: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
380 // User name does not exist
385 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.ifUserNameExists: Found userName={1} - EXIT!", this.getClass().getSimpleName(), userName)); //NOI18N
392 public boolean isEmailAddressRegistered (final User user) {
394 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
396 // user should not be null
399 throw new NullPointerException("user is null"); //NOI18N
403 final Query query = this.getEntityManager().createNamedQuery("SearchUserByEmailAddress", LoginUser.class); //NOI18N
406 query.setParameter("emailAddress", user.getUserContact().getContactEmailAddress()); //NOI18N
410 // Try to get single result
411 final User dummy = (User) query.getSingleResult();
414 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
415 } catch (final NoResultException ex) {
417 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isEmailAddressRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
419 // Email address does not exist
421 } catch (final PersistenceException ex) {
422 // Something bad happened
423 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
430 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isEmailAddressRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N
437 public boolean isUserNameRegistered (final User user) {
439 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
441 // user should not be null
444 throw new NullPointerException("user is null"); //NOI18N
448 final Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
451 query.setParameter("userName", user.getUserName()); //NOI18N
455 // Try to get single result
456 final User dummy = (User) query.getSingleResult();
459 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: dummy.userId={1} found.", this.getClass().getSimpleName(), dummy.getUserId())); //NOI18N
460 } catch (final NoResultException ex) {
462 this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.isUserNameRegistered: getSingleResult() returned no result: {1}", this.getClass().getSimpleName(), ex)); //NOI18N
464 // User name does not exist
466 } catch (final PersistenceException ex) {
467 // Something bad happened
468 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
475 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isUserNameRegistered: Returning true ... - EXIT!", this.getClass().getSimpleName())); //NOI18N
482 public User updateUserData (final User user) {
484 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
486 // user should not be null
489 throw new NullPointerException("user is null"); //NOI18N
490 } else if (user.getUserId() == null) {
492 throw new NullPointerException("user.userId is null"); //NOI18N
493 } else if (user.getUserId() < 1) {
495 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
496 } else if (user.getUserAccountStatus() == null) {
498 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
499 } else if (!this.ifUserExists(user)) {
500 // User does not exist
501 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
505 final User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
508 assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
511 final User managedUser = this.getEntityManager().merge(foundUser);
514 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", managedUser.getUserId()); //NOI18N
517 UserUtils.copyAll(user, managedUser);
520 managedUser.setUserUpdated(new Date());
523 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
525 // Return updated instance
530 public PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
532 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
534 // user should not be null
537 throw new NullPointerException("user is null"); //NOI18N
538 } else if (user.getUserId() == null) {
540 throw new NullPointerException("user.userId is null"); //NOI18N
541 } else if (user.getUserId() < 1) {
543 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
544 } else if (user.getUserName() == null) {
546 throw new NullPointerException("user.userName is null"); //NOI18N
547 } else if (user.getUserName().isEmpty()) {
549 throw new IllegalArgumentException("user.userName is empty"); //NOI18N
550 } else if (user.getUserAccountStatus() == null) {
552 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
553 } else if (user.getUserContact() == null) {
555 throw new NullPointerException("user.userContact is null"); //NOI18N
556 } else if (user.getUserContact().getContactId() == null) {
558 throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
559 } else if (user.getUserContact().getContactId() < 1) {
561 throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N
562 } else if (user.getUserContact().getContactPersonalTitle() == null) {
564 throw new NullPointerException("user.userContact.contactPersonalTitle is null"); //NOI18N
565 } else if (!this.ifUserExists(user)) {
566 // User does not exist
567 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
568 } else if (null == baseUrl) {
570 throw new NullPointerException("baseUrl is null"); //NOI18N
571 } else if (baseUrl.isEmpty()) {
573 throw new IllegalArgumentException("baseUrl is empty"); //NOI18N
577 final User managedUser = this.updateUserData(user);
579 // Update user account
580 managedUser.setUserUpdated(new Date());
582 // Create history entry
583 PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), managedUser);
585 // Set created timestamp
586 entry.setUserPasswordHistoryCreated(new Date());
588 // Merge user to make sure it is not re-persisted
589 final User mergedUser = this.getEntityManager().merge(managedUser);
590 entry.setUserPasswordHistoryUser(mergedUser);
593 this.getEntityManager().persist(entry);
595 // Send email to user
596 this.sendEmail("User password change", "user_password_change", managedUser, baseUrl, null); //NOI18N
599 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N
606 public User updateUserPersonalData (final User user) {
608 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
610 // user should not be null
613 throw new NullPointerException("user is null"); //NOI18N
614 } else if (user.getUserId() == null) {
616 throw new NullPointerException("user.userId is null"); //NOI18N
617 } else if (user.getUserId() < 1) {
619 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
620 } else if (user.getUserAccountStatus() == null) {
622 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
623 } else if (!this.ifUserExists(user)) {
624 // User does not exist
625 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
629 final User managedUser = this.getEntityManager().find(user.getClass(), user.getUserId());
632 assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
635 UserUtils.copyAll(user, managedUser);
638 managedUser.setUserUpdated(new Date());
639 managedUser.getUserContact().setContactUpdated(new Date());
641 // Get contact from it and find it
642 final Contact foundContact = this.getEntityManager().find(managedUser.getUserContact().getClass(), managedUser.getUserContact().getContactId());
645 assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
648 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId())); //NOI18N
650 // Merge contact instance
651 final Contact managedContact = this.getEntityManager().merge(foundContact);
654 ContactUtils.copyAll(user.getUserContact(), managedContact);
656 // Set it back in user
657 user.setUserContact(managedContact);
660 assert (managedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", user.getUserContact().getContactId()); //NOI18N
662 // Get mobile instance
663 final DialableMobileNumber mobileNumber = managedContact.getContactMobileNumber();
665 // Is there a mobile instance set?
666 if (mobileNumber instanceof DialableMobileNumber) {
668 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: mobile.phoneId={0} is being updated ...", mobileNumber.getPhoneId())); //NOI18N
671 final DialableMobileNumber foundMobile = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getPhoneId());
674 assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getPhoneId()); //NOI18N
676 // Then merge it, too
677 final DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
680 assert (managedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", managedMobile.getPhoneId()); //NOI18N
683 MobileNumbers.copyAll(managedUser.getUserContact().getContactMobileNumber(), managedMobile);
686 managedContact.setContactMobileNumber(this.createManaged(mobileNumber, mobileNumber));
689 // Get mobile instance
690 final DialableFaxNumber faxNumber = managedContact.getContactFaxNumber();
692 // Is there a fax instance set?
693 if (faxNumber instanceof DialableFaxNumber) {
695 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: faxNumber.phoneId={0} is being updated ...", faxNumber.getPhoneId())); //NOI18N
698 final DialableFaxNumber foundFax = this.getEntityManager().find(faxNumber.getClass(), faxNumber.getPhoneId());
701 assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
703 // Then merge it, too
704 final DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
707 assert (managedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", managedFax.getPhoneId()); //NOI18N
710 FaxNumbers.copyAll(managedUser.getUserContact().getContactFaxNumber(), managedFax);
713 managedContact.setContactFaxNumber(managedFax);
716 // Get mobile instance
717 final DialableLandLineNumber landLineNumber = managedContact.getContactLandLineNumber();
719 // Is there a fax instance set?
720 if (landLineNumber instanceof DialableLandLineNumber) {
722 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLineNumber.phoneId={0} is being updated ...", landLineNumber.getPhoneId())); //NOI18N
725 final DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLineNumber.getClass(), landLineNumber.getPhoneId());
728 assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
730 // Then merge it, too
731 final DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
734 assert (managedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", managedLandLine.getPhoneId()); //NOI18N
737 LandLineNumbers.copyAll(managedUser.getUserContact().getContactLandLineNumber(), managedLandLine);
740 managedContact.setContactLandLineNumber(managedLandLine);
744 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: entry.managedUser={1} - EXIT!", this.getClass().getSimpleName(), managedUser)); //NOI18N
746 // Return updated user instance