2 * Copyright (C) 2016 Roland Haeder
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.
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.
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/>.
17 package org.mxchange.pizzaapplication.beans.user;
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;
35 * An interface for user beans
37 * @author Roland Haeder<roland@mxchange.org>
39 public interface PizzaUserWebSessionController extends Serializable {
42 * Minimum password length
44 public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
47 * Observes events being fired when an administrator has added a new
50 * @param event Event being fired
52 void afterAdminAddedContact (final AdminAddedContactEvent event);
55 * Event observer for newly added users by adminstrator
57 * @param event Event being fired
59 void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
62 * Event observer for updated user data by administrator
64 * @param event Event being updated
66 void afterAdminUpdatedUserDataEvent (final AdminUpdatedUserDataEvent event);
69 * Event observer when user confirmed account.
71 * @param event Event being fired
73 void afterUserConfirmedAccount (final UserConfirmedAccountEvent event);
76 * Listens to fired event when user updated personal data
78 * @param event Event being fired
80 void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
83 * Event observer for new user registrations
85 * @param event User registration event
87 void afterRegistrationEvent (final UserRegisteredEvent event);
90 * Event observer for logged-in user
92 * @param event Event instance
94 void afterUserLogin (final UserLoggedInEvent event);
99 * @return A list of all public user profiles
101 List<User> allUsers ();
104 * All public user profiles
106 * @return A list of all public user profiles
108 List<User> allVisibleUsers ();
111 * Checks whether users are registered
113 * @return Whether users are registered
118 * Checks whether the given contact is a user
120 * @param contact Contact to check
122 * @return Whether the contact is a user
124 boolean isContactFound (final Contact contact);
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.
130 * @return Whether at least one user has a public profile
132 boolean isVisibleUserFound ();
135 * Checks whether given user instance's name is used
137 * @param user User instance's name to check
139 * @return Whether it is already used
141 boolean isUserNameRegistered (final User user);
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.
147 * @param userId User id
149 * @return User instance
151 * @throws UserNotFoundException If the user is not found
153 User lookupUserById (final Long userId) throws UserNotFoundException;
156 * Tries to lookup user by given email address. If the user is not found a
157 * proper exceptions is thrown.
159 * @param emailAddress Email address
161 * @return User instance
163 * @throws UserEmailAddressNotFoundException If the user's email address is not found
165 User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException;
168 * Creates an instance from all properties
170 * @return A user instance
172 User createUserInstance ();
175 * Creates a user instance for login phase
177 * @return User instance
179 User createUserLogin ();
191 * @param userId User id
193 void setUserId (final Long userId);
196 * Getter for user name
200 String getUserName ();
203 * Setter for user name
205 * @param userName User name
207 void setUserName (final String userName);
210 * Getter for unencrypted user password
212 * @return Unencrypted user password
214 String getUserPassword ();
217 * Setter for unencrypted user password
219 * @param userPassword Unencrypted user password
221 void setUserPassword (final String userPassword);
224 * Getter for unencrypted user password repeated
226 * @return Unencrypted user password repeated
228 String getUserPasswordRepeat ();
231 * Setter for unencrypted user password repeated
233 * @param userPasswordRepeat Unencrypted user password repeated
235 void setUserPasswordRepeat (final String userPasswordRepeat);
238 * Getter for user profile mode
240 * @return User profile mode
242 ProfileMode getUserProfileMode ();
245 * Setter for user profile mode
247 * @param userProfileMode User profile mode
249 void setUserProfileMode (final ProfileMode userProfileMode);
252 * Checks whether all required personal data is set
254 * @return Whether the required personal data is set
256 boolean isRequiredPersonalDataSet ();
259 * Checks whether all required personal data is set for changing them
261 * @return Whether the required personal data is set
263 boolean isRequiredChangePersonalDataSet ();
266 * Checks whether same passwords has been entered
268 * @return Whether same passwords has been entered
270 boolean isSamePasswordEntered ();
273 * Checks if the user id is empty
275 * @return Whether the user id is empty
277 boolean isUserIdEmpty ();
280 * Changes logged-in user's personal data if the current password matches
281 * and TAC + privacy statement has been accepted.
283 * @return New target page
285 String doChangePersonalData ();
288 * Checks whether this application requires a user name to be entered.
289 * Otherwise a random name like "userXXXXX" is generated
291 * @return Whether this application requires a user name
293 boolean isUserNameRequired ();
296 * Checks wether public user profiles are enabled. This requires that user
297 * names are also enabled.
299 * @return Whether public user profiles are enabled
301 boolean isPublicUserProfileEnabled ();