From cd0648efe004ef4550b15db24b93ddffa8236d0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 20 Oct 2022 19:17:46 +0200 Subject: [PATCH] Please cherry-pick: - added missing parameter "country" for updated constructor - also validated if contact's Country instance is set and already persisted --- .../JobsAdminContactWebRequestBean.java | 20 ++++++++++++------- .../contact/JobsContactWebRequestBean.java | 5 +++-- web/admin/contact/admin_contact_list.xhtml | 1 + 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index ab6f1db2..1b52b855 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -38,9 +38,9 @@ import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.AdminContactSessionBeanRemote; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; -import org.mxchange.jcontacts.model.utils.ContactUtils; import org.mxchange.jcontacts.model.contact.UserContact; import org.mxchange.jcontacts.model.contact.title.PersonalTitle; +import org.mxchange.jcontacts.model.utils.ContactUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController; @@ -196,7 +196,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs private boolean isLandLineUnlinked; /** - * Whether a cmobile entry has been unlinked + * Whether a mobile entry has been unlinked */ private boolean isMobileNumberUnlinked; @@ -411,6 +411,15 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs } else if (this.getFamilyName().isEmpty()) { // Empty string throw new IllegalStateException("familyName is empty"); //NOI18N + } else if (this.getContactCountry() == null) { + // Throw NPE + throw new NullPointerException("contactCountry is null"); //NOI18N + } else if (this.getContactCountry().getCountryId() == null) { + // Throw it again + throw new NullPointerException("contactCountry.countryId is null"); //NOI18N + } else if (this.getContactCountry().getCountryId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("contactCountry.countryId={0} is invalid", this.getContactCountry().getCountryId())); //NOI18N } // Generate phone number @@ -440,14 +449,14 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs final Contact localContact = new UserContact( this.getPersonalTitle(), this.getFirstName(), - this.getFamilyName() + this.getFamilyName(), + this.getContactCountry() ); // Add all others localContact.setContactBirthday(this.getBirthday()); localContact.setContactCity(this.getCity()); localContact.setContactComment(this.getComment()); - localContact.setContactCountry(this.getContactCountry()); localContact.setContactEmailAddress(this.getEmailAddress()); localContact.setContactHouseNumber(this.getHouseNumber()); localContact.setContactId(this.getContactId()); @@ -455,9 +464,6 @@ public class JobsAdminContactWebRequestBean extends BaseJobsBean implements Jobs localContact.setContactTitle(this.getAcademicTitle()); localContact.setContactZipCode(this.getZipCode()); - // Set ownContact - localContact.setContactOwnContact(Boolean.TRUE); - // Don't set null or wrong references if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) { // Now the number must be given diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java index 867e93e7..2b8415c3 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebRequestBean.java @@ -33,9 +33,9 @@ import org.mxchange.jcontacts.events.contact.update.UpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; -import org.mxchange.jcontacts.model.utils.ContactUtils; import org.mxchange.jcontacts.model.contact.UserContact; import org.mxchange.jcontacts.model.contact.title.PersonalTitle; +import org.mxchange.jcontacts.model.utils.ContactUtils; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jjobs.beans.BaseJobsBean; import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController; @@ -330,7 +330,8 @@ public class JobsContactWebRequestBean extends BaseJobsBean implements JobsConta final Contact contact = new UserContact( this.getPersonalTitle(), this.getFirstName(), - this.getFamilyName() + this.getFamilyName(), + this.getCountry() ); // Return instance diff --git a/web/admin/contact/admin_contact_list.xhtml b/web/admin/contact/admin_contact_list.xhtml index cc23c119..decc2a8a 100644 --- a/web/admin/contact/admin_contact_list.xhtml +++ b/web/admin/contact/admin_contact_list.xhtml @@ -244,6 +244,7 @@ type="reset" value="#{msg.BUTTON_RESET_FORM}" /> +