]> git.mxchange.org Git - pizzaservice-war.git/blob - src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java
implemented lookupUserByEmailAddress() (this can be cherry-picked)
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / user / PizzaUserWebSessionController.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 Affero General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (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 Affero General Public License for more details.
13  *
14  * You should have received a copy of the GNU Affero General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.pizzaapplication.beans.user;
18
19 import java.io.Serializable;
20 import java.util.List;
21 import org.mxchange.jcontacts.contact.Contact;
22 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
23 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
24 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
25 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
26 import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
27 import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
28 import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
29 import org.mxchange.jusercore.exceptions.UserNotFoundException;
30 import org.mxchange.jusercore.model.user.User;
31 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
32
33 /**
34  * An interface for user beans
35  * <p>
36  * @author Roland Haeder<roland@mxchange.org>
37  */
38 public interface PizzaUserWebSessionController extends Serializable {
39
40         /**
41          * Minimum password length
42          */
43         public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
44
45         /**
46          * Observes events being fired when an administrator has added a new
47          * contact.
48          * <p>
49          * @param event Event being fired
50          */
51         void afterAdminAddedContact (final AdminAddedContactEvent event);
52
53         /**
54          * Event observer for newly added users by adminstrator
55          * <p>
56          * @param event Event being fired
57          */
58         void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
59
60         /**
61          * Event observer for updated user data by administrator
62          * <p>
63          * @param event Event being updated
64          */
65         void afterAdminUpdatedUserDataEvent (final AdminUpdatedUserDataEvent event);
66
67         /**
68          * Listens to fired event when user updated personal data
69          * <p>
70          * @param event Event being fired
71          */
72         void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
73
74         /**
75          * Event observer for new user registrations
76          * <p>
77          * @param event User registration event
78          */
79         void afterRegistrationEvent (final UserRegisteredEvent event);
80
81         /**
82          * Event observer for logged-in user
83          * <p>
84          * @param event Event instance
85          */
86         void afterUserLogin (final UserLoggedInEvent event);
87
88         /**
89          * All users
90          * <p>
91          * @return A list of all public user profiles
92          */
93         List<User> allUsers ();
94
95         /**
96          * All public user profiles
97          * <p>
98          * @return A list of all public user profiles
99          */
100         List<User> allVisibleUsers ();
101
102         /**
103          * Checks whether users are registered
104          * <p>
105          * @return Whether users are registered
106          */
107         boolean hasUsers ();
108
109         /**
110          * Checks whether the given contact is a user
111          * <p>
112          * @param contact Contact to check
113          * <p>
114          * @return Whether the contact is a user
115          */
116         boolean isContactFound (final Contact contact);
117
118         /**
119          * Checks whether a public user account is registered. This means that at
120          * least one user profile has its flag "public user profile" enabled.
121          * <p>
122          * @return Whether at least one user has a public profile
123          */
124         boolean isVisibleUserFound ();
125
126         /**
127          * Checks whether given user instance's name is used
128          * <p>
129          * @param user User instance's name to check
130          * <p>
131          * @return Whether it is already used
132          */
133         boolean isUserNameRegistered (final User user);
134
135         /**
136          * Tries to lookup user by given id number. If the user is not found or the
137          * account status is not CONFIRMED proper exceptions are thrown.
138          * <p>
139          * @param userId User id
140          * <p>
141          * @return User instance
142          * <p>
143          * @throws UserNotFoundException If the user is not found
144          */
145         User lookupUserById (final Long userId) throws UserNotFoundException;
146
147         /**
148          * Tries to lookup user by given email address. If the user is not found a
149          * proper exceptions is thrown.
150          * <p>
151          * @param emailAddress Email address
152          * <p>
153          * @return User instance
154          * <p>
155          * @throws UserEmailAddressNotFoundException If the user's email address is not found
156          */
157         User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException;
158
159         /**
160          * Returns a list of all selectable contacts for user creation. Contacts
161          * from already existing users are excluded in this list.
162          * <p>
163          * @return A list of all selectable contacts
164          */
165         List<Contact> selectableContacts ();
166
167         /**
168          * Creates an instance from all properties
169          * <p>
170          * @return A user instance
171          */
172         User createUserInstance ();
173
174         /**
175          * Creates a user instance for login phase
176          * <p>
177          * @return User instance
178          */
179         User createUserLogin ();
180
181         /**
182          * Getter for user id
183          * <p>
184          * @return User id
185          */
186         Long getUserId ();
187
188         /**
189          * Setter for user id
190          * <p>
191          * @param userId User id
192          */
193         void setUserId (final Long userId);
194
195         /**
196          * Getter for user name
197          * <p>
198          * @return User name
199          */
200         String getUserName ();
201
202         /**
203          * Setter for user name
204          * <p>
205          * @param userName User name
206          */
207         void setUserName (final String userName);
208
209         /**
210          * Getter for unencrypted user password
211          * <p>
212          * @return Unencrypted user password
213          */
214         String getUserPassword ();
215
216         /**
217          * Setter for unencrypted user password
218          * <p>
219          * @param userPassword Unencrypted user password
220          */
221         void setUserPassword (final String userPassword);
222
223         /**
224          * Getter for unencrypted user password repeated
225          * <p>
226          * @return Unencrypted user password repeated
227          */
228         String getUserPasswordRepeat ();
229
230         /**
231          * Setter for unencrypted user password repeated
232          * <p>
233          * @param userPasswordRepeat Unencrypted user password repeated
234          */
235         void setUserPasswordRepeat (final String userPasswordRepeat);
236
237         /**
238          * Getter for user profile mode
239          * <p>
240          * @return User profile mode
241          */
242         ProfileMode getUserProfileMode ();
243
244         /**
245          * Setter for user profile mode
246          * <p>
247          * @param userProfileMode User profile mode
248          */
249         void setUserProfileMode (final ProfileMode userProfileMode);
250
251         /**
252          * Checks whether all required personal data is set
253          * <p>
254          * @return Whether the required personal data is set
255          */
256         boolean isRequiredPersonalDataSet ();
257
258         /**
259          * Checks whether all required personal data is set for changing them
260          * <p>
261          * @return Whether the required personal data is set
262          */
263         boolean isRequiredChangePersonalDataSet ();
264
265         /**
266          * Checks whether same passwords has been entered
267          * <p>
268          * @return Whether same passwords has been entered
269          */
270         boolean isSamePasswordEntered ();
271
272         /**
273          * Checks if the user id is empty
274          * <p>
275          * @return Whether the user id is empty
276          */
277         boolean isUserIdEmpty ();
278
279         /**
280          * Changes logged-in user's personal data if the current password matches
281          * and TAC + privacy statement has been accepted.
282          * <p>
283          * @return New target page
284          */
285         String doChangePersonalData ();
286
287         /**
288          * Checks whether this application requires a user name to be entered.
289          * Otherwise a random name like "userXXXXX" is generated
290          * <p>
291          * @return Whether this application requires a user name
292          */
293         boolean isUserNameRequired ();
294
295         /**
296          * Checks wether public user profiles are enabled. This requires that user
297          * names are also enabled.
298          * <p>
299          * @return Whether public user profiles are enabled
300          */
301         boolean isPublicUserProfileEnabled ();
302
303 }