From 5d9de3805863dce4cecde935dd811e047149f8b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org> Date: Thu, 12 May 2016 13:52:38 +0200 Subject: [PATCH] Added business method for generating pseudo-random user names that are available. This may be useful for applications that don't work with user names, still one is required (see juser-core) to persist the user instance. --- .../model/user/UserSessionBeanRemote.java | 383 +++++++++--------- 1 file changed, 195 insertions(+), 188 deletions(-) diff --git a/src/org/mxchange/jusercore/model/user/UserSessionBeanRemote.java b/src/org/mxchange/jusercore/model/user/UserSessionBeanRemote.java index 7e3ba03..e2a65ab 100644 --- a/src/org/mxchange/jusercore/model/user/UserSessionBeanRemote.java +++ b/src/org/mxchange/jusercore/model/user/UserSessionBeanRemote.java @@ -1,188 +1,195 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * 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 <http://www.gnu.org/licenses/>. - */ -package org.mxchange.jusercore.model.user; - -import java.io.Serializable; -import java.util.List; -import javax.ejb.Remote; -import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; -import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException; -import org.mxchange.jusercore.exceptions.UserNotFoundException; - -/** - * An interface for user beans - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -@Remote -public interface UserSessionBeanRemote extends Serializable { - - /** - * Creates the user instance and links it with the set contact instance - * <p> - * @param user User instance to - * <p> - * @return Updated user instance - * <p> - * @throws - * org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException When - * the user name is already used - * @throws - * org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException - * When the email address is already used - */ - User linkUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException; - - /** - * Updates entiity from given user instance and returns updated instance. - * <p> - * @param user User instance to update - * <p> - * @return Updated user instance - */ - User updateUserData (final User user); - - /** - * Find user by given user id and returns fetched instance. If the user is - * not found, an exception is thrown. - * <p> - * @param userId User id - * <p> - * @return User instance - * - * @throws org.mxchange.jusercore.exceptions.UserNotFoundException If the - * user is not found - */ - User findUserById (final Long userId) throws UserNotFoundException; - - /** - * Adds given user to database, if not found by user name or email address. - * <p> - * @param user User instance to add - * <p> - * @return Updated user instance - * <p> - * @throws - * org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException When - * the user name is already used - * @throws - * org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException - * When the email address is already used - */ - User addUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException; - - /** - * Returns a list of all users. This is mostly suitable for administrative - * interfaces. - * <p> - * @return A list of all users - */ - List<User> allUsers (); - - /** - * Returns a list with all public and member-visible users. Members are - * logged-in users. ;-) - * <p> - * @return A list of public and member-visible users - */ - List<User> allMemberPublicVisibleUsers (); - - /** - * Returns a list of all public user profiles - * <p> - * @return A list of all public user profiles - */ - List<User> allPublicUsers (); - - /** - * Fills given user instance with all available data - * <p> - * @param user Initial User instance - * <p> - * @return Prepared User instance - */ - User fillUserData (final User user); - - /** - * Some "getter" for a full user name list - * <p> - * @return User name list - */ - List<String> getUserNameList (); - - /** - * Some "getter" for a full email address list - * <p> - * @return User name list - */ - List<String> getEmailAddressList (); - - /** - * Checks if given user id exists - * <p> - * @param userId User id to check - * <p> - * @return Whether the user id exists - */ - boolean ifUserIdExists (final Long userId); - - /** - * Checks if given user name is already used - * <p> - * @param userName User name to check - * <p> - * @return Whether given user name is found - */ - boolean ifUserNameExists (final String userName); - - /** - * Checks if given user exists - * <p> - * @param user User to check - * <p> - * @return Whether the user exists - */ - boolean ifUserExists (final User user); - - /** - * Checks if the the given user's name is already registered - * <p> - * @param user User instance - * <p> - * @return Whether the user is already registered - */ - boolean isUserNameRegistered (final User user); - - /** - * Checks if the the given user's email address is already registered - * <p> - * @param user User instance - * <p> - * @return Whether the user is already registered - */ - boolean isEmailAddressRegistered (final User user); - - /** - * Updates given user instance in database - * <p> - * @param user User instance to update - * <p> - * @return Updated user instance (detached) - */ - User updateUserPersonalData (final User user); - -} +/* + * Copyright (C) 2016 Roland Haeder + * + * 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 <http://www.gnu.org/licenses/>. + */ +package org.mxchange.jusercore.model.user; + +import java.io.Serializable; +import java.util.List; +import javax.ejb.Remote; +import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; +import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException; +import org.mxchange.jusercore.exceptions.UserNotFoundException; + +/** + * An interface for user beans + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +@Remote +public interface UserSessionBeanRemote extends Serializable { + + /** + * Generates random user name that is available. + * <p> + * @return Generated user name + */ + String generateRandomUserName (); + + /** + * Creates the user instance and links it with the set contact instance + * <p> + * @param user User instance to + * <p> + * @return Updated user instance + * <p> + * @throws + * org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException When + * the user name is already used + * @throws + * org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException + * When the email address is already used + */ + User linkUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException; + + /** + * Updates entiity from given user instance and returns updated instance. + * <p> + * @param user User instance to update + * <p> + * @return Updated user instance + */ + User updateUserData (final User user); + + /** + * Find user by given user id and returns fetched instance. If the user is + * not found, an exception is thrown. + * <p> + * @param userId User id + * <p> + * @return User instance + * + * @throws org.mxchange.jusercore.exceptions.UserNotFoundException If the + * user is not found + */ + User findUserById (final Long userId) throws UserNotFoundException; + + /** + * Adds given user to database, if not found by user name or email address. + * <p> + * @param user User instance to add + * <p> + * @return Updated user instance + * <p> + * @throws + * org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException When + * the user name is already used + * @throws + * org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException + * When the email address is already used + */ + User addUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException; + + /** + * Returns a list of all users. This is mostly suitable for administrative + * interfaces. + * <p> + * @return A list of all users + */ + List<User> allUsers (); + + /** + * Returns a list with all public and member-visible users. Members are + * logged-in users. ;-) + * <p> + * @return A list of public and member-visible users + */ + List<User> allMemberPublicVisibleUsers (); + + /** + * Returns a list of all public user profiles + * <p> + * @return A list of all public user profiles + */ + List<User> allPublicUsers (); + + /** + * Fills given user instance with all available data + * <p> + * @param user Initial User instance + * <p> + * @return Prepared User instance + */ + User fillUserData (final User user); + + /** + * Some "getter" for a full user name list + * <p> + * @return User name list + */ + List<String> getUserNameList (); + + /** + * Some "getter" for a full email address list + * <p> + * @return User name list + */ + List<String> getEmailAddressList (); + + /** + * Checks if given user id exists + * <p> + * @param userId User id to check + * <p> + * @return Whether the user id exists + */ + boolean ifUserIdExists (final Long userId); + + /** + * Checks if given user name is already used + * <p> + * @param userName User name to check + * <p> + * @return Whether given user name is found + */ + boolean ifUserNameExists (final String userName); + + /** + * Checks if given user exists + * <p> + * @param user User to check + * <p> + * @return Whether the user exists + */ + boolean ifUserExists (final User user); + + /** + * Checks if the the given user's name is already registered + * <p> + * @param user User instance + * <p> + * @return Whether the user is already registered + */ + boolean isUserNameRegistered (final User user); + + /** + * Checks if the the given user's email address is already registered + * <p> + * @param user User instance + * <p> + * @return Whether the user is already registered + */ + boolean isEmailAddressRegistered (final User user); + + /** + * Updates given user instance in database + * <p> + * @param user User instance to update + * <p> + * @return Updated user instance (detached) + */ + User updateUserPersonalData (final User user); + +} -- 2.39.5