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.addressbook.database.BaseAddressbookDatabaseBean;
32 import org.mxchange.jcontacts.contact.Contact;
33 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
34 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
35 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
36 import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
37 import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
38 import org.mxchange.jusercore.exceptions.UserNotFoundException;
39 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
40 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
41 import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote;
42 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
43 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
48 * @author Roland Haeder<roland@mxchange.org>
50 @Stateless (name = "user", description = "A bean handling the user data")
51 public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean implements UserSessionBeanRemote {
56 private static final long serialVersionUID = 542_145_347_916L;
62 private UserRegistrationSessionBeanRemote registerBean;
67 public AddressbookUserSessionBean () {
71 public User addUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException {
73 this.getLoggerBeanLocal().logTrace(MessageFormat.format("addUser: user={0} - CALLED!", user)); //NOI18N
75 // user should not be null
78 throw new NullPointerException("user is null"); //NOI18N
79 } else if (user.getUserId() != null) {
81 throw new IllegalStateException(MessageFormat.format("user.userId must be null, is: {0}", user.getUserId())); //NOI18N
84 // Check if user is registered
85 if (this.registerBean.isUserNameRegistered(user)) {
87 throw new UserNameAlreadyRegisteredException(user);
88 } else if (this.registerBean.isEmailAddressRegistered(user)) {
90 throw new EmailAddressAlreadyRegisteredException(user);
93 // Set created timestamp
94 user.setUserCreated(new GregorianCalendar());
95 user.getUserContact().setContactCreated(new GregorianCalendar());
97 // Update cellphone, land-line and fax instance
98 this.setAllContactPhoneEntriesCreated(user.getUserContact());
101 this.getEntityManager().persist(user);
103 // Flush to get id back
104 this.getEntityManager().flush();
107 this.getLoggerBeanLocal().logTrace(MessageFormat.format("addUser: user={0},user.id={1} - EXIT!", user, user.getUserId())); //NOI18N
114 @SuppressWarnings ("unchecked")
115 public List<User> allMemberPublicVisibleUsers () {
117 this.getLoggerBeanLocal().logTrace("allMemberPublicVisibleUsers: CALLED!"); //NOI18N
120 Query query = this.getEntityManager().createNamedQuery("AllMemberPublicUsers", LoginUser.class); //NOI18N
123 query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
124 query.setParameter("members", ProfileMode.MEMBERS); //NOI18N
125 query.setParameter("public", ProfileMode.PUBLIC); //NOI18N
128 List<User> users = query.getResultList();
131 this.getLoggerBeanLocal().logTrace(MessageFormat.format("allMemberPublicVisibleUsers: users.size()={0} - EXIT!", users.size())); //NOI18N
138 @SuppressWarnings ("unchecked")
139 public List<User> allPublicUsers () {
141 this.getLoggerBeanLocal().logTrace("allPublicUsers: CALLED!"); //NOI18N
144 Query query = this.getEntityManager().createNamedQuery("AllPublicUsers", LoginUser.class); //NOI18N
147 query.setParameter("status", UserAccountStatus.CONFIRMED); //NOI18N
148 query.setParameter("mode", ProfileMode.PUBLIC); //NOI18N
151 List<User> users = query.getResultList();
154 this.getLoggerBeanLocal().logTrace(MessageFormat.format("allPublicUsers: users.size()={0} - EXIT!", users.size())); //NOI18N
161 @SuppressWarnings ("unchecked")
162 public List<User> allUsers () {
164 this.getLoggerBeanLocal().logTrace("allUsers: CALLED!"); //NOI18N
167 Query query = this.getEntityManager().createNamedQuery("AllUsers", LoginUser.class); //NOI18N
170 List<User> users = query.getResultList();
173 this.getLoggerBeanLocal().logTrace(MessageFormat.format("allUsers: users.size()={0} - EXIT!", users.size())); //NOI18N
180 public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException {
182 this.getLoggerBeanLocal().logTrace(MessageFormat.format("confirmAccount: user={0},baseUrl={1} - CALLED!", user, baseUrl)); //NOI18N
184 // Parameter must be valid
187 throw new NullPointerException("user is null"); //NOI18N
188 } else if (user.getUserId() == null) {
190 throw new NullPointerException("user.userId is null"); //NOI18N
191 } else if (user.getUserId() < 1) {
193 throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", user.getUserId())); //NOI18N
194 } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
195 // Account is already confirmed
196 throw new UserStatusConfirmedException(user);
197 } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
198 // Account is already confirmed
199 throw new UserStatusLockedException(user);
200 } else if (user.getUserConfirmKey() == null) {
202 throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
205 // Update user status and remove confirmation key
206 user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
207 user.setUserConfirmKey(null);
208 user.setUserUpdated(new GregorianCalendar());
210 // Update user account
211 User updatedUser = this.updateUserData(user);
214 Address emailAddress;
217 // Create email address and set
218 emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress());
219 } catch (final AddressException ex) {
221 throw new EJBException(ex);
225 this.sendEmail("Account confirmed", "account_confirmed", emailAddress, updatedUser, baseUrl); //NOI18N
228 this.getLoggerBeanLocal().logTrace(MessageFormat.format("confirmAccount: updatedUser={0} - EXIT!", updatedUser)); //NOI18N
230 // Return updated instance
235 public User fillUserData (final User user) {
237 this.getLoggerBeanLocal().logTrace(MessageFormat.format("fillUserData: user={0} - CALLED!", user)); //NOI18N
239 // user should not be null
242 throw new NullPointerException("user is null"); //NOI18N
246 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
249 query.setParameter("userName", user.getUserName()); //NOI18N
251 // Initialize variable
252 User foundUser = null;
256 // Try to get single result
257 foundUser = (User) query.getSingleResult();
258 } catch (final NoResultException ex) {
260 this.getLoggerBeanLocal().logException(ex);
264 this.getLoggerBeanLocal().logTrace(MessageFormat.format("fillUserData: foundUser={0} - EXIT!", foundUser)); //NOI18N
266 // Return prepared instance
271 public User findUserById (final Long userId) throws UserNotFoundException {
273 this.getLoggerBeanLocal().logTrace(MessageFormat.format("findUserById: userId={0} - CALLED!", userId)); //NOI18N
275 // Is the parameter valid?
276 if (null == userId) {
278 throw new NullPointerException("userId is null"); //NOI18N
279 } else if (userId < 1) {
281 throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
282 } else if (!this.ifUserIdExists(userId)) {
284 throw new UserNotFoundException(userId);
287 // Create query instance
288 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
291 query.setParameter("id", userId); //NOI18N
293 // Fetch the result, it should be there by now
294 User user = (User) query.getSingleResult();
297 this.getLoggerBeanLocal().logTrace(MessageFormat.format("findUserById: user={0} - EXIT!", user)); //NOI18N
304 public String generateRandomUserName () {
306 this.getLoggerBeanLocal().logTrace("generateRandomUserName - CALLED!"); //NOI18N
309 List<String> userList = this.getUserNameList();
312 String userName = null;
314 // Loop until a user name is found
315 while ((userName == null) || (userList.contains(userName))) {
316 // Generate random name
317 userName = UserUtils.generateRandomUserName();
321 this.getLoggerBeanLocal().logTrace(MessageFormat.format("generateRandomUserName: userName={0} - EXIT!", userName)); //NOI18N
323 // Found one, so return it
328 @SuppressWarnings ("unchecked")
329 public List<String> getEmailAddressList () {
331 Query query = this.getEntityManager().createNamedQuery("AllEmailAddresses", String.class); //NOI18N
334 List<String> emailAddressList = query.getResultList();
337 return emailAddressList;
341 @SuppressWarnings ("unchecked")
342 public List<String> getUserNameList () {
344 Query query = this.getEntityManager().createNamedQuery("AllUserNames", String.class); //NOI18N
347 List<String> userNameList = query.getResultList();
354 public boolean ifUserExists (final User user) {
356 this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserExists: user={0} - CALLED!", user)); //NOI18N
358 // userId should not be null
361 throw new NullPointerException("user is null"); //NOI18N
362 } else if (user.getUserId() == null) {
364 throw new NullPointerException("user.userId is null"); //NOI18N
365 } else if (user.getUserId() < 1) {
367 throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", user.getUserId())); //NOI18N
371 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
374 query.setParameter("id", user.getUserId()); //NOI18N
378 User dummy = (User) query.getSingleResult();
381 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: dummy.id={0} found.", dummy.getUserId())); //NOI18N
382 } catch (final NoResultException ex) {
384 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserExists: getSingleResult() returned no result: {0}", ex)); //NOI18N
386 // User name does not exist
388 } catch (final PersistenceException ex) {
389 // Something bad happened
390 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user {0} found.", user, ex)); //NOI18N
397 this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserExists: Found user {0} - EXIT!", user)); //NOI18N
404 public boolean ifUserIdExists (final Long userId) {
406 this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserIdExists: userId={0} - CALLED!", userId)); //NOI18N
408 // userId should not be null
409 if (null == userId) {
411 throw new NullPointerException("userId is null"); //NOI18N
412 } else if (userId < 1) {
414 throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", userId)); //NOI18N
418 Query query = this.getEntityManager().createNamedQuery("SearchUserById", LoginUser.class); //NOI18N
421 query.setParameter("id", userId); //NOI18N
425 User dummy = (User) query.getSingleResult();
428 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserIdExists: dummy.id={0} found.", dummy.getUserId())); //NOI18N
429 } catch (final NoResultException ex) {
431 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserIdExists: getSingleResult() returned no result: {0}", ex)); //NOI18N
433 // User name does not exist
435 } catch (final PersistenceException ex) {
436 // Something bad happened
437 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one user id {0} found.", userId, ex)); //NOI18N
444 this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserIdExists: Found user id {0} - EXIT!", userId)); //NOI18N
451 public boolean ifUserNameExists (final String userName) {
453 this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserNameExists: userName={0} - CALLED!", userName)); //NOI18N
455 // userId should not be null
456 if (null == userName) {
458 throw new NullPointerException("userName is null"); //NOI18N
459 } else if (userName.isEmpty()) {
461 throw new NullPointerException("userName is empty"); //NOI18N
465 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
468 query.setParameter("userName", userName); //NOI18N
472 User dummy = (User) query.getSingleResult();
475 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserNameExists: dummy.id={0} found.", dummy.getUserId())); //NOI18N
476 } catch (final NoResultException ex) {
478 this.getLoggerBeanLocal().logDebug(MessageFormat.format("ifUserNameExists: getSingleResult() returned no result: {0}", ex)); //NOI18N
480 // User name does not exist
485 this.getLoggerBeanLocal().logTrace(MessageFormat.format("ifUserNameExists: Found user name {0} - EXIT!", userName)); //NOI18N
492 public boolean isEmailAddressRegistered (final User user) {
494 this.getLoggerBeanLocal().logTrace(MessageFormat.format("isEmailAddressRegistered: user={0} - CALLED!", user)); //NOI18N
496 // user should not be null
499 throw new NullPointerException("user is null"); //NOI18N
503 Query query = this.getEntityManager().createNamedQuery("SearchUserByEmailAddress", LoginUser.class); //NOI18N
506 query.setParameter("emailAddress", user.getUserContact().getContactEmailAddress()); //NOI18N
510 User dummy = (User) query.getSingleResult();
513 this.getLoggerBeanLocal().logDebug(MessageFormat.format("isEmailAddressRegistered: dummy.id={0} found.", dummy.getUserId())); //NOI18N
514 } catch (final NoResultException ex) {
516 this.getLoggerBeanLocal().logDebug(MessageFormat.format("isEmailAddressRegistered: getSingleResult() returned no result: {0}", ex)); //NOI18N
518 // Email address does not exist
520 } catch (final PersistenceException ex) {
521 // Something bad happened
522 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
533 public boolean isUserNameRegistered (final User user) {
535 this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserNameRegistered: user={0} - CALLED!", user)); //NOI18N
537 // user should not be null
540 throw new NullPointerException("user is null"); //NOI18N
544 Query query = this.getEntityManager().createNamedQuery("SearchUserByName", LoginUser.class); //NOI18N
547 query.setParameter("userName", user.getUserName()); //NOI18N
551 User dummy = (User) query.getSingleResult();
554 this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserNameRegistered: dummy.id={0} found.", dummy.getUserId())); //NOI18N
555 } catch (final NoResultException ex) {
557 this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserNameRegistered: getSingleResult() returned no result: {0}", ex)); //NOI18N
559 // User name does not exist
561 } catch (final PersistenceException ex) {
562 // Something bad happened
563 this.getLoggerBeanLocal().logWarning(MessageFormat.format("More than one email address {0} found.", user.getUserContact().getContactEmailAddress()), ex); //NOI18N
574 public User linkUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException {
576 this.getLoggerBeanLocal().logTrace(MessageFormat.format("linkUser: user={0} - CALLED!", user)); //NOI18N
578 // user should not be null
581 throw new NullPointerException("user is null"); //NOI18N
582 } else if (user.getUserId() instanceof Long) {
584 throw new IllegalArgumentException("user.userId is not null"); //NOI18N
585 } else if (user.getUserContact() == null) {
587 throw new NullPointerException("user.userContact is null"); //NOI18N
588 } else if (user.getUserContact().getContactId() == null) {
590 throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
591 } else if (user.getUserContact().getContactId() < 1) {
592 // Not valid id number
593 throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is not valid", user.getUserContact().getContactId())); //NOI18N
594 } else if (user.getUserAccountStatus() == null) {
596 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
597 } else if (this.ifUserNameExists(user.getUserName())) {
598 // Name already found
599 throw new UserNameAlreadyRegisteredException(user.getUserName());
600 } else if (this.ifUserExists(user)) {
601 // User does not exist
602 throw new IllegalStateException("User does already exist."); //NOI18N
605 // Try to find the contact
606 Contact foundContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
608 // Set detached object in rexcruiter instance
609 user.setUserContact(foundContact);
612 user.setUserCreated(new GregorianCalendar());
615 this.getEntityManager().persist(user);
617 // Flush it to get updated instance back
618 this.getEntityManager().flush();
621 this.getLoggerBeanLocal().logTrace(MessageFormat.format("linkUser: user={0} - EXIT!", user)); //NOI18N
623 // Return updated instanc
628 public User updateUserData (final User user) {
630 this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateUserData: user={0} - CALLED!", user)); //NOI18N
632 // user should not be null
635 throw new NullPointerException("user is null"); //NOI18N
636 } else if (user.getUserId() == null) {
638 throw new NullPointerException("user.userId is null"); //NOI18N
639 } else if (user.getUserId() < 1) {
641 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
642 } else if (user.getUserAccountStatus() == null) {
644 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
645 } else if (!this.ifUserExists(user)) {
646 // User does not exist
647 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
650 // Remove contact instance as this is not updatedf
651 user.setUserContact(null);
654 User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
657 assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
660 User detachedUser = this.getEntityManager().merge(foundUser);
663 assert (detachedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", user.getUserId()); //NOI18N
666 detachedUser.copyAll(user);
669 detachedUser.setUserUpdated(new GregorianCalendar());
671 // Return updated instance
676 public User updateUserPersonalData (final User user) {
678 this.getLoggerBeanLocal().logTrace(MessageFormat.format("updateUserPersonalData: user={0} - CALLED!", user)); //NOI18N
680 // user should not be null
683 throw new NullPointerException("user is null"); //NOI18N
684 } else if (user.getUserId() == null) {
686 throw new NullPointerException("user.userId is null"); //NOI18N
687 } else if (user.getUserId() < 1) {
689 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
690 } else if (user.getUserAccountStatus() == null) {
692 throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
693 } else if (!this.ifUserExists(user)) {
694 // User does not exist
695 throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
699 User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
702 assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
705 User detachedUser = this.getEntityManager().merge(foundUser);
708 assert (detachedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", user.getUserId()); //NOI18N
711 detachedUser.copyAll(user);
714 detachedUser.setUserUpdated(new GregorianCalendar());
715 detachedUser.getUserContact().setContactUpdated(new GregorianCalendar());
717 // Get contact from it and find it
718 Contact foundContact = this.getEntityManager().find(user.getUserContact().getClass(), user.getUserContact().getContactId());
721 assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", user.getUserContact().getContactId()); //NOI18N
724 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId())); //NOI18N
726 // Merge contact instance
727 Contact detachedContact = this.getEntityManager().merge(foundContact);
730 detachedContact.copyAll(user.getUserContact());
732 // Set it back in user
733 user.setUserContact(detachedContact);
736 assert (detachedContact instanceof Contact) : MessageFormat.format("Contact with id {0} not merged, but should be.", user.getUserContact().getContactId()); //NOI18N
738 // Get cellphone instance
739 DialableCellphoneNumber cellphone = detachedContact.getContactCellphoneNumber();
741 // Is there a cellphone instance set?
742 if (cellphone instanceof DialableCellphoneNumber) {
744 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: cellphone.phoneId={0} is being updated ...", cellphone.getPhoneId())); //NOI18N
747 DialableCellphoneNumber foundCellphone = this.getEntityManager().find(cellphone.getClass(), cellphone.getPhoneId());
750 assert (foundCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", foundCellphone.getPhoneId()); //NOI18N
752 // Then merge it, too
753 DialableCellphoneNumber detachedCellphone = this.getEntityManager().merge(foundCellphone);
756 assert (detachedCellphone instanceof DialableCellphoneNumber) : MessageFormat.format("Cellphone number with id {0} not found but should be.", detachedCellphone.getPhoneId()); //NOI18N
759 detachedCellphone.copyAll(user.getUserContact().getContactCellphoneNumber());
762 detachedContact.setContactCellphoneNumber(detachedCellphone);
765 // Get cellphone instance
766 DialableFaxNumber fax = detachedContact.getContactFaxNumber();
768 // Is there a fax instance set?
769 if (fax instanceof DialableFaxNumber) {
771 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: fax.phoneId={0} is being updated ...", fax.getPhoneId())); //NOI18N
774 DialableFaxNumber foundFax = this.getEntityManager().find(fax.getClass(), fax.getPhoneId());
777 assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
779 // Then merge it, too
780 DialableFaxNumber detachedFax = this.getEntityManager().merge(foundFax);
783 assert (detachedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", detachedFax.getPhoneId()); //NOI18N
786 detachedFax.copyAll(user.getUserContact().getContactFaxNumber());
789 detachedContact.setContactFaxNumber(detachedFax);
792 // Get cellphone instance
793 DialableLandLineNumber landLine = detachedContact.getContactLandLineNumber();
795 // Is there a fax instance set?
796 if (landLine instanceof DialableLandLineNumber) {
798 this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: landLine.phoneId={0} is being updated ...", landLine.getPhoneId())); //NOI18N
801 DialableLandLineNumber foundLandLine = this.getEntityManager().find(landLine.getClass(), landLine.getPhoneId());
804 assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
806 // Then merge it, too
807 DialableLandLineNumber detachedLandLine = this.getEntityManager().merge(foundLandLine);
810 assert (detachedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", detachedLandLine.getPhoneId()); //NOI18N
813 detachedLandLine.copyAll(user.getUserContact().getContactLandLineNumber());
816 detachedContact.setContactLandLineNumber(detachedLandLine);
819 // Return updated user instance