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.AdminUpdatedUserDataEvent;
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;
44 * Event observer for newly added users by adminstrator
46 * @param event Event being fired
48 void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
51 * Event observer for updated user data by administrator
53 * @param event Event being updated
55 void afterAdminUpdatedUserDataEvent (final AdminUpdatedUserDataEvent event);
58 * Listens to fired event when user updated personal data
60 * @param event Event being fired
62 void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
65 * Event observer for new user registrations
67 * @param event User registration event
69 void afterRegistrationEvent (final UserRegisteredEvent event);
72 * Event observer for logged-in user
74 * @param event Event instance
76 void afterUserLogin (final UserLoggedInEvent event);
81 * @return A list of all public user profiles
83 List<User> allUsers ();
86 * All public user profiles
88 * @return A list of all public user profiles
90 List<User> allVisibleUsers ();
93 * Checks whether users are registered
95 * @return Whether users are registered
100 * Checks whether the given contact is a user
102 * @param contact Contact to check
104 * @return Whether the contact is a user
106 boolean isContactFound (final Contact contact);
109 * Checks whether a public user account is registered. This means that at
110 * least one user profile has its flag "public user profile" enabled.
112 * @return Whether at least one user has a public profile
114 boolean isVisibleUserFound ();
117 * Checks whether given user instance's name is used
119 * @param user User instance's name to check
121 * @return Whether it is already used
123 boolean isUserNameRegistered (final User user);
126 * Tries to lookup user by given id number. If the user is not found or the
127 * account status is not CONFIRMED proper exceptions are thrown.
129 * @param userId User id
131 * @return User instance
133 * @throws UserNotFoundException If the user is not found
135 User lookupUserById (final Long userId) throws UserNotFoundException;
138 * Returns a list of all selectable contacts for user creation. Contacts
139 * from already existing users are excluded in this list.
141 * @return A list of all selectable contacts
143 List<Contact> selectableContacts ();
146 * Creates an instance from all properties
148 * @return A user instance
150 User createUserInstance ();
153 * Creates a user instance for login phase
155 * @return User instance
157 User createUserLogin ();
169 * @param userId User id
171 void setUserId (final Long userId);
174 * Getter for user name
178 String getUserName ();
181 * Setter for user name
183 * @param userName User name
185 void setUserName (final String userName);
188 * Getter for unencrypted user password
190 * @return Unencrypted user password
192 String getUserPassword ();
195 * Setter for unencrypted user password
197 * @param userPassword Unencrypted user password
199 void setUserPassword (final String userPassword);
202 * Getter for unencrypted user password repeated
204 * @return Unencrypted user password repeated
206 String getUserPasswordRepeat ();
209 * Setter for unencrypted user password repeated
211 * @param userPasswordRepeat Unencrypted user password repeated
213 void setUserPasswordRepeat (final String userPasswordRepeat);
216 * Getter for user profile mode
218 * @return User profile mode
220 ProfileMode getUserProfileMode ();
223 * Setter for user profile mode
225 * @param userProfileMode User profile mode
227 void setUserProfileMode (final ProfileMode userProfileMode);
230 * Checks whether all required personal data is set
232 * @return Whether the required personal data is set
234 boolean isRequiredPersonalDataSet ();
237 * Checks whether all required personal data is set for changing them
239 * @return Whether the required personal data is set
241 boolean isRequiredChangePersonalDataSet ();
244 * Checks whether same passwords has been entered
246 * @return Whether same passwords has been entered
248 boolean isSamePasswordEntered ();
251 * Checks if the user id is empty
253 * @return Whether the user id is empty
255 boolean isUserIdEmpty ();
258 * Changes logged-in user's personal data if the current password matches
259 * and TAC + privacy statement has been accepted.
261 * @return New target page
263 String doChangePersonalData ();