From: Roland Häder Date: Fri, 29 Apr 2016 13:43:26 +0000 (+0200) Subject: Continued a bit: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=573da7fc20068c1c3a7c4fbcf1614349140a8620;p=jjobs-war.git Continued a bit: - renamed method changeUserData() to editUserData() (members sorted) - surpressed some warnings that are not being fixed - clear() needs to be called Signed-off-by: Roland Häder --- 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; }