2 * Copyright (C) 2016 - 2018 Free Software Foundation
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.jjobs.beans.user;
19 import java.io.Serializable;
20 import java.util.List;
21 import org.mxchange.jcontacts.model.contact.Contact;
22 import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
23 import org.mxchange.jusercore.exceptions.UserNotFoundException;
24 import org.mxchange.jusercore.model.user.User;
27 * An interface for user beans
29 * @author Roland Häder<roland@mxchange.org>
31 public interface JobsUserWebRequestController extends Serializable {
34 * Minimum password length
36 * @deprecated Better set as context parameter
39 public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
42 * Returns a user instance by given primary key. If not found, a proper
43 * exception is thrown.
45 * @param userId User id
47 * @return User instance
49 * @throws UserNotFoundException If the user is not found
51 User findUserById (final Long userId) throws UserNotFoundException;
54 * Checks if given user id exists
56 * @param userId User id to check
58 * @return Whether the user id exists
60 boolean ifUserIdExists (final Long userId);
63 * Getter for clear-text user password
65 * @return Clear-text user password
67 String getUserPassword ();
70 * Checks if both user passwords are left empty and if this is enabled
71 * (allowed) in context parameter. If true, the calling bean should create a
72 * random password (preferable with UserUtils.createRandomPassword() and set
73 * it in both user password fields.
75 * @return Whether empty passwords are allowed
77 boolean ifBothPasswordsEmptyAllowed ();
82 * @return A list of all public user profiles
84 List<User> allUsers ();
87 * Checks whether the given contact is a user
89 * @param contact Contact to check
91 * @return Whether the contact is a user
93 boolean isContactFound (final Contact contact);
96 * Checks whether given user instance name is used
98 * @param user User instance name to check
100 * @return Whether it is already used
102 boolean isUserNameRegistered (final User user);
105 * Tries to lookup user by given id number. If the user is not found or the
106 * account status is not CONFIRMED proper exceptions are thrown.
108 * @param userId User id
110 * @return User instance
112 * @throws UserNotFoundException If the user is not found
114 User lookupUserById (final Long userId) throws UserNotFoundException;
117 * Tries to lookup user by given email address. If the user is not found a
118 * proper exceptions is thrown.
120 * @param emailAddress Email address
122 * @return User instance
124 * @throws UserEmailAddressNotFoundException If the user's email address is
127 User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException;
130 * Creates an instance from all properties
132 * @param createContactData Whether contact data should be created
134 * @return A user instance
136 User createUserInstance (final boolean createContactData);
139 * Creates a user instance for login phase
141 * @return User instance
143 User createUserLogin ();
146 * Checks whether all required personal data is set
148 * @return Whether the required personal data is set
150 boolean isRequiredPersonalDataSet ();
153 * Checks whether all required personal data is set for changing them
155 * @return Whether the required personal data is set
157 boolean isRequiredChangePersonalDataSet ();
160 * Checks whether same passwords has been entered
162 * @return Whether same passwords has been entered
164 boolean isSamePasswordEntered ();
167 * Checks if the user id is empty
169 * @return Whether the user id is empty
171 boolean isUserIdEmpty ();
174 * Changes logged-in user's personal data if the current password matches
175 * and TAC + privacy statement has been accepted.
177 * @return New target page
179 String doChangePersonalData ();
182 * Checks whether this application requires a user name to be entered.
183 * Otherwise a random name like "userXXXXX" is generated
185 * @return Whether this application requires a user name
187 boolean isUserNameRequired ();