- /**
- * Unlinks mobile data with current contact
- * <p>
- * @return Redirect outcome
- */
- public String unlinkMobileContactData () {
- // Create fax number instance
- final DialableMobileNumber number = this.createMobileNumber();
-
- // Is all data set
- if (number == null) {
- // Not set, throw NPE
- throw new NullPointerException("number is null"); //NOI18N
- } else if (number.getPhoneId() == null) {
- // Throw NPE again
- throw new NullPointerException("number.phoneId is null"); //NOI18N
- } else if (number.getPhoneId() < 1) {
- // Invalid number
- throw new IllegalArgumentException(MessageFormat.format("number.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
- } else if (number.getMobileProvider() == null) {
- // Throw NPE
- throw new NullPointerException("number.mobileProvider is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() == null) {
- // ... throw again
- throw new NullPointerException("number.mobileProvider.providerId is null"); //NOI18N
- } else if (number.getMobileProvider().getProviderId() < 1) {
- // Id not valid
- throw new IllegalArgumentException(MessageFormat.format("number.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
- } else if (number.getPhoneNumber() == null) {
- // Throw NPE again
- throw new NullPointerException("number.phoneNumber is null"); //NOI18N
- } else if (number.getPhoneNumber() < 1) {
- // Throw it again ...
- throw new NullPointerException(MessageFormat.format("number.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
- } else if (this.getContact() == null) {
- // ... and throw again
- throw new NullPointerException("this.contact is null"); //NOI18N
- } else if (this.getContact().getContactId() == null) {
- // ... and again ...
- throw new NullPointerException("this.contact.contactId is null"); //NOI18N
- } else if (this.getContact().getContactId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("this.contact.contactId={0} is invalid.", this.getContact().getContactId())); //NOI18N
- }
-
- // Init contact instance
- final Contact updatedContact;
-
- try {
- // Unlink it and return contact without mobile instance
- updatedContact = this.adminContactPhoneBean.unlinkMobileDataFromContact(this.getContact(), number);
- } catch (final PhoneNumberNotLinkedException ex) {
- // Did not work
- this.showFacesMessage("form_unlink_contact_mobile:mobileNumberId", ex, FacesMessage.SEVERITY_ERROR); //NOI18N
- return ""; //NOI18N
- }
-
- // Fire event
- this.mobileNumberUnlinkedEvent.fire(new AdminUnlinkedMobileNumberEvent(updatedContact, number));
-
- // All fine here
- return "admin_show_contact"; //NOI18N
- }
-