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.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 Haeder<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
42 * @return Password history entry with updated user instance
44 * @throws UserNotFoundException If the user is not found
45 * @throws UserStatusUnconfirmedException If the user status is unconfirmed
46 * @throws UserStatusLockedException If the user status is locked
48 PasswordHistory updateUserPassword (final User user) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException;
51 * Changes the user' account status to CONFIRMED if the status is
52 * UNCONFIRMED, else propper exceptions are thrown.
54 * @param user Unconfirmed user instance
55 * @param baseUrl Base URL
57 * @return Updated user instance
59 * @throws UserStatusConfirmedException If the user account is confirmed
60 * @throws UserStatusLockedException If the user account is locked
62 User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException;
65 * Generates random user name that is available.
67 * @return Generated user name
69 String generateRandomUserName ();
72 * Updates entiity from given user instance and returns updated instance.
74 * @param user User instance to update
76 * @return Updated user instance
78 User updateUserData (final User user);
81 * Find user by given user id and returns fetched instance. If the user is
82 * not found, an exception is thrown.
84 * @param userId User id
86 * @return User instance
88 * @throws org.mxchange.jusercore.exceptions.UserNotFoundException If the
91 User findUserById (final Long userId) throws UserNotFoundException;
94 * Returns a list of all users. This is mostly suitable for administrative
97 * @return A list of all users
99 List<User> allUsers ();
102 * Returns a list with all public and member-visible users. Members are
103 * logged-in users. ;-)
105 * @return A list of public and member-visible users
107 List<User> allMemberPublicVisibleUsers ();
110 * Returns a list of all public user profiles
112 * @return A list of all public user profiles
114 List<User> allPublicUsers ();
117 * Fills given user instance with all available data
119 * @param user Initial User instance
121 * @return Prepared User instance
123 User fillUserData (final User user);
126 * Some "getter" for a full user name list
128 * @return User name list
130 List<String> getUserNameList ();
133 * Some "getter" for a full email address list
135 * @return User name list
137 List<String> getEmailAddressList ();
140 * Checks if given user id exists
142 * @param userId User id to check
144 * @return Whether the user id exists
146 boolean ifUserIdExists (final Long userId);
149 * Checks if given user name is already used
151 * @param userName User name to check
153 * @return Whether given user name is found
155 boolean ifUserNameExists (final String userName);
158 * Checks if given user exists
160 * @param user User to check
162 * @return Whether the user exists
164 boolean ifUserExists (final User user);
167 * Checks if the the given user's name is already registered
169 * @param user User instance
171 * @return Whether the user is already registered
173 boolean isUserNameRegistered (final User user);
176 * Checks if the the given user's email address is already registered
178 * @param user User instance
180 * @return Whether the user is already registered
182 boolean isEmailAddressRegistered (final User user);
185 * Updates given user instance in database
187 * @param user User instance to update
189 * @return Updated user instance (detached)
191 User updateUserPersonalData (final User user);