import javax.ejb.Stateless;
import org.mxchange.jcontacts.contact.Contact;
import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
-import org.mxchange.jphone.exceptions.CellphoneNotLinkedException;
-import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.exceptions.MobileNumberNotLinkedException;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
/**
* A session EJB for administrative contact's phone number purposes
private ContactSessionBeanRemote contactBean;
@Override
- public Contact unlinkCellphoneDataFromContact (final Contact contact, final DialableCellphoneNumber cellphoneNumber) throws CellphoneNotLinkedException {
+ public Contact unlinkMobileDataFromContact (final Contact contact, final DialableMobileNumber mobileNumber) throws MobileNumberNotLinkedException {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkCellphoneDataFromContact: contact={1},cellphoneNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, cellphoneNumber)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: contact={1},mobileNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, mobileNumber)); //NOI18N
// Is the contact set?
if (null == contact) {
} else if (contact.getContactId() < 1) {
// Invalid id number
throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
- } else if (contact.getContactCellphoneNumber() == null) {
+ } else if (contact.getContactMobileNumber() == null) {
// Not set cell phone instance
- throw new CellphoneNotLinkedException(cellphoneNumber);
- } else if (contact.getContactCellphoneNumber().getPhoneId() == null) {
+ throw new MobileNumberNotLinkedException(mobileNumber);
+ } else if (contact.getContactMobileNumber().getPhoneId() == null) {
// Throw NPE again
throw new NullPointerException("contact.contactCellphoneNumber.phoneId is null"); //NOI18N
- } else if (contact.getContactCellphoneNumber().getPhoneId() < 1) {
+ } else if (contact.getContactMobileNumber().getPhoneId() < 1) {
// Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("contact.contactCellphoneNumber.phoneId={0} is invalid.", contact.getContactCellphoneNumber().getPhoneId())); //NOI18N
- } else if (!Objects.equals(cellphoneNumber.getPhoneId(), contact.getContactCellphoneNumber().getPhoneId())) {
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactCellphoneNumber.phoneId={0} is invalid.", contact.getContactMobileNumber().getPhoneId())); //NOI18N
+ } else if (!Objects.equals(mobileNumber.getPhoneId(), contact.getContactMobileNumber().getPhoneId())) {
// Not same object
- throw new IllegalArgumentException(MessageFormat.format("contact.contactCellphoneNumber.phoneId={0} and cellphoneNumber.phoneId={1} are not the same.", contact.getContactCellphoneNumber().getPhoneId(), cellphoneNumber.getPhoneId())); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactCellphoneNumber.phoneId={0} and mobileNumber.phoneId={1} are not the same.", contact.getContactMobileNumber().getPhoneId(), mobileNumber.getPhoneId())); //NOI18N
}
// Remove it from contact
- contact.setContactCellphoneNumber(null);
+ contact.setContactMobileNumber(null);
// Update database
Contact updatedContact = this.contactBean.updateContactData(contact);
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkCellphoneDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.unlinkMobileDataFromContact: updatedContact={1} - EXIT!", this.getClass().getSimpleName(), updatedContact)); //NOI18N
// Return it
return updatedContact;