2 * Copyright (C) 2016 Roland Haeder
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.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.jcontacts.contact.Contact;
31 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
32 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
33 import org.mxchange.jcontacts.events.fax.linked.AdminFaxNumberLinkedEvent;
34 import org.mxchange.jcontacts.events.fax.linked.AdminLinkedFaxNumberEvent;
35 import org.mxchange.jcontacts.events.fax.unlinked.AdminFaxNumberUnlinkedEvent;
36 import org.mxchange.jcontacts.events.fax.unlinked.AdminUnlinkedFaxNumberEvent;
37 import org.mxchange.jcontacts.events.landline.linked.AdminLandLineNumberLinkedEvent;
38 import org.mxchange.jcontacts.events.landline.linked.AdminLinkedLandLineNumberEvent;
39 import org.mxchange.jcontacts.events.landline.unlinked.AdminLandLineNumberUnlinkedEvent;
40 import org.mxchange.jcontacts.events.landline.unlinked.AdminUnlinkedLandLineNumberEvent;
41 import org.mxchange.jcontacts.events.mobile.linked.AdminLinkedMobileNumberEvent;
42 import org.mxchange.jcontacts.events.mobile.linked.AdminMobileNumberLinkedEvent;
43 import org.mxchange.jcontacts.events.mobile.unlinked.AdminMobileNumberUnlinkedEvent;
44 import org.mxchange.jcontacts.events.mobile.unlinked.AdminUnlinkedMobileNumberEvent;
45 import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote;
46 import org.mxchange.jcountry.data.Country;
47 import org.mxchange.jjobs.beans.BaseJobsController;
48 import org.mxchange.jjobs.beans.helper.JobsWebViewHelperController;
49 import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController;
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.AdminAddedUserEvent;
62 * An administrative contact phone controller (bean)
64 * @author Roland Haeder<roland@mxchange.org>
66 @Named ("adminContactPhoneController")
68 public class JobsAdminContactPhoneWebRequestBean extends BaseJobsController implements JobsAdminContactPhoneWebRequestController {
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<AdminLinkedFaxNumberEvent> adminLinkedFaxNumberEvent;
88 * Event being fired when a land-line number has been linked
92 private Event<AdminLinkedLandLineNumberEvent> adminLinkedLandLineNumberEvent;
95 * Event being fired when a mobile number has been linked
99 private Event<AdminLinkedMobileNumberEvent> adminLinkedMobileNumberEvent;
102 * Administrative EJB for phone number
104 private AdminContactsPhoneSessionBeanRemote adminPhoneBean;
107 * Administrative phone controller
110 private JobsAdminPhoneWebRequestController adminPhoneController;
116 private JobsWebViewHelperController beanHelper;
119 * Event being fired when a fax number has been unlinked
123 private Event<AdminUnlinkedFaxNumberEvent> faxNumberUnlinkedEvent;
126 * Event being fired when a land-line number has been unlinked
130 private Event<AdminUnlinkedLandLineNumberEvent> landLineNumberUnlinkedEvent;
133 * Event being fired when admin unlinks mobile from contact
137 private Event<AdminUnlinkedMobileNumberEvent> mobileNumberUnlinkedEvent;
140 * Default constructor
142 public JobsAdminContactPhoneWebRequestBean () {
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/jlandingpage-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
153 } catch (final NamingException e) {
155 throw new FaceletException(e);
160 public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
161 // The event must be valid
164 throw new NullPointerException("event is null"); //NOI18N
165 } else if (event.getAddedContact() == null) {
167 throw new NullPointerException("event.addedContact is null"); //NOI18N
168 } else if (event.getAddedContact().getContactId() == null) {
170 throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
171 } else if (event.getAddedContact().getContactId() < 1) {
173 throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
181 public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
182 // event should not be null
185 throw new NullPointerException("event is null"); //NOI18N
186 } else if (event.getAddedUser() == null) {
188 throw new NullPointerException("event.addedUser is null"); //NOI18N
189 } else if (event.getAddedUser().getUserId() == null) {
191 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
192 } else if (event.getAddedUser().getUserId() < 1) {
194 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
202 public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
203 // event should not be null
206 throw new NullPointerException("event is null"); //NOI18N
207 } else if (event.getUpdatedContact() == null) {
209 throw new NullPointerException("event.updatedContact is null"); //NOI18N
210 } else if (event.getUpdatedContact().getContactId() == null) {
212 throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
213 } else if (event.getUpdatedContact().getContactId() < 1) {
215 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
223 public String doLinkAddFaxNumber (final Contact contact) {
224 // Is all data properly set?
225 if (null == contact) {
227 throw new NullPointerException("contact is null"); //NOI18N
228 } else if (contact.getContactId() == null) {
230 throw new NullPointerException("contact.contactId is null"); //NOI18N
231 } else if (contact.getContactId() < 1) {
233 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
234 } else if ((this.adminPhoneController.getChoosenFaxNumber() == null) && (this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
235 // All fields are empty
236 throw new NullPointerException("choosenFaxNumber, mobileProvider and phoneNumer are null"); //NOI18N
237 } else if ((this.adminPhoneController.getChoosenFaxNumber() instanceof DialableFaxNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
238 // All fields are set
239 throw new IllegalStateException("choosenFaxNumber, mobileProvider and phoneNumer are all set"); //NOI18N
240 } else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
241 // No country selected
242 this.showFacesMessage("form_add_contact_fax:phoneCountry", "ERROR_ADMIN_NO_PHONE_COUNTRY_SELECTED"); //NOI18N
244 } else if (((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
245 // No area code entered
246 this.showFacesMessage("form_add_contact_fax:phoneAreaCode", "ERROR_ADMIN_NO_PHONE_AREA_CODE_ENTERED"); //NOI18N
248 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneAreaCode() instanceof Integer))) {
249 // No phone number entered
250 this.showFacesMessage("form_add_contact_fax:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
255 Contact updatedContact;
256 DialableFaxNumber faxNumber = this.adminPhoneController.getChoosenFaxNumber();
260 // All fine so far, then which was choosen?
261 if (faxNumber instanceof DialableFaxNumber) {
262 // User has choosen number
263 updatedContact = this.adminPhoneBean.linkExistingFaxNumberWithContact(contact, faxNumber);
265 // Create new instance
266 faxNumber = new FaxNumber(this.adminPhoneController.getPhoneCountry(), this.adminPhoneController.getPhoneAreaCode(), this.adminPhoneController.getPhoneNumber());
269 updatedContact = this.adminPhoneBean.linkNewFaxNumberWithContact(contact, faxNumber);
271 } catch (final PhoneNumberAlreadyLinkedException ex) {
272 // Throw again as cause
273 this.showFacesMessage("form_add_contact_fax:phoneNumber", ex); //NOI18N
278 this.adminLinkedFaxNumberEvent.fire(new AdminFaxNumberLinkedEvent(updatedContact, faxNumber));
280 // Return to contact profile
281 return "admin_show_contact"; //NOI18N
285 public String doLinkAddLandLineNumber (final Contact contact) {
286 // Is all data properly set?
287 if (null == contact) {
289 throw new NullPointerException("contact is null"); //NOI18N
290 } else if (contact.getContactId() == null) {
292 throw new NullPointerException("contact.contactId is null"); //NOI18N
293 } else if (contact.getContactId() < 1) {
295 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
296 } else if ((this.adminPhoneController.getChoosenLandLineNumber() == null) && (this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
297 // All fields are empty
298 throw new NullPointerException("choosenLandLineNumber, mobileProvider and phoneNumer are null"); //NOI18N
299 } else if ((this.adminPhoneController.getChoosenLandLineNumber() instanceof DialableLandLineNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
300 // All fields are set
301 throw new IllegalStateException("choosenLandLineNumber, mobileProvider and phoneNumer are all set"); //NOI18N
302 } else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
303 // No country selected
304 this.showFacesMessage("form_add_contact_landLine:phoneCountry", "ERROR_ADMIN_NO_PHONE_COUNTRY_SELECTED"); //NOI18N
306 } else if (((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
307 // No area code entered
308 this.showFacesMessage("form_add_contact_landLine:phoneAreaCode", "ERROR_ADMIN_NO_PHONE_AREA_CODE_ENTERED"); //NOI18N
310 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneAreaCode() instanceof Integer))) {
311 // No phone number entered
312 this.showFacesMessage("form_add_contact_landLine:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
317 Contact updatedContact;
318 DialableLandLineNumber landLineNumber = this.adminPhoneController.getChoosenLandLineNumber();
322 // All fine so far, then which was choosen?
323 if (landLineNumber instanceof DialableLandLineNumber) {
324 // User has choosen number
325 updatedContact = this.adminPhoneBean.linkExistingLandLineNumberWithContact(contact, landLineNumber);
327 // Create new instance
328 landLineNumber = new LandLineNumber(this.adminPhoneController.getPhoneCountry(), this.adminPhoneController.getPhoneAreaCode(), this.adminPhoneController.getPhoneNumber());
331 updatedContact = this.adminPhoneBean.linkNewLandLineNumberWithContact(contact, landLineNumber);
333 } catch (final PhoneNumberAlreadyLinkedException ex) {
334 // Throw again as cause
335 this.showFacesMessage("form_add_contact_landLine:phoneNumber", ex); //NOI18N
340 this.adminLinkedLandLineNumberEvent.fire(new AdminLandLineNumberLinkedEvent(updatedContact, landLineNumber));
342 // Return to contact profile
343 return "admin_show_contact"; //NOI18N
347 public String doLinkAddMobileNumber (final Contact contact) {
348 // Is all data properly set?
349 if (null == contact) {
351 throw new NullPointerException("contact is null"); //NOI18N
352 } else if (contact.getContactId() == null) {
354 throw new NullPointerException("contact.contactId is null"); //NOI18N
355 } else if (contact.getContactId() < 1) {
357 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
358 } else if ((this.adminPhoneController.getChoosenMobileNumber() == null) && (this.adminPhoneController.getMobileProvider() == null) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
359 // All fields are empty
360 throw new NullPointerException("choosenMobileNumber, mobileProvider and phoneNumer are null"); //NOI18N
361 } else if ((this.adminPhoneController.getChoosenMobileNumber() instanceof DialableMobileNumber) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
362 // All fields are set
363 throw new IllegalStateException("choosenMobileNumber, mobileProvider and phoneNumer are all set"); //NOI18N
364 } else if ((this.adminPhoneController.getMobileProvider() == null) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
365 // No mobile provider selected
366 this.showFacesMessage("form_add_contact_mobile:phoneCountry", "ERROR_ADMIN_NO_PHONE_MOBILE_PROVIDER_SELECTED"); //NOI18N
368 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider)) {
369 // No phone number entered
370 this.showFacesMessage("form_add_contact_mobile:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
375 Contact updatedContact;
376 DialableMobileNumber mobileNumber = this.adminPhoneController.getChoosenMobileNumber();
380 // All fine so far, then which was choosen?
381 if (mobileNumber instanceof DialableMobileNumber) {
382 // User has choosen number
383 updatedContact = this.adminPhoneBean.linkExistingMobileNumberWithContact(contact, mobileNumber);
385 // Create new instance
386 mobileNumber = new MobileNumber(this.adminPhoneController.getMobileProvider(), this.adminPhoneController.getPhoneNumber());
389 updatedContact = this.adminPhoneBean.linkNewMobileNumberWithContact(contact, mobileNumber);
391 } catch (final PhoneNumberAlreadyLinkedException ex) {
392 // Throw again as cause
393 this.showFacesMessage("form_add_contact_mobile:phoneNumber", ex); //NOI18N
398 this.adminLinkedMobileNumberEvent.fire(new AdminMobileNumberLinkedEvent(updatedContact, mobileNumber));
400 // Return to contact profile
401 return "admin_show_contact"; //NOI18N
405 public String unlinkFaxContactData () {
407 if (this.beanHelper.getFaxNumber() == null) {
408 // Not set, throw NPE
409 throw new NullPointerException("this.beanHelper.faxNumber is null"); //NOI18N
410 } else if (this.beanHelper.getFaxNumber().getPhoneId() == null) {
412 throw new NullPointerException("this.beanHelper.faxNumber.phoneId is null"); //NOI18N
413 } else if (this.beanHelper.getFaxNumber().getPhoneId() < 1) {
415 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.faxNumber.phoneId={0} is not valid", this.beanHelper.getFaxNumber().getPhoneId())); //NOI18N
416 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() == null) {
418 throw new NullPointerException("this.beanHelper.faxNumber.phoneNumber is null"); //NOI18N
419 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() < 1) {
420 // Throw it again ...
421 throw new NullPointerException(MessageFormat.format("this.beanHelper.faxNumber.phoneNumber={0} is not valid.", this.beanHelper.getFaxNumber().getPhoneNumber())); //NOI18N
422 } else if (this.beanHelper.getContact() == null) {
423 // ... and throw again
424 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
425 } else if (this.beanHelper.getContact().getContactId() == null) {
427 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
428 } else if (this.beanHelper.getContact().getContactId() < 1) {
430 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
433 // Init contact instance
434 Contact updatedContact;
437 // Unlink it and return contact without fax instance
438 updatedContact = this.adminPhoneBean.unlinkFaxDataFromContact(this.beanHelper.getContact(), this.beanHelper.getFaxNumber());
439 } catch (final PhoneNumberNotLinkedException ex) {
441 this.showFacesMessage("form_unlink_contact_fax:faxNumberId", ex); //NOI18N
446 this.faxNumberUnlinkedEvent.fire(new AdminFaxNumberUnlinkedEvent(updatedContact, this.beanHelper.getFaxNumber()));
449 return "admin_show_contact"; //NOI18N
453 public String unlinkLandLineContactData () {
455 if (this.beanHelper.getLandLineNumber() == null) {
456 // Not set, throw NPE
457 throw new NullPointerException("this.beanHelper.landLineNumber is null"); //NOI18N
458 } else if (this.beanHelper.getLandLineNumber().getPhoneId() == null) {
460 throw new NullPointerException("this.beanHelper.landLineNumber.phoneId is null"); //NOI18N
461 } else if (this.beanHelper.getLandLineNumber().getPhoneId() < 1) {
463 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.landLineNumber.phoneId={0} is not valid", this.beanHelper.getLandLineNumber().getPhoneId())); //NOI18N
464 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() == null) {
466 throw new NullPointerException("this.beanHelper.landLineNumber.phoneNumber is null"); //NOI18N
467 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() < 1) {
468 // Throw it again ...
469 throw new NullPointerException(MessageFormat.format("this.beanHelper.landLineNumber.phoneNumber={0} is not valid.", this.beanHelper.getLandLineNumber().getPhoneNumber())); //NOI18N
470 } else if (this.beanHelper.getContact() == null) {
471 // ... and throw again
472 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
473 } else if (this.beanHelper.getContact().getContactId() == null) {
475 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
476 } else if (this.beanHelper.getContact().getContactId() < 1) {
478 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
481 // Init contact instance
482 Contact updatedContact;
485 // Unlink it and return contact without landLine instance
486 updatedContact = this.adminPhoneBean.unlinkLandLineDataFromContact(this.beanHelper.getContact(), this.beanHelper.getLandLineNumber());
487 } catch (final PhoneNumberNotLinkedException ex) {
489 this.showFacesMessage("form_unlink_contact_landLine:landLineNumberId", ex); //NOI18N
494 this.landLineNumberUnlinkedEvent.fire(new AdminLandLineNumberUnlinkedEvent(updatedContact, this.beanHelper.getLandLineNumber()));
497 return "admin_show_contact"; //NOI18N
501 public String unlinkMobileContactData () {
503 if (this.beanHelper.getMobileNumber() == null) {
504 // Not set, throw NPE
505 throw new NullPointerException("this.beanHelper.mobileNumber is null"); //NOI18N
506 } else if (this.beanHelper.getMobileNumber().getPhoneId() == null) {
508 throw new NullPointerException("this.beanHelper.mobileNumber.phoneId is null"); //NOI18N
509 } else if (this.beanHelper.getMobileNumber().getPhoneId() < 1) {
511 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.phoneId={0} is not valid", this.beanHelper.getMobileNumber().getPhoneId())); //NOI18N
512 } else if (this.beanHelper.getMobileNumber().getMobileProvider() == null) {
514 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider is null"); //NOI18N
515 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() == null) {
517 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider.providerId is null"); //NOI18N
518 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() < 1) {
520 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.mobileProvider.providerId={0} is not valid.", this.beanHelper.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
521 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() == null) {
523 throw new NullPointerException("this.beanHelper.mobileNumber.phoneNumber is null"); //NOI18N
524 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() < 1) {
525 // Throw it again ...
526 throw new NullPointerException(MessageFormat.format("this.beanHelper.mobileNumber.phoneNumber={0} is not valid.", this.beanHelper.getMobileNumber().getPhoneNumber())); //NOI18N
527 } else if (this.beanHelper.getContact() == null) {
528 // ... and throw again
529 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
530 } else if (this.beanHelper.getContact().getContactId() == null) {
532 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
533 } else if (this.beanHelper.getContact().getContactId() < 1) {
535 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
538 // Init contact instance
539 Contact updatedContact;
542 // Unlink it and return contact without mobile instance
543 updatedContact = this.adminPhoneBean.unlinkMobileDataFromContact(this.beanHelper.getContact(), this.beanHelper.getMobileNumber());
544 } catch (final PhoneNumberNotLinkedException ex) {
546 this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex); //NOI18N
551 this.mobileNumberUnlinkedEvent.fire(new AdminMobileNumberUnlinkedEvent(updatedContact, this.beanHelper.getMobileNumber()));
554 return "admin_show_contact"; //NOI18N
560 private void clear () {