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;
109 * Event being fired when a user has updated his contact data
113 private Event<ObservableUpdatedContactEvent> contactUpdatedEvent;
118 private Country country;
123 private String emailAddress;
126 * Email address repeated
128 private String emailAddressRepeat;
133 private String familyName;
136 * Fax number's area code
138 private Integer faxAreaCode;
141 * Country instance for fax number
143 private Country faxCountry;
148 private Long faxNumber;
153 private String firstName;
158 private Short houseNumber;
161 * House number extension
163 private String houseNumberExtension;
166 * Phone number area code
168 private Integer landLineAreaCode;
171 * Country instance for phone number
173 private Country landLineCountry;
178 private Long landLineNumber;
183 private Long mobileNumber;
186 * Mobile number's carrier
188 private MobileProvider mobileProvider;
191 * Personal academicTitle
193 private PersonalTitle personalTitle;
198 private String street;
201 * Login bean (controller)
204 private JobsUserLoginWebSessionController userLoginController;
209 private Integer zipCode;
212 * Default constructor
214 public JobsContactWebRequestBean () {
215 // Call super constructor
220 * Event observer for newly added users by administrator
222 * @param event Event being fired
224 public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
225 // Event and contained entity instance should not be null
228 throw new NullPointerException("event is null"); //NOI18N
229 } else if (event.getAddedUser() == null) {
231 throw new NullPointerException("event.addedUser is null"); //NOI18N
232 } else if (event.getAddedUser().getUserId() == null) {
234 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
235 } else if (event.getAddedUser().getUserId() < 1) {
237 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
245 * Observes events being fired when an administrator has linked a new user
246 * with existing contact data.
248 * @param event Event being fired
250 public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
251 // Event and contained entity instance should not be null
254 throw new NullPointerException("event is null"); //NOI18N
255 } else if (event.getLinkedUser() == null) {
257 throw new NullPointerException("event.linkedUser is null"); //NOI18N
258 } else if (event.getLinkedUser().getUserContact() == null) {
260 throw new NullPointerException("event.linkedUser.userContact is null"); //NOI18N
261 } else if (event.getLinkedUser().getUserContact().getContactId() == null) {
263 throw new NullPointerException("event.linkedUser.userContact.contactId is null"); //NOI18N
264 } else if (event.getLinkedUser().getUserContact().getContactId() < 1) {
266 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserContact().getContactId())); //NOI18N
274 * Event observer for logged-in user
276 * @param event Event instance
278 public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
279 // Event and contained entity instance should not be null
282 throw new NullPointerException("event is null"); //NOI18N
283 } else if (event.getLoggedInUser() == null) {
285 throw new NullPointerException("event.loggedInUser is null"); //NOI18N
286 } else if (event.getLoggedInUser().getUserId() == null) {
288 throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
289 } else if (event.getLoggedInUser().getUserId() < 1) {
291 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
294 // Copy all data to this bean
295 this.copyFromContact(event.getLoggedInUser().getUserContact());
299 * Observes events being fired before an updated of personal data done by a
302 * @param event Event being observed
304 public void beforeUserUpdatedPersonalDataEvent (@Observes final ObservablePreUserPersonalDataUpdatedEvent event) {
305 // Is the instance valid?
308 throw new NullPointerException("event is null"); //NOI18N
309 } else if (event.getUpdatedUser() == null) {
311 throw new NullPointerException("event.updatedUser is null"); //NOI18N
315 this.copyToContact(event.getUpdatedUser().getUserContact());
319 public void clearEmailAddresses () {
321 this.setEmailAddress(null);
322 this.setEmailAddressRepeat(null);
326 public Contact createContactInstance () {
327 // Is all required data set?
328 if (!this.isRequiredPersonalDataSet()) {
329 // No, then abort here
330 throw new FacesException(new IllegalArgumentException("Not all personal data is set, but createContactInstance() is called.")); //NOI18N
333 // Required personal data must be set
334 assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
336 // Create new contact
337 final Contact contact = new UserContact(
338 this.getPersonalTitle(),
348 public String doChangePersonalContactData () {
349 // This method shall only be called if the user is logged-in
350 if (!this.userLoginController.isUserLoggedIn()) {
352 throw new IllegalStateException("User is not logged-in"); //NOI18N
353 } else if (!this.isRequiredChangePersonalDataSet()) {
354 // Not all required fields are set
355 throw new FacesException("Not all required fields are set."); //NOI18N
356 } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
357 // Password not matching
358 this.showFacesMessage("form_login_change_personal:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()), FacesMessage.SEVERITY_ERROR); //NOI18N
362 // Get contact instance
363 final Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
365 // It should be there, so run some tests on it
366 assert (contact instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
367 assert (contact.getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
368 assert (contact.getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
371 contact.setContactPersonalTitle(this.getPersonalTitle());
372 contact.setContactFirstName(this.getFirstName());
373 contact.setContactFamilyName(this.getFamilyName());
374 contact.setContactStreet(this.getStreet());
375 contact.setContactHouseNumber(this.getHouseNumber());
376 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
377 contact.setContactZipCode(this.getZipCode());
378 contact.setContactCity(this.getCity());
379 contact.setContactCountry(this.getCountry());
381 // Update contact's mobile number
382 final boolean isMobileUnlinked = Contacts.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
384 // Update contact's land-line number
385 final boolean isLandLineUnlinked = Contacts.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
387 // Update contact's fax number
388 final boolean isFaxUnlinked = Contacts.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
390 // Init updated contact instance
391 final Contact updatedContact;
394 // Send it to the EJB
395 updatedContact = this.contactBean.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
396 } catch (final ContactNotFoundException ex) {
398 throw new FacesException(ex);
402 this.contactUpdatedEvent.fire(new UpdatedContactEvent(updatedContact));
405 return "contact_data_saved"; //NOI18N
409 * Getter for academic title
411 * @return Academic title
413 public String getAcademicTitle () {
414 return this.academicTitle;
418 * Setter for academic title
420 * @param academicTitle Academic title
422 public void setAcademicTitle (final String academicTitle) {
423 this.academicTitle = academicTitle;
427 * Getter for birth day
431 @SuppressWarnings ("ReturnOfDateField")
432 public Date getBirthday () {
433 return this.birthday;
437 * Setter for birth day
439 * @param birthday Birth day
441 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
442 public void setBirthday (final Date birthday) {
443 this.birthday = birthday;
447 * Getter for city name
451 public String getCity () {
456 * Setter for city name
458 * @param city City name
460 public void setCity (final String city) {
465 * Getter for comments
469 public String getComment () {
476 * @param comment Comments
478 public void setComment (final String comment) {
479 this.comment = comment;
483 public String getControllerType () {
484 return "general"; //NOI18N
489 public void setControllerType (final String controllerType) {
490 throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
494 * Getter for country instance
496 * @return Country instance
498 public Country getCountry () {
503 * Setter for country instance
505 * @param country Country instance
507 public void setCountry (final Country country) {
508 this.country = country;
512 public String getEmailAddress () {
513 return this.emailAddress;
517 * Setter for email address
519 * @param emailAddress Email address
521 public void setEmailAddress (final String emailAddress) {
522 this.emailAddress = emailAddress;
526 * Getter for email address, repeated
528 * @return the emailAddress, repeated
530 public String getEmailAddressRepeat () {
531 return this.emailAddressRepeat;
535 * Setter for email address repeated
537 * @param emailAddressRepeat the emailAddress to set
539 public void setEmailAddressRepeat (final String emailAddressRepeat) {
540 this.emailAddressRepeat = emailAddressRepeat;
546 * @return the familyName
548 public String getFamilyName () {
549 return this.familyName;
555 * @param familyName the familyName to set
557 public void setFamilyName (final String familyName) {
558 this.familyName = familyName;
562 * Getter for fax number's area code
564 * @return Fax number's area code
566 public Integer getFaxAreaCode () {
567 return this.faxAreaCode;
571 * Setter for fax number's area code
573 * @param faxAreaCode Fax number's area code
575 public void setFaxAreaCode (final Integer faxAreaCode) {
576 this.faxAreaCode = faxAreaCode;
580 * Getter for fax's country instance
582 * @return Fax' country instance
584 public Country getFaxCountry () {
585 return this.faxCountry;
589 * Setter for fax's country instance
591 * @param faxCountry Fax' country instance
593 public void setFaxCountry (final Country faxCountry) {
594 this.faxCountry = faxCountry;
598 * Getter for fax number
602 public Long getFaxNumber () {
603 return this.faxNumber;
607 * Setter for fax number
609 * @param faxNumber Fax number
611 public void setFaxNumber (final Long faxNumber) {
612 this.faxNumber = faxNumber;
618 * @return the first name
620 public String getFirstName () {
621 return this.firstName;
627 * @param firstName the first name to set
629 public void setFirstName (final String firstName) {
630 this.firstName = firstName;
636 * @return the houseNumber
638 public Short getHouseNumber () {
639 return this.houseNumber;
645 * @param houseNumber the houseNumber to set
647 public void setHouseNumber (final Short houseNumber) {
648 this.houseNumber = houseNumber;
652 * Getter for house number extension, example: 123a 'a' is then the
653 * extension and 123 is the house number.
655 * @return House number extension
657 public String getHouseNumberExtension () {
658 return this.houseNumberExtension;
662 * Setter for house number extension
664 * @param houseNumberExtension House number extension
666 public void setHouseNumberExtension (final String houseNumberExtension) {
667 this.houseNumberExtension = houseNumberExtension;
671 * Getter for land-line number's area code
673 * @return Land-line number's area code
675 public Integer getLandLineAreaCode () {
676 return this.landLineAreaCode;
680 * Setter for land-line number's area code
682 * @param landLineAreaCode Land-line number's area code
684 public void setLandLineAreaCode (final Integer landLineAreaCode) {
685 this.landLineAreaCode = landLineAreaCode;
689 * Getter for land-line number's country instance
691 * @return Land-line number's country instance
693 public Country getLandLineCountry () {
694 return this.landLineCountry;
698 * Setter for land-line number's country instance
700 * @param landLineCountry Land-line number's country instance
702 public void setLandLineCountry (final Country landLineCountry) {
703 this.landLineCountry = landLineCountry;
707 * Getter for land-line number
709 * @return Land-line number
711 public Long getLandLineNumber () {
712 return this.landLineNumber;
716 * Setter for land-line number
718 * @param landLineNumber Land-line number
720 public void setLandLineNumber (final Long landLineNumber) {
721 this.landLineNumber = landLineNumber;
725 * Getter for mobile number
727 * @return Mobile number
729 public Long getMobileNumber () {
730 return this.mobileNumber;
734 * Setter for mobile number
736 * @param mobileNumber Mobile number
738 public void setMobileNumber (final Long mobileNumber) {
739 this.mobileNumber = mobileNumber;
743 * Getter for mobile number's carrier
745 * @return Mobile number's carrier
747 public MobileProvider getMobileProvider () {
748 return this.mobileProvider;
752 * Setter for mobile number's provider
754 * @param mobileProvider Mobile number's provider
756 public void setMobileProvider (final MobileProvider mobileProvider) {
757 this.mobileProvider = mobileProvider;
761 * Getter for personal title
763 * @return Personal title
765 public PersonalTitle getPersonalTitle () {
766 return this.personalTitle;
770 * Setter for personal title
772 * @param personalTitle Personal title
774 public void setPersonalTitle (final PersonalTitle personalTitle) {
775 this.personalTitle = personalTitle;
783 public String getStreet () {
790 * @param street Street
792 public void setStreet (final String street) {
793 this.street = street;
797 * Getter for ZIP code
801 public Integer getZipCode () {
806 * Setter for ZIP code
808 * @param zipCode ZIP code
810 public void setZipCode (final Integer zipCode) {
811 this.zipCode = zipCode;
815 public boolean isEmailAddressRegistered (final Contact contact) {
817 if (null == contact) {
819 throw new NullPointerException("contact is null"); //NOI18N
820 } else if (contact.getContactEmailAddress() == null) {
822 throw new NullPointerException("contact.contactEmailAddress is null"); //NOI18N
823 } else if (contact.getContactEmailAddress().isEmpty()) {
825 throw new IllegalArgumentException("contact.contactEmailAddress is empty."); //NOI18N
828 // Default is not registered
829 boolean isRegistered = false;
832 for (final Contact currentContact : this.contactListController.getAllContacts()) {
833 // Is same contact found?
834 if (currentContact.getContactEmailAddress().equals(contact.getContactEmailAddress())) {
835 // Found same email address
838 // Skipp further iterations
848 public boolean isEmailAddressRegistered (final String emailAddress) {
849 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
853 public boolean isRequiredChangePersonalDataSet () {
854 return ((this.getPersonalTitle() != null) &&
855 (this.getFirstName() != null) &&
856 (this.getFamilyName() != null) &&
857 (this.getStreet() != null) &&
858 (this.getHouseNumber() != null) &&
859 (this.getZipCode() != null) &&
860 (this.getCity() != null));
864 public boolean isRequiredPersonalDataSet () {
865 return ((this.getPersonalTitle() != null) &&
866 (this.getFirstName() != null) &&
867 (this.getFamilyName() != null) &&
868 (this.getStreet() != null) &&
869 (this.getHouseNumber() != null) &&
870 (this.getZipCode() != null) &&
871 (this.getCity() != null) &&
872 (this.getEmailAddress() != null) &&
873 (this.getEmailAddressRepeat() != null));
877 public boolean isSameEmailAddressEntered () {
878 return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
884 private void clear () {
887 this.setPersonalTitle(null);
888 this.setAcademicTitle(null);
889 this.setFirstName(null);
890 this.setFamilyName(null);
891 this.setStreet(null);
892 this.setHouseNumber(null);
893 this.setHouseNumberExtension(null);
894 this.setZipCode(null);
896 this.setCountry(null);
899 this.clearEmailAddresses();
900 this.setLandLineAreaCode(null);
901 this.setLandLineCountry(null);
902 this.setLandLineNumber(null);
903 this.setMobileProvider(null);
904 this.setMobileNumber(null);
905 this.setFaxAreaCode(null);
906 this.setFaxCountry(null);
907 this.setFaxNumber(null);
910 this.setBirthday(null);
911 this.setComment(null);
915 * Copies given contact data into the controller
917 * @param contact Contact instance
919 private void copyFromContact (final Contact contact) {
922 this.setPersonalTitle(contact.getContactPersonalTitle());
923 this.setAcademicTitle(contact.getContactTitle());
924 this.setFirstName(contact.getContactFirstName());
925 this.setFamilyName(contact.getContactFamilyName());
926 this.setStreet(contact.getContactStreet());
927 this.setHouseNumber(contact.getContactHouseNumber());
928 this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
929 this.setZipCode(contact.getContactZipCode());
930 this.setCity(contact.getContactCity());
931 this.setCountry(contact.getContactCountry());
932 this.setEmailAddress(contact.getContactEmailAddress());
933 this.setBirthday(contact.getContactBirthday());
934 this.setComment(contact.getContactComment());
936 // Get mobile, phone and fax instance
937 final DialableFaxNumber fax = contact.getContactFaxNumber();
938 final DialableLandLineNumber landLine = contact.getContactLandLineNumber();
939 final DialableMobileNumber mobile = contact.getContactMobileNumber();
941 // Is a fax number set?
942 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
944 this.setFaxCountry(fax.getPhoneCountry());
945 this.setFaxAreaCode(fax.getPhoneAreaCode());
946 this.setFaxNumber(fax.getPhoneNumber());
949 // Is a land-line number set?
950 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneAreaCode() > 0)) {
952 this.setLandLineCountry(landLine.getPhoneCountry());
953 this.setLandLineAreaCode(landLine.getPhoneAreaCode());
954 this.setLandLineNumber(landLine.getPhoneNumber());
957 // Is a mobile number set?
958 if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
960 this.setMobileProvider(mobile.getMobileProvider());
961 this.setMobileNumber(mobile.getMobileNumber());
966 * Copies all fields from this backing bean into given instance.
968 * @param contact An instance of a Contact class
970 private void copyToContact (final Contact contact) {
971 // Set other elements
972 contact.setContactStreet(this.getStreet());
973 contact.setContactHouseNumber(this.getHouseNumber());
974 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
975 contact.setContactZipCode(this.getZipCode());
976 contact.setContactCity(this.getCity());
977 contact.setContactCountry(this.getCountry());
978 contact.setContactEmailAddress(this.getEmailAddress());
979 contact.setContactBirthday(this.getBirthday());
980 contact.setContactComment(this.getComment());
982 // Generate phone number
983 final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
984 final DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
985 final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
987 // Don't set null or wrong references
988 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
989 // Now the number must be given
990 if (landLine.getPhoneAreaCode() == null) {
992 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
993 } else if (landLine.getPhoneAreaCode() < 1) {
995 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
996 } else if (landLine.getPhoneNumber() == null) {
998 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
999 } else if (landLine.getPhoneNumber() < 1) {
1001 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
1005 contact.setContactLandLineNumber(landLine);
1008 // Don't set null or wrong references
1009 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
1010 // Now the number must be given
1011 if (fax.getPhoneAreaCode() == null) {
1013 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
1014 } else if (fax.getPhoneAreaCode() < 1) {
1016 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
1017 } else if (fax.getPhoneNumber() == null) {
1019 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
1020 } else if (fax.getPhoneNumber() < 1) {
1022 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
1026 contact.setContactFaxNumber(fax);
1029 // Is the provider set?
1030 if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
1031 // Is the number set?
1032 if (mobile.getMobileNumber() == null) {
1034 throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
1035 } else if (mobile.getMobileNumber() < 1) {
1037 throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
1040 // Set mobile number
1041 contact.setContactMobileNumber(mobile);