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 General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (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 General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jusercore.model.user;
19 import java.io.Serializable;
20 import java.util.List;
21 import javax.ejb.Remote;
22 import org.mxchange.jusercore.exceptions.UserNotFoundException;
23 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
24 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
25 import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
26 import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
29 * An interface for user beans
31 * @author Roland Häder<roland@mxchange.org>
34 public interface UserSessionBeanRemote extends Serializable {
37 * Updates user's password (must be set encrypted before calling this
38 * method) and records the password change in user's password history.
40 * @param user User instance with updated password
41 * @param baseUrl Base URL for all links
43 * @return Password history entry with updated user instance
45 * @throws UserNotFoundException If the user is not found
46 * @throws UserStatusUnconfirmedException If the user status is unconfirmed
47 * @throws UserStatusLockedException If the user status is locked
49 PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException;
52 * Changes the user' account status to CONFIRMED if the status is
53 * UNCONFIRMED, else proper exceptions are thrown.
55 * @param user Unconfirmed user instance
56 * @param baseUrl Base URL
58 * @return Updated user instance
60 * @throws UserStatusConfirmedException If the user account is confirmed
61 * @throws UserStatusLockedException If the user account is locked
63 User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException;
66 * Generates random user name that is available.
68 * @return Generated user name
70 String generateRandomUserName ();
73 * Updates entity from given user instance and returns updated instance.
75 * @param user User instance to update
77 * @return Updated user instance
79 User updateUserData (final User user);
82 * Find user by given user id and returns fetched instance. If the user is
83 * not found, an exception is thrown.
85 * @param userId User id
87 * @return User instance
89 * @throws org.mxchange.jusercore.exceptions.UserNotFoundException If the
92 User findUserById (final Long userId) throws UserNotFoundException;
95 * Returns a list of all users. This is mostly suitable for administrative
98 * @return A list of all users
100 List<User> allUsers ();
103 * Returns a list with all public and member-visible users. Members are
104 * logged-in users. ;-)
106 * @return A list of public and member-visible users
108 List<User> allMemberPublicVisibleUsers ();
111 * Returns a list of all public user profiles
113 * @return A list of all public user profiles
115 List<User> allPublicUsers ();
118 * Fills given user instance with all available data
120 * @param user Initial User instance
122 * @return Prepared User instance
124 User fillUserData (final User user);
127 * Some "getter" for a full user name list
129 * @return User name list
131 List<String> getUserNameList ();
134 * Some "getter" for a full email address list
136 * @return User name list
138 List<String> getEmailAddressList ();
141 * Checks if given user id exists
143 * @param userId User id to check
145 * @return Whether the user id exists
147 boolean ifUserIdExists (final Long userId);
150 * Checks if given user name is already used
152 * @param userName User name to check
154 * @return Whether given user name is found
156 boolean ifUserNameExists (final String userName);
159 * Checks if given user exists
161 * @param user User to check
163 * @return Whether the user exists
165 boolean ifUserExists (final User user);
168 * Checks if the the given user's name is already registered
170 * @param user User instance
172 * @return Whether the user is already registered
174 boolean isUserNameRegistered (final User user);
177 * Checks if the the given user's email address is already registered
179 * @param user User instance
181 * @return Whether the user is already registered
183 boolean isEmailAddressRegistered (final User user);
186 * Updates given user instance in database
188 * @param user User instance to update
190 * @return Updated user instance (detached)
192 User updateUserPersonalData (final User user);