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.JobsWebRequestController;
49 import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController;
50 import org.mxchange.jphone.exceptions.FaxNumberNotLinkedException;
51 import org.mxchange.jphone.exceptions.LandLineNumberNotLinkedException;
52 import org.mxchange.jphone.exceptions.MobileNumberNotLinkedException;
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.AdminAddedUserEvent;
63 * An administrative contact phone controller (bean)
65 * @author Roland Haeder<roland@mxchange.org>
67 @Named ("adminContactPhoneController")
69 public class JobsAdminContactPhoneWebRequestBean extends BaseJobsController implements JobsAdminContactPhoneWebRequestController {
74 private static final long serialVersionUID = 542_145_347_916L;
77 * Event being fired when a fax number has been linked
79 private Event<AdminLinkedFaxNumberEvent> adminLinkedFaxNumberEvent;
82 * Event being fired when a land-line number has been linked
84 private Event<AdminLinkedLandLineNumberEvent> adminLinkedLandLineNumberEvent;
87 * Event being fired when a mobile number has been linked
89 private Event<AdminLinkedMobileNumberEvent> adminLinkedMobileNumberEvent;
92 * Administrative EJB for phone number
94 private AdminContactsPhoneSessionBeanRemote adminPhoneBean;
97 * Administrative phone controller
100 private JobsAdminPhoneWebRequestController adminPhoneController;
103 * Admin helper instance
106 private JobsWebRequestController beanHelper;
109 * Event being fired when a fax number has been unlinked
113 private Event<AdminUnlinkedFaxNumberEvent> faxNumberUnlinkedEvent;
116 * Event being fired when a land-line number has been unlinked
120 private Event<AdminUnlinkedLandLineNumberEvent> landLineNumberUnlinkedEvent;
123 * Event being fired when admin unlinks mobile from contact
127 private Event<AdminUnlinkedMobileNumberEvent> mobileNumberUnlinkedEvent;
130 * Default constructor
132 public JobsAdminContactPhoneWebRequestBean () {
135 // Get initial context
136 Context context = new InitialContext();
138 // Try to lookup the beans
139 this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/adminContactPhone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
140 } catch (final NamingException e) {
142 throw new FaceletException(e);
147 public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
148 // The event must be valid
151 throw new NullPointerException("event is null"); //NOI18N
152 } else if (event.getAddedContact() == null) {
154 throw new NullPointerException("event.addedContact is null"); //NOI18N
155 } else if (event.getAddedContact().getContactId() == null) {
157 throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
158 } else if (event.getAddedContact().getContactId() < 1) {
160 throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
168 public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
169 // event should not be null
172 throw new NullPointerException("event is null"); //NOI18N
173 } else if (event.getAddedUser() == null) {
175 throw new NullPointerException("event.addedUser is null"); //NOI18N
176 } else if (event.getAddedUser().getUserId() == null) {
178 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
179 } else if (event.getAddedUser().getUserId() < 1) {
181 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
189 public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
190 // event should not be null
193 throw new NullPointerException("event is null"); //NOI18N
194 } else if (event.getUpdatedContact() == null) {
196 throw new NullPointerException("event.updatedContact is null"); //NOI18N
197 } else if (event.getUpdatedContact().getContactId() == null) {
199 throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
200 } else if (event.getUpdatedContact().getContactId() < 1) {
202 throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
210 public String doLinkAddFaxNumber (final Contact contact) {
211 // Is all data properly set?
212 if (null == contact) {
214 throw new NullPointerException("contact is null"); //NOI18N
215 } else if (contact.getContactId() == null) {
217 throw new NullPointerException("contact.contactId is null"); //NOI18N
218 } else if (contact.getContactId() < 1) {
220 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
221 } 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))) {
222 // All fields are empty
223 throw new NullPointerException("choosenFaxNumber, mobileProvider and phoneNumer are null"); //NOI18N
224 } else if ((this.adminPhoneController.getChoosenFaxNumber() instanceof DialableFaxNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
225 // All fields are set
226 throw new IllegalStateException("choosenFaxNumber, mobileProvider and phoneNumer are all set"); //NOI18N
227 } else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
228 // No country selected
229 this.showFacesMessage("form_add_contact_fax:phoneCountry", "ERROR_ADMIN_NO_PHONE_COUNTRY_SELECTED"); //NOI18N
231 } else if (((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
232 // No area code entered
233 this.showFacesMessage("form_add_contact_fax:phoneAreaCode", "ERROR_ADMIN_NO_PHONE_AREA_CODE_ENTERED"); //NOI18N
235 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneAreaCode() instanceof Integer))) {
236 // No phone number entered
237 this.showFacesMessage("form_add_contact_fax:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
242 Contact updatedContact;
243 DialableFaxNumber faxNumber = this.adminPhoneController.getChoosenFaxNumber();
245 // All fine so far, then which was choosen?
246 if (faxNumber instanceof DialableFaxNumber) {
247 // User has choosen number
248 updatedContact = this.adminPhoneBean.linkExistingFaxNumberWithContact(contact, faxNumber);
250 // Create new instance
251 faxNumber = new FaxNumber(this.adminPhoneController.getPhoneCountry(), this.adminPhoneController.getPhoneAreaCode(), this.adminPhoneController.getPhoneNumber());
254 updatedContact = this.adminPhoneBean.linkNewFaxNumberWithContact(contact, faxNumber);
258 this.adminLinkedFaxNumberEvent.fire(new AdminFaxNumberLinkedEvent(updatedContact, faxNumber));
260 // Return to contact profile
261 return "admin_show_contact?faces-redirect=true&includeViewParams=true"; //NOI18N
265 public String doLinkAddLandLineNumber (final Contact contact) {
266 // Is all data properly set?
267 if (null == contact) {
269 throw new NullPointerException("contact is null"); //NOI18N
270 } else if (contact.getContactId() == null) {
272 throw new NullPointerException("contact.contactId is null"); //NOI18N
273 } else if (contact.getContactId() < 1) {
275 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
276 } 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))) {
277 // All fields are empty
278 throw new NullPointerException("choosenLandLineNumber, mobileProvider and phoneNumer are null"); //NOI18N
279 } else if ((this.adminPhoneController.getChoosenLandLineNumber() instanceof DialableLandLineNumber) && (this.adminPhoneController.getPhoneCountry() instanceof Country) && (this.adminPhoneController.getPhoneAreaCode() instanceof Integer) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
280 // All fields are set
281 throw new IllegalStateException("choosenLandLineNumber, mobileProvider and phoneNumer are all set"); //NOI18N
282 } else if ((this.adminPhoneController.getPhoneCountry() == null) && ((this.adminPhoneController.getPhoneAreaCode() instanceof Integer) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
283 // No country selected
284 this.showFacesMessage("form_add_contact_landLine:phoneCountry", "ERROR_ADMIN_NO_PHONE_COUNTRY_SELECTED"); //NOI18N
286 } else if (((this.adminPhoneController.getPhoneAreaCode() == null) || (this.adminPhoneController.getPhoneAreaCode() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneNumber() instanceof Long))) {
287 // No area code entered
288 this.showFacesMessage("form_add_contact_landLine:phoneAreaCode", "ERROR_ADMIN_NO_PHONE_AREA_CODE_ENTERED"); //NOI18N
290 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && ((this.adminPhoneController.getPhoneCountry() instanceof Country) || (this.adminPhoneController.getPhoneAreaCode() instanceof Integer))) {
291 // No phone number entered
292 this.showFacesMessage("form_add_contact_landLine:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
297 Contact updatedContact;
298 DialableLandLineNumber landLineNumber = this.adminPhoneController.getChoosenLandLineNumber();
300 // All fine so far, then which was choosen?
301 if (landLineNumber instanceof DialableLandLineNumber) {
302 // User has choosen number
303 updatedContact = this.adminPhoneBean.linkExistingLandLineNumberWithContact(contact, landLineNumber);
305 // Create new instance
306 landLineNumber = new LandLineNumber(this.adminPhoneController.getPhoneCountry(), this.adminPhoneController.getPhoneAreaCode(), this.adminPhoneController.getPhoneNumber());
309 updatedContact = this.adminPhoneBean.linkNewLandLineNumberWithContact(contact, landLineNumber);
313 this.adminLinkedLandLineNumberEvent.fire(new AdminLandLineNumberLinkedEvent(updatedContact, landLineNumber));
315 // Return to contact profile
316 return "admin_show_contact?faces-redirect=true&includeViewParams=true"; //NOI18N
320 public String doLinkAddMobileNumber (final Contact contact) {
321 // Is all data properly set?
322 if (null == contact) {
324 throw new NullPointerException("contact is null"); //NOI18N
325 } else if (contact.getContactId() == null) {
327 throw new NullPointerException("contact.contactId is null"); //NOI18N
328 } else if (contact.getContactId() < 1) {
330 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
331 } else if ((this.adminPhoneController.getChoosenMobileNumber() == null) && (this.adminPhoneController.getMobileProvider() == null) && ((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1))) {
332 // All fields are empty
333 throw new NullPointerException("choosenMobileNumber, mobileProvider and phoneNumer are null"); //NOI18N
334 } else if ((this.adminPhoneController.getChoosenMobileNumber() instanceof DialableMobileNumber) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
335 // All fields are set
336 throw new IllegalStateException("choosenMobileNumber, mobileProvider and phoneNumer are all set"); //NOI18N
337 } else if ((this.adminPhoneController.getMobileProvider() == null) && (this.adminPhoneController.getPhoneNumber() instanceof Long)) {
338 // No mobile provider selected
339 this.showFacesMessage("form_add_contact_mobile:phoneCountry", "ERROR_ADMIN_NO_PHONE_MOBILE_PROVIDER_SELECTED"); //NOI18N
341 } else if (((this.adminPhoneController.getPhoneNumber() == null) || (this.adminPhoneController.getPhoneNumber() < 1)) && (this.adminPhoneController.getMobileProvider() instanceof MobileProvider)) {
342 // No phone number entered
343 this.showFacesMessage("form_add_contact_mobile:phoneNumber", "ERROR_ADMIN_NO_PHONE_NUMBER_ENTERED"); //NOI18N
348 Contact updatedContact;
349 DialableMobileNumber mobileNumber = this.adminPhoneController.getChoosenMobileNumber();
351 // All fine so far, then which was choosen?
352 if (mobileNumber instanceof DialableMobileNumber) {
353 // User has choosen number
354 updatedContact = this.adminPhoneBean.linkExistingMobileNumberWithContact(contact, mobileNumber);
356 // Create new instance
357 mobileNumber = new MobileNumber(this.adminPhoneController.getMobileProvider(), this.adminPhoneController.getPhoneNumber());
360 updatedContact = this.adminPhoneBean.linkNewMobileNumberWithContact(contact, mobileNumber);
364 this.adminLinkedMobileNumberEvent.fire(new AdminMobileNumberLinkedEvent(updatedContact, mobileNumber));
366 // Return to contact profile
367 return "admin_show_contact?faces-redirect=true&includeViewParams=true"; //NOI18N
371 public String unlinkFaxContactData () {
373 if (this.beanHelper.getFaxNumber() == null) {
374 // Not set, throw NPE
375 throw new NullPointerException("this.beanHelper.faxNumber is null"); //NOI18N
376 } else if (this.beanHelper.getFaxNumber().getPhoneId() == null) {
378 throw new NullPointerException("this.beanHelper.faxNumber.phoneId is null"); //NOI18N
379 } else if (this.beanHelper.getFaxNumber().getPhoneId() < 1) {
381 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.faxNumber.phoneId={0} is not valid", this.beanHelper.getFaxNumber().getPhoneId())); //NOI18N
382 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() == null) {
384 throw new NullPointerException("this.beanHelper.faxNumber.phoneNumber is null"); //NOI18N
385 } else if (this.beanHelper.getFaxNumber().getPhoneNumber() < 1) {
386 // Throw it again ...
387 throw new NullPointerException(MessageFormat.format("this.beanHelper.faxNumber.phoneNumber={0} is not valid.", this.beanHelper.getFaxNumber().getPhoneNumber())); //NOI18N
388 } else if (this.beanHelper.getContact() == null) {
389 // ... and throw again
390 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
391 } else if (this.beanHelper.getContact().getContactId() == null) {
393 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
394 } else if (this.beanHelper.getContact().getContactId() < 1) {
396 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
399 // Init contact instance
400 Contact updatedContact;
403 // Unlink it and return contact without fax instance
404 updatedContact = this.adminPhoneBean.unlinkFaxDataFromContact(this.beanHelper.getContact(), this.beanHelper.getFaxNumber());
405 } catch (final FaxNumberNotLinkedException ex) {
407 this.showFacesMessage("form_unlink_contact_fax:faxNumberId", ex); //NOI18N
412 this.faxNumberUnlinkedEvent.fire(new AdminFaxNumberUnlinkedEvent(updatedContact, this.beanHelper.getFaxNumber()));
415 return "admin_show_contact?faces-redirect=true&includeViewParams=true"; //NOI18N
419 public String unlinkLandLineContactData () {
421 if (this.beanHelper.getLandLineNumber() == null) {
422 // Not set, throw NPE
423 throw new NullPointerException("this.beanHelper.landLineNumber is null"); //NOI18N
424 } else if (this.beanHelper.getLandLineNumber().getPhoneId() == null) {
426 throw new NullPointerException("this.beanHelper.landLineNumber.phoneId is null"); //NOI18N
427 } else if (this.beanHelper.getLandLineNumber().getPhoneId() < 1) {
429 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.landLineNumber.phoneId={0} is not valid", this.beanHelper.getLandLineNumber().getPhoneId())); //NOI18N
430 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() == null) {
432 throw new NullPointerException("this.beanHelper.landLineNumber.phoneNumber is null"); //NOI18N
433 } else if (this.beanHelper.getLandLineNumber().getPhoneNumber() < 1) {
434 // Throw it again ...
435 throw new NullPointerException(MessageFormat.format("this.beanHelper.landLineNumber.phoneNumber={0} is not valid.", this.beanHelper.getLandLineNumber().getPhoneNumber())); //NOI18N
436 } else if (this.beanHelper.getContact() == null) {
437 // ... and throw again
438 throw new NullPointerException("this.beanHelper.contact is null"); //NOI18N
439 } else if (this.beanHelper.getContact().getContactId() == null) {
441 throw new NullPointerException("this.beanHelper.contact.contactId is null"); //NOI18N
442 } else if (this.beanHelper.getContact().getContactId() < 1) {
444 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.contact.contactId={0} is invalid.", this.beanHelper.getContact().getContactId())); //NOI18N
447 // Init contact instance
448 Contact updatedContact;
451 // Unlink it and return contact without landLine instance
452 updatedContact = this.adminPhoneBean.unlinkLandLineDataFromContact(this.beanHelper.getContact(), this.beanHelper.getLandLineNumber());
453 } catch (final LandLineNumberNotLinkedException ex) {
455 this.showFacesMessage("form_unlink_contact_landLine:landLineNumberId", ex); //NOI18N
460 this.landLineNumberUnlinkedEvent.fire(new AdminLandLineNumberUnlinkedEvent(updatedContact, this.beanHelper.getLandLineNumber()));
463 return "admin_show_contact?faces-redirect=true&includeViewParams=true"; //NOI18N
467 public String unlinkMobileContactData () {
469 if (this.beanHelper.getMobileNumber() == null) {
470 // Not set, throw NPE
471 throw new NullPointerException("this.beanHelper.mobileNumber is null"); //NOI18N
472 } else if (this.beanHelper.getMobileNumber().getPhoneId() == null) {
474 throw new NullPointerException("this.beanHelper.mobileNumber.phoneId is null"); //NOI18N
475 } else if (this.beanHelper.getMobileNumber().getPhoneId() < 1) {
477 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.phoneId={0} is not valid", this.beanHelper.getMobileNumber().getPhoneId())); //NOI18N
478 } else if (this.beanHelper.getMobileNumber().getMobileProvider() == null) {
480 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider is null"); //NOI18N
481 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() == null) {
483 throw new NullPointerException("this.beanHelper.mobileNumber.mobileProvider.providerId is null"); //NOI18N
484 } else if (this.beanHelper.getMobileNumber().getMobileProvider().getProviderId() < 1) {
486 throw new IllegalArgumentException(MessageFormat.format("this.beanHelper.mobileNumber.mobileProvider.providerId={0} is not valid.", this.beanHelper.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
487 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() == null) {
489 throw new NullPointerException("this.beanHelper.mobileNumber.phoneNumber is null"); //NOI18N
490 } else if (this.beanHelper.getMobileNumber().getPhoneNumber() < 1) {
491 // Throw it again ...
492 throw new NullPointerException(MessageFormat.format("this.beanHelper.mobileNumber.phoneNumber={0} is not valid.", this.beanHelper.getMobileNumber().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 mobile instance
509 updatedContact = this.adminPhoneBean.unlinkMobileDataFromContact(this.beanHelper.getContact(), this.beanHelper.getMobileNumber());
510 } catch (final MobileNumberNotLinkedException ex) {
512 this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex); //NOI18N
517 this.mobileNumberUnlinkedEvent.fire(new AdminMobileNumberUnlinkedEvent(updatedContact, this.beanHelper.getMobileNumber()));
520 return "admin_show_contact?faces-redirect=true&includeViewParams=true"; //NOI18N
526 private void clear () {