2 * Copyright (C) 2016 - 2022 Free Software Foundation
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jfinancials.beans.contact;
19 import java.text.MessageFormat;
20 import java.util.Date;
21 import java.util.Objects;
23 import javax.enterprise.context.RequestScoped;
24 import javax.enterprise.event.Event;
25 import javax.enterprise.event.Observes;
26 import javax.enterprise.inject.Any;
27 import javax.faces.FacesException;
28 import javax.faces.application.FacesMessage;
29 import javax.inject.Inject;
30 import javax.inject.Named;
31 import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent;
32 import org.mxchange.jcontacts.events.contact.update.UpdatedContactEvent;
33 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
34 import org.mxchange.jcontacts.model.contact.Contact;
35 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
36 import org.mxchange.jcontacts.model.utils.ContactUtils;
37 import org.mxchange.jcontacts.model.contact.UserContact;
38 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
39 import org.mxchange.jcountry.model.data.Country;
40 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
41 import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
42 import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
43 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
44 import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
45 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
46 import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
47 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
48 import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
49 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
50 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
51 import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
52 import org.mxchange.jusercore.events.user.update.pre.ObservablePreUserPersonalDataUpdatedEvent;
53 import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
54 import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
57 * A general contact bean (controller)
59 * @author Roland Häder<roland@mxchange.org>
61 @Named ("contactController")
63 public class FinancialsContactWebRequestBean extends BaseFinancialsBean implements FinancialsContactWebRequestController {
68 private static final long serialVersionUID = 542_145_347_916L;
71 * Academic academicTitle
73 private String academicTitle;
78 private Date birthday;
88 private String comment;
91 * EJB for general contact purposes
93 @EJB (lookup = "java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote")
94 private ContactSessionBeanRemote contactBean;
97 * An instance of a contact-list backing bean
99 private FinancialsContactListWebViewController contactListController;
102 * Event being fired when a user has updated his contact data
106 private Event<ObservableUpdatedContactEvent> contactUpdatedEvent;
111 private Country country;
116 private String emailAddress;
119 * Email address repeated
121 private String emailAddressRepeat;
126 private String familyName;
129 * Fax number's area code
131 private Integer faxAreaCode;
134 * Country instance for fax number
136 private Country faxCountry;
141 private Long faxNumber;
146 private String firstName;
151 private Short houseNumber;
154 * House number extension
156 private String houseNumberExtension;
159 * Phone number area code
161 private Integer landLineAreaCode;
164 * Country instance for phone number
166 private Country landLineCountry;
171 private Long landLineNumber;
176 private Long mobileNumber;
179 * Mobile number's carrier
181 private MobileProvider mobileProvider;
184 * Personal academicTitle
186 private PersonalTitle personalTitle;
191 private String street;
194 * Login bean (controller)
197 private FinancialsUserLoginWebSessionController userLoginController;
202 private Integer zipCode;
205 * Default constructor
207 public FinancialsContactWebRequestBean () {
208 // Call super constructor
213 * Event observer for newly added users by administrator
215 * @param event Event being fired
217 public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
218 // Event and contained entity instance should not be null
221 throw new NullPointerException("event is null"); //NOI18N
222 } else if (event.getAddedUser() == null) {
224 throw new NullPointerException("event.addedUser is null"); //NOI18N
225 } else if (event.getAddedUser().getUserId() == null) {
227 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
228 } else if (event.getAddedUser().getUserId() < 1) {
230 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
238 * Observes events being fired when an administrator has linked a new user
239 * with existing contact data.
241 * @param event Event being fired
243 public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
244 // Event and contained entity instance should not be null
247 throw new NullPointerException("event is null"); //NOI18N
248 } else if (event.getLinkedUser() == null) {
250 throw new NullPointerException("event.linkedUser is null"); //NOI18N
251 } else if (event.getLinkedUser().getUserContact() == null) {
253 throw new NullPointerException("event.linkedUser.userContact is null"); //NOI18N
254 } else if (event.getLinkedUser().getUserContact().getContactId() == null) {
256 throw new NullPointerException("event.linkedUser.userContact.contactId is null"); //NOI18N
257 } else if (event.getLinkedUser().getUserContact().getContactId() < 1) {
259 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserContact().getContactId())); //NOI18N
267 * Event observer for logged-in user
269 * @param event Event instance
271 public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
272 // Event and contained entity instance should not be null
275 throw new NullPointerException("event is null"); //NOI18N
276 } else if (event.getLoggedInUser() == null) {
278 throw new NullPointerException("event.loggedInUser is null"); //NOI18N
279 } else if (event.getLoggedInUser().getUserId() == null) {
281 throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
282 } else if (event.getLoggedInUser().getUserId() < 1) {
284 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
287 // Copy all data to this bean
288 this.copyFromContact(event.getLoggedInUser().getUserContact());
292 * Observes events being fired before an updated of personal data done by a
295 * @param event Event being observed
297 public void beforeUserUpdatedPersonalDataEvent (@Observes final ObservablePreUserPersonalDataUpdatedEvent event) {
298 // Is the instance valid?
301 throw new NullPointerException("event is null"); //NOI18N
302 } else if (event.getUpdatedUser() == null) {
304 throw new NullPointerException("event.updatedUser is null"); //NOI18N
308 this.copyToContact(event.getUpdatedUser().getUserContact());
312 public void clearEmailAddresses () {
314 this.setEmailAddress(null);
315 this.setEmailAddressRepeat(null);
319 public Contact createContactInstance () {
320 // Is all required data set?
321 if (!this.isRequiredPersonalDataSet()) {
322 // No, then abort here
323 throw new FacesException(new IllegalArgumentException("Not all personal data is set, but createContactInstance() is called.")); //NOI18N
326 // Required personal data must be set
327 assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
329 // Create new contact
330 final Contact contact = new UserContact(
331 this.getPersonalTitle(),
341 public String doChangePersonalContactData () {
342 // This method shall only be called if the user is logged-in
343 if (!this.userLoginController.isUserLoggedIn()) {
345 throw new IllegalStateException("User is not logged-in"); //NOI18N
346 } else if (!this.isRequiredChangePersonalDataSet()) {
347 // Not all required fields are set
348 throw new FacesException("Not all required fields are set."); //NOI18N
349 } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
350 // Password not matching
351 this.showFacesMessage("form_login_change_personal:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()), FacesMessage.SEVERITY_ERROR); //NOI18N
355 // Get contact instance
356 final Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
358 // It should be there, so run some tests on it
359 assert (contact instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
360 assert (contact.getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
361 assert (contact.getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
364 contact.setContactPersonalTitle(this.getPersonalTitle());
365 contact.setContactFirstName(this.getFirstName());
366 contact.setContactFamilyName(this.getFamilyName());
367 contact.setContactStreet(this.getStreet());
368 contact.setContactHouseNumber(this.getHouseNumber());
369 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
370 contact.setContactZipCode(this.getZipCode());
371 contact.setContactCity(this.getCity());
372 contact.setContactCountry(this.getCountry());
374 // Update contact's mobile number
375 final boolean isMobileUnlinked = ContactUtils.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
377 // Update contact's land-line number
378 final boolean isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
380 // Update contact's fax number
381 final boolean isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
383 // Init updated contact instance
384 final Contact updatedContact;
387 // Send it to the EJB
388 updatedContact = this.contactBean.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
389 } catch (final ContactNotFoundException ex) {
391 throw new FacesException(ex);
395 this.contactUpdatedEvent.fire(new UpdatedContactEvent(updatedContact));
398 return "contact_data_saved"; //NOI18N
402 * Getter for academic title
404 * @return Academic title
406 public String getAcademicTitle () {
407 return this.academicTitle;
411 * Setter for academic title
413 * @param academicTitle Academic title
415 public void setAcademicTitle (final String academicTitle) {
416 this.academicTitle = academicTitle;
420 * Getter for birth day
424 @SuppressWarnings ("ReturnOfDateField")
425 public Date getBirthday () {
426 return this.birthday;
430 * Setter for birth day
432 * @param birthday Birth day
434 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
435 public void setBirthday (final Date birthday) {
436 this.birthday = birthday;
440 * Getter for city name
444 public String getCity () {
449 * Setter for city name
451 * @param city City name
453 public void setCity (final String city) {
458 * Getter for comments
462 public String getComment () {
469 * @param comment Comments
471 public void setComment (final String comment) {
472 this.comment = comment;
476 * Getter for country instance
478 * @return Country instance
480 public Country getCountry () {
485 * Setter for country instance
487 * @param country Country instance
489 public void setCountry (final Country country) {
490 this.country = country;
494 public String getEmailAddress () {
495 return this.emailAddress;
499 * Setter for email address
501 * @param emailAddress Email address
503 public void setEmailAddress (final String emailAddress) {
504 this.emailAddress = emailAddress;
508 * Getter for email address, repeated
510 * @return the emailAddress, repeated
512 public String getEmailAddressRepeat () {
513 return this.emailAddressRepeat;
517 * Setter for email address repeated
519 * @param emailAddressRepeat the emailAddress to set
521 public void setEmailAddressRepeat (final String emailAddressRepeat) {
522 this.emailAddressRepeat = emailAddressRepeat;
528 * @return the familyName
530 public String getFamilyName () {
531 return this.familyName;
537 * @param familyName the familyName to set
539 public void setFamilyName (final String familyName) {
540 this.familyName = familyName;
544 * Getter for fax number's area code
546 * @return Fax number's area code
548 public Integer getFaxAreaCode () {
549 return this.faxAreaCode;
553 * Setter for fax number's area code
555 * @param faxAreaCode Fax number's area code
557 public void setFaxAreaCode (final Integer faxAreaCode) {
558 this.faxAreaCode = faxAreaCode;
562 * Getter for fax's country instance
564 * @return Fax' country instance
566 public Country getFaxCountry () {
567 return this.faxCountry;
571 * Setter for fax's country instance
573 * @param faxCountry Fax' country instance
575 public void setFaxCountry (final Country faxCountry) {
576 this.faxCountry = faxCountry;
580 * Getter for fax number
584 public Long getFaxNumber () {
585 return this.faxNumber;
589 * Setter for fax number
591 * @param faxNumber Fax number
593 public void setFaxNumber (final Long faxNumber) {
594 this.faxNumber = faxNumber;
600 * @return the first name
602 public String getFirstName () {
603 return this.firstName;
609 * @param firstName the first name to set
611 public void setFirstName (final String firstName) {
612 this.firstName = firstName;
618 * @return the houseNumber
620 public Short getHouseNumber () {
621 return this.houseNumber;
627 * @param houseNumber the houseNumber to set
629 public void setHouseNumber (final Short houseNumber) {
630 this.houseNumber = houseNumber;
634 * Getter for house number extension, example: 123a 'a' is then the
635 * extension and 123 is the house number.
637 * @return House number extension
639 public String getHouseNumberExtension () {
640 return this.houseNumberExtension;
644 * Setter for house number extension
646 * @param houseNumberExtension House number extension
648 public void setHouseNumberExtension (final String houseNumberExtension) {
649 this.houseNumberExtension = houseNumberExtension;
653 * Getter for land-line number's area code
655 * @return Land-line number's area code
657 public Integer getLandLineAreaCode () {
658 return this.landLineAreaCode;
662 * Setter for land-line number's area code
664 * @param landLineAreaCode Land-line number's area code
666 public void setLandLineAreaCode (final Integer landLineAreaCode) {
667 this.landLineAreaCode = landLineAreaCode;
671 * Getter for land-line number's country instance
673 * @return Land-line number's country instance
675 public Country getLandLineCountry () {
676 return this.landLineCountry;
680 * Setter for land-line number's country instance
682 * @param landLineCountry Land-line number's country instance
684 public void setLandLineCountry (final Country landLineCountry) {
685 this.landLineCountry = landLineCountry;
689 * Getter for land-line number
691 * @return Land-line number
693 public Long getLandLineNumber () {
694 return this.landLineNumber;
698 * Setter for land-line number
700 * @param landLineNumber Land-line number
702 public void setLandLineNumber (final Long landLineNumber) {
703 this.landLineNumber = landLineNumber;
707 * Getter for mobile number
709 * @return Mobile number
711 public Long getMobileNumber () {
712 return this.mobileNumber;
716 * Setter for mobile number
718 * @param mobileNumber Mobile number
720 public void setMobileNumber (final Long mobileNumber) {
721 this.mobileNumber = mobileNumber;
725 * Getter for mobile number's carrier
727 * @return Mobile number's carrier
729 public MobileProvider getMobileProvider () {
730 return this.mobileProvider;
734 * Setter for mobile number's provider
736 * @param mobileProvider Mobile number's provider
738 public void setMobileProvider (final MobileProvider mobileProvider) {
739 this.mobileProvider = mobileProvider;
743 * Getter for personal title
745 * @return Personal title
747 public PersonalTitle getPersonalTitle () {
748 return this.personalTitle;
752 * Setter for personal title
754 * @param personalTitle Personal title
756 public void setPersonalTitle (final PersonalTitle personalTitle) {
757 this.personalTitle = personalTitle;
765 public String getStreet () {
772 * @param street Street
774 public void setStreet (final String street) {
775 this.street = street;
779 * Getter for ZIP code
783 public Integer getZipCode () {
788 * Setter for ZIP code
790 * @param zipCode ZIP code
792 public void setZipCode (final Integer zipCode) {
793 this.zipCode = zipCode;
797 public boolean isEmailAddressRegistered (final Contact contact) {
799 if (null == contact) {
801 throw new NullPointerException("contact is null"); //NOI18N
802 } else if (contact.getContactEmailAddress() == null) {
804 throw new NullPointerException("contact.contactEmailAddress is null"); //NOI18N
805 } else if (contact.getContactEmailAddress().isEmpty()) {
807 throw new IllegalArgumentException("contact.contactEmailAddress is empty."); //NOI18N
810 // Default is not registered
811 boolean isRegistered = false;
814 for (final Contact currentContact : this.contactListController.getAllContacts()) {
815 // Is same contact found?
816 if (currentContact.getContactEmailAddress().equals(contact.getContactEmailAddress())) {
817 // Found same email address
820 // Skipp further iterations
830 public boolean isEmailAddressRegistered (final String emailAddress) {
831 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
835 public boolean isRequiredChangePersonalDataSet () {
836 return ((this.getPersonalTitle() != null) &&
837 (this.getFirstName() != null) &&
838 (this.getFamilyName() != null) &&
839 (this.getStreet() != null) &&
840 (this.getHouseNumber() != null) &&
841 (this.getZipCode() != null) &&
842 (this.getCity() != null));
846 public boolean isRequiredPersonalDataSet () {
847 return ((this.getPersonalTitle() != null) &&
848 (this.getFirstName() != null) &&
849 (this.getFamilyName() != null) &&
850 (this.getStreet() != null) &&
851 (this.getHouseNumber() != null) &&
852 (this.getZipCode() != null) &&
853 (this.getCity() != null) &&
854 (this.getEmailAddress() != null) &&
855 (this.getEmailAddressRepeat() != null));
859 public boolean isSameEmailAddressEntered () {
860 return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
866 private void clear () {
869 this.setPersonalTitle(null);
870 this.setAcademicTitle(null);
871 this.setFirstName(null);
872 this.setFamilyName(null);
873 this.setStreet(null);
874 this.setHouseNumber(null);
875 this.setHouseNumberExtension(null);
876 this.setZipCode(null);
878 this.setCountry(null);
881 this.clearEmailAddresses();
882 this.setLandLineAreaCode(null);
883 this.setLandLineCountry(null);
884 this.setLandLineNumber(null);
885 this.setMobileProvider(null);
886 this.setMobileNumber(null);
887 this.setFaxAreaCode(null);
888 this.setFaxCountry(null);
889 this.setFaxNumber(null);
892 this.setBirthday(null);
893 this.setComment(null);
897 * Copies given contact data into the controller
899 * @param contact Contact instance
901 private void copyFromContact (final Contact contact) {
904 this.setPersonalTitle(contact.getContactPersonalTitle());
905 this.setAcademicTitle(contact.getContactTitle());
906 this.setFirstName(contact.getContactFirstName());
907 this.setFamilyName(contact.getContactFamilyName());
908 this.setStreet(contact.getContactStreet());
909 this.setHouseNumber(contact.getContactHouseNumber());
910 this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
911 this.setZipCode(contact.getContactZipCode());
912 this.setCity(contact.getContactCity());
913 this.setCountry(contact.getContactCountry());
914 this.setEmailAddress(contact.getContactEmailAddress());
915 this.setBirthday(contact.getContactBirthday());
916 this.setComment(contact.getContactComment());
918 // Get mobile, phone and fax instance
919 final DialableFaxNumber fax = contact.getContactFaxNumber();
920 final DialableLandLineNumber landLine = contact.getContactLandLineNumber();
921 final DialableMobileNumber mobile = contact.getContactMobileNumber();
923 // Is a fax number set?
924 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
926 this.setFaxCountry(fax.getPhoneCountry());
927 this.setFaxAreaCode(fax.getPhoneAreaCode());
928 this.setFaxNumber(fax.getPhoneNumber());
931 // Is a land-line number set?
932 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneAreaCode() > 0)) {
934 this.setLandLineCountry(landLine.getPhoneCountry());
935 this.setLandLineAreaCode(landLine.getPhoneAreaCode());
936 this.setLandLineNumber(landLine.getPhoneNumber());
939 // Is a mobile number set?
940 if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
942 this.setMobileProvider(mobile.getMobileProvider());
943 this.setMobileNumber(mobile.getMobileNumber());
948 * Copies all fields from this backing bean into given instance.
950 * @param contact An instance of a Contact class
952 private void copyToContact (final Contact contact) {
953 // Set other elements
954 contact.setContactStreet(this.getStreet());
955 contact.setContactHouseNumber(this.getHouseNumber());
956 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
957 contact.setContactZipCode(this.getZipCode());
958 contact.setContactCity(this.getCity());
959 contact.setContactCountry(this.getCountry());
960 contact.setContactEmailAddress(this.getEmailAddress());
961 contact.setContactBirthday(this.getBirthday());
962 contact.setContactComment(this.getComment());
964 // Generate phone number
965 final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
966 final DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
967 final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
969 // Don't set null or wrong references
970 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
971 // Now the number must be given
972 if (landLine.getPhoneAreaCode() == null) {
974 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
975 } else if (landLine.getPhoneAreaCode() < 1) {
977 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
978 } else if (landLine.getPhoneNumber() == null) {
980 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
981 } else if (landLine.getPhoneNumber() < 1) {
983 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
987 contact.setContactLandLineNumber(landLine);
990 // Don't set null or wrong references
991 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
992 // Now the number must be given
993 if (fax.getPhoneAreaCode() == null) {
995 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
996 } else if (fax.getPhoneAreaCode() < 1) {
998 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
999 } else if (fax.getPhoneNumber() == null) {
1001 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
1002 } else if (fax.getPhoneNumber() < 1) {
1004 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
1008 contact.setContactFaxNumber(fax);
1011 // Is the provider set?
1012 if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
1013 // Is the number set?
1014 if (mobile.getMobileNumber() == null) {
1016 throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
1017 } else if (mobile.getMobileNumber() < 1) {
1019 throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
1022 // Set mobile number
1023 contact.setContactMobileNumber(mobile);