public void initializeList () {
// Is cache there?
if (!this.basicDataCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<BasicData> basicDatas = this.basicDataBean.allBusinessBasicData();
-
// Add all
- for (final BasicData basicData : basicDatas) {
+ for (final BasicData basicData : this.basicDataBean.allBusinessBasicData()) {
// Add it to cache
this.basicDataCache.put(basicData.getBasicDataId(), basicData);
}
public void initializeList () {
// Is cache there?
if (!this.branchOfficeCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<BranchOffice> branchOffices = this.branchOfficeBean.allBranchOffices();
-
// Add all
- for (final BranchOffice branchOffice : branchOffices) {
+ for (final BranchOffice branchOffice : this.branchOfficeBean.allBranchOffices()) {
// Add it to cache
this.branchOfficeCache.put(branchOffice.getBranchId(), branchOffice);
}
public void initializeList () {
// Is cache there?
if (!this.departmentCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<Department> departments = this.departmentBean.allDepartments();
-
// Add all
- for (final Department department : departments) {
+ for (final Department department : this.departmentBean.allDepartments()) {
// Add it to cache
this.departmentCache.put(department.getDepartmentId(), department);
}
public void init () {
// Is cache there?
if (!this.employeeCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<Employable> employees = this.employeeBean.allEmployees();
-
// Add all
- for (final Employable employee : employees) {
+ for (final Employable employee : this.employeeBean.allEmployees()) {
// Add it to cache
this.employeeCache.put(employee.getEmployeeId(), employee);
}
public void initializeList () {
// Is cache there?
if (!this.headquarterCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<Headquarter> Headquarter = this.headquarterBean.allHeadquarters();
-
// Add all
- for (final Headquarter headquarter : Headquarter) {
+ for (final Headquarter headquarter : this.headquarterBean.allHeadquarters()) {
// Add it to cache
this.headquarterCache.put(headquarter.getHeadquarterId(), headquarter);
}
public void initializeList () {
// Is cache there?
if (!this.openingTimesCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<OpeningTime> openingTimes = this.openingTimesBean.allOpeningTimes();
-
// Add all
- for (final OpeningTime openingTime : openingTimes) {
+ for (final OpeningTime openingTime : this.openingTimesBean.allOpeningTimes()) {
// Add it to cache
this.openingTimesCache.put(openingTime.getOpeningId(), openingTime);
}
final Contact contact = this.createContactInstance();
// Default is not same contact
- if (this.contactListController.isSameContactFound(contact)) {
+ if (this.contactListController.isContactFound(contact)) {
// Already registered
throw new FaceletException(new ContactAlreadyAddedException(contact));
}
* @param event Event being fired
*/
public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event instance
*/
public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Updated contact data event
*/
public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterUserConfirmedAccount (@Observes final ObservableUserConfirmedAccountEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event User registration event
*/
public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
public void initializeList () {
// Is cache there?
if (!this.contactCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<Contact> contacts = this.contactBean.allContacts();
-
// Add all
- for (final Contact contact : contacts) {
+ for (final Contact contact : this.contactBean.allContacts()) {
// Add it to cache
this.contactCache.put(contact.getContactId(), contact);
}
}
@Override
- public boolean isSameContactFound (final Contact contact) {
+ public boolean isContactFound (final Contact contact) {
// Default is not found
boolean IsFound = false;
*
* @return Whether contact has been found
*/
- boolean isSameContactFound (final Contact contact);
+ boolean isContactFound (final Contact contact);
/**
* Getter for all contacts
* @param event Event being fired
*/
public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Updated contact data event
*/
public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Unlinked fax contact event
*/
public void afterAdminUnlinkedFaxContactDataEvent (@Observes final ObservableAdminUnlinkedFaxNumberEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Unlinked land-line contact event
*/
public void afterAdminUnlinkedLandLineContactDataEvent (@Observes final ObservableAdminUnlinkedLandLineNumberEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Unlinked mobile contact event
*/
public void afterAdminUnlinkedMobileContactDataEvent (@Observes final ObservableAdminUnlinkedMobileNumberEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Updated contact data event
*/
public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
public void initializeList () {
// Is cache there?
if (!this.countryCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<Country> countrys = this.countryBean.allCountries();
-
// Add all
- for (final Country country : countrys) {
+ for (final Country country : this.countryBean.allCountries()) {
// Add it to cache
this.countryCache.put(country.getCountryId(), country);
}
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.contact.list.FinancialsContactListWebViewController;
import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
import org.mxchange.jphone.events.fax.created.CreatedFaxNumberEvent;
import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
import org.mxchange.jphone.events.landline.created.CreatedLandLineNumberEvent;
* Regular user controller
*/
@Inject
- private FinancialsUserWebRequestController userController;
+ private FinancialsContactListWebViewController contactListController;
/**
* Event for when a user instance was created
String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
// Check user first
- if (this.userController.isContactFound(contact)) {
+ if (this.contactListController.isContactFound(contact)) {
// Only user
messageKey = "CONTACT_IS_USER"; //NOI18N
}
* @param event Event instance
*/
public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event instance
*/
public void afterUserLogoutEvent (@Observes final ObservableUserLogoutEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
return NUMBER_FORMAT.format(amount);
}
- /**
- * Getter for locale
- * <p>
- * @return Locale
- */
+ @Override
public Locale getLocale () {
return this.locale;
}
package org.mxchange.jfinancials.beans.localization;
import java.io.Serializable;
+import java.util.Locale;
/**
* An interface for localization change beans
*/
String formatCurrency (final Float amount);
+ /**
+ * Getter for locale
+ * <p>
+ * @return Locale
+ */
+ Locale getLocale ();
+
}
public void initCache () {
// Is cache there?
if (!this.mobileProviderCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<MobileProvider> mobileProviders = this.mobileProviderBean.allMobileProviders();
-
// Add all
- for (final MobileProvider mobileProvider : mobileProviders) {
+ for (final MobileProvider mobileProvider : this.mobileProviderBean.allMobileProviders()) {
// Add it to cache
this.mobileProviderCache.put(mobileProvider.getProviderId(), mobileProvider);
}
* @param event Event being fired
*/
public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminDeletedFaxNumberEvent (@Observes final AdminDeletedFaxNumberEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminDeletedLandLineNumberEvent (@Observes final AdminDeletedLandLineNumberEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminDeletedMobileNumberEvent (@Observes final AdminDeletedMobileNumberEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminUpdatedContactDataEvent (@Observes final ObservableAdminUpdatedContactEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminUpdatedFaxNumberEvent (@Observes final AdminUpdatedFaxNumberEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminUpdatedLandLineNumberEvent (@Observes final AdminUpdatedLandLineNumberEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminUpdatedMobileNumberEvent (@Observes final AdminUpdatedMobileNumberEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
public void init () {
// Is cache there?
if (!this.faxNumberCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<DialableFaxNumber> faxNumbers = this.phoneBean.allFaxNumbers();
-
// Add all
- for (final DialableFaxNumber faxNumber : faxNumbers) {
+ for (final DialableFaxNumber faxNumber : this.phoneBean.allFaxNumbers()) {
// Add it to cache
this.faxNumberCache.put(faxNumber.getPhoneId(), faxNumber);
}
// Is cache there?
if (!this.landLineNumberCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<DialableLandLineNumber> lineNumbers = this.phoneBean.allLandLineNumbers();
-
// Add all
- for (final DialableLandLineNumber lineNumber : lineNumbers) {
+ for (final DialableLandLineNumber lineNumber : this.phoneBean.allLandLineNumbers()) {
// Add it to cache
this.landLineNumberCache.put(lineNumber.getPhoneId(), lineNumber);
}
// Is cache there?
if (!this.mobileNumberCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<DialableMobileNumber> mobileNumbers = this.phoneBean.allMobileNumbers();
-
// Add all
- for (final DialableMobileNumber mobileNumber : mobileNumbers) {
+ for (final DialableMobileNumber mobileNumber : this.phoneBean.allMobileNumbers()) {
// Add it to cache
this.mobileNumberCache.put(mobileNumber.getPhoneId(), mobileNumber);
}
import javax.inject.Inject;
import javax.inject.Named;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.user.User;
private static final long serialVersionUID = 187_687_145_286_710L;
/**
- * User controller
+ * User list controller
*/
@Inject
- private FinancialsUserWebRequestController userController;
+ private FinancialsUserListWebViewController userListController;
/**
* Login controller
try {
// Try to get it
- user = this.userController.lookupUserById(userId);
+ user = this.userListController.lookupUserById(userId);
} catch (final UserNotFoundException ex) {
// Throw again
throw new FaceletException(ex);
import org.mxchange.jfinancials.beans.contact.FinancialsAdminContactWebRequestController;
import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController;
import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
@EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
private UserSessionBeanRemote userBean;
- /**
- * Regular user controller
- */
- @Inject
- private FinancialsUserWebRequestController userController;
-
/**
* Delete reason
*/
@Any
private Event<ObservableAdminLinkedUserEvent> userLinkedEvent;
+ /**
+ * Regular user controller
+ */
+ @Inject
+ private FinancialsUserListWebViewController userListController;
+
/**
* User lock reason
*/
// Is the user name or email address used already?
// @TODO Add password length check
- if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userController.isUserNameRegistered(newUser))) {
+ if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userListController.isUserNameRegistered(newUser))) {
// User name is already used
throw new FaceletException(new UserNameAlreadyRegisteredException(newUser));
} else if ((this.getContact() == null) && (this.contactController.isEmailAddressRegistered(newUser.getUserContact()))) {
* @param event User registration event
*/
public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
*/
package org.mxchange.jfinancials.beans.user;
-import fish.payara.cdi.jsr107.impl.NamedCache;
import java.text.MessageFormat;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.inject.Named;
import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.jcoreee.events.locale.ObservableLocaleChangeEvent;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController;
import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController;
import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.clear.password.ObservableClearUserPasswordEvent;
import org.mxchange.jusercore.events.user.clear.username.ObservableClearUserNameEvent;
import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
-import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
-import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
-import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
-import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
import org.mxchange.jusercore.events.user.update.ObservableUpdatedUserPersonalDataEvent;
import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
-import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
*/
private static final long serialVersionUID = 542_145_347_916L;
- /**
- * List of all users
- */
- private final List<User> allUsers;
-
/**
* General contact controller
*/
private FinancialsFeaturesWebApplicationController featureController;
/**
- * List of filtered users
- */
- private List<User> filteredUsers;
-
- /**
- * Locale instance
+ * Localization controller
*/
- private Locale locale;
+ @Inject
+ private FinancialsLocalizationSessionController localizationController;
/**
* Event being fired when user updated personal data
@EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
private UserSessionBeanRemote userBean;
- /**
- * A list of all user profiles
- */
- @Inject
- @NamedCache (cacheName = "userCache")
- private Cache<Long, User> userCache;
-
/**
* User id
*/
public FinancialsUserWebRequestBean () {
// Call super constructor
super();
-
- // Init list
- this.allUsers = new LinkedList<>();
}
/**
* @param event Event being fired
*/
public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
}
- // Update user list
- this.updateList(event.getAddedUser());
-
- // Clear all data
- this.clear();
-
// Set user id again
this.setUserId(event.getAddedUser().getUserId());
}
- /**
- * Event observer for deleted user accounts (by administrator)
- * <p>
- * @param event Event being fired
- */
- public void afterAdminDeletedUserEvent (@Observes final ObservableAdminDeletedUserEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getDeletedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.deletedUser is null"); //NOI18N
- } else if (event.getDeletedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.deletedUser.userId is null"); //NOI18N
- } else if (event.getDeletedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getDeletedUser(), event.getDeletedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.removeFromList(event.getDeletedUser());
-
- // Clear all data
- this.clear();
- }
-
/**
* Event observer for linked users with existing contact data
* <p>
* @param event Event being fired
*/
public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserId())); //NOI18N
}
- // Update user list
- this.updateList(event.getLinkedUser());
-
- // Clear all data
- this.clear();
-
// Set user id again
this.setUserId(event.getLinkedUser().getUserId());
}
- /**
- * Event observer for locked users
- * <p>
- * @param event Event being fired
- */
- public void afterAdminLockedUserEvent (@Observes final ObservableAdminLockedUserEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLockedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.lockedUser is null"); //NOI18N
- } else if (event.getLockedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.lockedUser.userId is null"); //NOI18N
- } else if (event.getLockedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLockedUser(), event.getLockedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getLockedUser());
- }
-
- /**
- * Event observer for unlocked users
- * <p>
- * @param event Event being fired
- */
- public void afterAdminUnlockedUserEvent (@Observes final ObservableAdminUnlockedUserEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUnlockedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.unlockedUser is null"); //NOI18N
- } else if (event.getUnlockedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.unlockedUser.userId is null"); //NOI18N
- } else if (event.getUnlockedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUnlockedUser(), event.getUnlockedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getUnlockedUser());
- }
-
- /**
- * Event observer for updated user data by administrator
- * <p>
- * @param event Event being updated
- */
- public void afterAdminUpdatedUserDataEvent (@Observes final ObservableAdminUpdatedUserDataEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedUser is null"); //NOI18N
- } else if (event.getUpdatedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
- } else if (event.getUpdatedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedUser(), event.getUpdatedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getUpdatedUser());
-
- // Clear all data
- this.clear();
- }
-
/**
* Event observer for when a bean helper has successfully created a user
* instance, means the user exists. If the user does not exist, this event
this.copyUser(user);
}
- /**
- * Observer method for events being fired when the application's locale has
- * been changed.
- * <p>
- * @param event Event being fired
- */
- public void afterLocaleChangeEvent (@Observes final ObservableLocaleChangeEvent event) {
- // Is the parameter valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLocale() == null) {
- // Throw NPE again
- throw new NullPointerException("event.locale is null"); //NOI18N
- }
-
- // Set it here
- this.setLocale(event.getLocale());
- }
-
- /**
- * Event observer when user confirmed account.
- * <p>
- * @param event Event being fired
- */
- public void afterUserConfirmedAccountEvent (@Observes final ObservableUserConfirmedAccountEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getConfirmedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.confirmedUser is null"); //NOI18N
- } else if (event.getConfirmedUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N
- } else if (event.getConfirmedUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getConfirmedUser());
- }
-
/**
* Event observer for logged-in user
* <p>
* @param event Event instance
*/
public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event User registration event
*/
public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
// Copy all data from registered->user
this.copyUser(registeredUser);
- // Clear all data
- this.clear();
-
- // Update user list
- this.updateList(registeredUser);
-
// Set user id again
this.setUserId(registeredUser.getUserId());
}
- /**
- * Method being call after user's password has been updated (and history
- * entry has been created).
- * <p>
- * @param event Event being observed
- */
- public void afterUserUpdatedPasswordEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
- // Check parameter
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getPasswordHistory() == null) {
- // Throw NPE again
- throw new NullPointerException("event.passwordHistory is null"); //NOI18N
- } else if (event.getPasswordHistory().getUserPasswordHistoryId() == null) {
- // ... and again
- throw new NullPointerException("event.passwordHistory.userPasswordHistoryId is null"); //NOI18N
- } else if (event.getPasswordHistory().getUserPasswordHistoryId() < 1) {
- // Invalid value
- throw new IllegalArgumentException(MessageFormat.format("event.passwordHistory.userPasswordHistoryId={0} is in valid", event.getPasswordHistory().getUserPasswordHistoryId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getPasswordHistory().getUserPasswordHistoryUser());
- }
-
- /**
- * Listens to fired event when user updated personal data
- * <p>
- * @param event Event being fired
- */
- public void afterUserUpdatedPersonalDataEvent (@Observes final ObservableUpdatedUserPersonalDataEvent event) {
- // Check parameter
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedUser is null"); //NOI18N
- } else if (event.getUpdatedUser().getUserId() == null) {
- // ... and again
- throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
- } else if (event.getUpdatedUser().getUserId() < 1) {
- // Invalid value
- throw new IllegalArgumentException(MessageFormat.format("event.updatedUser.userId={0} is in valid", event.getUpdatedUser().getUserId())); //NOI18N
- }
-
- // Update user list
- this.updateList(event.getUpdatedUser());
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<User> allUsers () {
- return this.allUsers;
- }
-
/**
* Event observer for when a user name should be cleared
* <p>
// Required personal data must be set
assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
- // Create new user instance
- final User user = new LoginUser();
-
// Is user name required?
if (!this.isUserNameRequired()) {
// Generate pseudo-random user name
this.setUserPasswordRepeat(randomPassword);
}
+ // Create new user instance
+ final User user = new LoginUser();
+
// Set user name profile mode and locale
user.setUserName(this.getUserName());
user.setUserProfileMode(this.getUserProfileMode());
- user.setUserLocale(this.getLocale());
+ user.setUserLocale(this.localizationController.getLocale());
// Is multiple registration page
if ((createContactData) || (!this.featureController.isFeatureEnabled("user_register_multiple_page"))) { //NOI18N
return "user_contact_data_saved"; //NOI18N
}
- @Override
- public User findUserById (final Long userId) throws UserNotFoundException {
- // Validate parameter
- if (null == userId) {
- // Throw NPE
- throw new NullPointerException("userId is null"); //NOI18N
- } else if (userId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N
- } else if (!this.userCache.containsKey(userId)) {
- // Not found
- throw new UserNotFoundException(userId);
- }
-
- // Get it from cache
- final User user = this.userCache.get(userId);
-
- // Return it
- return user;
- }
-
- /**
- * Getter for filtered users list
- * <p>
- * @return Filtered users list
- */
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<User> getFilteredUsers () {
- return this.filteredUsers;
- }
-
- /**
- * Setter for filtered users list
- * <p>
- * @param filteredUsers Filtered users list
- */
- @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
- public void setFilteredUsers (final List<User> filteredUsers) {
- this.filteredUsers = filteredUsers;
- }
-
/**
* Getter for user id
* <p>
((this.getUserPasswordRepeat() == null) || (this.getUserPasswordRepeat().isEmpty())));
}
- @Override
- public boolean ifUserIdExists (final Long userId) {
- // Validate parameter
- if (null == userId) {
- // Throw NPE
- throw new NullPointerException("userId is null"); //NOI18N
- } else if (userId < 1) {
- // Throw IAE
- throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N
- }
-
- // Check if key is there
- boolean isFound = this.userCache.containsKey(userId);
-
- // Return flag
- return isFound;
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- // Is cache there?
- if (!this.userCache.iterator().hasNext()) {
- // Get whole list from EJB
- final List<User> users = this.userBean.allUsers();
-
- // Add all
- for (final User user : users) {
- // Add it to cache
- this.userCache.put(user.getUserId(), user);
- }
- }
-
- // Is cache filled and list is empty
- if ((this.userCache.iterator().hasNext()) && (this.allUsers.isEmpty())) {
- // Build up list
- for (final Cache.Entry<Long, User> currentEntry : this.userCache) {
- // Add to list
- this.allUsers.add(currentEntry.getValue());
- }
-
- // Sort list
- this.allUsers.sort(new Comparator<User>() {
- @Override
- public int compare (final User user1, final User user2) {
- return user1.getUserId() > user2.getUserId() ? 1 : user1.getUserId() < user2.getUserId() ? -1 : 0;
- }
- });
- }
- }
-
- @Override
- public boolean isContactFound (final Contact contact) {
- // The contact must be valid
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw again ...
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
- }
-
- // Default is not found
- boolean isFound = false;
-
- // Loop through all entries
- for (final User currentUser : this.allUsers()) {
- // Compare both objects
- if (Objects.equals(contact, currentUser.getUserContact())) {
- // Found it
- isFound = true;
- break;
- }
- }
-
- // Return status
- return isFound;
- }
-
@Override
public boolean isRequiredChangePersonalDataSet () {
return ((this.getUserProfileMode() != null) &&
return ((this.getUserId() == null) || (this.getUserId() == 0));
}
- @Override
- public boolean isUserNameRegistered (final User user) {
- // Default is not found
- boolean isFound = false;
-
- // Determine it
- for (final User currentUser : this.allUsers()) {
- // Is same name found?
- if (Objects.equals(user.getUserName(), currentUser.getUserName())) {
- // Yes, then set flag and abort loop
- isFound = true;
- break;
- }
- }
-
- // Return flag
- return isFound;
- }
-
@Override
public boolean isUserNameRequired () {
// Get context parameter
return isRequired;
}
- @Override
- public User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException {
- // Parameter must be valid
- if (null == emailAddress) {
- // Throw NPE
- throw new NullPointerException("emailAddress is null"); //NOI18N
- } else if (emailAddress.isEmpty()) {
- // Not valid
- throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
- }
-
- // Init variable
- User user = null;
-
- // Try to lookup it in visible user list
- for (final Cache.Entry<Long, User> currentUser : this.userCache) {
- // Contact should be set
- if (currentUser.getValue().getUserContact() == null) {
- // Contact is null
- throw new NullPointerException(MessageFormat.format("currentUser.userContact is null for user id {0}", currentUser.getKey())); //NOI18N
- } else if (currentUser.getValue().getUserContact().getContactEmailAddress() == null) {
- // Email address should be set
- throw new NullPointerException(MessageFormat.format("currentUser.userContact.contactEmailAddress is null for user id {0}", currentUser.getKey())); //NOI18N
- }
-
- // Is the email address found?
- if (Objects.equals(currentUser.getValue().getUserContact().getContactEmailAddress(), emailAddress)) {
- // Copy to other variable
- user = currentUser.getValue();
- break;
- }
- }
-
- // Is it still null?
- if (null == user) {
- // Not visible for the current user
- throw new UserEmailAddressNotFoundException(emailAddress);
- }
-
- // Return it
- return user;
- }
-
- @Override
- public User lookupUserById (final Long userId) throws UserNotFoundException {
- // Parameter must be valid
- if (null == userId) {
- // Throw NPE
- throw new NullPointerException("userId is null"); //NOI18N
- } else if (userId < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
- }
-
- // Init variable
- User user = null;
-
- // Try to lookup it in visible user list
- for (final Cache.Entry<Long, User> currentUser : this.userCache) {
- // Is the user id found?
- if (Objects.equals(currentUser.getKey(), userId)) {
- // Copy to other variable
- user = currentUser.getValue();
- break;
- }
- }
-
- // Is it still null?
- if (null == user) {
- // Not visible for the current user
- throw new UserNotFoundException(userId);
- }
-
- // Return it
- return user;
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- // - personal data
- this.setUserId(null);
- this.setUserProfileMode(null);
-
- // - other data
- this.clearUserName();
- this.clearUserPasswords();
- this.setLocale(null);
- }
-
/**
* Clears user name
*/
this.setUserProfileMode(user.getUserProfileMode());
}
- /**
- * Getter for locale instance
- * <p>
- * @return Locale instance
- */
- private Locale getLocale () {
- return this.locale;
- }
-
- /**
- * Setter for locale instance
- * <p>
- * @param locale Locale instance
- */
- private void setLocale (final Locale locale) {
- this.locale = locale;
- }
-
- /**
- * Removes user from all lists
- * <p>
- * @param user User to remove
- */
- private void removeFromList (final User user) {
- // The user should be valid
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // ... again NPE
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Invalid id
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
- }
-
- // Remove it from lists
- this.allUsers().remove(user);
- this.userCache.remove(user.getUserId());
- }
-
- /**
- * Updates list with given user instance
- * <p>
- * @param user User instance
- */
- private void updateList (final User user) {
- // The user should be valid
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // ... again NPE
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Invalid id
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
- } else if (user.getUserContact() == null) {
- // Throw again ...
- throw new NullPointerException("user.userContact is null"); //NOI18N
- } else if (user.getUserContact().getContactId() == null) {
- // Throw again ...
- throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
- } else if (user.getUserContact().getContactId() < 1) {
- // Throw again ...
- throw new NullPointerException(MessageFormat.format("user.userContact.contactId={0} is invalid.", user.getUserContact().getContactId())); //NOI18N
- }
-
- // Add/update user
- this.userCache.put(user.getUserId(), user);
- this.allUsers.add(user);
- }
-
}
package org.mxchange.jfinancials.beans.user;
import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.user.User;
/**
@Deprecated
public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
- /**
- * Returns a user instance by given primary key. If not found, a proper
- * exception is thrown.
- * <p>
- * @param userId User id
- * <p>
- * @return User instance
- * <p>
- * @throws UserNotFoundException If the user is not found
- */
- User findUserById (final Long userId) throws UserNotFoundException;
-
- /**
- * Checks if given user id exists
- * <p>
- * @param userId User id to check
- * <p>
- * @return Whether the user id exists
- */
- boolean ifUserIdExists (final Long userId);
-
/**
* Getter for clear-text user password
* <p>
*/
boolean ifBothPasswordsEmptyAllowed ();
- /**
- * All users
- * <p>
- * @return A list of all public user profiles
- */
- List<User> allUsers ();
-
- /**
- * 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 given user instance name is used
- * <p>
- * @param user User instance 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 event Event being fired
*/
public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminDeletedUserEvent (@Observes final ObservableAdminDeletedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminLockedUserEvent (@Observes final ObservableAdminLockedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterAdminUnlockedUserEvent (@Observes final ObservableAdminUnlockedUserEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being updated
*/
public void afterAdminUpdatedUserDataEvent (@Observes final ObservableAdminUpdatedUserDataEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterUserConfirmedAccountEvent (@Observes final ObservableUserConfirmedAccountEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event instance
*/
public void afterUserLogoutEvent (@Observes final ObservableUserLogoutEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
* @param event Event being fired
*/
public void afterUserResendConfirmationLinkEvent (@Observes final ObservableUserResendLinkAccountEvent event) {
- // event should not be null
+ // Event and contained entity instance should not be null
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
*/
@PostConstruct
public void init () {
- // Get whole list from EJB
- final List<LogableUserActivity> userActivities = this.userActivityBean.fetchAllUserActivityLog();
-
// Put all in map, per-user
- for (final LogableUserActivity userActivity : userActivities) {
+ for (final LogableUserActivity userActivity : this.userActivityBean.fetchAllUserActivityLog()) {
// Is the list there?
if (!this.userActivityCache.containsKey(userActivity.getActivityUser())) {
// Init list
import org.mxchange.jcoreee.events.helper.clear.ObservableHelperCleanupEvent;
import org.mxchange.jcoreee.utils.FacesUtils;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
import org.mxchange.jusercore.events.user.created.CreatedUserEvent;
import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
private Event<ObservableUserConfirmedAccountEvent> userConfirmedEvent;
/**
- * User controller
+ * Event for when a user instance was created
*/
+ @Any
@Inject
- private FinancialsUserWebRequestController userController;
+ private Event<ObservableCreatedUserEvent> userCreatedEvent;
/**
- * Event for when a user instance was created
+ * User controller
*/
- @Any
@Inject
- private Event<ObservableCreatedUserEvent> userCreatedEvent;
+ private FinancialsUserListWebViewController userListController;
/**
* Default constructor
User user = null;
// Then loop through all
- for (final User currentUser : this.userController.allUsers()) {
+ for (final User currentUser : this.userListController.getAllUsers()) {
// Same confirmation key?
if (Objects.equals(this.getConfirmationKey(), currentUser.getUserConfirmKey())) {
// Found it, then set it and abort loop
--- /dev/null
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.user.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsUserListWebViewController extends Serializable {
+
+ /**
+ * Returns a user instance by given primary key. If not found, a proper
+ * exception is thrown.
+ * <p>
+ * @param userId User id
+ * <p>
+ * @return User instance
+ * <p>
+ * @throws UserNotFoundException If the user is not found
+ */
+ User findUserById (final Long userId) throws UserNotFoundException;
+
+ /**
+ * All users
+ * <p>
+ * @return A list of all public user profiles
+ */
+ List<User> getAllUsers ();
+
+ /**
+ * Checks if given user id exists
+ * <p>
+ * @param userId User id to check
+ * <p>
+ * @return Whether the user id exists
+ */
+ boolean ifUserIdExists (final Long userId);
+
+ /**
+ * Checks whether given user instance name is used
+ * <p>
+ * @param user User instance 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;
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.user.list;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.enterprise.event.Observes;
+import javax.faces.view.ViewScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
+import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
+import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
+import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
+import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
+import org.mxchange.jusercore.events.user.update.ObservableUpdatedUserPersonalDataEvent;
+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.UserSessionBeanRemote;
+import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
+import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
+import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
+
+/**
+ * A user list bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("userListController")
+@ViewScoped
+public class FinancialsUserListWebViewtBean extends BaseFinancialsBean implements FinancialsUserListWebViewController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_918L;
+
+ /**
+ * List of all users
+ */
+ private final List<User> allUsers;
+
+ /**
+ * List of filtered users
+ */
+ private List<User> filteredUsers;
+
+ /**
+ * Selected user instance
+ */
+ private User selectedUser;
+
+ /**
+ * Remote user bean
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
+ private UserSessionBeanRemote userBean;
+
+ /**
+ * A list of all user profiles
+ */
+ @Inject
+ @NamedCache (cacheName = "userCache")
+ private transient Cache<Long, User> userCache;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsUserListWebViewtBean () {
+ // Call super constructor
+ super();
+
+ // Init list
+ this.allUsers = new LinkedList<>();
+ }
+
+ /**
+ * Event observer for newly added users by administrator
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.addedUser is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getAddedUser());
+ }
+
+ /**
+ * Event observer for deleted user accounts (by administrator)
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminDeletedUserEvent (@Observes final ObservableAdminDeletedUserEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getDeletedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.deletedUser is null"); //NOI18N
+ } else if (event.getDeletedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.deletedUser.userId is null"); //NOI18N
+ } else if (event.getDeletedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getDeletedUser(), event.getDeletedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.removeFromList(event.getDeletedUser());
+ }
+
+ /**
+ * Event observer for linked users with existing contact data
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getLinkedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.linkedUser is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.linkedUser.userId is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getLinkedUser());
+ }
+
+ /**
+ * Event observer for locked users
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminLockedUserEvent (@Observes final ObservableAdminLockedUserEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getLockedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.lockedUser is null"); //NOI18N
+ } else if (event.getLockedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.lockedUser.userId is null"); //NOI18N
+ } else if (event.getLockedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLockedUser(), event.getLockedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getLockedUser());
+ }
+
+ /**
+ * Event observer for unlocked users
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterAdminUnlockedUserEvent (@Observes final ObservableAdminUnlockedUserEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUnlockedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.unlockedUser is null"); //NOI18N
+ } else if (event.getUnlockedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.unlockedUser.userId is null"); //NOI18N
+ } else if (event.getUnlockedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUnlockedUser(), event.getUnlockedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getUnlockedUser());
+ }
+
+ /**
+ * Event observer for updated user data by administrator
+ * <p>
+ * @param event Event being updated
+ */
+ public void afterAdminUpdatedUserDataEvent (@Observes final ObservableAdminUpdatedUserDataEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedUser is null"); //NOI18N
+ } else if (event.getUpdatedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
+ } else if (event.getUpdatedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedUser(), event.getUpdatedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getUpdatedUser());
+ }
+
+ /**
+ * Event observer when user confirmed account.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterUserConfirmedAccountEvent (@Observes final ObservableUserConfirmedAccountEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getConfirmedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.confirmedUser is null"); //NOI18N
+ } else if (event.getConfirmedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N
+ } else if (event.getConfirmedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getConfirmedUser());
+ }
+
+ /**
+ * Event observer for new user registrations
+ * <p>
+ * @param event User registration event
+ */
+ public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
+ // Event and contained entity instance should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getRegisteredUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.registeredUser is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getRegisteredUser());
+ }
+
+ /**
+ * Method being call after user's password has been updated (and history
+ * entry has been created).
+ * <p>
+ * @param event Event being observed
+ */
+ public void afterUserUpdatedPasswordEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
+ // Check parameter
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getPasswordHistory() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.passwordHistory is null"); //NOI18N
+ } else if (event.getPasswordHistory().getUserPasswordHistoryId() == null) {
+ // ... and again
+ throw new NullPointerException("event.passwordHistory.userPasswordHistoryId is null"); //NOI18N
+ } else if (event.getPasswordHistory().getUserPasswordHistoryId() < 1) {
+ // Invalid value
+ throw new IllegalArgumentException(MessageFormat.format("event.passwordHistory.userPasswordHistoryId={0} is in valid", event.getPasswordHistory().getUserPasswordHistoryId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getPasswordHistory().getUserPasswordHistoryUser());
+ }
+
+ /**
+ * Listens to fired event when user updated personal data
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterUserUpdatedPersonalDataEvent (@Observes final ObservableUpdatedUserPersonalDataEvent event) {
+ // Check parameter
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedUser is null"); //NOI18N
+ } else if (event.getUpdatedUser().getUserId() == null) {
+ // ... and again
+ throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
+ } else if (event.getUpdatedUser().getUserId() < 1) {
+ // Invalid value
+ throw new IllegalArgumentException(MessageFormat.format("event.updatedUser.userId={0} is in valid", event.getUpdatedUser().getUserId())); //NOI18N
+ }
+
+ // Update user list
+ this.updateList(event.getUpdatedUser());
+ }
+
+ @Override
+ public User findUserById (final Long userId) throws UserNotFoundException {
+ // Validate parameter
+ if (null == userId) {
+ // Throw NPE
+ throw new NullPointerException("userId is null"); //NOI18N
+ } else if (userId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N
+ } else if (!this.userCache.containsKey(userId)) {
+ // Not found
+ throw new UserNotFoundException(userId);
+ }
+
+ // Get it from cache
+ final User user = this.userCache.get(userId);
+
+ // Return it
+ return user;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<User> getAllUsers () {
+ return this.allUsers;
+ }
+
+ /**
+ * Getter for filtered users list
+ * <p>
+ * @return Filtered users list
+ */
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<User> getFilteredUsers () {
+ return this.filteredUsers;
+ }
+
+ /**
+ * Setter for filtered users list
+ * <p>
+ * @param filteredUsers Filtered users list
+ */
+ @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+ public void setFilteredUsers (final List<User> filteredUsers) {
+ this.filteredUsers = filteredUsers;
+ }
+
+ /**
+ * Getter for selected user instance
+ * <p>
+ * @return Selected user instance
+ */
+ public User getSelectedUser () {
+ return this.selectedUser;
+ }
+
+ /**
+ * Setter for selected user instance
+ * <p>
+ * @param selectedUser Selected user instance
+ */
+ public void setSelectedUser (final User selectedUser) {
+ this.selectedUser = selectedUser;
+ }
+
+ @Override
+ public boolean ifUserIdExists (final Long userId) {
+ // Validate parameter
+ if (null == userId) {
+ // Throw NPE
+ throw new NullPointerException("userId is null"); //NOI18N
+ } else if (userId < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException("userId=" + userId + " is invalid."); //NOI18N
+ }
+
+ // Check if key is there
+ boolean isFound = this.userCache.containsKey(userId);
+
+ // Return flag
+ return isFound;
+ }
+
+ /**
+ * Post-initialization of this class
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.userCache.iterator().hasNext()) {
+ // Add all
+ for (final User user : this.userBean.allUsers()) {
+ // Add it to cache
+ this.userCache.put(user.getUserId(), user);
+ }
+ }
+
+ // Is cache filled and list is empty
+ if ((this.userCache.iterator().hasNext()) && (this.getAllUsers().isEmpty())) {
+ // Build up list
+ for (final Cache.Entry<Long, User> currentEntry : this.userCache) {
+ // Add to list
+ this.getAllUsers().add(currentEntry.getValue());
+ }
+
+ // Sort list
+ this.getAllUsers().sort(new Comparator<User>() {
+ @Override
+ public int compare (final User user1, final User user2) {
+ return user1.getUserId() > user2.getUserId() ? 1 : user1.getUserId() < user2.getUserId() ? -1 : 0;
+ }
+ });
+
+ // Set full list
+ this.setFilteredUsers(this.getAllUsers());
+ }
+ }
+
+ @Override
+ public boolean isUserNameRegistered (final User user) {
+ // Default is not found
+ boolean isFound = false;
+
+ // Determine it
+ for (final User currentUser : this.getAllUsers()) {
+ // Is same name found?
+ if (Objects.equals(user.getUserName(), currentUser.getUserName())) {
+ // Yes, then set flag and abort loop
+ isFound = true;
+ break;
+ }
+ }
+
+ // Return flag
+ return isFound;
+ }
+
+ @Override
+ public User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException {
+ // Parameter must be valid
+ if (null == emailAddress) {
+ // Throw NPE
+ throw new NullPointerException("emailAddress is null"); //NOI18N
+ } else if (emailAddress.isEmpty()) {
+ // Not valid
+ throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
+ }
+
+ // Init variable
+ User user = null;
+
+ // Try to lookup it in visible user list
+ for (final Cache.Entry<Long, User> currentUser : this.userCache) {
+ // Contact should be set
+ if (currentUser.getValue().getUserContact() == null) {
+ // Contact is null
+ throw new NullPointerException(MessageFormat.format("currentUser.userContact is null for user id {0}", currentUser.getKey())); //NOI18N
+ } else if (currentUser.getValue().getUserContact().getContactEmailAddress() == null) {
+ // Email address should be set
+ throw new NullPointerException(MessageFormat.format("currentUser.userContact.contactEmailAddress is null for user id {0}", currentUser.getKey())); //NOI18N
+ }
+
+ // Is the email address found?
+ if (Objects.equals(currentUser.getValue().getUserContact().getContactEmailAddress(), emailAddress)) {
+ // Copy to other variable
+ user = currentUser.getValue();
+ break;
+ }
+ }
+
+ // Is it still null?
+ if (null == user) {
+ // Not visible for the current user
+ throw new UserEmailAddressNotFoundException(emailAddress);
+ }
+
+ // Return it
+ return user;
+ }
+
+ @Override
+ public User lookupUserById (final Long userId) throws UserNotFoundException {
+ // Parameter must be valid
+ if (null == userId) {
+ // Throw NPE
+ throw new NullPointerException("userId is null"); //NOI18N
+ } else if (userId < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
+ }
+
+ // Init variable
+ User user = null;
+
+ // Try to lookup it in visible user list
+ for (final Cache.Entry<Long, User> currentUser : this.userCache) {
+ // Is the user id found?
+ if (Objects.equals(currentUser.getKey(), userId)) {
+ // Copy to other variable
+ user = currentUser.getValue();
+ break;
+ }
+ }
+
+ // Is it still null?
+ if (null == user) {
+ // Not visible for the current user
+ throw new UserNotFoundException(userId);
+ }
+
+ // Return it
+ return user;
+ }
+
+ /**
+ * Removes user from all lists
+ * <p>
+ * @param user User to remove
+ */
+ private void removeFromList (final User user) {
+ // Remove it from lists
+ this.getAllUsers().remove(user);
+ this.userCache.remove(user.getUserId());
+ }
+
+ /**
+ * Updates list with given user instance
+ * <p>
+ * @param user User instance
+ */
+ private void updateList (final User user) {
+ // Add/update user
+ this.userCache.put(user.getUserId(), user);
+ this.getAllUsers().add(user);
+ }
+
+}
import org.mxchange.jfinancials.beans.contact.FinancialsContactWebRequestController;
import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
import org.mxchange.jusercore.events.user.clear.password.ClearUserPasswordEvent;
import org.mxchange.jusercore.events.user.clear.password.ObservableClearUserPasswordEvent;
import org.mxchange.jusercore.events.user.clear.username.ClearUserNameEvent;
@Inject
private FinancialsUserWebRequestController userController;
+ /**
+ * User list controller
+ */
+ @Inject
+ private FinancialsUserListWebViewController userListController;
+
/**
* An event being fired when a user password was changed
*/
} else if (!this.userController.isRequiredPersonalDataSet()) {
// Not all required fields are set
throw new FaceletException("Not all required fields are set."); //NOI18N
- } else if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userController.isUserNameRegistered(user))) { //NOI18N
+ } else if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userListController.isUserNameRegistered(user))) { //NOI18N
// Is multi-page enabled?
if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
// User name is already used, should not happen here
if (null == user) {
// user must be set
throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
- } else if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userController.isUserNameRegistered(user))) { //NOI18N
+ } else if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userListController.isUserNameRegistered(user))) { //NOI18N
// User name is already used, so clear it
this.clearUserNameEvent.fire(new ClearUserNameEvent());
*/
package org.mxchange.jfinancials.beans.user.resendlink;
-import java.util.Locale;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
import javax.enterprise.inject.Any;
import javax.faces.application.FacesMessage;
import javax.inject.Inject;
import javax.inject.Named;
-import org.mxchange.jcoreee.events.locale.ObservableLocaleChangeEvent;
import org.mxchange.jcoreee.utils.FacesUtils;
import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
+import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
private String emailAddress;
/**
- * Locale instance
+ * Localization controller
*/
- private Locale locale;
+ @Inject
+ private FinancialsLocalizationSessionController localizationController;
/**
* EJB for resending confirmation link
* Regular user controller
*/
@Inject
- private FinancialsUserWebRequestController userController;
+ private FinancialsUserListWebViewController userListController;
/**
* Event being fired after confirmation link is being sent
super();
}
- /**
- * Observer method for events being fired when the application's locale has
- * been changed.
- * <p>
- * @param event Event being fired
- */
- public void afterLocaleChangeEvent (@Observes final ObservableLocaleChangeEvent event) {
- // Is the parameter valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null");
- } else if (event.getLocale() == null) {
- // Throw NPE again
- throw new NullPointerException("event.locale is null");
- }
-
- // Set it here
- this.setLocale(event.getLocale());
- }
-
/**
* Resends (new) confirmation link to given email address, if found.
* Otherwise an exception is thrown. On success a redirect takes place.
try {
// Is the email address really not used?
- user = this.userController.lookupUserByEmailAddress(this.getEmailAddress());
+ user = this.userListController.lookupUserByEmailAddress(this.getEmailAddress());
} catch (final UserEmailAddressNotFoundException ex) {
// Always clear bean
this.clear();
final String baseUrl = FacesUtils.generateBaseUrl();
// Call EJB and return redirect target
- managedUser = this.resendLinkBean.resendConfirmationLink(user, this.getLocale(), baseUrl);
+ managedUser = this.resendLinkBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
} catch (final UserNotFoundException ex) {
// User not found
this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_NOT_FOUND", FacesMessage.SEVERITY_ERROR); //NOI18N
this.setEmailAddress(null);
}
- /**
- * Getter for locale instance
- * <p>
- * @return Locale instance
- */
- private Locale getLocale () {
- return this.locale;
- }
-
- /**
- * Setter for locale instance
- * <p>
- * @param locale Locale instance
- */
- private void setLocale (final Locale locale) {
- this.locale = locale;
- }
-
}
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.FacesConverter;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestBean;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewtBean;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.model.user.User;
/**
* User backing bean
*/
- private static FinancialsUserWebRequestController USER_CONTROLLER;
+ private static FinancialsUserListWebViewController USER_LIST_CONTROLLER;
@Override
public User getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
// Is the instance there?
- if (null == USER_CONTROLLER) {
+ if (null == USER_LIST_CONTROLLER) {
// Get bean from CDI directly
- USER_CONTROLLER = CDI.current().select(FinancialsUserWebRequestBean.class).get();
+ USER_LIST_CONTROLLER = CDI.current().select(FinancialsUserListWebViewtBean.class).get();
}
// Is the value null or empty?
final Long userId = Long.valueOf(submittedValue);
// Try to get user instance from it
- user = USER_CONTROLLER.findUserById(userId);
+ user = USER_LIST_CONTROLLER.findUserById(userId);
} catch (final NumberFormatException ex) {
// Throw again
throw new ConverterException(ex);
import javax.faces.validator.FacesValidator;
import javax.faces.validator.ValidatorException;
import org.mxchange.jcoreee.validator.number.BaseNumberValidator;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestBean;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewController;
+import org.mxchange.jfinancials.beans.user.list.FinancialsUserListWebViewtBean;
/**
* A validator for user ids
/**
* User backing bean
*/
- private static FinancialsUserWebRequestController USER_CONTROLLER;
+ private static FinancialsUserListWebViewController USER_LIST_CONTROLLER;
/**
* Serial number
super.preValidate(context, component, value, requiredFields, false);
// Is the instance there?
- if (null == USER_CONTROLLER) {
+ if (null == USER_LIST_CONTROLLER) {
// Get bean from CDI directly
- USER_CONTROLLER = CDI.current().select(FinancialsUserWebRequestBean.class).get();
+ USER_LIST_CONTROLLER = CDI.current().select(FinancialsUserListWebViewtBean.class).get();
}
// Cast value
final Long userId = (Long) value;
// Define variable
- final Boolean ifUserExists = USER_CONTROLLER.ifUserIdExists(userId);
+ final Boolean ifUserExists = USER_LIST_CONTROLLER.ifUserIdExists(userId);
// Is the user id valid?
if (!ifUserExists) {
ADMIN_LINK_EDIT_DELETE_MOBILE_PROVIDER_TITLE=Editieren oder l\u00f6schen des Handyanbieters
ADMIN_USER_DATA_ENTER_PASSWORD=Passwort eingeben:
ADMIN_USER_DATA_ENTER_PASSWORD_REPEAT=Passwort wiederholen:
-ADMIN_LIST_USER_ID=Benutzer-Id:
-ADMIN_LIST_USER_NAME=Benutzername:
+DATA_USER_ID=Benutzer-Id:
+DATA_USER_NAME=Benutzername:
+#@TODO Please fix German umlauts!
+CHANGE=Aendern?
ADMIN_LIST_USER_PERSONAL_TITLE=Anrede:
ADMIN_LIST_USER_FIRST_NAME=Vorname:
ADMIN_LIST_USER_FAMILY_NAME=Nachname:
ERROR_USER_NOT_FOUND=Fehler: Benutzereintrag nicht gefunden.
ADMIN_TABLE_SUMMARY_SHOW_USER_DATA=Diese Tabelle zeigt ein Benutzerprofil f\u00fcr administrative Zwecke an.
ADMIN_SHOW_USER_HEADER=Benutzer {0} (Nummer {1}):
-ADMIN_USER_ID=Benutzer-Id:
-ADMIN_USER_NAME=Benutzername:
ADMIN_USER_CREATED=Wann Benutzer erstellt:
ADMIN_USER_UPDATED=Wann Benutzerdaten ge\u00e4ndert:
ADMIN_USER_ACCOUNT_STATUS=Account-Status:
ADMIN_USER_PROFILE_MODE=Profilmodus:
-ADMIN_USER_LAST_LOCKED=Zuletzt gesperrt:
-ADMIN_USER_LAST_LOCKED_REASON=Letzter Sperrgrund:
+DATA_USER_LAST_LOCKED=Zuletzt gesperrt:
+DATA_USER_LAST_LOCKED_REASON=Letzter Sperrgrund:
ADMIN_CONTACT_IS_OWN_CONTACT=Eigenes Account:
ADMIN_CONTACT_PERSONAL_TITLE=Anrede:
ADMIN_CONTACT_ACADEMIC_TITLE=Akademischer Titel:
ADMIN_LINK_EDIT_DELETE_MOBILE_PROVIDER_TITLE=Edit or delete mobile provider
ADMIN_USER_DATA_ENTER_PASSWORD=Enter password:
ADMIN_USER_DATA_ENTER_PASSWORD_REPEAT=Repeat password:
-ADMIN_LIST_USER_ID=User id:
-ADMIN_LIST_USER_NAME=User name:
+DATA_USER_ID=User id:
+DATA_USER_NAME=User name:
ADMIN_LIST_USER_PERSONAL_TITLE=Gender:
ADMIN_LIST_USER_FIRST_NAME=First name:
ADMIN_LIST_USER_FAMILY_NAME=Family name:
ERROR_USER_NOT_FOUND=Error: User entry not found.
ADMIN_TABLE_SUMMARY_SHOW_USER_DATA=This table shows a single user profile for administrative purposes.
ADMIN_SHOW_USER_HEADER=User {0} (id {1}):
-ADMIN_USER_ID=User id:
-ADMIN_USER_NAME=User name:
ADMIN_USER_CREATED=When user created:
ADMIN_USER_UPDATED=When user data updated:
ADMIN_USER_ACCOUNT_STATUS=Account status:
ADMIN_USER_PROFILE_MODE=Profile mode:
-ADMIN_USER_LAST_LOCKED=Last locked:
-ADMIN_USER_LAST_LOCKED_REASON=Last lock reason:
+DATA_USER_LAST_LOCKED=Last locked:
+DATA_USER_LAST_LOCKED_REASON=Last lock reason:
ADMIN_CONTACT_IS_OWN_CONTACT=Own account:
ADMIN_CONTACT_PERSONAL_TITLE=Gender:
ADMIN_CONTACT_ACADEMIC_TITLE=Academic title:
ADMIN_CONTACT_DETAILS_HEADER=Contact data of {0} {1} {2}:
ADMIN_DEPARTMENT_DETAILS_HEADER=Data of department {0} (Id {1}):
ADMIN_HEADQUARTER_DETAILS_HEADER=Headquarter of {0} (Id {1})):
+CHANGE=Change?
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="companyUserOwner"
itemValue="#{companyUserOwner}"
itemLabel="#{beanHelper.renderContact(companyUserOwner.userContact)} (#{companyUserOwner.userName})"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="branchUserOwner"
itemValue="#{branchUserOwner}"
itemLabel="#{beanHelper.renderContact(branchUserOwner.userContact)} (#{branchUserOwner.userName})"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="departmentUserOwner"
itemValue="#{departmentUserOwner}"
itemLabel="#{beanHelper.renderContact(departmentUserOwner.userContact)} (#{departmentUserOwner.userName})"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="employeeUserOwner"
itemValue="#{employeeUserOwner}"
itemLabel="#{beanHelper.renderContact(employeeUserOwner.userContact)} (#{employeeUserOwner.userName})"
<f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="headquarterUserOwner"
itemValue="#{headquarterUserOwner}"
itemLabel="#{beanHelper.renderContact(headquarterUserOwner.userContact)} (#{headquarterUserOwner.userName})"
</f:facet>
<p:column>
- <p:outputLabel for="userId" styleClass="table-data-label" value="#{msg.ADMIN_USER_ID}" />
+ <p:outputLabel for="userId" styleClass="table-data-label" value="#{msg.DATA_USER_ID}" />
<h:outputText id="userId" styleClass="table-data-field" value="#{beanHelper.user.userId}" />
</p:column>
<ui:fragment rendered="#{featureController.isFeatureEnabled('user_login_require_user_name')}">
<p:column>
- <p:outputLabel for="userName" styleClass="table-data-label" value="#{msg.ADMIN_USER_NAME}" />
+ <p:outputLabel for="userName" styleClass="table-data-label" value="#{msg.DATA_USER_NAME}" />
<h:outputText id="userName" styleClass="table-data-field" value="#{beanHelper.user.userName}" />
</p:column>
</p:column>
<p:column>
- <p:outputLabel for="userLastLocked" styleClass="table-data-label" value="#{msg.ADMIN_USER_LAST_LOCKED}" />
+ <p:outputLabel for="userLastLocked" styleClass="table-data-label" value="#{msg.DATA_USER_LAST_LOCKED}" />
<h:outputText id="userLastLocked" styleClass="table-data-field" value="#{beanHelper.user.userLastLocked}">
<f:convertDateTime type="both" />
</p:column>
<p:column>
- <p:outputLabel for="userLastLockedReason" styleClass="table-data-label" value="#{msg.ADMIN_USER_LAST_LOCKED_REASON}" />
+ <p:outputLabel for="userLastLockedReason" styleClass="table-data-label" value="#{msg.DATA_USER_LAST_LOCKED_REASON}" />
<h:outputText id="userLastLockedReason" styleClass="table-data-field" value="#{beanHelper.user.userLastLockedReason}" />
</p:column>
</f:facet>
<p:column>
- <p:outputLabel for="userId" styleClass="table-data-label" value="#{msg.ADMIN_USER_ID}" />
+ <p:outputLabel for="userId" styleClass="table-data-label" value="#{msg.DATA_USER_ID}" />
<h:panelGroup styleClass="table-data-field" layout="block">
<p:link
<ui:fragment rendered="#{featureController.isFeatureEnabled('user_login_require_user_name')}">
<p:column>
- <p:outputLabel for="userName" styleClass="table-data-label" value="#{msg.ADMIN_USER_NAME}" />
+ <p:outputLabel for="userName" styleClass="table-data-label" value="#{msg.DATA_USER_NAME}" />
<h:outputText id="userName" styleClass="table-data-field" value="#{beanHelper.user.userName}" />
</p:column>
<f:converter converterId="UserConverter" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="user"
itemValue="#{user}"
itemLabel="#{beanHelper.renderUser(user)}"
<f:converter converterId="UserConverter" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="user"
itemValue="#{user}"
itemLabel="#{beanHelper.renderUser(user)}"
<f:converter converterId="UserConverter" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="user"
itemValue="#{user}"
itemLabel="#{beanHelper.renderUser(user)}"
<f:converter converterId="UserConverter" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="user"
itemValue="#{user}"
itemLabel="#{beanHelper.renderUser(user)}"
<f:converter converterId="UserConverter" />
<f:selectItems
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
var="user"
itemValue="#{user}"
itemLabel="#{beanHelper.renderUser(user)}"
>
<p:column>
<f:facet name="header">
- <h:outputText value="#{msg.ADMIN_LIST_USER_ID}" />
+ <h:outputText value="#{msg.DATA_USER_ID}" />
</f:facet>
<p:link
<ui:fragment rendered="#{featureController.isFeatureEnabled('user_login_require_user_name')}">
<p:column>
<f:facet name="header">
- <h:outputText value="#{msg.ADMIN_LIST_USER_NAME}" />
+ <h:outputText value="#{msg.DATA_USER_NAME}" />
</f:facet>
<h:outputText value="#{userActivity.activityUserName}" />
<p:dataTable
id="table-export-users"
var="user"
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
paginator="true"
rows="10"
summary="#{msg.TABLE_SUMMARY_ADMIN_EXPORT_USER}"
<p:dataTable
id="userList"
var="user"
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
- filteredValue="#{userController.filteredUsers}"
+ filteredValue="#{userListController.filteredUsers}"
rows="10"
+ rowKey="#{user.userId}"
reflow="true"
resizableColumns="true"
rowsPerPageTemplate="5,10,20,50,100"
summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_USERS}"
emptyMessage="#{msg.ADMIN_EMPTY_LIST_USER}"
widgetVar="userList"
+ selectionMode="single"
+ selection="#{userListController.selectedUser}"
+ skipChildren="true"
>
<f:facet name="header">
- <p:panelGrid columns="2" columnClasses="ui-grid-col-10,ui-grid-col-2" layout="grid" styleClass="ui-noborder ui-transparent-widget">
- <h:outputText value="#{msg.ADMIN_LIST_USERS_HEADER}" />
+ <p:panelGrid
+ columns="3"
+ layout="grid"
+ columnClasses="ui-grid-col-4,ui-grid-col-6,ui-grid-col-2"
+ >
+ <p:spacer />
- <p:commandButton
- id="toggler"
- type="button"
- value="#{msg.SELECT_SHOWN_COLUMNS}"
- styleClass="column-selector"
- />
+ <p:panelGrid
+ columns="2"
+ columnClasses="ui-grid-4,ui-grid-8"
+ layout="grid"
+ styleClass="ui-noborder"
+ >
+ <p:outputLabel
+ for="globalFilter"
+ value="#{msg.SEARCH_ALL_FIELDS}"
+ style="float: right"
+ />
+
+ <p:inputText
+ id="globalFilter"
+ onkeyup="PF('userList').filter()"
+ placeholder="#{msg.ENTER_KEYWORD}"
+ />
+ </p:panelGrid>
+
+ <p:outputPanel>
+ <p:spacer height="4" />
+
+ <p:commandButton
+ id="toggler"
+ type="button"
+ value="#{msg.SELECT_SHOWN_COLUMNS}"
+ styleClass="column-selector"
+ />
- <p:columnToggler datasource="userList" trigger="toggler" />
+ <p:columnToggler datasource="userList" trigger="toggler" />
+ </p:outputPanel>
</p:panelGrid>
</f:facet>
+ <p:ajax
+ event="rowSelect"
+ update="form-list-users:user-details"
+ oncomplete="PF('userDialog').show()"
+ />
+
<p:column
- headerText="#{msg.ADMIN_USER_ID}"
+ headerText="#{msg.DATA_USER_ID}"
sortBy="#{user.userId}"
- filterBy="#{user.userId}"
- filterMatchMode="contains"
+ filterable="false"
>
<p:link
outcome="admin_show_user"
</p:column>
<p:column
- headerText="#{msg.ADMIN_LIST_USER_NAME}"
+ headerText="#{msg.DATA_USER_NAME}"
sortBy="#{user.userName}"
filterBy="#{user.userName}"
filterMatchMode="contains"
<h:outputText value="#{msg[user.userProfileMode.messageKey]}" />
</p:column>
+ <p:column
+ headerText="#{msg.DATA_USER_LAST_LOCKED_REASON}"
+ sortBy="#{user.userLastLockedReason}"
+ filterBy="#{user.userLastLockedReason}"
+ filterMatchMode="contains"
+ >
+ <h:outputText value="#{user.userLastLockedReason}" />
+ </p:column>
+
+ <p:column
+ headerText="#{msg.DATA_USER_LAST_LOCKED}"
+ sortBy="#{user.userLastLocked}"
+ filterable="false"
+ >
+ <h:outputText value="#{user.userLastLocked}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
+ <p:column
+ headerText="#{msg.CHANGE}"
+ sortBy="#{user.userMustChangePassword}"
+ filterable="false"
+ >
+ <h:outputText value="#{user.userMustChangePassword ? msg.CHOICE_YES : msg.CHOICE_NO}" />
+ </p:column>
+
<p:column
headerText="#{msg.ENTRY_CREATED_HEADER}"
sortBy="#{user.userCreated}"
filterable="false"
>
- <h:outputText id="userCreated" value="#{user.userCreated}">
+ <h:outputText value="#{user.userCreated}">
+ <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
+ </h:outputText>
+ </p:column>
+
+ <p:column
+ headerText="#{msg.ENTRY_UPDATED_HEADER}"
+ sortBy="#{user.userUpdated}"
+ filterable="false"
+ >
+ <h:outputText value="#{user.userUpdated}">
<f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
</h:outputText>
</p:column>
<links:outputUserAdminDropdownMenu user="#{user}" />
</p:column>
</p:dataTable>
+
+ <p:dialog
+ dynamic="true"
+ modal="true"
+ resizable="false"
+ header="#{msg.ADMIN_SINGLE_USER_DETAILS_HEADER}"
+ hideEffect="fade"
+ showEffect="fade"
+ widgetVar="userDialog"
+ position="top"
+ responsive="true"
+ closeOnEscape="true"
+ >
+ <p:outputPanel id="user-details">
+ <p:panelGrid columns="2" rendered="#{not empty userListController.selectedUser}">
+ <f:facet name="header">
+ <h:outputFormat value="#{msg.ADMIN_USER_DETAILS_HEADER}">
+ <f:param value="#{userListController.selectedUser.userName}" />
+ <f:param value="#{userListController.selectedUser.userId}" />
+ </h:outputFormat>
+ </f:facet>
+
+ <p:outputLabel value="#{msg.ID_HEADER}" title="#{msg.USER_ID_NUMBER_TITLE}" />
+ <h:outputText value="#{userListController.selectedUser.userId}" />
+ </p:panelGrid>
+ </p:outputPanel>
+ </p:dialog>
</h:form>
<h:form>
<h:panelGroup styleClass="para" layout="block">
<div class="table-data-label">
- <p:outputLabel for="userLastLocked" value="#{msg.ADMIN_USER_LAST_LOCKED}" />
+ <p:outputLabel for="userLastLocked" value="#{msg.DATA_USER_LAST_LOCKED}" />
</div>
<div class="table-data-field">
<h:panelGroup styleClass="para" layout="block">
<div class="table-data-label">
- <p:outputLabel for="userLockReason" value="#{msg.ADMIN_USER_LAST_LOCKED_REASON}" />
+ <p:outputLabel for="userLockReason" value="#{msg.DATA_USER_LAST_LOCKED_REASON}" />
</div>
<div class="table-data-field">
<p:dataTable
id="userList"
var="user"
- value="#{userController.allUsers()}"
+ value="#{userListController.allUsers}"
paginator="true"
rows="10"
summary="#{msg.TABLE_SUMMARY_USER_LIST}"