From 573da7fc20068c1c3a7c4fbcf1614349140a8620 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 --- .../JobsAdminContactWebRequestBean.java | 51 ++++++++++++------- .../contact/JobsContactWebSessionBean.java | 2 +- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index 96d913f1..3532a1e0 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -344,24 +344,6 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques 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 JobsAdminContactWebRequestBean implements JobsAdminContactWebReques 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/jjobs/beans/contact/JobsContactWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java index 29abbe31..1203e058 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java @@ -338,8 +338,8 @@ public class JobsContactWebSessionBean implements JobsContactWebSessionControlle //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N } - @SuppressWarnings ("ReturnOfCollectionOrArrayField") @Override + @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allContacts () { return this.contactList; } -- 2.39.5