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.Observes;
25 import javax.faces.FacesException;
26 import javax.faces.application.FacesMessage;
27 import javax.inject.Inject;
28 import javax.inject.Named;
29 import org.mxchange.jcontacts.model.contact.Contact;
30 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
31 import org.mxchange.jcontacts.model.contact.Contacts;
32 import org.mxchange.jcontacts.model.contact.UserContact;
33 import org.mxchange.jcontacts.model.contact.title.PersonalTitle;
34 import org.mxchange.jcountry.model.data.Country;
35 import org.mxchange.jjobs.beans.BaseJobsBean;
36 import org.mxchange.jjobs.beans.contact.list.JobsContactListWebViewController;
37 import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
38 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
39 import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
40 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
41 import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
42 import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
43 import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
44 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
45 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
46 import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
47 import org.mxchange.jusercore.events.user.update.pre.ObservablePreUserPersonalDataUpdatedEvent;
48 import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
49 import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
52 * A general contact controller (bean)
54 * @author Roland Häder<roland@mxchange.org>
56 @Named ("contactController")
58 public class JobsContactWebRequestBean extends BaseJobsBean implements JobsContactWebRequestController {
63 private static final long serialVersionUID = 542_145_347_916L;
66 * Academic academicTitle
68 private String academicTitle;
73 private Date birthday;
83 private String comment;
86 * EJB for general contact purposes
88 @EJB (lookup = "java:global/jjobs-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote")
89 private ContactSessionBeanRemote contactBean;
92 * An instance of a contact-list backing bean
94 private JobsContactListWebViewController contactListController;
99 private Country country;
104 private String emailAddress;
107 * Email address repeated
109 private String emailAddressRepeat;
114 private String familyName;
117 * Fax number's area code
119 private Integer faxAreaCode;
122 * Country instance for fax number
124 private Country faxCountry;
129 private Long faxNumber;
134 private String firstName;
139 private Short houseNumber;
142 * House number extension
144 private String houseNumberExtension;
147 * Phone number area code
149 private Integer landLineAreaCode;
152 * Country instance for phone number
154 private Country landLineCountry;
159 private Long landLineNumber;
164 private Long mobileNumber;
167 * Mobile number's carrier
169 private MobileProvider mobileProvider;
172 * Personal academicTitle
174 private PersonalTitle personalTitle;
179 private String street;
182 * Login bean (controller)
185 private JobsUserLoginWebSessionController userLoginController;
190 private Integer zipCode;
193 * Default constructor
195 public JobsContactWebRequestBean () {
196 // Call super constructor
201 * Event observer for newly added users by administrator
203 * @param event Event being fired
205 public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
206 // Event and contained entity instance should not be null
209 throw new NullPointerException("event is null"); //NOI18N
210 } else if (event.getAddedUser() == null) {
212 throw new NullPointerException("event.addedUser is null"); //NOI18N
213 } else if (event.getAddedUser().getUserId() == null) {
215 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
216 } else if (event.getAddedUser().getUserId() < 1) {
218 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
226 * Observes events being fired when an administrator has linked a new user
227 * with existing contact data.
229 * @param event Event being fired
231 public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
232 // Event and contained entity instance should not be null
235 throw new NullPointerException("event is null"); //NOI18N
236 } else if (event.getLinkedUser() == null) {
238 throw new NullPointerException("event.linkedUser is null"); //NOI18N
239 } else if (event.getLinkedUser().getUserContact() == null) {
241 throw new NullPointerException("event.linkedUser.userContact is null"); //NOI18N
242 } else if (event.getLinkedUser().getUserContact().getContactId() == null) {
244 throw new NullPointerException("event.linkedUser.userContact.contactId is null"); //NOI18N
245 } else if (event.getLinkedUser().getUserContact().getContactId() < 1) {
247 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserContact().getContactId())); //NOI18N
255 * Event observer for logged-in user
257 * @param event Event instance
259 public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
260 // Event and contained entity instance should not be null
263 throw new NullPointerException("event is null"); //NOI18N
264 } else if (event.getLoggedInUser() == null) {
266 throw new NullPointerException("event.loggedInUser is null"); //NOI18N
267 } else if (event.getLoggedInUser().getUserId() == null) {
269 throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
270 } else if (event.getLoggedInUser().getUserId() < 1) {
272 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
275 // Copy all data to this bean
276 this.copyFromContact(event.getLoggedInUser().getUserContact());
280 * Observes events being fired before an updated of personal data done by a
283 * @param event Event being observed
285 public void beforeUserUpdatedPersonalDataEvent (@Observes final ObservablePreUserPersonalDataUpdatedEvent event) {
286 // Is the instance valid?
289 throw new NullPointerException("event is null"); //NOI18N
290 } else if (event.getUpdatedUser() == null) {
292 throw new NullPointerException("event.updatedUser is null"); //NOI18N
296 this.copyToContact(event.getUpdatedUser().getUserContact());
300 public void clearEmailAddresses () {
302 this.setEmailAddress(null);
303 this.setEmailAddressRepeat(null);
307 public Contact createContactInstance () {
308 // Is all required data set?
309 if (!this.isRequiredPersonalDataSet()) {
310 // No, then abort here
311 throw new FacesException(new IllegalArgumentException("Not all personal data is set, but createContactInstance() is called.")); //NOI18N
314 // Required personal data must be set
315 assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
317 // Create new contact
318 final Contact contact = new UserContact(
319 this.getPersonalTitle(),
329 public String doChangePersonalContactData () {
330 // This method shall only be called if the user is logged-in
331 if (!this.userLoginController.isUserLoggedIn()) {
333 throw new IllegalStateException("User is not logged-in"); //NOI18N
334 } else if (!this.isRequiredChangePersonalDataSet()) {
335 // Not all required fields are set
336 throw new FacesException("Not all required fields are set."); //NOI18N
337 } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
338 // Password not matching
339 this.showFacesMessage("form_login_change_personal:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()), FacesMessage.SEVERITY_ERROR); //NOI18N
343 // Get contact instance
344 final Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
346 // It should be there, so run some tests on it
347 assert (contact instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
348 assert (contact.getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
349 assert (contact.getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
352 contact.setContactPersonalTitle(this.getPersonalTitle());
353 contact.setContactFirstName(this.getFirstName());
354 contact.setContactFamilyName(this.getFamilyName());
355 contact.setContactStreet(this.getStreet());
356 contact.setContactHouseNumber(this.getHouseNumber());
357 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
358 contact.setContactZipCode(this.getZipCode());
359 contact.setContactCity(this.getCity());
360 contact.setContactCountry(this.getCountry());
362 // Update contact's mobile number
363 final boolean isMobileUnlinked = Contacts.updateMobileNumber(contact, this.getMobileProvider(), this.getMobileNumber());
365 // Update contact's land-line number
366 final boolean isLandLineUnlinked = Contacts.updateLandLineNumber(contact, this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
368 // Update contact's fax number
369 final boolean isFaxUnlinked = Contacts.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
371 // Send it to the EJB
372 this.contactBean.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
375 return "contact_data_saved"; //NOI18N
379 * Getter for academic title
381 * @return Academic title
383 public String getAcademicTitle () {
384 return this.academicTitle;
388 * Setter for academic title
390 * @param academicTitle Academic title
392 public void setAcademicTitle (final String academicTitle) {
393 this.academicTitle = academicTitle;
397 * Getter for birth day
401 @SuppressWarnings ("ReturnOfDateField")
402 public Date getBirthday () {
403 return this.birthday;
407 * Setter for birth day
409 * @param birthday Birth day
411 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
412 public void setBirthday (final Date birthday) {
413 this.birthday = birthday;
417 * Getter for city name
421 public String getCity () {
426 * Setter for city name
428 * @param city City name
430 public void setCity (final String city) {
435 * Getter for comments
439 public String getComment () {
446 * @param comment Comments
448 public void setComment (final String comment) {
449 this.comment = comment;
453 public String getControllerType () {
454 return "general"; //NOI18N
459 public void setControllerType (final String controllerType) {
460 throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
464 * Getter for country instance
466 * @return Country instance
468 public Country getCountry () {
473 * Setter for country instance
475 * @param country Country instance
477 public void setCountry (final Country country) {
478 this.country = country;
482 public String getEmailAddress () {
483 return this.emailAddress;
487 * Setter for email address
489 * @param emailAddress Email address
491 public void setEmailAddress (final String emailAddress) {
492 this.emailAddress = emailAddress;
496 * Getter for email address, repeated
498 * @return the emailAddress, repeated
500 public String getEmailAddressRepeat () {
501 return this.emailAddressRepeat;
505 * Setter for email address repeated
507 * @param emailAddressRepeat the emailAddress to set
509 public void setEmailAddressRepeat (final String emailAddressRepeat) {
510 this.emailAddressRepeat = emailAddressRepeat;
516 * @return the familyName
518 public String getFamilyName () {
519 return this.familyName;
525 * @param familyName the familyName to set
527 public void setFamilyName (final String familyName) {
528 this.familyName = familyName;
532 * Getter for fax number's area code
534 * @return Fax number's area code
536 public Integer getFaxAreaCode () {
537 return this.faxAreaCode;
541 * Setter for fax number's area code
543 * @param faxAreaCode Fax number's area code
545 public void setFaxAreaCode (final Integer faxAreaCode) {
546 this.faxAreaCode = faxAreaCode;
550 * Getter for fax's country instance
552 * @return Fax' country instance
554 public Country getFaxCountry () {
555 return this.faxCountry;
559 * Setter for fax's country instance
561 * @param faxCountry Fax' country instance
563 public void setFaxCountry (final Country faxCountry) {
564 this.faxCountry = faxCountry;
568 * Getter for fax number
572 public Long getFaxNumber () {
573 return this.faxNumber;
577 * Setter for fax number
579 * @param faxNumber Fax number
581 public void setFaxNumber (final Long faxNumber) {
582 this.faxNumber = faxNumber;
588 * @return the first name
590 public String getFirstName () {
591 return this.firstName;
597 * @param firstName the first name to set
599 public void setFirstName (final String firstName) {
600 this.firstName = firstName;
606 * @return the houseNumber
608 public Short getHouseNumber () {
609 return this.houseNumber;
615 * @param houseNumber the houseNumber to set
617 public void setHouseNumber (final Short houseNumber) {
618 this.houseNumber = houseNumber;
622 * Getter for house number extension, example: 123a 'a' is then the
623 * extension and 123 is the house number.
625 * @return House number extension
627 public String getHouseNumberExtension () {
628 return this.houseNumberExtension;
632 * Setter for house number extension
634 * @param houseNumberExtension House number extension
636 public void setHouseNumberExtension (final String houseNumberExtension) {
637 this.houseNumberExtension = houseNumberExtension;
641 * Getter for land-line number's area code
643 * @return Land-line number's area code
645 public Integer getLandLineAreaCode () {
646 return this.landLineAreaCode;
650 * Setter for land-line number's area code
652 * @param landLineAreaCode Land-line number's area code
654 public void setLandLineAreaCode (final Integer landLineAreaCode) {
655 this.landLineAreaCode = landLineAreaCode;
659 * Getter for land-line number's country instance
661 * @return Land-line number's country instance
663 public Country getLandLineCountry () {
664 return this.landLineCountry;
668 * Setter for land-line number's country instance
670 * @param landLineCountry Land-line number's country instance
672 public void setLandLineCountry (final Country landLineCountry) {
673 this.landLineCountry = landLineCountry;
677 * Getter for land-line number
679 * @return Land-line number
681 public Long getLandLineNumber () {
682 return this.landLineNumber;
686 * Setter for land-line number
688 * @param landLineNumber Land-line number
690 public void setLandLineNumber (final Long landLineNumber) {
691 this.landLineNumber = landLineNumber;
695 * Getter for mobile number
697 * @return Mobile number
699 public Long getMobileNumber () {
700 return this.mobileNumber;
704 * Setter for mobile number
706 * @param mobileNumber Mobile number
708 public void setMobileNumber (final Long mobileNumber) {
709 this.mobileNumber = mobileNumber;
713 * Getter for mobile number's carrier
715 * @return Mobile number's carrier
717 public MobileProvider getMobileProvider () {
718 return this.mobileProvider;
722 * Setter for mobile number's provider
724 * @param mobileProvider Mobile number's provider
726 public void setMobileProvider (final MobileProvider mobileProvider) {
727 this.mobileProvider = mobileProvider;
731 * Getter for personal title
733 * @return Personal title
735 public PersonalTitle getPersonalTitle () {
736 return this.personalTitle;
740 * Setter for personal title
742 * @param personalTitle Personal title
744 public void setPersonalTitle (final PersonalTitle personalTitle) {
745 this.personalTitle = personalTitle;
753 public String getStreet () {
760 * @param street Street
762 public void setStreet (final String street) {
763 this.street = street;
767 * Getter for ZIP code
771 public Integer getZipCode () {
776 * Setter for ZIP code
778 * @param zipCode ZIP code
780 public void setZipCode (final Integer zipCode) {
781 this.zipCode = zipCode;
785 public boolean isEmailAddressRegistered (final Contact contact) {
787 if (null == contact) {
789 throw new NullPointerException("contact is null"); //NOI18N
790 } else if (contact.getContactEmailAddress() == null) {
792 throw new NullPointerException("contact.contactEmailAddress is null"); //NOI18N
793 } else if (contact.getContactEmailAddress().isEmpty()) {
795 throw new IllegalArgumentException("contact.contactEmailAddress is empty."); //NOI18N
798 // Default is not registered
799 boolean isRegistered = false;
802 for (final Contact currentContact : this.contactListController.getAllContacts()) {
803 // Is same contact found?
804 if (currentContact.getContactEmailAddress().equals(contact.getContactEmailAddress())) {
805 // Found same email address
808 // Skipp further iterations
818 public boolean isEmailAddressRegistered (final String emailAddress) {
819 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
823 public boolean isRequiredChangePersonalDataSet () {
824 return ((this.getPersonalTitle() != null) &&
825 (this.getFirstName() != null) &&
826 (this.getFamilyName() != null) &&
827 (this.getStreet() != null) &&
828 (this.getHouseNumber() != null) &&
829 (this.getZipCode() != null) &&
830 (this.getCity() != null));
834 public boolean isRequiredPersonalDataSet () {
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) &&
842 (this.getEmailAddress() != null) &&
843 (this.getEmailAddressRepeat() != null));
847 public boolean isSameEmailAddressEntered () {
848 return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
854 private void clear () {
857 this.setPersonalTitle(null);
858 this.setAcademicTitle(null);
859 this.setFirstName(null);
860 this.setFamilyName(null);
861 this.setStreet(null);
862 this.setHouseNumber(null);
863 this.setHouseNumberExtension(null);
864 this.setZipCode(null);
866 this.setCountry(null);
869 this.clearEmailAddresses();
870 this.setLandLineAreaCode(null);
871 this.setLandLineCountry(null);
872 this.setLandLineNumber(null);
873 this.setMobileProvider(null);
874 this.setMobileNumber(null);
875 this.setFaxAreaCode(null);
876 this.setFaxCountry(null);
877 this.setFaxNumber(null);
880 this.setBirthday(null);
881 this.setComment(null);
885 * Copies given contact data into the controller
887 * @param contact Contact instance
889 private void copyFromContact (final Contact contact) {
892 this.setPersonalTitle(contact.getContactPersonalTitle());
893 this.setAcademicTitle(contact.getContactTitle());
894 this.setFirstName(contact.getContactFirstName());
895 this.setFamilyName(contact.getContactFamilyName());
896 this.setStreet(contact.getContactStreet());
897 this.setHouseNumber(contact.getContactHouseNumber());
898 this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
899 this.setZipCode(contact.getContactZipCode());
900 this.setCity(contact.getContactCity());
901 this.setCountry(contact.getContactCountry());
902 this.setEmailAddress(contact.getContactEmailAddress());
903 this.setBirthday(contact.getContactBirthday());
904 this.setComment(contact.getContactComment());
906 // Get mobile, phone and fax instance
907 final DialableFaxNumber fax = contact.getContactFaxNumber();
908 final DialableLandLineNumber landLine = contact.getContactLandLineNumber();
909 final DialableMobileNumber mobile = contact.getContactMobileNumber();
911 // Is a fax number set?
912 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
914 this.setFaxCountry(fax.getPhoneCountry());
915 this.setFaxAreaCode(fax.getPhoneAreaCode());
916 this.setFaxNumber(fax.getPhoneNumber());
919 // Is a land-line number set?
920 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneAreaCode() > 0)) {
922 this.setLandLineCountry(landLine.getPhoneCountry());
923 this.setLandLineAreaCode(landLine.getPhoneAreaCode());
924 this.setLandLineNumber(landLine.getPhoneNumber());
927 // Is a mobile number set?
928 if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
930 this.setMobileProvider(mobile.getMobileProvider());
931 this.setMobileNumber(mobile.getMobileNumber());
936 * Copies all fields from this backing bean into given instance.
938 * @param contact An instance of a Contact class
940 private void copyToContact (final Contact contact) {
941 // Set other elements
942 contact.setContactStreet(this.getStreet());
943 contact.setContactHouseNumber(this.getHouseNumber());
944 contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
945 contact.setContactZipCode(this.getZipCode());
946 contact.setContactCity(this.getCity());
947 contact.setContactCountry(this.getCountry());
948 contact.setContactEmailAddress(this.getEmailAddress());
949 contact.setContactBirthday(this.getBirthday());
950 contact.setContactComment(this.getComment());
952 // Generate phone number
953 final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
954 final DialableMobileNumber mobile = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
955 final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
957 // Don't set null or wrong references
958 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
959 // Now the number must be given
960 if (landLine.getPhoneAreaCode() == null) {
962 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
963 } else if (landLine.getPhoneAreaCode() < 1) {
965 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
966 } else if (landLine.getPhoneNumber() == null) {
968 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
969 } else if (landLine.getPhoneNumber() < 1) {
971 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
975 contact.setContactLandLineNumber(landLine);
978 // Don't set null or wrong references
979 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
980 // Now the number must be given
981 if (fax.getPhoneAreaCode() == null) {
983 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
984 } else if (fax.getPhoneAreaCode() < 1) {
986 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
987 } else if (fax.getPhoneNumber() == null) {
989 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
990 } else if (fax.getPhoneNumber() < 1) {
992 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
996 contact.setContactFaxNumber(fax);
999 // Is the provider set?
1000 if ((mobile instanceof DialableMobileNumber) && (this.getMobileProvider() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
1001 // Is the number set?
1002 if (mobile.getMobileNumber() == null) {
1004 throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
1005 } else if (mobile.getMobileNumber() < 1) {
1007 throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
1010 // Set mobile number
1011 contact.setContactMobileNumber(mobile);