]> git.mxchange.org Git - addressbook-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Thu, 20 Oct 2022 17:17:46 +0000 (19:17 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 20 Oct 2022 17:20:16 +0000 (19:20 +0200)
- added missing parameter "country" for updated constructor
- also validated if contact's Country instance is set and already persisted

lib/jcontacts-core.jar
src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebRequestBean.java
web/admin/contact/admin_contact_list.xhtml

index 14ab378f90ce45eff5815f34d37ebb7bd1d249e8..a30c9f085494b4d59401bd0375883808bbf39d14 100644 (file)
Binary files a/lib/jcontacts-core.jar and b/lib/jcontacts-core.jar differ
index 57bb7db616b90e34ff0fb634b2e84303a9d56c3b..9f3ed0cf6ad5c26251d3310985b286f8e2605e01 100644 (file)
@@ -37,9 +37,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 AddressbookAdminContactWebRequestBean extends BaseAddressbookBean i
        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 AddressbookAdminContactWebRequestBean extends BaseAddressbookBean i
                } 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 AddressbookAdminContactWebRequestBean extends BaseAddressbookBean i
                        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)) {
index c677fc8b83d7261b609380e75f72f2568cafbb42..4bcf24cff03ba83e7ca818635290b6555668aae8 100644 (file)
@@ -38,9 +38,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 AddressbookContactWebRequestBean extends BaseAddressbookBean implem
                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)) {
index 855fdc21c79cd9ab5550d05c7af54e36b67c4d2e..0d8e32ee0dd88c62b9dce33e8fd8eb0572a430ab 100644 (file)
 
                                <widgets:outputAdminContactDataFormFields />
 
+<<<<<<< HEAD
                                <div class="table-footer">
                                        <p:commandButton styleClass="reset divider-right" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
                                        <p:commandButton styleClass="submit" type="submit" id="button_add_contact" value="#{msg.BUTTON_ADMIN_ADD_CONTACT}" action="#{adminContactController.addContact()}" />
                                </div>
                        </h:panelGroup>
+=======
+                               <f:facet name="footer">
+                                       <p:panelGrid columns="2" layout="grid">
+                                               <p:commandButton
+                                                       styleClass="reset"
+                                                       type="reset"
+                                                       value="#{msg.BUTTON_RESET_FORM}"
+                                                       />
+
+                                               <p:commandButton
+                                                       type="submit"
+                                                       value="#{msg.BUTTON_ADMIN_ADD_CONTACT}"
+                                                       action="#{adminContactController.addContact()}"
+                                                       update="form-list-contacts:contactList"
+                                                       />
+                                       </p:panelGrid>
+                               </f:facet>
+                       </p:panelGrid>
+>>>>>>> 2b3f1b133 (Please cherry-pick:)
                </h:form>
        </ui:define>
 </ui:composition>