2 * Copyright (C) 2016 - 2024 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.addressbook.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.addressbook.beans.BaseAddressbookBean;
32 import org.mxchange.addressbook.beans.contact.list.AddressbookContactListWebViewController;
33 import org.mxchange.addressbook.beans.user.login.AddressbookUserLoginWebSessionController;
34 import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent;
35 import org.mxchange.jcontacts.events.contact.update.UpdatedContactEvent;
36 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
37 import org.mxchange.jcontacts.model.contact.Contact;
38 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
39 import org.mxchange.jcontacts.model.contact.UserContact;
40 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
41 import org.mxchange.jcontacts.model.utils.ContactUtils;
42 import org.mxchange.jcountry.model.data.Country;
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 AddressbookContactWebRequestBean extends BaseAddressbookBean implements AddressbookContactWebRequestController {
68 private static final long serialVersionUID = 542_145_352_001L;
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/addressbook-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote")
94 private ContactSessionBeanRemote contactBean;
97 * An instance of a contact-list backing bean
99 private AddressbookContactListWebViewController 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 AddressbookUserLoginWebSessionController userLoginController;
202 private Integer zipCode;
205 * Default constructor
207 public AddressbookContactWebRequestBean () {
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 // Create new contact
327 final Contact contact = new UserContact(
328 this.getPersonalTitle(),
330 this.getFamilyName(),
340 public String doChangePersonalContactData () {
341 // This method shall only be called if the user is logged-in
342 if (!this.userLoginController.isUserLoggedIn()) {
344 throw new IllegalStateException("User is not logged-in"); //NOI18N
345 } else if (!this.isRequiredChangePersonalDataSet()) {
346 // Not all required fields are set
347 throw new FacesException("Not all required fields are set."); //NOI18N
348 } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
349 // Password not matching
350 this.showFacesException("form_login_change_personal:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()), FacesMessage.SEVERITY_ERROR); //NOI18N
354 // Get contact instance
355 final Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
357 // It should be there, so run some tests on it
358 assert (contact instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
359 assert (contact.getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
360 assert (contact.getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
363 contact.setContactPersonalTitle(this.getPersonalTitle());
364 contact.setContactFirstName(this.getFirstName());
365 contact.setContactFamilyName(this.getFamilyName());
366 contact.setContactStreet(this.getStreet());
367 contact.setContactHouseNumber(this.getHouseNumber());
368 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
369 contact.setContactZipCode(this.getZipCode());
370 contact.setContactCity(this.getCity());
371 contact.setContactCountry(this.getCountry());
373 // Update contact's mobile number
374 final boolean isMobileUnlinked = ContactUtils.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
376 // Update contact's land-line number
377 final boolean isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
379 // Update contact's fax number
380 final boolean isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
382 // Init updated contact instance
383 final Contact updatedContact;
386 // Send it to the EJB
387 updatedContact = this.contactBean.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
388 } catch (final ContactNotFoundException ex) {
390 throw new FacesException(ex);
394 this.contactUpdatedEvent.fire(new UpdatedContactEvent(updatedContact));
397 return "contact_data_saved"; //NOI18N
401 * Getter for academic title
403 * @return Academic title
405 public String getAcademicTitle () {
406 return this.academicTitle;
410 * Setter for academic title
412 * @param academicTitle Academic title
414 public void setAcademicTitle (final String academicTitle) {
415 this.academicTitle = academicTitle;
419 * Getter for birth day
423 @SuppressWarnings ("ReturnOfDateField")
424 public Date getBirthday () {
425 return this.birthday;
429 * Setter for birth day
431 * @param birthday Birth day
433 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
434 public void setBirthday (final Date birthday) {
435 this.birthday = birthday;
439 * Getter for city name
443 public String getCity () {
448 * Setter for city name
450 * @param city City name
452 public void setCity (final String city) {
457 * Getter for comments
461 public String getComment () {
468 * @param comment Comments
470 public void setComment (final String comment) {
471 this.comment = comment;
475 * Getter for country instance
477 * @return Country instance
479 public Country getCountry () {
484 * Setter for country instance
486 * @param country Country instance
488 public void setCountry (final Country country) {
489 this.country = country;
493 public String getEmailAddress () {
494 return this.emailAddress;
498 * Setter for email address
500 * @param emailAddress Email address
502 public void setEmailAddress (final String emailAddress) {
503 this.emailAddress = emailAddress;
507 * Getter for email address, repeated
509 * @return the emailAddress, repeated
511 public String getEmailAddressRepeat () {
512 return this.emailAddressRepeat;
516 * Setter for email address repeated
518 * @param emailAddressRepeat the emailAddress to set
520 public void setEmailAddressRepeat (final String emailAddressRepeat) {
521 this.emailAddressRepeat = emailAddressRepeat;
527 * @return the familyName
529 public String getFamilyName () {
530 return this.familyName;
536 * @param familyName the familyName to set
538 public void setFamilyName (final String familyName) {
539 this.familyName = familyName;
543 * Getter for fax number's area code
545 * @return Fax number's area code
547 public Integer getFaxAreaCode () {
548 return this.faxAreaCode;
552 * Setter for fax number's area code
554 * @param faxAreaCode Fax number's area code
556 public void setFaxAreaCode (final Integer faxAreaCode) {
557 this.faxAreaCode = faxAreaCode;
561 * Getter for fax's country instance
563 * @return Fax' country instance
565 public Country getFaxCountry () {
566 return this.faxCountry;
570 * Setter for fax's country instance
572 * @param faxCountry Fax' country instance
574 public void setFaxCountry (final Country faxCountry) {
575 this.faxCountry = faxCountry;
579 * Getter for fax number
583 public Long getFaxNumber () {
584 return this.faxNumber;
588 * Setter for fax number
590 * @param faxNumber Fax number
592 public void setFaxNumber (final Long faxNumber) {
593 this.faxNumber = faxNumber;
599 * @return the first name
601 public String getFirstName () {
602 return this.firstName;
608 * @param firstName the first name to set
610 public void setFirstName (final String firstName) {
611 this.firstName = firstName;
617 * @return the houseNumber
619 public Short getHouseNumber () {
620 return this.houseNumber;
626 * @param houseNumber the houseNumber to set
628 public void setHouseNumber (final Short houseNumber) {
629 this.houseNumber = houseNumber;
633 * Getter for house number extension, example: 123a 'a' is then the
634 * extension and 123 is the house number.
636 * @return House number extension
638 public String getHouseNumberExtension () {
639 return this.houseNumberExtension;
643 * Setter for house number extension
645 * @param houseNumberExtension House number extension
647 public void setHouseNumberExtension (final String houseNumberExtension) {
648 this.houseNumberExtension = houseNumberExtension;
652 * Getter for land-line number's area code
654 * @return Land-line number's area code
656 public Integer getLandLineAreaCode () {
657 return this.landLineAreaCode;
661 * Setter for land-line number's area code
663 * @param landLineAreaCode Land-line number's area code
665 public void setLandLineAreaCode (final Integer landLineAreaCode) {
666 this.landLineAreaCode = landLineAreaCode;
670 * Getter for land-line number's country instance
672 * @return Land-line number's country instance
674 public Country getLandLineCountry () {
675 return this.landLineCountry;
679 * Setter for land-line number's country instance
681 * @param landLineCountry Land-line number's country instance
683 public void setLandLineCountry (final Country landLineCountry) {
684 this.landLineCountry = landLineCountry;
688 * Getter for land-line number
690 * @return Land-line number
692 public Long getLandLineNumber () {
693 return this.landLineNumber;
697 * Setter for land-line number
699 * @param landLineNumber Land-line number
701 public void setLandLineNumber (final Long landLineNumber) {
702 this.landLineNumber = landLineNumber;
706 * Getter for mobile number
708 * @return Mobile number
710 public Long getMobileNumber () {
711 return this.mobileNumber;
715 * Setter for mobile number
717 * @param mobileNumber Mobile number
719 public void setMobileNumber (final Long mobileNumber) {
720 this.mobileNumber = mobileNumber;
724 * Getter for mobile number's carrier
726 * @return Mobile number's carrier
728 public MobileProvider getMobileProvider () {
729 return this.mobileProvider;
733 * Setter for mobile number's provider
735 * @param mobileProvider Mobile number's provider
737 public void setMobileProvider (final MobileProvider mobileProvider) {
738 this.mobileProvider = mobileProvider;
742 * Getter for personal title
744 * @return Personal title
746 public PersonalTitle getPersonalTitle () {
747 return this.personalTitle;
751 * Setter for personal title
753 * @param personalTitle Personal title
755 public void setPersonalTitle (final PersonalTitle personalTitle) {
756 this.personalTitle = personalTitle;
764 public String getStreet () {
771 * @param street Street
773 public void setStreet (final String street) {
774 this.street = street;
778 * Getter for ZIP code
782 public Integer getZipCode () {
787 * Setter for ZIP code
789 * @param zipCode ZIP code
791 public void setZipCode (final Integer zipCode) {
792 this.zipCode = zipCode;
796 public boolean isEmailAddressRegistered (final Contact contact) {
798 if (null == contact) {
800 throw new NullPointerException("contact is null"); //NOI18N
801 } else if (contact.getContactEmailAddress() == null) {
803 throw new NullPointerException("contact.contactEmailAddress is null"); //NOI18N
804 } else if (contact.getContactEmailAddress().isEmpty()) {
806 throw new IllegalArgumentException("contact.contactEmailAddress is empty."); //NOI18N
809 // Default is not registered
810 boolean isRegistered = false;
813 for (final Contact currentContact : this.contactListController.getAllContacts()) {
814 // Is same contact found?
815 if (currentContact.getContactEmailAddress().equals(contact.getContactEmailAddress())) {
816 // Found same email address
819 // Skipp further iterations
829 public boolean isEmailAddressRegistered (final String emailAddress) {
830 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
834 public boolean isRequiredChangePersonalDataSet () {
835 return ((this.getPersonalTitle() != null) &&
836 (this.getFirstName() != null) &&
837 (this.getFamilyName() != null) &&
838 (this.getStreet() != null) &&
839 (this.getHouseNumber() != null) &&
840 (this.getZipCode() != null) &&
841 (this.getCity() != null));
845 public boolean isRequiredPersonalDataSet () {
846 return ((this.getPersonalTitle() != null) &&
847 (this.getFirstName() != null) &&
848 (this.getFamilyName() != null) &&
849 (this.getStreet() != null) &&
850 (this.getHouseNumber() != null) &&
851 (this.getZipCode() != null) &&
852 (this.getCity() != null) &&
853 (this.getEmailAddress() != null) &&
854 (this.getEmailAddressRepeat() != null));
858 public boolean isSameEmailAddressEntered () {
859 return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
865 private void clear () {
868 this.setPersonalTitle(null);
869 this.setAcademicTitle(null);
870 this.setFirstName(null);
871 this.setFamilyName(null);
872 this.setStreet(null);
873 this.setHouseNumber(null);
874 this.setHouseNumberExtension(null);
875 this.setZipCode(null);
877 this.setCountry(null);
880 this.clearEmailAddresses();
881 this.setLandLineAreaCode(null);
882 this.setLandLineCountry(null);
883 this.setLandLineNumber(null);
884 this.setMobileProvider(null);
885 this.setMobileNumber(null);
886 this.setFaxAreaCode(null);
887 this.setFaxCountry(null);
888 this.setFaxNumber(null);
891 this.setBirthday(null);
892 this.setComment(null);
896 * Copies given contact data into the controller
898 * @param contact Contact instance
900 private void copyFromContact (final Contact contact) {
903 this.setPersonalTitle(contact.getContactPersonalTitle());
904 this.setAcademicTitle(contact.getContactTitle());
905 this.setFirstName(contact.getContactFirstName());
906 this.setFamilyName(contact.getContactFamilyName());
907 this.setStreet(contact.getContactStreet());
908 this.setHouseNumber(contact.getContactHouseNumber());
909 this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
910 this.setZipCode(contact.getContactZipCode());
911 this.setCity(contact.getContactCity());
912 this.setCountry(contact.getContactCountry());
913 this.setEmailAddress(contact.getContactEmailAddress());
914 this.setBirthday(contact.getContactBirthday());
915 this.setComment(contact.getContactComment());
917 // Get mobile, phone and fax instance
918 final DialableFaxNumber fax = contact.getContactFaxNumber();
919 final DialableLandLineNumber landLine = contact.getContactLandLineNumber();
920 final DialableMobileNumber mobile = contact.getContactMobileNumber();
922 // Is a fax number set?
923 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
925 this.setFaxCountry(fax.getPhoneCountry());
926 this.setFaxAreaCode(fax.getPhoneAreaCode());
927 this.setFaxNumber(fax.getPhoneNumber());
930 // Is a land-line number set?
931 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneAreaCode() > 0)) {
933 this.setLandLineCountry(landLine.getPhoneCountry());
934 this.setLandLineAreaCode(landLine.getPhoneAreaCode());
935 this.setLandLineNumber(landLine.getPhoneNumber());
938 // Is a mobile number set?
939 if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
941 this.setMobileProvider(mobile.getMobileProvider());
942 this.setMobileNumber(mobile.getMobileNumber());
947 * Copies all fields from this backing bean into given instance.
949 * @param contact An instance of a Contact class
951 private void copyToContact (final Contact contact) {
952 // Set other elements
953 contact.setContactStreet(this.getStreet());
954 contact.setContactHouseNumber(this.getHouseNumber());
955 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
956 contact.setContactZipCode(this.getZipCode());
957 contact.setContactCity(this.getCity());
958 contact.setContactCountry(this.getCountry());
959 contact.setContactEmailAddress(this.getEmailAddress());
960 contact.setContactBirthday(this.getBirthday());
961 contact.setContactComment(this.getComment());
963 // Generate phone number
964 final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
965 final DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
966 final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
968 // Don't set null or wrong references
969 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
970 // Now the number must be given
971 if (landLine.getPhoneAreaCode() == null) {
973 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
974 } else if (landLine.getPhoneAreaCode() < 1) {
976 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
977 } else if (landLine.getPhoneNumber() == null) {
979 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
980 } else if (landLine.getPhoneNumber() < 1) {
982 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
986 contact.setContactLandLineNumber(landLine);
989 // Don't set null or wrong references
990 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
991 // Now the number must be given
992 if (fax.getPhoneAreaCode() == null) {
994 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
995 } else if (fax.getPhoneAreaCode() < 1) {
997 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
998 } else if (fax.getPhoneNumber() == null) {
1000 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
1001 } else if (fax.getPhoneNumber() < 1) {
1003 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
1007 contact.setContactFaxNumber(fax);
1010 // Is the provider set?
1011 if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
1012 // Is the number set?
1013 if (mobile.getMobileNumber() == null) {
1015 throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
1016 } else if (mobile.getMobileNumber() < 1) {
1018 throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
1021 // Set mobile number
1022 contact.setContactMobileNumber(mobile);