/*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016, 2017 Roland Häder
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
package org.mxchange.pizzaapplication.beans.user;
import java.io.Serializable;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import java.util.List;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
/**
* An interface for user beans
* <p>
- * @author Roland Haeder<roland@mxchange.org>
+ * @author Roland Häder<roland@mxchange.org>
*/
public interface PizzaUserWebSessionController extends Serializable {
public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
/**
- * Event observer for new user registrations
+ * Checks if both user passwords are left empty and if this is enabled
+ * (allowed) in context parameter. If true, the calling bean should create a
+ * random password (preferable with UserUtils.createRandomPassword() and set
+ * it in both user password fields.
* <p>
- * @param event User registration event
+ * @return Whether empty passwords are allowed
*/
- void afterRegistrationEvent (final UserRegisteredEvent event);
+ boolean ifBothPasswordsEmptyAllowed ();
/**
- * Event observer for logged-in user
+ * All users
* <p>
- * @param event Event instance
+ * @return A list of all public user profiles
*/
- void afterUserLogin (final UserLoggedInEvent event);
+ List<User> allUsers ();
+
+ /**
+ * All public user profiles
+ * <p>
+ * @return A list of all public user profiles
+ */
+ List<User> allVisibleUsers ();
+
+ /**
+ * Checks whether the given contact is a user
+ * <p>
+ * @param contact Contact to check
+ * <p>
+ * @return Whether the contact is a user
+ */
+ boolean isContactFound (final Contact contact);
+
+ /**
+ * Checks whether a public user account is registered. This means that at
+ * least one user profile has its flag "public user profile" enabled.
+ * <p>
+ * @return Whether at least one user has a public profile
+ */
+ boolean isVisibleUserFound ();
+
+ /**
+ * Checks whether given user instance's name is used
+ * <p>
+ * @param user User instance's name to check
+ * <p>
+ * @return Whether it is already used
+ */
+ boolean isUserNameRegistered (final User user);
+
+ /**
+ * Tries to lookup user by given id number. If the user is not found or the
+ * account status is not CONFIRMED proper exceptions are thrown.
+ * <p>
+ * @param userId User id
+ * <p>
+ * @return User instance
+ * <p>
+ * @throws UserNotFoundException If the user is not found
+ */
+ User lookupUserById (final Long userId) throws UserNotFoundException;
+
+ /**
+ * Tries to lookup user by given email address. If the user is not found a
+ * proper exceptions is thrown.
+ * <p>
+ * @param emailAddress Email address
+ * <p>
+ * @return User instance
+ * <p>
+ * @throws UserEmailAddressNotFoundException If the user's email address is
+ * not found
+ */
+ User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException;
/**
* Creates an instance from all properties
* <p>
+ * @param createContactData Whether contact data should be created
+ * <p>
* @return A user instance
*/
- User createUserInstance ();
+ User createUserInstance (final boolean createContactData);
+
+ /**
+ * Creates a user instance for login phase
+ * <p>
+ * @return User instance
+ */
+ User createUserLogin ();
/**
* Getter for user id
void setUserName (final String userName);
/**
- * Getter for unencrypted user password
+ * Getter for clear-text user password
* <p>
- * @return Unencrypted user password
+ * @return Clear-text user password
*/
String getUserPassword ();
/**
- * Setter for unencrypted user password
+ * Setter for clear-text user password
* <p>
- * @param userPassword Unencrypted user password
+ * @param userPassword Clear-text user password
*/
void setUserPassword (final String userPassword);
/**
- * Getter for unencrypted user password repeated
+ * Getter for clear-text user password repeated
* <p>
- * @return Unencrypted user password repeated
+ * @return Clear-text user password repeated
*/
String getUserPasswordRepeat ();
/**
- * Setter for unencrypted user password repeated
+ * Setter for clear-text user password repeated
* <p>
- * @param userPasswordRepeat Unencrypted user password repeated
+ * @param userPasswordRepeat Clear-text user password repeated
*/
void setUserPasswordRepeat (final String userPasswordRepeat);
*/
String doChangePersonalData ();
+ /**
+ * Checks whether this application requires a user name to be entered.
+ * Otherwise a random name like "userXXXXX" is generated
+ * <p>
+ * @return Whether this application requires a user name
+ */
+ boolean isUserNameRequired ();
+
+ /**
+ * Checks wether public user profiles are enabled. This requires that user
+ * names are also enabled.
+ * <p>
+ * @return Whether public user profiles are enabled
+ */
+ boolean isPublicUserProfileEnabled ();
+
}