]> git.mxchange.org Git - juser-activity-lib.git/blob - src/org/mxchange/jusercore/model/user/UserSessionBeanRemote.java
opps, needs to be PasswordHistory which contains the updated instance as 2 things...
[juser-activity-lib.git] / src / org / mxchange / jusercore / model / user / UserSessionBeanRemote.java
1 /*
2  * Copyright (C) 2016 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jusercore.model.user;
18
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;
29
30 /**
31  * An interface for user beans
32  * <p>
33  * @author Roland Haeder<roland@mxchange.org>
34  */
35 @Remote
36 public interface UserSessionBeanRemote extends Serializable {
37
38         /**
39          * Updates user's password (must be set encrypted before calling this
40          * method) and records the password change in user's password history.
41          * <p>
42          * @param user User instance with updated password
43          * <p>
44          * @return Password history entry with updated user instance
45          *
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
49          */
50         PasswordHistory updateUserPassword (final User user) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException;
51
52         /**
53          * Changes the user' account status to CONFIRMED if the status is
54          * UNCONFIRMED, else propper exceptions are thrown.
55          * <p>
56          * @param user Unconfirmed user instance
57          * @param baseUrl Base URL
58          * <p>
59          * @return Updated user instance
60          * <p>
61          * @throws UserStatusConfirmedException If the user account is confirmed
62          * @throws UserStatusLockedException If the user account is locked
63          */
64         User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException;
65
66         /**
67          * Generates random user name that is available.
68          * <p>
69          * @return Generated user name
70          */
71         String generateRandomUserName ();
72
73         /**
74          * Creates the user instance and links it with the set contact instance
75          * <p>
76          * @param user User instance to
77          * <p>
78          * @return Updated user instance
79          * <p>
80          * @throws
81          * org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException When
82          * the user name is already used
83          * @throws
84          * org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException
85          * When the email address is already used
86          */
87         User linkUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException;
88
89         /**
90          * Updates entiity from given user instance and returns updated instance.
91          * <p>
92          * @param user User instance to update
93          * <p>
94          * @return Updated user instance
95          */
96         User updateUserData (final User user);
97
98         /**
99          * Find user by given user id and returns fetched instance. If the user is
100          * not found, an exception is thrown.
101          * <p>
102          * @param userId User id
103          * <p>
104          * @return User instance
105          *
106          * @throws org.mxchange.jusercore.exceptions.UserNotFoundException If the
107          * user is not found
108          */
109         User findUserById (final Long userId) throws UserNotFoundException;
110
111         /**
112          * Adds given user to database, if not found by user name or email address.
113          * <p>
114          * @param user User instance to add
115          * <p>
116          * @return Updated user instance
117          * <p>
118          * @throws
119          * org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException When
120          * the user name is already used
121          * @throws
122          * org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException
123          * When the email address is already used
124          */
125         User addUser (final User user) throws UserNameAlreadyRegisteredException, EmailAddressAlreadyRegisteredException;
126
127         /**
128          * Returns a list of all users. This is mostly suitable for administrative
129          * interfaces.
130          * <p>
131          * @return A list of all users
132          */
133         List<User> allUsers ();
134
135         /**
136          * Returns a list with all public and member-visible users. Members are
137          * logged-in users. ;-)
138          * <p>
139          * @return A list of public and member-visible users
140          */
141         List<User> allMemberPublicVisibleUsers ();
142
143         /**
144          * Returns a list of all public user profiles
145          * <p>
146          * @return A list of all public user profiles
147          */
148         List<User> allPublicUsers ();
149
150         /**
151          * Fills given user instance with all available data
152          * <p>
153          * @param user Initial User instance
154          * <p>
155          * @return Prepared User instance
156          */
157         User fillUserData (final User user);
158
159         /**
160          * Some "getter" for a full user name list
161          * <p>
162          * @return User name list
163          */
164         List<String> getUserNameList ();
165
166         /**
167          * Some "getter" for a full email address list
168          * <p>
169          * @return User name list
170          */
171         List<String> getEmailAddressList ();
172
173         /**
174          * Checks if given user id exists
175          * <p>
176          * @param userId User id to check
177          * <p>
178          * @return Whether the user id exists
179          */
180         boolean ifUserIdExists (final Long userId);
181
182         /**
183          * Checks if given user name is already used
184          * <p>
185          * @param userName User name to check
186          * <p>
187          * @return Whether given user name is found
188          */
189         boolean ifUserNameExists (final String userName);
190
191         /**
192          * Checks if given user exists
193          * <p>
194          * @param user User to check
195          * <p>
196          * @return Whether the user exists
197          */
198         boolean ifUserExists (final User user);
199
200         /**
201          * Checks if the the given user's name is already registered
202          * <p>
203          * @param user User instance
204          * <p>
205          * @return Whether the user is already registered
206          */
207         boolean isUserNameRegistered (final User user);
208
209         /**
210          * Checks if the the given user's email address is already registered
211          * <p>
212          * @param user User instance
213          * <p>
214          * @return Whether the user is already registered
215          */
216         boolean isEmailAddressRegistered (final User user);
217
218         /**
219          * Updates given user instance in database
220          * <p>
221          * @param user User instance to update
222          * <p>
223          * @return Updated user instance (detached)
224          */
225         User updateUserPersonalData (final User user);
226
227 }