From: Roland Häder Date: Thu, 20 Oct 2022 17:17:46 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2b3f1b133572cd2c0832e9f142f050199287c5d0;p=jfinancials-war.git Please cherry-pick: - added missing parameter "country" for updated constructor - also validated if contact's Country instance is set and already persisted --- diff --git a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java index 5e12ea7a..b4b2fbc7 100644 --- a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.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.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController; @@ -190,7 +190,7 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp private boolean isLandLineUnlinked; /** - * Whether a cmobile entry has been unlinked + * Whether a mobile entry has been unlinked */ private boolean isMobileNumberUnlinked; @@ -405,6 +405,15 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp } 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 @@ -434,14 +443,14 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp 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()); @@ -449,9 +458,6 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp 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/jfinancials/beans/contact/FinancialsContactWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java index 6ea9a996..21024af8 100644 --- a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.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.jfinancials.beans.BaseFinancialsBean; import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController; @@ -330,7 +330,8 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen 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}" /> +