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.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.UpdatedUserPersonalDataEvent;
27 import org.mxchange.jusercore.exceptions.UserNotFoundException;
28 import org.mxchange.jusercore.model.user.User;
29 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
32 * An interface for user beans
34 * @author Roland Haeder<roland@mxchange.org>
36 public interface PizzaUserWebSessionController extends Serializable {
39 * Minimum password length
41 public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
46 * @return A list of all public user profiles
48 List<User> allUsers ();
51 * Checks whether users are registered
53 * @return Whether users are registered
58 * Checks whether the given contact is a user
60 * @param contact Contact to check
62 * @return Whether the contact is a user
64 boolean isContactFound (final Contact contact);
67 * Observes events being fired when an administrator has added a new
70 * @param event Event being fired
72 void afterAdminAddedContact (final AdminAddedContactEvent event);
75 * Listens to fired event when user updated personal data
77 * @param event Event being fired
79 void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
82 * Updates list with given user
84 * @param user User to update
86 void updateList (final User user);
89 * Returns a list of all selectable contacts for user creation. Contacts
90 * from already existing users are excluded in this list.
92 * @return A list of all selectable contacts
94 List<Contact> selectableContacts ();
97 * Tries to lookup user by given id number. If the user is not found or the
98 * account status is not CONFIRMED proper exceptions are thrown.
100 * @param userId User id
102 * @return User instance
104 * @throws UserNotFoundException If the user is not found
106 User lookupUserById (final Long userId) throws UserNotFoundException;
109 * Event observer for newly added users by an administrator
111 * @param event Event being fired
113 void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
116 * Event observer for new user registrations
118 * @param event User registration event
120 void afterRegistrationEvent (final UserRegisteredEvent event);
123 * Event observer for logged-in user
125 * @param event Event instance
127 void afterUserLogin (final UserLoggedInEvent event);
130 * All public user profiles
132 * @return A list of all public user profiles
134 List<User> allVisibleUsers ();
137 * Creates an instance from all properties
139 * @return A user instance
141 User createUserInstance ();
153 * @param userId User id
155 void setUserId (final Long userId);
158 * Getter for user name
162 String getUserName ();
165 * Setter for user name
167 * @param userName User name
169 void setUserName (final String userName);
172 * Getter for unencrypted user password
174 * @return Unencrypted user password
176 String getUserPassword ();
179 * Setter for unencrypted user password
181 * @param userPassword Unencrypted user password
183 void setUserPassword (final String userPassword);
186 * Getter for unencrypted user password repeated
188 * @return Unencrypted user password repeated
190 String getUserPasswordRepeat ();
193 * Setter for unencrypted user password repeated
195 * @param userPasswordRepeat Unencrypted user password repeated
197 void setUserPasswordRepeat (final String userPasswordRepeat);
200 * Getter for user profile mode
202 * @return User profile mode
204 ProfileMode getUserProfileMode ();
207 * Setter for user profile mode
209 * @param userProfileMode User profile mode
211 void setUserProfileMode (final ProfileMode userProfileMode);
214 * Checks whether all required personal data is set
216 * @return Whether the required personal data is set
218 boolean isRequiredPersonalDataSet ();
221 * Checks whether all required personal data is set for changing them
223 * @return Whether the required personal data is set
225 boolean isRequiredChangePersonalDataSet ();
228 * Checks whether same passwords has been entered
230 * @return Whether same passwords has been entered
232 boolean isSamePasswordEntered ();
235 * Checks whether given user instance's name is used
237 * @param user User instance's name to check
239 * @return Whether it is already used
241 boolean isUserNameRegistered (final User user);
244 * Checks whether a public user account is registered. This means that at
245 * least one user profile has its flag "public user profile" enabled.
247 * @return Whether at least one user has a public profile
249 boolean isVisibleUserFound ();
252 * Checks if the user id is empty
254 * @return Whether the user id is empty
256 boolean isUserIdEmpty ();
259 * Changes logged-in user's personal data if the current password matches
260 * and TAC + privacy statement has been accepted.
262 * @return New target page
264 String doChangePersonalData ();