From 71eaad630886ea1fa6024bf6cd0dba3226e37a8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 29 Apr 2016 15:43:26 +0200 Subject: [PATCH] Continued a bit: - renamed method changeUserData() to editUserData() (members sorted) - surpressed some warnings that are not being fixed - clear() needs to be called MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- ...AddressbookAdminContactWebRequestBean.java | 51 ++++++++++++------- .../AddressbookContactWebSessionBean.java | 2 +- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java index 6c1a4831..e11fc05a 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java @@ -344,24 +344,6 @@ public class AddressbookAdminContactWebRequestBean implements AddressbookAdminCo this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber()); } - @Override - public String editContactData () { - // Get contact instance - Contact contact = this.adminHelper.getContact(); - - // Is the land-line number set? - if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) { - // .. land-line data - this.setLandLineId(contact.getContactLandLineNumber().getPhoneId()); - this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode()); - this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry()); - this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber()); - } - - // Log message - //* NOISY-DEBUG: */ System.out.println("AdminContactController::copyContactToController(): EXIT!"); //NOI18N - } - @Override public Contact createContactInstance () { // Generate phone number @@ -400,6 +382,39 @@ public class AddressbookAdminContactWebRequestBean implements AddressbookAdminCo return contact; } + @Override + public String editContactData () { + // Get contact instance + Contact contact = this.adminHelper.getContact(); + + // Check if contact instance is in helper and valid + if (null == contact) { + // Throw NPE + throw new NullPointerException("adminHelper.contact is null"); //NOI18N + } else if (contact.getContactId() == null) { + // Throw NPE again + throw new NullPointerException("adminHelper.contact.contactId is null"); //NOI18N //NOI18N + } else if (contact.getContactId() < 1) { + // Invalid id + throw new IllegalStateException(MessageFormat.format("adminHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N + } + + // Update all data in contact + this.updateContactData(contact); + + // Call EJB for updating contact data + Contact updatedContact = this.contactBean.updateContactData(contact, this.isCellphoneUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked); + + // Fire event + this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact)); + + // Clear bean + this.clear(); + + // Return to contact list (for now) + return "admin_list_contact"; //NOI18N + } + @Override @SuppressWarnings ("ReturnOfDateField") public Date getBirthday () { diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java index 310508de..4923262b 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java @@ -338,8 +338,8 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N } - @SuppressWarnings ("ReturnOfCollectionOrArrayField") @Override + @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allContacts () { return this.contactList; } -- 2.39.5