2 * Copyright (C) 2016 Roland Haeder
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.EmailAddressAlreadyRegisteredException;
23 import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
24 import org.mxchange.jusercore.exceptions.UserNotFoundException;
25 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
26 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
27 import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
28 import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
31 * An interface for user beans
33 * @author Roland Haeder<roland@mxchange.org>
36 public interface UserSessionBeanRemote extends Serializable {
39 * Updates user's password (must be set encrypted before calling this
40 * method) and records the password change in user's password history.
42 * @param user User instance with updated password
44 * @return Password history entry with updated user instance
46 * @throws UserNotFoundException If the user is not found
47 * @throws UserStatusUnconfirmedException If the user status is unconfirmed
48 * @throws UserStatusLockedException If the user status is locked
50 PasswordHistory updateUserPassword (final User user) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException;
53 * Changes the user' account status to CONFIRMED if the status is
54 * UNCONFIRMED, else propper exceptions are thrown.
56 * @param user Unconfirmed user instance
57 * @param baseUrl Base URL
59 * @return Updated user instance
61 * @throws UserStatusConfirmedException If the user account is confirmed
62 * @throws UserStatusLockedException If the user account is locked
64 User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException;
67 * Generates random user name that is available.
69 * @return Generated user name
71 String generateRandomUserName ();
74 * Creates the user instance and links it with the set contact instance
76 * @param user User instance to
78 * @return Updated user instance
81 * org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException When
82 * the user name is already used
84 * org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException
85 * When the email address is already used
87 User linkUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException;
90 * Updates entiity from given user instance and returns updated instance.
92 * @param user User instance to update
94 * @return Updated user instance
96 User updateUserData (final User user);
99 * Find user by given user id and returns fetched instance. If the user is
100 * not found, an exception is thrown.
102 * @param userId User id
104 * @return User instance
106 * @throws org.mxchange.jusercore.exceptions.UserNotFoundException If the
109 User findUserById (final Long userId) throws UserNotFoundException;
112 * Adds given user to database, if not found by user name or email address.
114 * @param user User instance to add
116 * @return Updated user instance
119 * org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException When
120 * the user name is already used
122 * org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException
123 * When the email address is already used
125 User addUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException;
128 * Returns a list of all users. This is mostly suitable for administrative
131 * @return A list of all users
133 List<User> allUsers ();
136 * Returns a list with all public and member-visible users. Members are
137 * logged-in users. ;-)
139 * @return A list of public and member-visible users
141 List<User> allMemberPublicVisibleUsers ();
144 * Returns a list of all public user profiles
146 * @return A list of all public user profiles
148 List<User> allPublicUsers ();
151 * Fills given user instance with all available data
153 * @param user Initial User instance
155 * @return Prepared User instance
157 User fillUserData (final User user);
160 * Some "getter" for a full user name list
162 * @return User name list
164 List<String> getUserNameList ();
167 * Some "getter" for a full email address list
169 * @return User name list
171 List<String> getEmailAddressList ();
174 * Checks if given user id exists
176 * @param userId User id to check
178 * @return Whether the user id exists
180 boolean ifUserIdExists (final Long userId);
183 * Checks if given user name is already used
185 * @param userName User name to check
187 * @return Whether given user name is found
189 boolean ifUserNameExists (final String userName);
192 * Checks if given user exists
194 * @param user User to check
196 * @return Whether the user exists
198 boolean ifUserExists (final User user);
201 * Checks if the the given user's name is already registered
203 * @param user User instance
205 * @return Whether the user is already registered
207 boolean isUserNameRegistered (final User user);
210 * Checks if the the given user's email address is already registered
212 * @param user User instance
214 * @return Whether the user is already registered
216 boolean isEmailAddressRegistered (final User user);
219 * Updates given user instance in database
221 * @param user User instance to update
223 * @return Updated user instance (detached)
225 User updateUserPersonalData (final User user);