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 * Default constructor
143 public FinancialsAdminContactPhoneWebRequestBean () {
144 // Call super constructor
147 // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
148 // System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
152 * Observes events being fired when an administrator has added a new
155 * @param event Event being fired
157 public void afterAdminAddedContactEvent (@Observes final ObservableAdminAddedContactEvent event) {
158 // The event must be valid
161 throw new NullPointerException("event is null"); //NOI18N
162 } else if (event.getAddedContact() == null) {
164 throw new NullPointerException("event.addedContact is null"); //NOI18N
165 } else if (event.getAddedContact().getContactId() == null) {
167 throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
168 } else if (event.getAddedContact().getContactId() < 1) {
170 throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
178 * Event observer for newly added users by administrator
180 * @param event Event being fired
182 public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
183 // event should not be null
186 throw new NullPointerException("event is null"); //NOI18N
187 } else if (event.getAddedUser() == null) {
189 throw new NullPointerException("event.addedUser is null"); //NOI18N
190 } else if (event.getAddedUser().getUserId() == null) {
192 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
193 } else if (event.getAddedUser().getUserId() < 1) {
195 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
203 * Event observer for updated contact data by administrators
205 * @param event Updated contact data event
207 public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
208 // event should not be null
211 throw new NullPointerException("event is null"); //NOI18N
212 } else if (event.getUpdatedContact() == null) {
214 throw new NullPointerException("event.updatedContact is null"); //NOI18N
215 } else if (event.getUpdatedContact().getContactId() == null) {
217 throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
218 } else if (event.getUpdatedContact().getContactId() < 1) {
220 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
228 public String doLinkAddFaxNumber (final Contact contact) {
229 // Is all data properly set?
230 if (null == contact) {
232 throw new NullPointerException("contact is null"); //NOI18N
233 } else if (contact.getContactId() == null) {
235 throw new NullPointerException("contact.contactId is null"); //NOI18N
236 } else if (contact.getContactId() < 1) {
238 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
239 } 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))) {
240 // All fields are empty
241 throw new NullPointerException("faxNumber, mobileProvider and phoneNumer are null"); //NOI18N
242 } else if ((this.adminPhoneController.getFaxNumber() instanceof DialableFaxNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
243 // All fields are set
244 throw new IllegalStateException("faxNumber, mobileProvider and phoneNumer are all set"); //NOI18N
245 } else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
246 // No country selected
247 this.showFacesMessage("form_add_contact_fax:phoneCountry", "ERROR_ADMIN_NO_PHONE_COUNTRY_SELECTED"); //NOI18N
249 } else if (((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
250 // No area code entered
251 this.showFacesMessage("form_add_contact_fax:phoneAreaCode", "ERROR_ADMIN_NO_PHONE_AREA_CODE_ENTERED"); //NOI18N
253 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneAreaCode() instanceof Integer))) {
254 // No phone number entered
255 this.showFacesMessage("form_add_contact_fax:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
260 Contact updatedContact;
261 DialableFaxNumber faxNumber = this.adminPhoneController.getFaxNumber();
265 // All fine so far, then which was choosen?
266 if (faxNumber instanceof DialableFaxNumber) {
267 // User has choosen number
268 updatedContact = this.adminPhoneBean.linkExistingFaxNumberWithContact(contact, faxNumber);
270 // Create new instance
271 faxNumber = new FaxNumber(this.adminPhoneController.getPhoneCountry(), this.adminPhoneController.getPhoneAreaCode(), this.adminPhoneController.getPhoneNumber());
274 updatedContact = this.adminPhoneBean.linkNewFaxNumberWithContact(contact, faxNumber);
276 } catch (final PhoneNumberAlreadyLinkedException ex) {
277 // Throw again as cause
278 this.showFacesMessage("form_add_contact_fax:phoneNumber", ex); //NOI18N
283 this.adminLinkedFaxNumberEvent.fire(new AdminLinkedFaxNumberEvent(updatedContact, faxNumber));
285 // Return to contact profile
286 return "admin_show_contact"; //NOI18N
290 public String doLinkAddLandLineNumber (final Contact contact) {
291 // Is all data properly set?
292 if (null == contact) {
294 throw new NullPointerException("contact is null"); //NOI18N
295 } else if (contact.getContactId() == null) {
297 throw new NullPointerException("contact.contactId is null"); //NOI18N
298 } else if (contact.getContactId() < 1) {
300 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
301 } 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))) {
302 // All fields are empty
303 throw new NullPointerException("landLineNumber, mobileProvider and phoneNumer are null"); //NOI18N
304 } else if ((this.adminPhoneController.getLandLineNumber() instanceof DialableLandLineNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
305 // All fields are set
306 throw new IllegalStateException("landLineNumber, mobileProvider and phoneNumer are all set"); //NOI18N
307 } else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
308 // No country selected
309 this.showFacesMessage("form_add_contact_landLine:phoneCountry", "ERROR_ADMIN_NO_PHONE_COUNTRY_SELECTED"); //NOI18N
311 } else if (((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
312 // No area code entered
313 this.showFacesMessage("form_add_contact_landLine:phoneAreaCode", "ERROR_ADMIN_NO_PHONE_AREA_CODE_ENTERED"); //NOI18N
315 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneAreaCode() instanceof Integer))) {
316 // No phone number entered
317 this.showFacesMessage("form_add_contact_landLine:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
322 Contact updatedContact;
323 DialableLandLineNumber landLineNumber = this.adminPhoneController.getLandLineNumber();
327 // All fine so far, then which was choosen?
328 if (landLineNumber instanceof DialableLandLineNumber) {
329 // User has choosen number
330 updatedContact = this.adminPhoneBean.linkExistingLandLineNumberWithContact(contact, landLineNumber);
332 // Create new instance
333 landLineNumber = new LandLineNumber(this.adminPhoneController.getPhoneCountry(), this.adminPhoneController.getPhoneAreaCode(), this.adminPhoneController.getPhoneNumber());
336 updatedContact = this.adminPhoneBean.linkNewLandLineNumberWithContact(contact, landLineNumber);
338 } catch (final PhoneNumberAlreadyLinkedException ex) {
339 // Throw again as cause
340 this.showFacesMessage("form_add_contact_landLine:phoneNumber", ex); //NOI18N
345 this.adminLinkedLandLineNumberEvent.fire(new AdminLinkedLandLineNumberEvent(updatedContact, landLineNumber));
347 // Return to contact profile
348 return "admin_show_contact"; //NOI18N
352 public String doLinkAddMobileNumber (final Contact contact) {
353 // Is all data properly set?
354 if (null == contact) {
356 throw new NullPointerException("contact is null"); //NOI18N
357 } else if (contact.getContactId() == null) {
359 throw new NullPointerException("contact.contactId is null"); //NOI18N
360 } else if (contact.getContactId() < 1) {
362 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
363 } else if ((this.adminPhoneController.getMobileNumber() == null) && (this.adminPhoneController.getMobileProvider() == null) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
364 // All fields are empty
365 throw new NullPointerException("mobileNumber, mobileProvider and phoneNumer are null"); //NOI18N
366 } else if ((this.adminPhoneController.getMobileNumber() instanceof DialableMobileNumber) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
367 // All fields are set
368 throw new IllegalStateException("mobileNumber, mobileProvider and phoneNumer are all set"); //NOI18N
369 } else if ((this.adminPhoneController.getMobileProvider() == null) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
370 // No mobile provider selected
371 this.showFacesMessage("form_add_contact_mobile:phoneCountry", "ERROR_ADMIN_NO_PHONE_MOBILE_PROVIDER_SELECTED"); //NOI18N
373 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider)) {
374 // No phone number entered
375 this.showFacesMessage("form_add_contact_mobile:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
380 Contact updatedContact;
381 DialableMobileNumber mobileNumber = this.adminPhoneController.getMobileNumber();
385 // All fine so far, then which was choosen?
386 if (mobileNumber instanceof DialableMobileNumber) {
387 // User has choosen number
388 updatedContact = this.adminPhoneBean.linkExistingMobileNumberWithContact(contact, mobileNumber);
390 // Create new instance
391 mobileNumber = new MobileNumber(this.adminPhoneController.getMobileProvider(), this.adminPhoneController.getPhoneNumber());
394 updatedContact = this.adminPhoneBean.linkNewMobileNumberWithContact(contact, mobileNumber);
396 } catch (final PhoneNumberAlreadyLinkedException ex) {
397 // Throw again as cause
398 this.showFacesMessage("form_add_contact_mobile:phoneNumber", ex); //NOI18N
403 this.adminLinkedMobileNumberEvent.fire(new AdminLinkedMobileNumberEvent(updatedContact, mobileNumber));
405 // Return to contact profile
406 return "admin_show_contact"; //NOI18N
410 * Post-construction method
413 public void init () {
416 // Get initial context
417 Context context = new InitialContext();
419 // Try to lookup the beans
420 this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
421 } catch (final NamingException e) {
423 throw new FaceletException(e);
428 public String unlinkFaxContactData () {
430 if (this.beanHelper.getFaxNumber() == null) {
431 // Not set, throw NPE
432 throw new NullPointerException("this.beanHelper.faxNumber is null"); //NOI18N
433 } else if (this.beanHelper.getFaxNumber().getPhoneId() == null) {
435 throw new NullPointerException("this.beanHelper.faxNumber.phoneId is null"); //NOI18N
436 } else if (this.beanHelper.getFaxNumber().getPhoneId() < 1) {
438 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.faxNumber.phoneId={0} is not valid", this.beanHelper.getFaxNumber().getPhoneId())); //NOI18N
439 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() == null) {
441 throw new NullPointerException("this.beanHelper.faxNumber.phoneNumber is null"); //NOI18N
442 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() < 1) {
443 // Throw it again ...
444 throw new NullPointerException(MessageFormat.format("this.beanHelper.faxNumber.phoneNumber={0} is not valid.", this.beanHelper.getFaxNumber().getPhoneNumber())); //NOI18N
445 } else if (this.beanHelper.getContact() == null) {
446 // ... and throw again
447 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
448 } else if (this.beanHelper.getContact().getContactId() == null) {
450 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
451 } else if (this.beanHelper.getContact().getContactId() < 1) {
453 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
456 // Init contact instance
457 Contact updatedContact;
460 // Unlink it and return contact without fax instance
461 updatedContact = this.adminPhoneBean.unlinkFaxDataFromContact(this.beanHelper.getContact(), this.beanHelper.getFaxNumber());
462 } catch (final PhoneNumberNotLinkedException ex) {
464 this.showFacesMessage("form_unlink_contact_fax:faxNumberId", ex); //NOI18N
469 this.faxNumberUnlinkedEvent.fire(new AdminUnlinkedFaxNumberEvent(updatedContact, this.beanHelper.getFaxNumber()));
472 return "admin_show_contact"; //NOI18N
476 public String unlinkLandLineContactData () {
478 if (this.beanHelper.getLandLineNumber() == null) {
479 // Not set, throw NPE
480 throw new NullPointerException("this.beanHelper.landLineNumber is null"); //NOI18N
481 } else if (this.beanHelper.getLandLineNumber().getPhoneId() == null) {
483 throw new NullPointerException("this.beanHelper.landLineNumber.phoneId is null"); //NOI18N
484 } else if (this.beanHelper.getLandLineNumber().getPhoneId() < 1) {
486 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.landLineNumber.phoneId={0} is not valid", this.beanHelper.getLandLineNumber().getPhoneId())); //NOI18N
487 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() == null) {
489 throw new NullPointerException("this.beanHelper.landLineNumber.phoneNumber is null"); //NOI18N
490 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() < 1) {
491 // Throw it again ...
492 throw new NullPointerException(MessageFormat.format("this.beanHelper.landLineNumber.phoneNumber={0} is not valid.", this.beanHelper.getLandLineNumber().getPhoneNumber())); //NOI18N
493 } else if (this.beanHelper.getContact() == null) {
494 // ... and throw again
495 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
496 } else if (this.beanHelper.getContact().getContactId() == null) {
498 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
499 } else if (this.beanHelper.getContact().getContactId() < 1) {
501 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
504 // Init contact instance
505 Contact updatedContact;
508 // Unlink it and return contact without landLine instance
509 updatedContact = this.adminPhoneBean.unlinkLandLineDataFromContact(this.beanHelper.getContact(), this.beanHelper.getLandLineNumber());
510 } catch (final PhoneNumberNotLinkedException ex) {
512 this.showFacesMessage("form_unlink_contact_landLine:landLineNumberId", ex); //NOI18N
517 this.landLineNumberUnlinkedEvent.fire(new AdminUnlinkedLandLineNumberEvent(updatedContact, this.beanHelper.getLandLineNumber()));
520 return "admin_show_contact"; //NOI18N
524 public String unlinkMobileContactData () {
526 if (this.beanHelper.getMobileNumber() == null) {
527 // Not set, throw NPE
528 throw new NullPointerException("this.beanHelper.mobileNumber is null"); //NOI18N
529 } else if (this.beanHelper.getMobileNumber().getPhoneId() == null) {
531 throw new NullPointerException("this.beanHelper.mobileNumber.phoneId is null"); //NOI18N
532 } else if (this.beanHelper.getMobileNumber().getPhoneId() < 1) {
534 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.phoneId={0} is not valid", this.beanHelper.getMobileNumber().getPhoneId())); //NOI18N
535 } else if (this.beanHelper.getMobileNumber().getMobileProvider() == null) {
537 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider is null"); //NOI18N
538 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() == null) {
540 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider.providerId is null"); //NOI18N
541 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() < 1) {
543 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.mobileProvider.providerId={0} is not valid.", this.beanHelper.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
544 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() == null) {
546 throw new NullPointerException("this.beanHelper.mobileNumber.phoneNumber is null"); //NOI18N
547 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() < 1) {
548 // Throw it again ...
549 throw new NullPointerException(MessageFormat.format("this.beanHelper.mobileNumber.phoneNumber={0} is not valid.", this.beanHelper.getMobileNumber().getPhoneNumber())); //NOI18N
550 } else if (this.beanHelper.getContact() == null) {
551 // ... and throw again
552 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
553 } else if (this.beanHelper.getContact().getContactId() == null) {
555 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
556 } else if (this.beanHelper.getContact().getContactId() < 1) {
558 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
561 // Init contact instance
562 Contact updatedContact;
565 // Unlink it and return contact without mobile instance
566 updatedContact = this.adminPhoneBean.unlinkMobileDataFromContact(this.beanHelper.getContact(), this.beanHelper.getMobileNumber());
567 } catch (final PhoneNumberNotLinkedException ex) {
569 this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex); //NOI18N
574 this.mobileNumberUnlinkedEvent.fire(new AdminUnlinkedMobileNumberEvent(updatedContact, this.beanHelper.getMobileNumber()));
577 return "admin_show_contact"; //NOI18N
583 private void clear () {