From 22fdc0c806eb95995569f36f59345af87767cb55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 24 Apr 2020 02:04:27 +0200 Subject: [PATCH] Continued: - further splitted phone <-> mobile number - added checked thrown exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../AdminContactSessionBeanRemote.java | 3 +- .../contact/ContactSessionBeanRemote.java | 9 ++- .../AdminContactsMobileSessionBeanRemote.java | 80 +++++++++++++++++++ .../AdminContactsPhoneSessionBeanRemote.java | 79 +++++------------- 4 files changed, 109 insertions(+), 62 deletions(-) create mode 100644 src/org/mxchange/jcontacts/model/mobile/AdminContactsMobileSessionBeanRemote.java diff --git a/src/org/mxchange/jcontacts/model/contact/AdminContactSessionBeanRemote.java b/src/org/mxchange/jcontacts/model/contact/AdminContactSessionBeanRemote.java index b880d33..8d89b3c 100644 --- a/src/org/mxchange/jcontacts/model/contact/AdminContactSessionBeanRemote.java +++ b/src/org/mxchange/jcontacts/model/contact/AdminContactSessionBeanRemote.java @@ -47,8 +47,7 @@ public interface AdminContactSessionBeanRemote extends Serializable { *

* @return Updated contact instance *

- * @throws org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException - * Contact already found + * @throws ContactAlreadyAddedException Contact already found */ Contact addContact (final Contact contact) throws ContactAlreadyAddedException; diff --git a/src/org/mxchange/jcontacts/model/contact/ContactSessionBeanRemote.java b/src/org/mxchange/jcontacts/model/contact/ContactSessionBeanRemote.java index 6fdc026..3352f3c 100644 --- a/src/org/mxchange/jcontacts/model/contact/ContactSessionBeanRemote.java +++ b/src/org/mxchange/jcontacts/model/contact/ContactSessionBeanRemote.java @@ -19,6 +19,7 @@ package org.mxchange.jcontacts.model.contact; import java.io.Serializable; import java.util.List; import javax.ejb.Remote; +import org.mxchange.jcontacts.exceptions.ContactNotFoundException; /** * A remote interface for general contact purposes @@ -40,8 +41,10 @@ public interface ContactSessionBeanRemote extends Serializable { * contact instance *

* @return Updated contact instance + *

+ * @throws ContactNotFoundException If the given contact is not found */ - Contact updateContactData (final Contact contact, final boolean isMobileUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked); + Contact updateContactData (final Contact contact, final boolean isMobileUnlinked, final boolean isLandlineUnlinked, final boolean isFaxUnlinked) throws ContactNotFoundException; /** * Updates given contact in database. Please note that the id number must be @@ -51,8 +54,10 @@ public interface ContactSessionBeanRemote extends Serializable { * @param contact Contact to update *

* @return Updated contact instance + *

+ * @throws ContactNotFoundException If the given contact is not found */ - Contact updateContactData (final Contact contact); + Contact updateContactData (final Contact contact) throws ContactNotFoundException; /** * Returns a list of all found contacts diff --git a/src/org/mxchange/jcontacts/model/mobile/AdminContactsMobileSessionBeanRemote.java b/src/org/mxchange/jcontacts/model/mobile/AdminContactsMobileSessionBeanRemote.java new file mode 100644 index 0000000..d720d0e --- /dev/null +++ b/src/org/mxchange/jcontacts/model/mobile/AdminContactsMobileSessionBeanRemote.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2016 - 2020 Free Software Foundation + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontacts.model.mobile; + +import java.io.Serializable; +import javax.ejb.Remote; +import org.mxchange.jcontacts.exceptions.ContactNotFoundException; +import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jphone.exceptions.mobile.MobileNumberAlreadyLinkedException; +import org.mxchange.jphone.exceptions.mobile.MobileNumberNotLinkedException; +import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; + +/** + * A remote interface for administrative purposes around contact's phone numbers + * (any type). + *

+ * @author Roland Häder + */ +@Remote +public interface AdminContactsMobileSessionBeanRemote extends Serializable { + + /** + * Links existing mobile number with given contact instance. The id number + * should be set. + *

+ * @param contact Contact to link to + * @param mobileNumber Mobile number to link + *

+ * @return Updated contact + *

+ * @throws MobileNumberAlreadyLinkedException If a mobile number is already + * linked in contact + */ + Contact linkExistingMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws MobileNumberAlreadyLinkedException, ContactNotFoundException; + + /** + * Links new mobile number with given contact instance. The id number should + * NOT be set. + *

+ * @param contact Contact to link to + * @param mobileNumber Mobile number to link + *

+ * @return Updated contact + *

+ * @throws MobileNumberAlreadyLinkedException If a mobile number is already + * linked in contact + * @throws ContactNotFoundException If contact instance was not found + */ + Contact linkNewMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws MobileNumberAlreadyLinkedException, ContactNotFoundException; + + /** + * Unlinks mobile data from given contact and returns the updated (managed) + * version. + *

+ * @param contact Contact to unlink mobile instance + * @param mobileNumber Mobile number being unlinked + *

+ * @return Updated contact instance + *

+ * @throws MobileNumberNotLinkedException If a mobile instance is not linked + * (null) with this contact + * @throws ContactNotFoundException If contact instance was not found + */ + Contact unlinkMobileDataFromContact (final Contact contact, final DialableMobileNumber mobileNumber) throws MobileNumberNotLinkedException, ContactNotFoundException; + +} diff --git a/src/org/mxchange/jcontacts/model/phone/AdminContactsPhoneSessionBeanRemote.java b/src/org/mxchange/jcontacts/model/phone/AdminContactsPhoneSessionBeanRemote.java index 4ca0e6c..cd15622 100644 --- a/src/org/mxchange/jcontacts/model/phone/AdminContactsPhoneSessionBeanRemote.java +++ b/src/org/mxchange/jcontacts/model/phone/AdminContactsPhoneSessionBeanRemote.java @@ -18,12 +18,12 @@ package org.mxchange.jcontacts.model.phone; import java.io.Serializable; import javax.ejb.Remote; +import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jphone.exceptions.phone.PhoneNumberAlreadyLinkedException; import org.mxchange.jphone.exceptions.phone.PhoneNumberNotLinkedException; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; /** * A remote interface for administrative purposes around contact's phone numbers @@ -38,21 +38,22 @@ public interface AdminContactsPhoneSessionBeanRemote extends Serializable { * Links existing fax number with given contact instance. The id number * should be set. *

- * @param contact Contact to link to + * @param contact Contact to link to * @param faxNumber Fax number to link *

* @return Updated contact *

* @throws PhoneNumberAlreadyLinkedException If a fax number is already * linked in contact + * @throws ContactNotFoundException If the contact instance was not found */ - Contact linkExistingFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException; + Contact linkExistingFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException, ContactNotFoundException; /** * Links existing land-line number with given contact instance. The id * number should be set. *

- * @param contact Contact to link to + * @param contact Contact to link to * @param landLineNumber Land-line number to link *

* @return Updated contact @@ -60,104 +61,66 @@ public interface AdminContactsPhoneSessionBeanRemote extends Serializable { * @throws PhoneNumberAlreadyLinkedException If a land-line number is * already linked in contact */ - Contact linkExistingLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException; - - /** - * Links existing mobile number with given contact instance. The id number - * should be set. - *

- * @param contact Contact to link to - * @param mobileNumber Mobile number to link - *

- * @return Updated contact - *

- * @throws PhoneNumberAlreadyLinkedException If a mobile number is already - * linked in contact - */ - Contact linkExistingMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException; + Contact linkExistingLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException, ContactNotFoundException; /** * Links new fax number with given contact instance. The id number should * NOT be set. *

- * @param contact Contact to link to + * @param contact Contact to link to * @param faxNumber Fax number to link *

* @return Updated contact *

* @throws PhoneNumberAlreadyLinkedException If a fax number is already * linked in contact + * @throws ContactNotFoundException If the contact instance was not found */ - Contact linkNewFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException; + Contact linkNewFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException, ContactNotFoundException; /** * Links new land-line number with given contact instance. The id number * should NOT be set. *

- * @param contact Contact to link to + * @param contact Contact to link to * @param landLineNumber Land-line number to link *

* @return Updated contact *

* @throws PhoneNumberAlreadyLinkedException If a land-line number is * already linked in contact + * @throws ContactNotFoundException If the contact instance was not found */ - Contact linkNewLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException; - - /** - * Links new mobile number with given contact instance. The id number should - * NOT be set. - *

- * @param contact Contact to link to - * @param mobileNumber Mobile number to link - *

- * @return Updated contact - *

- * @throws PhoneNumberAlreadyLinkedException If a mobile number is already - * linked in contact - */ - Contact linkNewMobileNumberWithContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberAlreadyLinkedException; + Contact linkNewLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException, ContactNotFoundException; /** * Unlinks fax data from given contact and returns the updated (managed) * version. *

- * @param contact Contact to unlink mobile instance + * @param contact Contact to unlink fax instance * @param faxNumber Fax number being unlinked *

* @return Updated contact instance *

- * @throws PhoneNumberNotLinkedException If a mobile instance is not linked + * @throws PhoneNumberNotLinkedException If a fax instance is not linked * (null) with this contact + * @throws ContactNotFoundException If the contact instance was not found */ - Contact unlinkFaxDataFromContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberNotLinkedException; + Contact unlinkFaxDataFromContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberNotLinkedException, ContactNotFoundException; /** * Unlinks land-line data from given contact and returns the updated * (managed) version. *

- * @param contact Contact to unlink mobile instance + * @param contact Contact to unlink land-line instance * @param landLineNumber Land-line number being unlinked *

* @return Updated contact instance *

- * @throws PhoneNumberNotLinkedException If a mobile instance is not linked - * (null) with this contact - */ - Contact unlinkLandLineDataFromContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberNotLinkedException; - - /** - * Unlinks mobile data from given contact and returns the updated (managed) - * version. - *

- * @param contact Contact to unlink mobile instance - * @param mobileNumber Mobile number being unlinked - *

- * @return Updated contact instance - *

- * @throws PhoneNumberNotLinkedException If a mobile instance is not linked - * (null) with this contact + * @throws PhoneNumberNotLinkedException If a land-line instance is not + * linked (null) with this contact + * @throws ContactNotFoundException If the contact instance was not found */ - Contact unlinkMobileDataFromContact (final Contact contact, final DialableMobileNumber mobileNumber) throws PhoneNumberNotLinkedException; + Contact unlinkLandLineDataFromContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberNotLinkedException, ContactNotFoundException; } -- 2.39.5