From: Roland Häder Date: Tue, 19 May 2020 22:11:55 +0000 (+0200) Subject: Continue: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7b575cad05d18d32a341c7c1fef92b6b1021e670;p=juser-lib.git Continue: - updateUserData() was throwing an unchecked EJBException, now better the well-known UserNotFoundException (maybe subject for renaming?) - re-added other business methods for checking of user existence. Please do NOT invoke them from your web/Swing application as this causes a lot EJB remote method invocations. - Instead you should implement a similar method in your application and have the user list cached and checked against that cached list. Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jusercore/model/user/UserSessionBeanRemote.java b/src/org/mxchange/jusercore/model/user/UserSessionBeanRemote.java index 7466736..1256a3d 100644 --- a/src/org/mxchange/jusercore/model/user/UserSessionBeanRemote.java +++ b/src/org/mxchange/jusercore/model/user/UserSessionBeanRemote.java @@ -59,8 +59,9 @@ public interface UserSessionBeanRemote extends Serializable { *

* @throws UserStatusConfirmedException If the user account is confirmed * @throws UserStatusLockedException If the user account is locked + * @throws UserNotFoundException If the given User instance was not found */ - User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException; + User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException, UserNotFoundException; /** * Updates entity from given user instance and returns updated instance. @@ -68,8 +69,10 @@ public interface UserSessionBeanRemote extends Serializable { * @param user User instance to update *

* @return Updated user instance + *

+ * @throws UserNotFoundException If the given User instance is not found */ - User updateUserData (final User user); + User updateUserData (final User user) throws UserNotFoundException; /** * Returns a list of all users. This is mostly suitable for administrative @@ -88,4 +91,43 @@ public interface UserSessionBeanRemote extends Serializable { */ User updateUserPersonalData (final User user); + /** + * Checks if given user name is already used + *

+ * @param userName User name to check + *

+ * @return Whether given user name is found + */ + boolean ifUserNameExists (final String userName); + + /** + * Checks if given user exists. You should only use this method within the + * EJB container as might cause a lot EJB method invocations and having a + * similar method implemented on your web container/Swing or console side + * with local cache is much better for overall performance. + *

+ * @param user User to check + *

+ * @return Whether the user exists + */ + boolean ifUserExists (final User user); + + /** + * Checks if the the given user's name is already registered + *

+ * @param user User instance + *

+ * @return Whether the user is already registered + */ + boolean isUserNameRegistered (final User user); + + /** + * Checks if the the given user's email address is already registered + *

+ * @param user User instance + *

+ * @return Whether the user is already registered + */ + boolean isEmailAddressRegistered (final User user); + }