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