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