2 * Copyright (C) 2016 - 2020 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.jjobs.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.contact.Contacts;
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.jjobs.beans.BaseJobsBean;
41 import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController;
42 import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
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 controller (bean)
59 * @author Roland Häder<roland@mxchange.org>
61 @Named ("contactController")
63 public class JobsContactWebRequestBean extends BaseJobsBean implements JobsContactWebRequestController {
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/jjobs-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote")
94 private ContactSessionBeanRemote contactBean;
97 * An instance of a contact-list backing bean
99 private JobsContactListWebViewController 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 JobsUserLoginWebSessionController userLoginController;
202 private Integer zipCode;
205 * Default constructor
207 public JobsContactWebRequestBean () {
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 = Contacts.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
377 // Update contact's land-line number
378 final boolean isLandLineUnlinked = Contacts.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
380 // Update contact's fax number
381 final boolean isFaxUnlinked = Contacts.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 public String getControllerType () {
477 return "general"; //NOI18N
482 public void setControllerType (final String controllerType) {
483 throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
487 * Getter for country instance
489 * @return Country instance
491 public Country getCountry () {
496 * Setter for country instance
498 * @param country Country instance
500 public void setCountry (final Country country) {
501 this.country = country;
505 public String getEmailAddress () {
506 return this.emailAddress;
510 * Setter for email address
512 * @param emailAddress Email address
514 public void setEmailAddress (final String emailAddress) {
515 this.emailAddress = emailAddress;
519 * Getter for email address, repeated
521 * @return the emailAddress, repeated
523 public String getEmailAddressRepeat () {
524 return this.emailAddressRepeat;
528 * Setter for email address repeated
530 * @param emailAddressRepeat the emailAddress to set
532 public void setEmailAddressRepeat (final String emailAddressRepeat) {
533 this.emailAddressRepeat = emailAddressRepeat;
539 * @return the familyName
541 public String getFamilyName () {
542 return this.familyName;
548 * @param familyName the familyName to set
550 public void setFamilyName (final String familyName) {
551 this.familyName = familyName;
555 * Getter for fax number's area code
557 * @return Fax number's area code
559 public Integer getFaxAreaCode () {
560 return this.faxAreaCode;
564 * Setter for fax number's area code
566 * @param faxAreaCode Fax number's area code
568 public void setFaxAreaCode (final Integer faxAreaCode) {
569 this.faxAreaCode = faxAreaCode;
573 * Getter for fax's country instance
575 * @return Fax' country instance
577 public Country getFaxCountry () {
578 return this.faxCountry;
582 * Setter for fax's country instance
584 * @param faxCountry Fax' country instance
586 public void setFaxCountry (final Country faxCountry) {
587 this.faxCountry = faxCountry;
591 * Getter for fax number
595 public Long getFaxNumber () {
596 return this.faxNumber;
600 * Setter for fax number
602 * @param faxNumber Fax number
604 public void setFaxNumber (final Long faxNumber) {
605 this.faxNumber = faxNumber;
611 * @return the first name
613 public String getFirstName () {
614 return this.firstName;
620 * @param firstName the first name to set
622 public void setFirstName (final String firstName) {
623 this.firstName = firstName;
629 * @return the houseNumber
631 public Short getHouseNumber () {
632 return this.houseNumber;
638 * @param houseNumber the houseNumber to set
640 public void setHouseNumber (final Short houseNumber) {
641 this.houseNumber = houseNumber;
645 * Getter for house number extension, example: 123a 'a' is then the
646 * extension and 123 is the house number.
648 * @return House number extension
650 public String getHouseNumberExtension () {
651 return this.houseNumberExtension;
655 * Setter for house number extension
657 * @param houseNumberExtension House number extension
659 public void setHouseNumberExtension (final String houseNumberExtension) {
660 this.houseNumberExtension = houseNumberExtension;
664 * Getter for land-line number's area code
666 * @return Land-line number's area code
668 public Integer getLandLineAreaCode () {
669 return this.landLineAreaCode;
673 * Setter for land-line number's area code
675 * @param landLineAreaCode Land-line number's area code
677 public void setLandLineAreaCode (final Integer landLineAreaCode) {
678 this.landLineAreaCode = landLineAreaCode;
682 * Getter for land-line number's country instance
684 * @return Land-line number's country instance
686 public Country getLandLineCountry () {
687 return this.landLineCountry;
691 * Setter for land-line number's country instance
693 * @param landLineCountry Land-line number's country instance
695 public void setLandLineCountry (final Country landLineCountry) {
696 this.landLineCountry = landLineCountry;
700 * Getter for land-line number
702 * @return Land-line number
704 public Long getLandLineNumber () {
705 return this.landLineNumber;
709 * Setter for land-line number
711 * @param landLineNumber Land-line number
713 public void setLandLineNumber (final Long landLineNumber) {
714 this.landLineNumber = landLineNumber;
718 * Getter for mobile number
720 * @return Mobile number
722 public Long getMobileNumber () {
723 return this.mobileNumber;
727 * Setter for mobile number
729 * @param mobileNumber Mobile number
731 public void setMobileNumber (final Long mobileNumber) {
732 this.mobileNumber = mobileNumber;
736 * Getter for mobile number's carrier
738 * @return Mobile number's carrier
740 public MobileProvider getMobileProvider () {
741 return this.mobileProvider;
745 * Setter for mobile number's provider
747 * @param mobileProvider Mobile number's provider
749 public void setMobileProvider (final MobileProvider mobileProvider) {
750 this.mobileProvider = mobileProvider;
754 * Getter for personal title
756 * @return Personal title
758 public PersonalTitle getPersonalTitle () {
759 return this.personalTitle;
763 * Setter for personal title
765 * @param personalTitle Personal title
767 public void setPersonalTitle (final PersonalTitle personalTitle) {
768 this.personalTitle = personalTitle;
776 public String getStreet () {
783 * @param street Street
785 public void setStreet (final String street) {
786 this.street = street;
790 * Getter for ZIP code
794 public Integer getZipCode () {
799 * Setter for ZIP code
801 * @param zipCode ZIP code
803 public void setZipCode (final Integer zipCode) {
804 this.zipCode = zipCode;
808 public boolean isEmailAddressRegistered (final Contact contact) {
810 if (null == contact) {
812 throw new NullPointerException("contact is null"); //NOI18N
813 } else if (contact.getContactEmailAddress() == null) {
815 throw new NullPointerException("contact.contactEmailAddress is null"); //NOI18N
816 } else if (contact.getContactEmailAddress().isEmpty()) {
818 throw new IllegalArgumentException("contact.contactEmailAddress is empty."); //NOI18N
821 // Default is not registered
822 boolean isRegistered = false;
825 for (final Contact currentContact : this.contactListController.getAllContacts()) {
826 // Is same contact found?
827 if (currentContact.getContactEmailAddress().equals(contact.getContactEmailAddress())) {
828 // Found same email address
831 // Skipp further iterations
841 public boolean isEmailAddressRegistered (final String emailAddress) {
842 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
846 public boolean isRequiredChangePersonalDataSet () {
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));
857 public boolean isRequiredPersonalDataSet () {
858 return ((this.getPersonalTitle() != null) &&
859 (this.getFirstName() != null) &&
860 (this.getFamilyName() != null) &&
861 (this.getStreet() != null) &&
862 (this.getHouseNumber() != null) &&
863 (this.getZipCode() != null) &&
864 (this.getCity() != null) &&
865 (this.getEmailAddress() != null) &&
866 (this.getEmailAddressRepeat() != null));
870 public boolean isSameEmailAddressEntered () {
871 return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
877 private void clear () {
880 this.setPersonalTitle(null);
881 this.setAcademicTitle(null);
882 this.setFirstName(null);
883 this.setFamilyName(null);
884 this.setStreet(null);
885 this.setHouseNumber(null);
886 this.setHouseNumberExtension(null);
887 this.setZipCode(null);
889 this.setCountry(null);
892 this.clearEmailAddresses();
893 this.setLandLineAreaCode(null);
894 this.setLandLineCountry(null);
895 this.setLandLineNumber(null);
896 this.setMobileProvider(null);
897 this.setMobileNumber(null);
898 this.setFaxAreaCode(null);
899 this.setFaxCountry(null);
900 this.setFaxNumber(null);
903 this.setBirthday(null);
904 this.setComment(null);
908 * Copies given contact data into the controller
910 * @param contact Contact instance
912 private void copyFromContact (final Contact contact) {
915 this.setPersonalTitle(contact.getContactPersonalTitle());
916 this.setAcademicTitle(contact.getContactTitle());
917 this.setFirstName(contact.getContactFirstName());
918 this.setFamilyName(contact.getContactFamilyName());
919 this.setStreet(contact.getContactStreet());
920 this.setHouseNumber(contact.getContactHouseNumber());
921 this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
922 this.setZipCode(contact.getContactZipCode());
923 this.setCity(contact.getContactCity());
924 this.setCountry(contact.getContactCountry());
925 this.setEmailAddress(contact.getContactEmailAddress());
926 this.setBirthday(contact.getContactBirthday());
927 this.setComment(contact.getContactComment());
929 // Get mobile, phone and fax instance
930 final DialableFaxNumber fax = contact.getContactFaxNumber();
931 final DialableLandLineNumber landLine = contact.getContactLandLineNumber();
932 final DialableMobileNumber mobile = contact.getContactMobileNumber();
934 // Is a fax number set?
935 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
937 this.setFaxCountry(fax.getPhoneCountry());
938 this.setFaxAreaCode(fax.getPhoneAreaCode());
939 this.setFaxNumber(fax.getPhoneNumber());
942 // Is a land-line number set?
943 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneAreaCode() > 0)) {
945 this.setLandLineCountry(landLine.getPhoneCountry());
946 this.setLandLineAreaCode(landLine.getPhoneAreaCode());
947 this.setLandLineNumber(landLine.getPhoneNumber());
950 // Is a mobile number set?
951 if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
953 this.setMobileProvider(mobile.getMobileProvider());
954 this.setMobileNumber(mobile.getMobileNumber());
959 * Copies all fields from this backing bean into given instance.
961 * @param contact An instance of a Contact class
963 private void copyToContact (final Contact contact) {
964 // Set other elements
965 contact.setContactStreet(this.getStreet());
966 contact.setContactHouseNumber(this.getHouseNumber());
967 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
968 contact.setContactZipCode(this.getZipCode());
969 contact.setContactCity(this.getCity());
970 contact.setContactCountry(this.getCountry());
971 contact.setContactEmailAddress(this.getEmailAddress());
972 contact.setContactBirthday(this.getBirthday());
973 contact.setContactComment(this.getComment());
975 // Generate phone number
976 final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
977 final DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
978 final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
980 // Don't set null or wrong references
981 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
982 // Now the number must be given
983 if (landLine.getPhoneAreaCode() == null) {
985 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
986 } else if (landLine.getPhoneAreaCode() < 1) {
988 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
989 } else if (landLine.getPhoneNumber() == null) {
991 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
992 } else if (landLine.getPhoneNumber() < 1) {
994 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
998 contact.setContactLandLineNumber(landLine);
1001 // Don't set null or wrong references
1002 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
1003 // Now the number must be given
1004 if (fax.getPhoneAreaCode() == null) {
1006 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
1007 } else if (fax.getPhoneAreaCode() < 1) {
1009 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
1010 } else if (fax.getPhoneNumber() == null) {
1012 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
1013 } else if (fax.getPhoneNumber() < 1) {
1015 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
1019 contact.setContactFaxNumber(fax);
1022 // Is the provider set?
1023 if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
1024 // Is the number set?
1025 if (mobile.getMobileNumber() == null) {
1027 throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
1028 } else if (mobile.getMobileNumber() < 1) {
1030 throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
1033 // Set mobile number
1034 contact.setContactMobileNumber(mobile);