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.jusercore.events.login.UserLoggedInEvent;
23 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
24 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
25 import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
26 import org.mxchange.jusercore.exceptions.UserNotFoundException;
27 import org.mxchange.jusercore.model.user.User;
28 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
31 * An interface for user beans
33 * @author Roland Haeder<roland@mxchange.org>
35 public interface PizzaUserWebSessionController extends Serializable {
38 * Minimum password length
40 public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
45 * @return A list of all public user profiles
47 List<User> allUsers ();
50 * Checks whether users are registered
52 * @return Whether users are registered
57 * Checks whether the given contact is a user
59 * @param contact Contact to check
61 * @return Whether the contact is a user
63 boolean isContactFound (final Contact contact);
66 * Listens to fired event when user updated personal data
68 * @param event Event being fired
70 void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
72 void updateList (final User user);
75 * Returns a list of all selectable contacts for user creation. Contacts
76 * from already existing users are excluded in this list.
78 * @return A list of all selectable contacts
80 List<Contact> selectableContacts ();
83 * Tries to lookup user by given id number. If the user is not found or the
84 * account status is not CONFIRMED proper exceptions are thrown.
86 * @param userId User id
88 * @return User instance
90 * @throws UserNotFoundException If the user is not found
92 User lookupUserById (final Long userId) throws UserNotFoundException;
95 * Event observer for newly added users by an administrator
97 * @param event Event being fired
99 void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
102 * Event observer for new user registrations
104 * @param event User registration event
106 void afterRegistrationEvent (final UserRegisteredEvent event);
109 * Event observer for logged-in user
111 * @param event Event instance
113 void afterUserLogin (final UserLoggedInEvent event);
116 * All public user profiles
118 * @return A list of all public user profiles
120 List<User> allVisibleUsers ();
123 * Creates an instance from all properties
125 * @return A user instance
127 User createUserInstance ();
139 * @param userId User id
141 void setUserId (final Long userId);
144 * Getter for user name
148 String getUserName ();
151 * Setter for user name
153 * @param userName User name
155 void setUserName (final String userName);
158 * Getter for unencrypted user password
160 * @return Unencrypted user password
162 String getUserPassword ();
165 * Setter for unencrypted user password
167 * @param userPassword Unencrypted user password
169 void setUserPassword (final String userPassword);
172 * Getter for unencrypted user password repeated
174 * @return Unencrypted user password repeated
176 String getUserPasswordRepeat ();
179 * Setter for unencrypted user password repeated
181 * @param userPasswordRepeat Unencrypted user password repeated
183 void setUserPasswordRepeat (final String userPasswordRepeat);
186 * Getter for user profile mode
188 * @return User profile mode
190 ProfileMode getUserProfileMode ();
193 * Setter for user profile mode
195 * @param userProfileMode User profile mode
197 void setUserProfileMode (final ProfileMode userProfileMode);
200 * Checks whether all required personal data is set
202 * @return Whether the required personal data is set
204 boolean isRequiredPersonalDataSet ();
207 * Checks whether all required personal data is set for changing them
209 * @return Whether the required personal data is set
211 boolean isRequiredChangePersonalDataSet ();
214 * Checks whether same passwords has been entered
216 * @return Whether same passwords has been entered
218 boolean isSamePasswordEntered ();
221 * Checks whether given user instance's name is used
223 * @param user User instance's name to check
225 * @return Whether it is already used
227 boolean isUserNameRegistered (final User user);
230 * Checks whether a public user account is registered. This means that at
231 * least one user profile has its flag "public user profile" enabled.
233 * @return Whether at least one user has a public profile
235 boolean isVisibleUserFound ();
238 * Checks if the user id is empty
240 * @return Whether the user id is empty
242 boolean isUserIdEmpty ();
245 * Changes logged-in user's personal data if the current password matches
246 * and TAC + privacy statement has been accepted.
248 * @return New target page
250 String doChangePersonalData ();