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