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.jcontacts.phone;
19 import java.text.MessageFormat;
20 import java.util.GregorianCalendar;
21 import java.util.Objects;
23 import javax.ejb.Stateless;
24 import org.mxchange.addressbook.database.BaseAddressbookDatabaseBean;
25 import org.mxchange.jcontacts.contact.Contact;
26 import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
27 import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException;
28 import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException;
29 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
30 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
31 import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
34 * A session EJB for administrative contact's phone number purposes
36 * @author Roland Häder<roland@mxchange.org>
38 @Stateless (name = "adminContactPhone", description = "An administrative bean handling contact's phone data")
39 public class AddressbookAdminContactPhoneSessionBean extends BaseAddressbookDatabaseBean implements AdminContactsPhoneSessionBeanRemote {
44 private static final long serialVersionUID = 189_217_561_460_237_108L;
50 private ContactSessionBeanRemote contactBean;
53 public Contact linkExistingFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException {
55 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
57 // Is the contact set?
58 if (null == contact) {
60 throw new NullPointerException("contact is null"); //NOI18N
61 } else if (contact.getContactId() == null) {
62 // ... and throw again
63 throw new NullPointerException("contact.contactId is null"); //NOI18N
64 } else if (contact.getContactId() < 1) {
66 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
67 } else if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
68 // Not set cell phone instance
69 throw new PhoneNumberAlreadyLinkedException(faxNumber);
70 } else if (null == faxNumber) {
72 throw new NullPointerException("faxNumber is null"); //NOI18N
73 } else if (faxNumber.getPhoneId() == null) {
75 throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
76 } else if (faxNumber.getPhoneId() < 1) {
78 throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
79 } else if (faxNumber.getPhoneCountry() == null) {
81 throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
82 } else if (faxNumber.getPhoneAreaCode() == null) {
84 throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
85 } else if (faxNumber.getPhoneAreaCode() < 1) {
87 throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid", faxNumber.getPhoneAreaCode())); //NOI18N
88 } else if (faxNumber.getPhoneNumber() == null) {
90 throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
91 } else if (faxNumber.getPhoneNumber() < 1) {
93 throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid", faxNumber.getPhoneNumber())); //NOI18N
96 // Set fax number in contact
97 contact.setContactFaxNumber(faxNumber);
99 // Detach all phone entries before persisting it
100 this.detachAllContactPhoneEntries(contact);
103 Contact updatedContact = this.contactBean.updateContactData(contact);
106 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
109 return updatedContact;
113 public Contact linkExistingLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException {
115 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
117 // Is the contact set?
118 if (null == contact) {
120 throw new NullPointerException("contact is null"); //NOI18N
121 } else if (contact.getContactId() == null) {
122 // ... and throw again
123 throw new NullPointerException("contact.contactId is null"); //NOI18N
124 } else if (contact.getContactId() < 1) {
126 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
127 } else if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
128 // Not set cell phone instance
129 throw new PhoneNumberAlreadyLinkedException(landLineNumber);
130 } else if (null == landLineNumber) {
132 throw new NullPointerException("landLineNumber is null"); //NOI18N
133 } else if (landLineNumber.getPhoneId() == null) {
135 throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
136 } else if (landLineNumber.getPhoneId() < 1) {
138 throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
139 } else if (landLineNumber.getPhoneCountry() == null) {
141 throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
142 } else if (landLineNumber.getPhoneAreaCode() == null) {
144 throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
145 } else if (landLineNumber.getPhoneAreaCode() < 1) {
147 throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid", landLineNumber.getPhoneAreaCode())); //NOI18N
148 } else if (landLineNumber.getPhoneNumber() == null) {
150 throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
151 } else if (landLineNumber.getPhoneNumber() < 1) {
153 throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid", landLineNumber.getPhoneNumber())); //NOI18N
156 // Set land-line number in contact
157 contact.setContactLandLineNumber(landLineNumber);
159 // Detach all phone entries before persisting it
160 this.detachAllContactPhoneEntries(contact);
163 Contact updatedContact = this.contactBean.updateContactData(contact);
166 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
169 return updatedContact;
173 public Contact linkExistingMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException {
175 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
177 // Is the contact set?
178 if (null == contact) {
180 throw new NullPointerException("contact is null"); //NOI18N
181 } else if (contact.getContactId() == null) {
182 // ... and throw again
183 throw new NullPointerException("contact.contactId is null"); //NOI18N
184 } else if (contact.getContactId() < 1) {
186 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
187 } else if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
188 // Not set cell phone instance
189 throw new PhoneNumberAlreadyLinkedException(mobileNumber);
190 } else if (null == mobileNumber) {
192 throw new NullPointerException("mobileNumber is null"); //NOI18N
193 } else if (mobileNumber.getPhoneId() == null) {
195 throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
196 } else if (mobileNumber.getPhoneId() < 1) {
198 throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
199 } else if (mobileNumber.getMobileProvider() == null) {
201 throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
202 } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
204 throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
205 } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
207 throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
210 // Set mobile number in contact
211 contact.setContactMobileNumber(mobileNumber);
213 // Detach all phone entries before persisting it
214 this.detachAllContactPhoneEntries(contact);
217 Contact updatedContact = this.contactBean.updateContactData(contact);
220 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
223 return updatedContact;
227 public Contact linkNewFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException {
229 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
231 // Is the contact set?
232 if (null == contact) {
234 throw new NullPointerException("contact is null"); //NOI18N
235 } else if (contact.getContactId() == null) {
236 // ... and throw again
237 throw new NullPointerException("contact.contactId is null"); //NOI18N
238 } else if (contact.getContactId() < 1) {
240 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
241 } else if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
242 // Not set cell phone instance
243 throw new PhoneNumberAlreadyLinkedException(faxNumber);
244 } else if (null == faxNumber) {
246 throw new NullPointerException("faxNumber is null"); //NOI18N
247 } else if (faxNumber.getPhoneId() instanceof Long) {
249 throw new IllegalStateException(MessageFormat.format("faxNumber.phoneId={0} is not null", faxNumber.getPhoneId())); //NOI18N
250 } else if (faxNumber.getPhoneCountry() == null) {
252 throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
253 } else if (faxNumber.getPhoneAreaCode() == null) {
255 throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
256 } else if (faxNumber.getPhoneAreaCode() < 1) {
258 throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid", faxNumber.getPhoneAreaCode())); //NOI18N
259 } else if (faxNumber.getPhoneNumber() == null) {
261 throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
262 } else if (faxNumber.getPhoneNumber() < 1) {
264 throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid", faxNumber.getPhoneNumber())); //NOI18N
267 // Set created instance
268 faxNumber.setPhoneEntryCreated(new GregorianCalendar());
270 // Set fax number in contact
271 contact.setContactFaxNumber(faxNumber);
273 // Detach all phone entries before persisting it
274 this.detachAllContactPhoneEntries(contact);
277 Contact updatedContact = this.contactBean.updateContactData(contact);
280 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewFaxNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
283 return updatedContact;
287 public Contact linkNewLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException {
289 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
291 // Is the contact set?
292 if (null == contact) {
294 throw new NullPointerException("contact is null"); //NOI18N
295 } else if (contact.getContactId() == null) {
296 // ... and throw again
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 (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
302 // Not set cell phone instance
303 throw new PhoneNumberAlreadyLinkedException(landLineNumber);
304 } else if (null == landLineNumber) {
306 throw new NullPointerException("landLineNumber is null"); //NOI18N
307 } else if (landLineNumber.getPhoneId() instanceof Long) {
309 throw new IllegalStateException(MessageFormat.format("landLineNumber.phoneId={0} is not null", landLineNumber.getPhoneId())); //NOI18N
310 } else if (landLineNumber.getPhoneCountry() == null) {
312 throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
313 } else if (landLineNumber.getPhoneAreaCode() == null) {
315 throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
316 } else if (landLineNumber.getPhoneAreaCode() < 1) {
318 throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid", landLineNumber.getPhoneAreaCode())); //NOI18N
319 } else if (landLineNumber.getPhoneNumber() == null) {
321 throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
322 } else if (landLineNumber.getPhoneNumber() < 1) {
324 throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid", landLineNumber.getPhoneNumber())); //NOI18N
327 // Set created instance
328 landLineNumber.setPhoneEntryCreated(new GregorianCalendar());
330 // Set landLine number in contact
331 contact.setContactLandLineNumber(landLineNumber);
333 // Detach all phone entries before persisting it
334 this.detachAllContactPhoneEntries(contact);
337 Contact updatedContact = this.contactBean.updateContactData(contact);
340 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewLandLineNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
343 return updatedContact;
347 public Contact linkNewMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException {
349 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
351 // Is the contact set?
352 if (null == contact) {
354 throw new NullPointerException("contact is null"); //NOI18N
355 } else if (contact.getContactId() == null) {
356 // ... and throw again
357 throw new NullPointerException("contact.contactId is null"); //NOI18N
358 } else if (contact.getContactId() < 1) {
360 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
361 } else if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
362 // Not set cell phone instance
363 throw new PhoneNumberAlreadyLinkedException(mobileNumber);
364 } else if (null == mobileNumber) {
366 throw new NullPointerException("mobileNumber is null"); //NOI18N
367 } else if (mobileNumber.getPhoneId() instanceof Long) {
369 throw new IllegalStateException(MessageFormat.format("mobileNumber.phoneId={0} is not null", mobileNumber.getPhoneId())); //NOI18N
370 } else if (mobileNumber.getMobileProvider() == null) {
372 throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
373 } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
375 throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
376 } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
378 throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
381 // Set created instance
382 mobileNumber.setPhoneEntryCreated(new GregorianCalendar());
384 // Set mobile number in contact
385 contact.setContactMobileNumber(mobileNumber);
387 // Detach all phone entries before persisting it
388 this.detachAllContactPhoneEntries(contact);
391 Contact updatedContact = this.contactBean.updateContactData(contact);
394 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkNewMobileNumberWithContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
397 return updatedContact;
401 public Contact unlinkFaxDataFromContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberNotLinkedException {
403 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
405 // Is the contact set?
406 if (null == contact) {
408 throw new NullPointerException("contact is null"); //NOI18N
409 } else if (contact.getContactId() == null) {
410 // ... and throw again
411 throw new NullPointerException("contact.contactId is null"); //NOI18N
412 } else if (contact.getContactId() < 1) {
414 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
415 } else if (contact.getContactFaxNumber() == null) {
416 // Not set cell phone instance
417 throw new PhoneNumberNotLinkedException(faxNumber);
418 } else if (contact.getContactFaxNumber().getPhoneId() == null) {
420 throw new NullPointerException("contact.contactFaxNumber.phoneId is null"); //NOI18N
421 } else if (contact.getContactFaxNumber().getPhoneId() < 1) {
423 throw new IllegalArgumentException(MessageFormat.format("contact.contactFaxNumber.phoneId={0} is invalid.", contact.getContactFaxNumber().getPhoneId())); //NOI18N
424 } else if (!Objects.equals(faxNumber.getPhoneId(), contact.getContactFaxNumber().getPhoneId())) {
426 throw new IllegalArgumentException(MessageFormat.format("contact.contactFaxNumber.phoneId={0} and faxNumber.phoneId={1} are not the same.", contact.getContactFaxNumber().getPhoneId(), faxNumber.getPhoneId())); //NOI18N
429 // Remove it from contact
430 contact.setContactFaxNumber(null);
432 // Detach all phone entries before persisting it
433 this.detachAllContactPhoneEntries(contact);
436 Contact updatedContact = this.contactBean.updateContactData(contact);
439 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkFaxDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
442 return updatedContact;
446 public Contact unlinkLandLineDataFromContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberNotLinkedException {
448 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
450 // Is the contact set?
451 if (null == contact) {
453 throw new NullPointerException("contact is null"); //NOI18N
454 } else if (contact.getContactId() == null) {
455 // ... and throw again
456 throw new NullPointerException("contact.contactId is null"); //NOI18N
457 } else if (contact.getContactId() < 1) {
459 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
460 } else if (contact.getContactLandLineNumber() == null) {
461 // Not set cell phone instance
462 throw new PhoneNumberNotLinkedException(landLineNumber);
463 } else if (contact.getContactLandLineNumber().getPhoneId() == null) {
465 throw new NullPointerException("contact.contactLandLineNumber.phoneId is null"); //NOI18N
466 } else if (contact.getContactLandLineNumber().getPhoneId() < 1) {
468 throw new IllegalArgumentException(MessageFormat.format("contact.contactLandLineNumber.phoneId={0} is invalid.", contact.getContactLandLineNumber().getPhoneId())); //NOI18N
469 } else if (!Objects.equals(landLineNumber.getPhoneId(), contact.getContactLandLineNumber().getPhoneId())) {
471 throw new IllegalArgumentException(MessageFormat.format("contact.contactLandLineNumber.phoneId={0} and landLineNumber.phoneId={1} are not the same.", contact.getContactLandLineNumber().getPhoneId(), landLineNumber.getPhoneId())); //NOI18N
474 // Remove it from contact
475 contact.setContactLandLineNumber(null);
477 // Detach all phone entries before persisting it
478 this.detachAllContactPhoneEntries(contact);
481 Contact updatedContact = this.contactBean.updateContactData(contact);
484 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkLandLineDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
487 return updatedContact;
491 public Contact unlinkMobileDataFromContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberNotLinkedException {
493 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
495 // Is the contact set?
496 if (null == contact) {
498 throw new NullPointerException("contact is null"); //NOI18N
499 } else if (contact.getContactId() == null) {
500 // ... and throw again
501 throw new NullPointerException("contact.contactId is null"); //NOI18N
502 } else if (contact.getContactId() < 1) {
504 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
505 } else if (contact.getContactMobileNumber() == null) {
506 // Not set cell phone instance
507 throw new PhoneNumberNotLinkedException(mobileNumber);
508 } else if (contact.getContactMobileNumber().getPhoneId() == null) {
510 throw new NullPointerException("contact.contactMobileNumber.phoneId is null"); //NOI18N
511 } else if (contact.getContactMobileNumber().getPhoneId() < 1) {
513 throw new IllegalArgumentException(MessageFormat.format("contact.contactMobileNumber.phoneId={0} is invalid.", contact.getContactMobileNumber().getPhoneId())); //NOI18N
514 } else if (!Objects.equals(mobileNumber.getPhoneId(), contact.getContactMobileNumber().getPhoneId())) {
516 throw new IllegalArgumentException(MessageFormat.format("contact.contactMobileNumber.phoneId={0} and mobileNumber.phoneId={1} are not the same.", contact.getContactMobileNumber().getPhoneId(), mobileNumber.getPhoneId())); //NOI18N
519 // Remove it from contact
520 contact.setContactMobileNumber(null);
522 // Detach all phone entries before persisting it
523 this.detachAllContactPhoneEntries(contact);
526 Contact updatedContact = this.contactBean.updateContactData(contact);
529 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
532 return updatedContact;