2 * Copyright (C) 2016 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.addressbook.beans.contact.phone;
19 import java.text.MessageFormat;
20 import javax.enterprise.context.RequestScoped;
21 import javax.enterprise.event.Event;
22 import javax.enterprise.event.Observes;
23 import javax.enterprise.inject.Any;
24 import javax.faces.view.facelets.FaceletException;
25 import javax.inject.Inject;
26 import javax.inject.Named;
27 import javax.naming.Context;
28 import javax.naming.InitialContext;
29 import javax.naming.NamingException;
30 import org.mxchange.addressbook.beans.BaseAddressbookController;
31 import org.mxchange.addressbook.beans.helper.AddressbookWebRequestHelperController;
32 import org.mxchange.addressbook.beans.phone.AddressbookAdminPhoneWebRequestController;
33 import org.mxchange.jcontacts.contact.Contact;
34 import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
35 import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
36 import org.mxchange.jcontacts.events.fax.linked.AdminLinkedFaxNumberEvent;
37 import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent;
38 import org.mxchange.jcontacts.events.fax.unlinked.AdminUnlinkedFaxNumberEvent;
39 import org.mxchange.jcontacts.events.fax.unlinked.ObservableAdminUnlinkedFaxNumberEvent;
40 import org.mxchange.jcontacts.events.landline.linked.AdminLinkedLandLineNumberEvent;
41 import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent;
42 import org.mxchange.jcontacts.events.landline.unlinked.AdminUnlinkedLandLineNumberEvent;
43 import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLandLineNumberEvent;
44 import org.mxchange.jcontacts.events.mobile.linked.AdminLinkedMobileNumberEvent;
45 import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent;
46 import org.mxchange.jcontacts.events.mobile.unlinked.AdminUnlinkedMobileNumberEvent;
47 import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent;
48 import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote;
49 import org.mxchange.jcountry.data.Country;
50 import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException;
51 import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException;
52 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
53 import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
54 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
55 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
56 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
57 import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
58 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
59 import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
62 * An administrative contact phone controller (bean)
64 * @author Roland Häder<roland@mxchange.org>
66 @Named ("adminContactPhoneController")
68 public class AddressbookAdminContactPhoneWebRequestBean extends BaseAddressbookController implements AddressbookAdminContactPhoneWebRequestController {
71 * Call-stack instance (5 may show BeanELResolver.getValue as caller)
73 private static final short THREAD_STACK = 5;
78 private static final long serialVersionUID = 542_145_347_916L;
81 * Event being fired when a fax number has been linked
85 private Event<ObservableAdminLinkedFaxNumberEvent> adminLinkedFaxNumberEvent;
88 * Event being fired when a land-line number has been linked
92 private Event<ObservableAdminLinkedLandLineNumberEvent> adminLinkedLandLineNumberEvent;
95 * Event being fired when a mobile number has been linked
99 private Event<ObservableAdminLinkedMobileNumberEvent> adminLinkedMobileNumberEvent;
102 * Administrative EJB for phone number
104 private AdminContactsPhoneSessionBeanRemote adminPhoneBean;
107 * Administrative phone controller
110 private AddressbookAdminPhoneWebRequestController adminPhoneController;
116 private AddressbookWebRequestHelperController beanHelper;
119 * Event being fired when a fax number has been unlinked
123 private Event<ObservableAdminUnlinkedFaxNumberEvent> faxNumberUnlinkedEvent;
126 * Event being fired when a land-line number has been unlinked
130 private Event<ObservableAdminUnlinkedLandLineNumberEvent> landLineNumberUnlinkedEvent;
133 * Event being fired when admin unlinks mobile from contact
137 private Event<ObservableAdminUnlinkedMobileNumberEvent> mobileNumberUnlinkedEvent;
140 * Default constructor
142 public AddressbookAdminContactPhoneWebRequestBean () {
143 // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
144 // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
148 // Get initial context
149 Context context = new InitialContext();
151 // Try to lookup the beans
152 this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
153 } catch (final NamingException e) {
155 throw new FaceletException(e);
160 * Observes events being fired when an administrator has added a new
163 * @param event Event being fired
165 public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
166 // The event must be valid
169 throw new NullPointerException("event is null"); //NOI18N
170 } else if (event.getAddedContact() == null) {
172 throw new NullPointerException("event.addedContact is null"); //NOI18N
173 } else if (event.getAddedContact().getContactId() == null) {
175 throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
176 } else if (event.getAddedContact().getContactId() < 1) {
178 throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
186 * Event observer for newly added users by administrator
188 * @param event Event being fired
190 public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
191 // event should not be null
194 throw new NullPointerException("event is null"); //NOI18N
195 } else if (event.getAddedUser() == null) {
197 throw new NullPointerException("event.addedUser is null"); //NOI18N
198 } else if (event.getAddedUser().getUserId() == null) {
200 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
201 } else if (event.getAddedUser().getUserId() < 1) {
203 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
211 * Event observer for updated contact data by administrators
213 * @param event Updated contact data event
215 public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
216 // event should not be null
219 throw new NullPointerException("event is null"); //NOI18N
220 } else if (event.getUpdatedContact() == null) {
222 throw new NullPointerException("event.updatedContact is null"); //NOI18N
223 } else if (event.getUpdatedContact().getContactId() == null) {
225 throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
226 } else if (event.getUpdatedContact().getContactId() < 1) {
228 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
236 public String doLinkAddFaxNumber (final Contact contact) {
237 // Is all data properly set?
238 if (null == contact) {
240 throw new NullPointerException("contact is null"); //NOI18N
241 } else if (contact.getContactId() == null) {
243 throw new NullPointerException("contact.contactId is null"); //NOI18N
244 } else if (contact.getContactId() < 1) {
246 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
247 } else if ((this.adminPhoneController.getFaxNumber() == null) && (this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
248 // All fields are empty
249 throw new NullPointerException("choosenFaxNumber, mobileProvider and phoneNumer are null"); //NOI18N
250 } else if ((this.adminPhoneController.getFaxNumber() instanceof DialableFaxNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
251 // All fields are set
252 throw new IllegalStateException("choosenFaxNumber, mobileProvider and phoneNumer are all set"); //NOI18N
253 } else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
254 // No country selected
255 this.showFacesMessage("form_add_contact_fax:phoneCountry", "ERROR_ADMIN_NO_PHONE_COUNTRY_SELECTED"); //NOI18N
257 } else if (((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
258 // No area code entered
259 this.showFacesMessage("form_add_contact_fax:phoneAreaCode", "ERROR_ADMIN_NO_PHONE_AREA_CODE_ENTERED"); //NOI18N
261 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneAreaCode() instanceof Integer))) {
262 // No phone number entered
263 this.showFacesMessage("form_add_contact_fax:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
268 Contact updatedContact;
269 DialableFaxNumber faxNumber = this.adminPhoneController.getFaxNumber();
273 // All fine so far, then which was choosen?
274 if (faxNumber instanceof DialableFaxNumber) {
275 // User has choosen number
276 updatedContact = this.adminPhoneBean.linkExistingFaxNumberWithContact(contact, faxNumber);
278 // Create new instance
279 faxNumber = new FaxNumber(this.adminPhoneController.getPhoneCountry(), this.adminPhoneController.getPhoneAreaCode(), this.adminPhoneController.getPhoneNumber());
282 updatedContact = this.adminPhoneBean.linkNewFaxNumberWithContact(contact, faxNumber);
284 } catch (final PhoneNumberAlreadyLinkedException ex) {
285 // Throw again as cause
286 this.showFacesMessage("form_add_contact_fax:phoneNumber", ex); //NOI18N
291 this.adminLinkedFaxNumberEvent.fire(new AdminLinkedFaxNumberEvent(updatedContact, faxNumber));
293 // Return to contact profile
294 return "admin_show_contact"; //NOI18N
298 public String doLinkAddLandLineNumber (final Contact contact) {
299 // Is all data properly set?
300 if (null == contact) {
302 throw new NullPointerException("contact is null"); //NOI18N
303 } else if (contact.getContactId() == null) {
305 throw new NullPointerException("contact.contactId is null"); //NOI18N
306 } else if (contact.getContactId() < 1) {
308 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
309 } else if ((this.adminPhoneController.getLandLineNumber() == null) && (this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
310 // All fields are empty
311 throw new NullPointerException("choosenLandLineNumber, mobileProvider and phoneNumer are null"); //NOI18N
312 } else if ((this.adminPhoneController.getLandLineNumber() instanceof DialableLandLineNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
313 // All fields are set
314 throw new IllegalStateException("choosenLandLineNumber, mobileProvider and phoneNumer are all set"); //NOI18N
315 } else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
316 // No country selected
317 this.showFacesMessage("form_add_contact_landLine:phoneCountry", "ERROR_ADMIN_NO_PHONE_COUNTRY_SELECTED"); //NOI18N
319 } else if (((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
320 // No area code entered
321 this.showFacesMessage("form_add_contact_landLine:phoneAreaCode", "ERROR_ADMIN_NO_PHONE_AREA_CODE_ENTERED"); //NOI18N
323 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneAreaCode() instanceof Integer))) {
324 // No phone number entered
325 this.showFacesMessage("form_add_contact_landLine:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
330 Contact updatedContact;
331 DialableLandLineNumber landLineNumber = this.adminPhoneController.getLandLineNumber();
335 // All fine so far, then which was choosen?
336 if (landLineNumber instanceof DialableLandLineNumber) {
337 // User has choosen number
338 updatedContact = this.adminPhoneBean.linkExistingLandLineNumberWithContact(contact, landLineNumber);
340 // Create new instance
341 landLineNumber = new LandLineNumber(this.adminPhoneController.getPhoneCountry(), this.adminPhoneController.getPhoneAreaCode(), this.adminPhoneController.getPhoneNumber());
344 updatedContact = this.adminPhoneBean.linkNewLandLineNumberWithContact(contact, landLineNumber);
346 } catch (final PhoneNumberAlreadyLinkedException ex) {
347 // Throw again as cause
348 this.showFacesMessage("form_add_contact_landLine:phoneNumber", ex); //NOI18N
353 this.adminLinkedLandLineNumberEvent.fire(new AdminLinkedLandLineNumberEvent(updatedContact, landLineNumber));
355 // Return to contact profile
356 return "admin_show_contact"; //NOI18N
360 public String doLinkAddMobileNumber (final Contact contact) {
361 // Is all data properly set?
362 if (null == contact) {
364 throw new NullPointerException("contact is null"); //NOI18N
365 } else if (contact.getContactId() == null) {
367 throw new NullPointerException("contact.contactId is null"); //NOI18N
368 } else if (contact.getContactId() < 1) {
370 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
371 } else if ((this.adminPhoneController.getMobileNumber() == null) && (this.adminPhoneController.getMobileProvider() == null) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
372 // All fields are empty
373 throw new NullPointerException("choosenMobileNumber, mobileProvider and phoneNumer are null"); //NOI18N
374 } else if ((this.adminPhoneController.getMobileNumber() instanceof DialableMobileNumber) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
375 // All fields are set
376 throw new IllegalStateException("choosenMobileNumber, mobileProvider and phoneNumer are all set"); //NOI18N
377 } else if ((this.adminPhoneController.getMobileProvider() == null) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
378 // No mobile provider selected
379 this.showFacesMessage("form_add_contact_mobile:phoneCountry", "ERROR_ADMIN_NO_PHONE_MOBILE_PROVIDER_SELECTED"); //NOI18N
381 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider)) {
382 // No phone number entered
383 this.showFacesMessage("form_add_contact_mobile:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
388 Contact updatedContact;
389 DialableMobileNumber mobileNumber = this.adminPhoneController.getMobileNumber();
393 // All fine so far, then which was choosen?
394 if (mobileNumber instanceof DialableMobileNumber) {
395 // User has choosen number
396 updatedContact = this.adminPhoneBean.linkExistingMobileNumberWithContact(contact, mobileNumber);
398 // Create new instance
399 mobileNumber = new MobileNumber(this.adminPhoneController.getMobileProvider(), this.adminPhoneController.getPhoneNumber());
402 updatedContact = this.adminPhoneBean.linkNewMobileNumberWithContact(contact, mobileNumber);
404 } catch (final PhoneNumberAlreadyLinkedException ex) {
405 // Throw again as cause
406 this.showFacesMessage("form_add_contact_mobile:phoneNumber", ex); //NOI18N
411 this.adminLinkedMobileNumberEvent.fire(new AdminLinkedMobileNumberEvent(updatedContact, mobileNumber));
413 // Return to contact profile
414 return "admin_show_contact"; //NOI18N
418 public String unlinkFaxContactData () {
420 if (this.beanHelper.getFaxNumber() == null) {
421 // Not set, throw NPE
422 throw new NullPointerException("this.beanHelper.faxNumber is null"); //NOI18N
423 } else if (this.beanHelper.getFaxNumber().getPhoneId() == null) {
425 throw new NullPointerException("this.beanHelper.faxNumber.phoneId is null"); //NOI18N
426 } else if (this.beanHelper.getFaxNumber().getPhoneId() < 1) {
428 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.faxNumber.phoneId={0} is not valid", this.beanHelper.getFaxNumber().getPhoneId())); //NOI18N
429 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() == null) {
431 throw new NullPointerException("this.beanHelper.faxNumber.phoneNumber is null"); //NOI18N
432 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() < 1) {
433 // Throw it again ...
434 throw new NullPointerException(MessageFormat.format("this.beanHelper.faxNumber.phoneNumber={0} is not valid.", this.beanHelper.getFaxNumber().getPhoneNumber())); //NOI18N
435 } else if (this.beanHelper.getContact() == null) {
436 // ... and throw again
437 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
438 } else if (this.beanHelper.getContact().getContactId() == null) {
440 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
441 } else if (this.beanHelper.getContact().getContactId() < 1) {
443 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
446 // Init contact instance
447 Contact updatedContact;
450 // Unlink it and return contact without fax instance
451 updatedContact = this.adminPhoneBean.unlinkFaxDataFromContact(this.beanHelper.getContact(), this.beanHelper.getFaxNumber());
452 } catch (final PhoneNumberNotLinkedException ex) {
454 this.showFacesMessage("form_unlink_contact_fax:faxNumberId", ex); //NOI18N
459 this.faxNumberUnlinkedEvent.fire(new AdminUnlinkedFaxNumberEvent(updatedContact, this.beanHelper.getFaxNumber()));
462 return "admin_show_contact"; //NOI18N
466 public String unlinkLandLineContactData () {
468 if (this.beanHelper.getLandLineNumber() == null) {
469 // Not set, throw NPE
470 throw new NullPointerException("this.beanHelper.landLineNumber is null"); //NOI18N
471 } else if (this.beanHelper.getLandLineNumber().getPhoneId() == null) {
473 throw new NullPointerException("this.beanHelper.landLineNumber.phoneId is null"); //NOI18N
474 } else if (this.beanHelper.getLandLineNumber().getPhoneId() < 1) {
476 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.landLineNumber.phoneId={0} is not valid", this.beanHelper.getLandLineNumber().getPhoneId())); //NOI18N
477 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() == null) {
479 throw new NullPointerException("this.beanHelper.landLineNumber.phoneNumber is null"); //NOI18N
480 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() < 1) {
481 // Throw it again ...
482 throw new NullPointerException(MessageFormat.format("this.beanHelper.landLineNumber.phoneNumber={0} is not valid.", this.beanHelper.getLandLineNumber().getPhoneNumber())); //NOI18N
483 } else if (this.beanHelper.getContact() == null) {
484 // ... and throw again
485 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
486 } else if (this.beanHelper.getContact().getContactId() == null) {
488 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
489 } else if (this.beanHelper.getContact().getContactId() < 1) {
491 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
494 // Init contact instance
495 Contact updatedContact;
498 // Unlink it and return contact without landLine instance
499 updatedContact = this.adminPhoneBean.unlinkLandLineDataFromContact(this.beanHelper.getContact(), this.beanHelper.getLandLineNumber());
500 } catch (final PhoneNumberNotLinkedException ex) {
502 this.showFacesMessage("form_unlink_contact_landLine:landLineNumberId", ex); //NOI18N
507 this.landLineNumberUnlinkedEvent.fire(new AdminUnlinkedLandLineNumberEvent(updatedContact, this.beanHelper.getLandLineNumber()));
510 return "admin_show_contact"; //NOI18N
514 public String unlinkMobileContactData () {
516 if (this.beanHelper.getMobileNumber() == null) {
517 // Not set, throw NPE
518 throw new NullPointerException("this.beanHelper.mobileNumber is null"); //NOI18N
519 } else if (this.beanHelper.getMobileNumber().getPhoneId() == null) {
521 throw new NullPointerException("this.beanHelper.mobileNumber.phoneId is null"); //NOI18N
522 } else if (this.beanHelper.getMobileNumber().getPhoneId() < 1) {
524 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.phoneId={0} is not valid", this.beanHelper.getMobileNumber().getPhoneId())); //NOI18N
525 } else if (this.beanHelper.getMobileNumber().getMobileProvider() == null) {
527 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider is null"); //NOI18N
528 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() == null) {
530 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider.providerId is null"); //NOI18N
531 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() < 1) {
533 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.mobileProvider.providerId={0} is not valid.", this.beanHelper.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
534 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() == null) {
536 throw new NullPointerException("this.beanHelper.mobileNumber.phoneNumber is null"); //NOI18N
537 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() < 1) {
538 // Throw it again ...
539 throw new NullPointerException(MessageFormat.format("this.beanHelper.mobileNumber.phoneNumber={0} is not valid.", this.beanHelper.getMobileNumber().getPhoneNumber())); //NOI18N
540 } else if (this.beanHelper.getContact() == null) {
541 // ... and throw again
542 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
543 } else if (this.beanHelper.getContact().getContactId() == null) {
545 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
546 } else if (this.beanHelper.getContact().getContactId() < 1) {
548 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
551 // Init contact instance
552 Contact updatedContact;
555 // Unlink it and return contact without mobile instance
556 updatedContact = this.adminPhoneBean.unlinkMobileDataFromContact(this.beanHelper.getContact(), this.beanHelper.getMobileNumber());
557 } catch (final PhoneNumberNotLinkedException ex) {
559 this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex); //NOI18N
564 this.mobileNumberUnlinkedEvent.fire(new AdminUnlinkedMobileNumberEvent(updatedContact, this.beanHelper.getMobileNumber()));
567 return "admin_show_contact"; //NOI18N
573 private void clear () {