]> git.mxchange.org Git - jfinancials-war.git/commitdiff
if the area code or SmsProvider is not selected, don't create the DialableNumber...
authorRoland Haeder <roland@mxchange.org>
Mon, 12 Oct 2015 12:55:09 +0000 (14:55 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 12 Oct 2015 13:12:13 +0000 (15:12 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/addressbook/beans/user/UserWebBean.java

index 01ae202d93fc4fc4f80836e55ae21b79e855b139..0ff385cc01015e12d47ebd295a0698abbdeb579f 100644 (file)
@@ -280,16 +280,16 @@ public class UserWebBean implements UserWebController {
                DialableLandLineNumber phone = user.getUserContact().getContactPhoneNumber();
 
                // - contact data
-               if (phone instanceof DialableLandLineNumber) {
+               if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
                        this.setPhoneCountry(phone.getPhoneCountry());
                        this.setPhoneAreaCode(phone.getPhoneAreaCode());
                        this.setPhoneNumber(phone.getPhoneNumber());
                }
-               if (cellphone instanceof DialableCellphoneNumber) {
+               if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof SmsProvider)) {
                        this.setCellphoneCarrier(cellphone.getCellphoneProvider());
                        this.setCellphoneNumber(cellphone.getPhoneNumber());
                }
-               if (fax instanceof DialableFaxNumber) {
+               if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
                        this.setFaxCountry(fax.getPhoneCountry());
                        this.setFaxAreaCode(fax.getPhoneAreaCode());
                        this.setFaxNumber(fax.getPhoneNumber());
@@ -326,9 +326,64 @@ public class UserWebBean implements UserWebController {
                contact.setContactCity(this.getCity());
                contact.setContactCountry(this.getCountry());
                contact.setContactEmailAddress(this.getEmailAddress());
-               contact.setContactPhoneNumber(phone);
-               contact.setContactFaxNumber(fax);
-               contact.setContactCellphoneNumber(cellphone);
+
+               // Don't set null or wrong references
+               if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() > 0) &&(this.getPhoneNumber() > 0)) {
+                       // Now the number must be given
+                       if (phone.getPhoneAreaCode() == null) {
+                               // Is null
+                               throw new NullPointerException("phone.phoneAreaCode is null");
+                       } else if (phone.getPhoneAreaCode() < 1) {
+                               // Abort here
+                               throw new IllegalArgumentException("phone.phoneAreaCode is zero or below.");
+                       } else if (phone.getPhoneNumber() == null) {
+                               // Is null
+                               throw new NullPointerException("phone.phoneNumber is null");
+                       } else if (phone.getPhoneNumber() < 1) {
+                               // Abort here
+                               throw new IllegalArgumentException("phone.phoneNumber is zero or below.");
+                       }
+
+                       // Set phone number
+                       contact.setContactPhoneNumber(phone);
+               }
+
+               // Don't set null or wrong references
+               if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
+                       // Now the number must be given
+                       if (fax.getPhoneAreaCode() == null) {
+                               // Is null
+                               throw new NullPointerException("fax.phoneAreaCode is null");
+                       } else if (fax.getPhoneAreaCode() < 1) {
+                               // Abort here
+                               throw new IllegalArgumentException("fax.phoneAreaCode is zero or below.");
+                       } else if (fax.getPhoneNumber() == null) {
+                               // Is null
+                               throw new NullPointerException("fax.phoneNumber is null");
+                       } else if (fax.getPhoneNumber() < 1) {
+                               // Abort here
+                               throw new IllegalArgumentException("fax.phoneNumber is zero or below.");
+                       }
+
+                       // Set fax number
+                       contact.setContactFaxNumber(fax);
+               }
+
+               // Is the provider set?
+               if ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof SmsProvider) && (this.getCellphoneNumber() > 0)) {
+                       // Is the number set?
+                       if (cellphone.getPhoneNumber() == null) {
+                               // Is null
+                               throw new NullPointerException("cellphone.phoneNumber is null");
+                       } else if (cellphone.getPhoneNumber() < 1) {
+                               // Abort here
+                               throw new IllegalArgumentException("cellphone.phoneNumber is zero or below.");
+                       }
+
+                       // Set cellphone number
+                       contact.setContactCellphoneNumber(cellphone);
+               }
+
                contact.setContactBirthday(this.getBirthday());
                contact.setContactComment(this.getComment());