2 * Copyright (C) 2016, 2017 Roland Häder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jfinancials.beans.contact.phone;
19 import java.text.MessageFormat;
20 import javax.annotation.PostConstruct;
21 import javax.enterprise.context.RequestScoped;
22 import javax.enterprise.event.Event;
23 import javax.enterprise.event.Observes;
24 import javax.enterprise.inject.Any;
25 import javax.faces.view.facelets.FaceletException;
26 import javax.inject.Inject;
27 import javax.inject.Named;
28 import javax.naming.Context;
29 import javax.naming.InitialContext;
30 import javax.naming.NamingException;
31 import org.mxchange.jcontacts.contact.Contact;
32 import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
33 import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
34 import org.mxchange.jcontacts.events.fax.linked.AdminLinkedFaxNumberEvent;
35 import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent;
36 import org.mxchange.jcontacts.events.fax.unlinked.AdminUnlinkedFaxNumberEvent;
37 import org.mxchange.jcontacts.events.fax.unlinked.ObservableAdminUnlinkedFaxNumberEvent;
38 import org.mxchange.jcontacts.events.landline.linked.AdminLinkedLandLineNumberEvent;
39 import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent;
40 import org.mxchange.jcontacts.events.landline.unlinked.AdminUnlinkedLandLineNumberEvent;
41 import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLandLineNumberEvent;
42 import org.mxchange.jcontacts.events.mobile.linked.AdminLinkedMobileNumberEvent;
43 import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent;
44 import org.mxchange.jcontacts.events.mobile.unlinked.AdminUnlinkedMobileNumberEvent;
45 import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent;
46 import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote;
47 import org.mxchange.jcountry.data.Country;
48 import org.mxchange.jfinancials.beans.BaseFinancialsController;
49 import org.mxchange.jfinancials.beans.helper.FinancialsWebRequestHelperController;
50 import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestController;
51 import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException;
52 import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException;
53 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
54 import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
55 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
56 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
57 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
58 import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
59 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
60 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
63 * An administrative contact phone controller (bean)
65 * @author Roland Häder<roland@mxchange.org>
67 @Named ("adminContactPhoneController")
69 public class FinancialsAdminContactPhoneWebRequestBean extends BaseFinancialsController implements FinancialsAdminContactPhoneWebRequestController {
72 * Call-stack instance (5 may show BeanELResolver.getValue as caller)
74 private static final short THREAD_STACK = 5;
79 private static final long serialVersionUID = 542_145_347_916L;
82 * Event being fired when a fax number has been linked
86 private Event<ObservableAdminLinkedFaxNumberEvent> adminLinkedFaxNumberEvent;
89 * Event being fired when a land-line number has been linked
93 private Event<ObservableAdminLinkedLandLineNumberEvent> adminLinkedLandLineNumberEvent;
96 * Event being fired when a mobile number has been linked
100 private Event<ObservableAdminLinkedMobileNumberEvent> adminLinkedMobileNumberEvent;
103 * Administrative EJB for phone number
105 private AdminContactsPhoneSessionBeanRemote adminPhoneBean;
108 * Administrative phone controller
111 private FinancialsAdminPhoneWebRequestController adminPhoneController;
117 private FinancialsWebRequestHelperController beanHelper;
120 * Event being fired when a fax number has been unlinked
124 private Event<ObservableAdminUnlinkedFaxNumberEvent> faxNumberUnlinkedEvent;
127 * Event being fired when a land-line number has been unlinked
131 private Event<ObservableAdminUnlinkedLandLineNumberEvent> landLineNumberUnlinkedEvent;
134 * Event being fired when admin unlinks mobile from contact
138 private Event<ObservableAdminUnlinkedMobileNumberEvent> mobileNumberUnlinkedEvent;
141 * Area code (city dial prefix) for fax number
143 private Integer faxAreaCode;
146 * Country (for dial prefix) for fax number
148 private Country faxCountry;
153 private Long faxNumber;
156 * Area code (city dial prefix) for land-line number
158 private Integer landLineAreaCode;
161 * Country (for dial prefix) for land-line number
163 private Country landLineCountry;
168 private Long landLineNumber;
173 private MobileProvider mobileProvider;
178 private Long mobileNumber;
181 * Default constructor
183 public FinancialsAdminContactPhoneWebRequestBean () {
184 // Call super constructor
187 // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
188 // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
192 * Observes events being fired when an administrator has added a new
195 * @param event Event being fired
197 public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
198 // The event must be valid
201 throw new NullPointerException("event is null"); //NOI18N
202 } else if (event.getAddedContact() == null) {
204 throw new NullPointerException("event.addedContact is null"); //NOI18N
205 } else if (event.getAddedContact().getContactId() == null) {
207 throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
208 } else if (event.getAddedContact().getContactId() < 1) {
210 throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
218 * Event observer for newly added users by administrator
220 * @param event Event being fired
222 public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
223 // event should not be null
226 throw new NullPointerException("event is null"); //NOI18N
227 } else if (event.getAddedUser() == null) {
229 throw new NullPointerException("event.addedUser is null"); //NOI18N
230 } else if (event.getAddedUser().getUserId() == null) {
232 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
233 } else if (event.getAddedUser().getUserId() < 1) {
235 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
243 * Event observer for updated contact data by administrators
245 * @param event Updated contact data event
247 public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
248 // event should not be null
251 throw new NullPointerException("event is null"); //NOI18N
252 } else if (event.getUpdatedContact() == null) {
254 throw new NullPointerException("event.updatedContact is null"); //NOI18N
255 } else if (event.getUpdatedContact().getContactId() == null) {
257 throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
258 } else if (event.getUpdatedContact().getContactId() < 1) {
260 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
268 * Links fax number to contact from bean helper as "main fax number".
270 * @return Redirect outcome
272 public String doLinkMainFaxNumber () {
273 // Get contact from helper
274 Contact contact = this.beanHelper.getContact();
276 // Is all data properly set?
277 if (null == contact) {
279 throw new NullPointerException("contact is null"); //NOI18N
280 } else if (contact.getContactId() == null) {
282 throw new NullPointerException("contact.contactId is null"); //NOI18N
283 } else if (contact.getContactId() < 1) {
285 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
286 } else if (this.getFaxCountry() == null) {
288 throw new NullPointerException("this.faxCountry is null"); //NOI18N
289 } else if (this.getFaxCountry().getCountryId() == null) {
291 throw new NullPointerException("this.faxCountry.countryId is null"); //NOI18N
292 } else if (this.getFaxCountry().getCountryId() < 1) {
294 throw new IllegalArgumentException(MessageFormat.format("this.faxCountry.countryId={0} is not valid.", this.getFaxCountry().getCountryId())); //NOI18N
295 } else if (this.getFaxAreaCode() == null) {
297 throw new NullPointerException("this.faxAreaCode is null"); //NOI18N
298 } else if (this.getFaxAreaCode() < 1) {
300 throw new IllegalArgumentException(MessageFormat.format("this.faxAreaCode={0} is invalid", this.getFaxAreaCode())); //NOI18N
301 } else if (this.getFaxNumber() == null) {
303 throw new NullPointerException("this.faxNumber is null"); //NOI18N
304 } else if (this.getFaxNumber() < 1) {
306 throw new IllegalArgumentException(MessageFormat.format("this.faxNumber={0} is invalid", this.getFaxNumber())); //NOI18N
310 Contact updatedContact;
311 DialableFaxNumber number = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
316 updatedContact = this.adminPhoneBean.linkNewFaxNumberWithContact(contact, number);
317 } catch (final PhoneNumberAlreadyLinkedException ex) {
318 // Throw again as cause
319 this.showFacesMessage("form_add_contact_fax:faxNumber", ex); //NOI18N
324 this.adminLinkedFaxNumberEvent.fire(new AdminLinkedFaxNumberEvent(updatedContact, number));
326 // Return to contact profile
327 return "admin_show_contact"; //NOI18N
331 * Links land-line number to contact from bean helper as "main land-line
334 * @return Redirect outcome
336 public String doLinkMainLandLineNumber () {
337 // Get contact from helper
338 Contact contact = this.beanHelper.getContact();
340 // Is all data properly set?
341 if (null == contact) {
343 throw new NullPointerException("contact is null"); //NOI18N
344 } else if (contact.getContactId() == null) {
346 throw new NullPointerException("contact.contactId is null"); //NOI18N
347 } else if (contact.getContactId() < 1) {
349 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
350 } else if (this.getLandLineCountry() == null) {
352 throw new NullPointerException("this.landLineCountry is null"); //NOI18N
353 } else if (this.getLandLineCountry().getCountryId() == null) {
355 throw new NullPointerException("this.landLineCountry.countryId is null"); //NOI18N
356 } else if (this.getLandLineCountry().getCountryId() < 1) {
358 throw new IllegalArgumentException(MessageFormat.format("this.landLineCountry.countryId={0} is not valid.", this.getLandLineCountry().getCountryId())); //NOI18N
359 } else if (this.getLandLineAreaCode() == null) {
361 throw new NullPointerException("this.landLineAreaCode is null"); //NOI18N
362 } else if (this.getLandLineAreaCode() < 1) {
364 throw new IllegalArgumentException(MessageFormat.format("this.landLineAreaCode={0} is invalid", this.getLandLineAreaCode())); //NOI18N
365 } else if (this.getLandLineNumber() == null) {
367 throw new NullPointerException("this.landLineNumber is null"); //NOI18N
368 } else if (this.getLandLineNumber() < 1) {
370 throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber={0} is invalid", this.getLandLineNumber())); //NOI18N
374 Contact updatedContact;
375 DialableLandLineNumber number = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
380 updatedContact = this.adminPhoneBean.linkNewLandLineNumberWithContact(contact, number);
381 } catch (final PhoneNumberAlreadyLinkedException ex) {
382 // Throw again as cause
383 this.showFacesMessage("form_add_contact_landLine:landLineNumber", ex); //NOI18N
388 this.adminLinkedLandLineNumberEvent.fire(new AdminLinkedLandLineNumberEvent(updatedContact, number));
390 // Return to contact profile
391 return "admin_show_contact"; //NOI18N
395 * Links mobile number to contact from bean helper as "main mobile number".
397 * @return Redirect outcome
399 public String doLinkMainMobileNumber () {
400 // Get contact from helper
401 Contact contact = this.beanHelper.getContact();
403 // Is all data properly set?
404 if (null == contact) {
406 throw new NullPointerException("contact is null"); //NOI18N
407 } else if (contact.getContactId() == null) {
409 throw new NullPointerException("contact.contactId is null"); //NOI18N
410 } else if (contact.getContactId() < 1) {
412 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
413 } else if (this.getMobileProvider() == null) {
415 throw new NullPointerException("this.mobileProvider is null"); //NOI18N
416 } else if (this.getMobileProvider().getProviderId() == null) {
418 throw new NullPointerException("this.mobileProvider.providerId is null"); //NOI18N
419 } else if (this.getMobileProvider().getProviderId() < 1) {
421 throw new NullPointerException(MessageFormat.format("this.mobileProvider.providerId={0} is invalid", this.getMobileProvider().getProviderId())); //NOI18N
422 } else if (this.getMobileNumber() == null) {
424 throw new NullPointerException("this.mobileNumber is null"); //NOI18N
425 } else if (this.getMobileNumber() < 1) {
427 throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber={0} is invalid", this.getMobileNumber())); //NOI18N
431 Contact updatedContact;
432 DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getMobileNumber());
437 updatedContact = this.adminPhoneBean.linkNewMobileNumberWithContact(contact, number);
438 } catch (final PhoneNumberAlreadyLinkedException ex) {
439 // Throw again as cause
440 this.showFacesMessage("form_add_contact_mobile:mobileNumber", ex); //NOI18N
445 this.adminLinkedMobileNumberEvent.fire(new AdminLinkedMobileNumberEvent(updatedContact, number));
447 // Return to contact profile
448 return "admin_show_contact"; //NOI18N
452 * Getter for fax area code
454 * @return Fax area code
456 public Integer getFaxAreaCode () {
457 return this.faxAreaCode;
461 * Setter for fax area code
463 * @param faxAreaCode Fax area code
465 public void setFaxAreaCode (final Integer faxAreaCode) {
466 this.faxAreaCode = faxAreaCode;
470 * Getter for fax numbers country
472 * @return Fax numbers country
474 public Country getFaxCountry () {
475 return this.faxCountry;
479 * Setter for fax numbers country
481 * @param faxCountry Fax numbers country
483 public void setFaxCountry (final Country faxCountry) {
484 this.faxCountry = faxCountry;
488 * Getter for fax number
492 public Long getFaxNumber () {
493 return this.faxNumber;
497 * Setter for fax number
499 * @param faxNumber Fax number
501 public void setFaxNumber (final Long faxNumber) {
502 this.faxNumber = faxNumber;
506 * Getter for land-line area code
508 * @return Land-line area code
510 public Integer getLandLineAreaCode () {
511 return this.landLineAreaCode;
515 * Setter for land-line area code
517 * @param landLineAreaCode Land-line area code
519 public void setLandLineAreaCode (final Integer landLineAreaCode) {
520 this.landLineAreaCode = landLineAreaCode;
524 * Getter for land-line country
526 * @return Land-line country
528 public Country getLandLineCountry () {
529 return this.landLineCountry;
533 * Setter for land-line country
535 * @param landLineCountry Land-line country
537 public void setLandLineCountry (final Country landLineCountry) {
538 this.landLineCountry = landLineCountry;
542 * Getter for land-line number
544 * @return Land-line number
546 public Long getLandLineNumber () {
547 return this.landLineNumber;
551 * Setter for land-line number
553 * @param landLineNumber Land-line number
555 public void setLandLineNumber (final Long landLineNumber) {
556 this.landLineNumber = landLineNumber;
560 * Getter for mobile provider
562 * @return Mobile provider
564 public MobileProvider getMobileProvider () {
565 return this.mobileProvider;
569 * Setter for mobile provider
571 * @param mobileProvider Mobile provider
573 public void setMobileProvider (final MobileProvider mobileProvider) {
574 this.mobileProvider = mobileProvider;
578 * Getter for mobile number
580 * @return Mobile number
582 public Long getMobileNumber () {
583 return this.mobileNumber;
587 * Setter for mobile number
589 * @param mobileNumber Mobile number
591 public void setMobileNumber (final Long mobileNumber) {
592 this.mobileNumber = mobileNumber;
596 * Post-construction method
599 public void init () {
602 // Get initial context
603 Context context = new InitialContext();
605 // Try to lookup the beans
606 this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
607 } catch (final NamingException e) {
609 throw new FaceletException(e);
614 * Unlinks fax data with current contact
616 * @return Redirect outcome
618 public String unlinkFaxContactData () {
620 if (this.beanHelper.getFaxNumber() == null) {
621 // Not set, throw NPE
622 throw new NullPointerException("this.beanHelper.faxNumber is null"); //NOI18N
623 } else if (this.beanHelper.getFaxNumber().getPhoneId() == null) {
625 throw new NullPointerException("this.beanHelper.faxNumber.phoneId is null"); //NOI18N
626 } else if (this.beanHelper.getFaxNumber().getPhoneId() < 1) {
628 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.faxNumber.phoneId={0} is not valid", this.beanHelper.getFaxNumber().getPhoneId())); //NOI18N
629 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() == null) {
631 throw new NullPointerException("this.beanHelper.faxNumber.phoneNumber is null"); //NOI18N
632 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() < 1) {
633 // Throw it again ...
634 throw new NullPointerException(MessageFormat.format("this.beanHelper.faxNumber.phoneNumber={0} is not valid.", this.beanHelper.getFaxNumber().getPhoneNumber())); //NOI18N
635 } else if (this.beanHelper.getContact() == null) {
636 // ... and throw again
637 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
638 } else if (this.beanHelper.getContact().getContactId() == null) {
640 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
641 } else if (this.beanHelper.getContact().getContactId() < 1) {
643 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
646 // Init contact instance
647 Contact updatedContact;
650 // Unlink it and return contact without fax instance
651 updatedContact = this.adminPhoneBean.unlinkFaxDataFromContact(this.beanHelper.getContact(), this.beanHelper.getFaxNumber());
652 } catch (final PhoneNumberNotLinkedException ex) {
654 this.showFacesMessage("form_unlink_contact_fax:faxNumberId", ex); //NOI18N
659 this.faxNumberUnlinkedEvent.fire(new AdminUnlinkedFaxNumberEvent(updatedContact, this.beanHelper.getFaxNumber()));
662 return "admin_show_contact"; //NOI18N
666 * Unlinks land-line data with current contact
668 * @return Redirect outcome
670 public String unlinkLandLineContactData () {
672 if (this.beanHelper.getLandLineNumber() == null) {
673 // Not set, throw NPE
674 throw new NullPointerException("this.beanHelper.landLineNumber is null"); //NOI18N
675 } else if (this.beanHelper.getLandLineNumber().getPhoneId() == null) {
677 throw new NullPointerException("this.beanHelper.landLineNumber.phoneId is null"); //NOI18N
678 } else if (this.beanHelper.getLandLineNumber().getPhoneId() < 1) {
680 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.landLineNumber.phoneId={0} is not valid", this.beanHelper.getLandLineNumber().getPhoneId())); //NOI18N
681 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() == null) {
683 throw new NullPointerException("this.beanHelper.landLineNumber.phoneNumber is null"); //NOI18N
684 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() < 1) {
685 // Throw it again ...
686 throw new NullPointerException(MessageFormat.format("this.beanHelper.landLineNumber.phoneNumber={0} is not valid.", this.beanHelper.getLandLineNumber().getPhoneNumber())); //NOI18N
687 } else if (this.beanHelper.getContact() == null) {
688 // ... and throw again
689 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
690 } else if (this.beanHelper.getContact().getContactId() == null) {
692 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
693 } else if (this.beanHelper.getContact().getContactId() < 1) {
695 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
698 // Init contact instance
699 Contact updatedContact;
702 // Unlink it and return contact without landLine instance
703 updatedContact = this.adminPhoneBean.unlinkLandLineDataFromContact(this.beanHelper.getContact(), this.beanHelper.getLandLineNumber());
704 } catch (final PhoneNumberNotLinkedException ex) {
706 this.showFacesMessage("form_unlink_contact_landLine:landLineNumberId", ex); //NOI18N
711 this.landLineNumberUnlinkedEvent.fire(new AdminUnlinkedLandLineNumberEvent(updatedContact, this.beanHelper.getLandLineNumber()));
714 return "admin_show_contact"; //NOI18N
718 * Unlinks mobile data with current contact
720 * @return Redirect outcome
722 public String unlinkMobileContactData () {
724 if (this.beanHelper.getMobileNumber() == null) {
725 // Not set, throw NPE
726 throw new NullPointerException("this.beanHelper.mobileNumber is null"); //NOI18N
727 } else if (this.beanHelper.getMobileNumber().getPhoneId() == null) {
729 throw new NullPointerException("this.beanHelper.mobileNumber.phoneId is null"); //NOI18N
730 } else if (this.beanHelper.getMobileNumber().getPhoneId() < 1) {
732 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.phoneId={0} is not valid", this.beanHelper.getMobileNumber().getPhoneId())); //NOI18N
733 } else if (this.beanHelper.getMobileNumber().getMobileProvider() == null) {
735 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider is null"); //NOI18N
736 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() == null) {
738 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider.providerId is null"); //NOI18N
739 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() < 1) {
741 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.mobileProvider.providerId={0} is not valid.", this.beanHelper.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
742 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() == null) {
744 throw new NullPointerException("this.beanHelper.mobileNumber.phoneNumber is null"); //NOI18N
745 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() < 1) {
746 // Throw it again ...
747 throw new NullPointerException(MessageFormat.format("this.beanHelper.mobileNumber.phoneNumber={0} is not valid.", this.beanHelper.getMobileNumber().getPhoneNumber())); //NOI18N
748 } else if (this.beanHelper.getContact() == null) {
749 // ... and throw again
750 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
751 } else if (this.beanHelper.getContact().getContactId() == null) {
753 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
754 } else if (this.beanHelper.getContact().getContactId() < 1) {
756 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
759 // Init contact instance
760 Contact updatedContact;
763 // Unlink it and return contact without mobile instance
764 updatedContact = this.adminPhoneBean.unlinkMobileDataFromContact(this.beanHelper.getContact(), this.beanHelper.getMobileNumber());
765 } catch (final PhoneNumberNotLinkedException ex) {
767 this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex); //NOI18N
772 this.mobileNumberUnlinkedEvent.fire(new AdminUnlinkedMobileNumberEvent(updatedContact, this.beanHelper.getMobileNumber()));
775 return "admin_show_contact"; //NOI18N
781 private void clear () {