From f505c04515e03a45704c25d246e72dcf43ab9830 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 --- lib/jcontacts-core.jar | Bin 60017 -> 60527 bytes .../PizzaAdminContactWebRequestBean.java | 43 ++++++++++++------ .../contact/PizzaContactWebRequestBean.java | 39 +++------------- web/admin/contact/admin_contact_list.xhtml | 20 ++++++++ 4 files changed, 55 insertions(+), 47 deletions(-) diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar index 14ab378f90ce45eff5815f34d37ebb7bd1d249e8..a30c9f085494b4d59401bd0375883808bbf39d14 100644 GIT binary patch delta 6759 zcmaJ`33wD$68@`al9^1JWVk{?AcR092as^Za0(%uF$8h|AzUGZGn@$^h%`Y&5ie{| z@mh5~7hPoogm^5l3f?EOtElMex(hC%qOPv1>sEF5OlF#%-Bu| zuIsD!Tx}*7x!gX$3#{E!zOzk+Yt5eWefh6PxmeV_(I@2DbUJ#;ytd3#9KY|Lh7J7y z`ODMaZr@qYjgHfgY>w4$SRAk2=0gX{h@ni%ia`}+`Xy_Dm_tCZ`Z zeqQSDgHKcgyfn~DgJSU-<$38+ALY|vFAed~P#+DW;WE$&A(sgmDP)wF3Su#YM$7nx z!WH^x42{)99w+iRAC0F8B2E->qK}H`auJI~EEaK+h$SMHi1B0*r-(R3xKiOteRze+ zL@XDvT(}D1DukOV+*IMF2{+A0+H|Uv2+Z(MmFQ=Rex{FR(QFath&V^Mxx&pAu3ETi z;pPc9Pq-T4YJ{6F+%S&3xzBavRKFxAxnkS#pEzuChT${D}<~RvP#HmA@u^L zL55!Ap|$$g6uBhyGT2Fa4Is+Uu`1r0Yi;v-JxN?LF%}bcKi3H^r=}it!)C zpFFfdr7Q7-ipTMUo|@1@zkO4;=%e_Akf@W^L4Rvgv}+?>rH@MKb*omU5fW-vEN`f; zX&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pz+z1C58RIf7d0`kn`H}MX=S*5 z$ujOpdcpg`N-d3MXD!mSWe=v#YXBX*px6sqc|mV4$oGO0FJPwE*maH zH1joOY$+RW&ejfu{1I4rejr3g@U>}Xtabm`;-%#mFy-8Zs>WG4=LAYU9i%l75zZF| zb7_73I2<8q!|vvl)Ja=u#}4PI(4KDvhf4iAAzH7`Tzg` diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java index c956ab1b..b5f5382c 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java @@ -36,9 +36,9 @@ import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; 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.contact.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.jphone.model.phonenumbers.DialableNumber; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; @@ -175,7 +175,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaBean implements Pi private boolean isLandLineUnlinked; /** - * Whether a cmobile entry has been unlinked + * Whether a mobile entry has been unlinked */ private boolean isMobileNumberUnlinked; @@ -392,6 +392,15 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaBean implements Pi } 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 @@ -408,20 +417,24 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaBean implements Pi contact.setContactId(this.getContactId()); } - // Add all others - contact.setContactTitle(this.getAcademicTitle()); - contact.setContactBirthday(this.getBirthday()); - contact.setContactStreet(this.getStreet()); - contact.setContactHouseNumber(this.getHouseNumber()); - contact.setContactZipCode(this.getZipCode()); - contact.setContactCity(this.getCity()); - contact.setContactCountry(this.getContactCountry()); - contact.setContactEmailAddress(this.getEmailAddress()); - contact.setContactBirthday(this.getBirthday()); - contact.setContactComment(this.getComment()); + // Create new instance + final Contact localContact = new UserContact( + this.getPersonalTitle(), + this.getFirstName(), + this.getFamilyName(), + this.getContactCountry() + ); - // Set ownContact - contact.setContactOwnContact(Boolean.TRUE); + // Add all others + localContact.setContactBirthday(this.getBirthday()); + localContact.setContactCity(this.getCity()); + localContact.setContactComment(this.getComment()); + localContact.setContactEmailAddress(this.getEmailAddress()); + localContact.setContactHouseNumber(this.getHouseNumber()); + localContact.setContactId(this.getContactId()); + localContact.setContactStreet(this.getStreet()); + localContact.setContactTitle(this.getAcademicTitle()); + localContact.setContactZipCode(this.getZipCode()); // 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)) { diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java index 79f52d47..5ec23a3d 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java @@ -35,9 +35,9 @@ import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEven import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; -import org.mxchange.jcontacts.model.contact.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.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; @@ -493,37 +493,12 @@ public class PizzaContactWebRequestBean extends BasePizzaBean implements PizzaCo DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber()); // Create new contact - Contact contact = new UserContact(this.getPersonalTitle(), this.getFirstName(), this.getFamilyName()); - contact.setContactStreet(this.getStreet()); - contact.setContactHouseNumber(this.getHouseNumber()); - contact.setContactHouseNumberExtension(this.getHouseNumberExtension()); - contact.setContactZipCode(this.getZipCode()); - contact.setContactCity(this.getCity()); - contact.setContactCountry(this.getCountry()); - contact.setContactEmailAddress(this.getEmailAddress()); - contact.setContactBirthday(this.getBirthday()); - contact.setContactComment(this.getComment()); - - // Don't set null or wrong references - if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) { - // Now the number must be given - if (phone.getPhoneAreaCode() == null) { - // Is null - throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N - } else if (phone.getPhoneAreaCode() < 1) { - // Abort here - throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N - } else if (phone.getPhoneNumber() == null) { - // Is null - throw new NullPointerException("phone.phoneNumber is null"); //NOI18N - } else if (phone.getPhoneNumber() < 1) { - // Abort here - throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N - } - - // Set phone number - contact.setContactLandLineNumber(phone); - } + final Contact contact = new UserContact( + this.getPersonalTitle(), + this.getFirstName(), + this.getFamilyName(), + this.getCountry() + ); // Don't set null or wrong references if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) { diff --git a/web/admin/contact/admin_contact_list.xhtml b/web/admin/contact/admin_contact_list.xhtml index 855fdc21..0d8e32ee 100644 --- a/web/admin/contact/admin_contact_list.xhtml +++ b/web/admin/contact/admin_contact_list.xhtml @@ -91,11 +91,31 @@ +<<<<<<< HEAD +======= + + + + + + + + +>>>>>>> 2b3f1b133 (Please cherry-pick:) -- 2.39.5