From 93deae43a53f7f3a0884d7b424ceb9e797c0d9f4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 10 May 2016 14:02:16 +0200 Subject: [PATCH] Continued a bit: - moved all contact data to one place (was a bit scattered) - no need to update cellphone data here (contact controller does it) - added check on parameter 'user' - added noisy debug line (contact) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../contact/AddressbookContactWebSessionBean.java | 14 +++++++++----- .../beans/user/AddressbookUserWebSessionBean.java | 15 ++++++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java index 49c7ea75..d8611e09 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java @@ -384,6 +384,10 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allContacts () { + // Debug message + /* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactController.allContacts: contactList.size()={0} - EXIT!", this.contactList.size())); + + // Return un-modified list return this.contactList; } @@ -910,6 +914,9 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe this.setZipCode(contact.getContactZipCode()); this.setCity(contact.getContactCity()); this.setCountry(contact.getContactCountry()); + this.setEmailAddress(contact.getContactEmailAddress()); + this.setBirthday(contact.getContactBirthday()); + this.setComment(contact.getContactComment()); // Get cellphone, phone and fax instance DialableCellphoneNumber cellphone = contact.getContactCellphoneNumber(); @@ -922,20 +929,17 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe this.setPhoneAreaCode(phone.getPhoneAreaCode()); this.setPhoneNumber(phone.getPhoneNumber()); } + if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof MobileProvider)) { this.setCellphoneCarrier(cellphone.getCellphoneProvider()); this.setCellphoneNumber(cellphone.getPhoneNumber()); } + if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) { this.setFaxCountry(fax.getPhoneCountry()); this.setFaxAreaCode(fax.getPhoneAreaCode()); this.setFaxNumber(fax.getPhoneNumber()); } - this.setEmailAddress(contact.getContactEmailAddress()); - - // -- other data - this.setBirthday(contact.getContactBirthday()); - this.setComment(contact.getContactComment()); } /** diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java index f20cb812..74a8975c 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java @@ -38,6 +38,7 @@ import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; @@ -698,15 +699,19 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC * @param user User instance */ private void copyUser (final User user) { + // Make sure the instance is valid + if (null == user) { + // Throw NPE + throw new NullPointerException("user is null"); //NOI18N + } else if (user.getUserContact() == null) { + // Throw again ... + throw new NullPointerException("user.userContact is null"); //NOI18N + } + // Copy all fields: // - base data this.setUserId(user.getUserId()); this.setUserProfileMode(user.getUserProfileMode()); - - // Get cellphone, phone and fax instance - DialableCellphoneNumber cellphone = user.getUserContact().getContactCellphoneNumber(); - DialableFaxNumber fax = user.getUserContact().getContactFaxNumber(); - DialableLandLineNumber phone = user.getUserContact().getContactLandLineNumber(); } /** -- 2.39.5