<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project">
- <Node id="admin/cellphone/admin_contact_cellphone_list.xhtml" x="2150" y="150" zoom="true"/>
+ <Node id="admin/mobile/admin_contact_mobile_list.xhtml" x="2150" y="150" zoom="true"/>
<Node id="user/login_logout.xhtml" x="1150" y="750" zoom="true"/>
- <Node id="admin/cellphone/admin_cellphone_delete.xhtml" x="150" y="1650" zoom="true"/>
+ <Node id="admin/mobile/admin_mobile_delete.xhtml" x="150" y="1650" zoom="true"/>
<Node id="admin/contact/admin_contact_show.xhtml" x="900" y="750" zoom="true"/>
<Node id="privacy.xhtml" x="650" y="300" zoom="true"/>
<Node id="admin/mobile_provider/admin_mobile_provider_show.xhtml" x="150" y="600" zoom="true"/>
<Node id="admin/user/admin_user_show.xhtml" x="1650" y="750" zoom="true"/>
<Node id="admin/index.xhtml" x="150" y="900" zoom="true"/>
<Node id="user/login_user_data_saved.xhtml" x="1650" y="600" zoom="true"/>
- <Node id="admin/cellphone/admin_cellphone_show.xhtml" x="2400" y="150" zoom="true"/>
+ <Node id="admin/mobile/admin_mobile_show.xhtml" x="2400" y="150" zoom="true"/>
<Node id="user/index.xhtml" x="1400" y="300" zoom="true"/>
<Node id="admin/admin_logout.xhtml" x="150" y="450" zoom="true"/>
<Node id="user/login_data_saved.xhtml" x="1400" y="150" zoom="true"/>
<Node id="admin/user/admin_user_unlock.xhtml" x="150" y="1050" zoom="true"/>
- <Node id="admin/cellphone/admin_cellphone_edit.xhtml" x="650" y="600" zoom="true"/>
+ <Node id="admin/mobile/admin_mobile_edit.xhtml" x="650" y="600" zoom="true"/>
<Node id="guest/user/user_list.xhtml" x="2150" y="450" zoom="true"/>
<Node id="index.xhtml" x="1900" y="600" zoom="true"/>
<Node id="user/login_edit_user_data.xhtml" x="900" y="600" zoom="true"/>
<Node id="admin/admin_category_delete.xhtml" x="1900" y="450" zoom="true"/>
<Node id="*" x="2400" y="300" zoom="true"/>
<Node id="user/login_index.xhtml" x="1650" y="150" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_edit.xhtml" x="1150" y="450" zoom="true"/>
+ <Node id="admin/mobile/admin_contact_mobile_edit.xhtml" x="1150" y="450" zoom="true"/>
<Node id="guest/user/lost_passwd.xhtml" x="1650" y="450" zoom="true"/>
<Node id="guest/user/register_done.xhtml" x="1150" y="600" zoom="true"/>
<Node id="user/login.xhtml" x="2150" y="600" zoom="true"/>
<Node id="admin/country/admin_country_list.xhtml" x="900" y="300" zoom="true"/>
<Node id="login/login_edit_user_data.xhtml" x="400" y="1050" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_unlink.xhtml" x="1900" y="300" zoom="true"/>
+ <Node id="admin/mobile/admin_contact_mobile_unlink.xhtml" x="1900" y="300" zoom="true"/>
<Node id="guest/user/login_error.xhtml" x="650" y="450" zoom="true"/>
<Node id="admin/user/admin_user_export.xhtml" x="400" y="1200" zoom="true"/>
<Node id="admin/mobile_provider/admin_mobile_provider_delete.xhtml" x="400" y="900" zoom="true"/>
<Node id="guest/user/confirm_account.xhtml" x="900" y="1200" zoom="true"/>
<Node id="exception.xhtml" x="900" y="150" zoom="true"/>
<Node id="admin/user/admin_user_delete.xhtml" x="400" y="750" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_delete.xhtml" x="1400" y="600" zoom="true"/>
+ <Node id="admin/mobile/admin_contact_mobile_delete.xhtml" x="1400" y="600" zoom="true"/>
<Node id="login/login_index.xhtml" x="2150" y="300" zoom="true"/>
<Node id="guest/user/register_page2.xhtml" x="1150" y="150" zoom="true"/>
<Node id="admin/user/admin_user_edit.xhtml" x="900" y="900" zoom="true"/>
<Node id="admin/contact/admin_contact_delete.xhtml" x="150" y="1500" zoom="true"/>
<Node id="imprint.xhtml" x="400" y="600" zoom="true"/>
<Node id="admin/mobile_provider/admin_mobile_provider_edit.xhtml" x="1400" y="900" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_show.xhtml" x="650" y="900" zoom="true"/>
+ <Node id="admin/mobile/admin_contact_mobile_show.xhtml" x="650" y="900" zoom="true"/>
<Node id="admin/admin_product_delete.xhtml" x="1150" y="900" zoom="true"/>
<Node id="guest/user/login.xhtml" x="2400" y="450" zoom="true"/>
<Node id="guest/user/register.xhtml" x="2650" y="300" zoom="true"/>
build.xml.stylesheet.CRC32=651128d4@1.68.1.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=3cd401ae
-nbproject/build-impl.xml.script.CRC32=b5ddf432
+nbproject/build-impl.xml.data.CRC32=6787cdaf
+nbproject/build-impl.xml.script.CRC32=d806451a
nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.75.1.1
javadoc.splitindex=true
javadoc.use=true
javadoc.version=true
-javadoc.windowtitle=jfinancials Web Application
+javadoc.windowtitle=JFinancials Web Application
lib.dir=${web.docbase.dir}/WEB-INF/lib
persistence.xml.dir=${conf.dir}
platform.active=default_platform
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans;
-
-import java.io.Serializable;
-import java.text.MessageFormat;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-
-/**
- * A general controller
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public abstract class BaseAddressbookController implements Serializable {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 50_837_597_127_567_140L;
-
- /**
- * Returns given property key or throws an exception if not found.
- * <p>
- * @param parameterKey Property key
- * <p>
- * @return Property value
- * <p>
- * @throws NullPointerException If given key is not found
- * @throws NumberFormatException If no number is given in context parameter
- */
- protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException {
- // Get context parameter
- Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey));
-
- // Return it
- return contextValue;
- }
-
- /**
- * Returns given property key or throws an exception if not found.
- * <p>
- * @param parameterKey Property key
- * <p>
- * @return Property value
- * <p>
- * @throws NullPointerException If given key is not found
- */
- protected String getStringContextParameter (final String parameterKey) throws NullPointerException {
- // Get context parameter
- String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey);
-
- // Is it null?
- if (null == contextValue) {
- // Throw NPE
- throw new NullPointerException("parameterKey=" + parameterKey + " is not set.");
- }
-
- // Return it
- return contextValue;
- }
-
- /**
- * Checks whether debug mode is enabled for given controller
- * <p>
- * @param controllerName Name of controller
- * <p>
- * @return Whether debug mode is enabled
- */
- protected boolean isDebugModeEnabled (final String controllerName) {
- // Parameters should be valid
- if (null == controllerName) {
- // Throw NPE
- throw new NullPointerException("controllerName is null"); //NOI18N
- } else if (controllerName.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("controllerName is empty"); //NOI18N
- }
-
- // Try to get context parameter
- String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N
-
- // Is it set and true?
- boolean isEnabled = ((contextParameter instanceof String) && (contextParameter.equals("true"))); //NOI18N
-
- // Return it
- return isEnabled;
- }
-
- /**
- * Shows a faces message for given causing exception. The message from the
- * exception is being inserted into the message.
- * <p>
- * @param clientId Client id to send message to
- * @param cause Causing exception
- */
- protected void showFacesMessage (final String clientId, final Throwable cause) {
- // Trace message
- System.out.println(MessageFormat.format("showFacesMessage: clientId={0},cause={1} - CALLED!", clientId, cause));
-
- // Get context and add message
- this.showFacesMessage(clientId, cause.getMessage());
- }
-
- /**
- * Shows a faces message with given message.
- * <p>
- * @param clientId Client id to send message to
- * @param message Causing exception
- */
- protected void showFacesMessage (final String clientId, final String message) {
- // Get context and add message
- FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.addressbook;
-
-import java.text.MessageFormat;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
-import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
-import org.mxchange.jaddressbookcore.events.addressbook.AddressbookLoadedEvent;
-import org.mxchange.jaddressbookcore.events.addressbook.LoadedAddressbookEvent;
-import org.mxchange.jaddressbookcore.exceptions.AddressbookNameAlreadyUsedException;
-import org.mxchange.jaddressbookcore.exceptions.AddressbookNotFoundException;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.UserAddressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.entry.AddressbookEntry;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * An address book bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("addressbookController")
-@SessionScoped
-public class AddressbookWebSessionBean extends BaseAddressbookController implements AddressbookWebSessionController {
-
- /**
- * Map for count of user's shared addresses
- */
- private static ConcurrentMap<User, Integer> countSharesList;
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 185_781_756_712_969L;
-
- /**
- * Address book instance
- */
- private Addressbook addressbook;
-
- /**
- * Remote address book bean
- */
- private AddressbookSessionBeanRemote addressbookBean;
-
- /**
- * When this address book has been created
- */
- private Calendar addressbookCreated;
-
- /**
- * Address book id number (from URL for example)
- */
- private Long addressbookId;
-
- /**
- * Name of the address book
- */
- private String addressbookName;
-
- /**
- * Who owns this address book
- */
- private User addressbookUser;
-
- /**
- * Event fired when user has logged in
- */
- @Inject
- @Any
- private Event<AddressbookLoadedEvent> loadedEvent;
-
- /**
- * Login controller
- */
- @Inject
- private AddressbookUserLoginWebSessionController loginController;
-
- /**
- * A list of all user's address books
- */
- private List<Addressbook> usersAddressbooks;
-
- /**
- * Default constructor
- */
- public AddressbookWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.addressbookBean = (AddressbookSessionBeanRemote) context.lookup("java:global/addressbook-ejb/addressbook!org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
-
- // Init list
- AddressbookWebSessionBean.countSharesList = new ConcurrentHashMap<>(0);
- }
-
- @Override
- public String addAddressbook () {
- // Is this name already used?
- if (!this.loginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- } else if (this.getAddressbookName() == null) {
- // Address book name is null
- throw new NullPointerException("addressbookName is null"); //NOI18N
- } else if (this.getAddressbookName().isEmpty()) {
- // Address book name is empty
- throw new IllegalStateException("addressbookName is empty."); //NOI18N
- } else if (this.isAddressbookNameUsed(this.getAddressbookName())) {
- // Already used by this user
- throw new FaceletException(MessageFormat.format("Address book name {0} already used.", this.getAddressbookName())); //NOI18N
- }
-
- // Create address book instance with name
- Addressbook book = new UserAddressbook(this.getAddressbookName(), this.loginController.getLoggedInUser());
-
- try {
- // Register this address book
- Addressbook updatedAddressbook = this.addressbookBean.createAddressbook(book);
-
- // Remove name
- this.setAddressbookName(null);
-
- // Add address book entry to list
- this.usersAddressbooks.add(updatedAddressbook);
-
- // All fine
- return "login_own_addressbooks"; //NOI18N
- } catch (final AddressbookNameAlreadyUsedException ex) {
- // Throw again as cause
- throw new FaceletException(ex);
- }
- }
-
- @Override
- public void afterAddressbookLoadedEvent (@Observes final AddressbookLoadedEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddressbook() == null) {
- // Throw NPE again
- throw new NullPointerException("event.addressbook is null"); //NOI18N
- } else if (event.getAddressbook().getAddressbookId() == null) {
- // And again a NPE
- throw new NullPointerException("event.addressbook.addressbookId is null"); //NOI18N
- } else if (event.getAddressbook().getAddressbookId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("Address book instance {0} has invalid id number: {1}", event.getAddressbook(), event.getAddressbook().getAddressbookId())); //NOI18N
- } else if (event.getAddressbook().getAddressbookUser() == null) {
- // One more NPE ...
- throw new NullPointerException("event.addressbook.addressbookUser is null"); //NOI18N
- }
-
- // Get address book instance
- Addressbook book = event.getAddressbook();
-
- // Set address book data
- this.setAddressbookId(book.getAddressbookId());
- this.setAddressbookName(book.getAddressbookName());
- this.setAddressbookUser(book.getAddressbookUser());
- this.setAddressbookCreated(book.getAddressbookCreated());
-
- // And instance ...
- this.setAddressbook(book);
- }
-
- @Override
- public void afterLoginEvent (@Observes final UserLoggedInEvent event) {
- // Is the user logged in?
- if (null == event) {
- // Is null
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLoggedInUser()== null) {
- // user is null
- throw new NullPointerException("event.user is null"); //NOI18N
- } else if (!event.getLoggedInUser().equals(this.loginController.getLoggedInUser())) {
- // Not matching
- throw new IllegalStateException("event.user and loginController.loggedInUser don't match."); //NOI18N
- } else if (!this.loginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- // Init user's address book list
- this.initAddressbookList();
- }
-
- @Override
- public List<Addressbook> allAddressbooks () {
- // Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- return Collections.unmodifiableList(this.usersAddressbooks);
- }
-
- @Override
- public List<AddressbookEntry> allEntries (final Addressbook addressbook) {
- // Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- // Ask the bean
- return this.addressbookBean.allEntries(addressbook);
- }
-
- @Override
- public int allEntriesSize (final Addressbook addressbook) {
- // Ask the bean
- return this.allEntries(addressbook).size();
- }
-
- @Override
- public List<User> allUsersNotSharing () {
- // Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- // Call EJB
- return this.addressbookBean.allUsersNotSharing(this.loginController.getLoggedInUser(), this.getAddressbook());
- }
-
- @Override
- public Integer countAllUserSharedAddressbooks (final User user) {
- // Is there cache?
- if (AddressbookWebSessionBean.countSharesList.containsKey(user)) {
- // Return it instead
- return AddressbookWebSessionBean.countSharesList.get(user);
- }
-
- // Call EJB ("expensive")
- Integer count = this.addressbookBean.countAllUserSharedAddressbooks(user);
-
- // Add to list
- AddressbookWebSessionBean.countSharesList.put(user, count);
-
- // Return it
- return count;
- }
-
- @Override
- public Addressbook getAddressbook () {
- return this.addressbook;
- }
-
- @Override
- public void setAddressbook (final Addressbook addressbook) {
- this.addressbook = addressbook;
- }
-
- @Override
- public Calendar getAddressbookCreated () {
- return this.addressbookCreated;
- }
-
- @Override
- public void setAddressbookCreated (final Calendar addressbookCreated) {
- this.addressbookCreated = addressbookCreated;
- }
-
- @Override
- public Long getAddressbookId () {
- return this.addressbookId;
- }
-
- @Override
- public void setAddressbookId (final Long addressbookId) {
- this.addressbookId = addressbookId;
- }
-
- @Override
- public String getAddressbookName () {
- return this.addressbookName;
- }
-
- @Override
- public void setAddressbookName (final String addressbookName) {
- this.addressbookName = addressbookName;
- }
-
- @Override
- public User getAddressbookUser () {
- return this.addressbookUser;
- }
-
- @Override
- public void setAddressbookUser (final User addressbookUser) {
- this.addressbookUser = addressbookUser;
- }
-
- @Override
- public boolean hasCreatedAddressbooks () {
- // Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- // Check if the list is filled
- return (!this.usersAddressbooks.isEmpty());
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- // Init list
- this.usersAddressbooks = new LinkedList<>();
-
- // Is the user logged-in?
- if (this.loginController.isUserLoggedIn()) {
- // Initialize list
- this.initAddressbookList();
- }
-
- // TODO Initialize list from bean with just one call
- //this.addressbookBean.getUserCountMap()
- }
-
- @Override
- public boolean isAddressbookLoaded () {
- return ((this.getAddressbookId() instanceof Long) &&
- (this.getAddressbookName() instanceof String) &&
- (!this.getAddressbookName().isEmpty()) &&
- (this.getAddressbookUser() instanceof User));
- }
-
- @Override
- public boolean isAddressbookNameUsed (final String addressbookName) {
- // Is it zero size?
- if (null == addressbookName) {
- // Is null
- throw new NullPointerException("addressbookName is null"); //NOI18N
- } else if (this.usersAddressbooks.isEmpty()) {
- // Not found!
- return false;
- }
-
- // Default is not found
- boolean isFound = false;
-
- // Check all entries
- for (final Addressbook book : this.usersAddressbooks) {
- // Is the name same?
- if (book.getAddressbookName().equals(addressbookName)) {
- // Found a match
- isFound = true;
- break;
- }
- }
-
- // Return status
- return isFound;
- }
-
- @Override
- public boolean isOtherAddressbook () {
- // Just call the other method and invert it
- return (!this.isOwnAddressbook());
- }
-
- @Override
- public boolean isOwnAddressbook () {
- // Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
- // No, then no own address book
- throw new IllegalStateException("isOwnAddressbook() has been invoked for a guest account"); //NOI18N
- }
-
- // Is same user?
- return Objects.equals(this.getAddressbookUser(), this.loginController.getLoggedInUser());
- }
-
- @Override
- public boolean loadAddressbook () {
- // Check if the id is set
- if (this.getAddressbookId() == null) {
- // Throw NPE
- throw new NullPointerException("this.addressbookId is null");
- } else if (this.getAddressbookId() < 1) {
- // Not valid id
- throw new IllegalStateException(MessageFormat.format("this.addressbook={0} is invalid", this.getAddressbookId()));
- }
-
- // Default is not found
- boolean isFound = false;
-
- try {
- // Then try to look it up
- Addressbook a = this.addressbookBean.getAddressbookById(this.getAddressbookId());
-
- // Fire event here
- this.loadedEvent.fire(new LoadedAddressbookEvent(a));
-
- // Found it
- isFound = true;
- } catch (final AddressbookNotFoundException ex) {
- // Not found!
- throw new FaceletException(ex);
- }
-
- // Return status
- return isFound;
- }
-
- /**
- * Initializes the user user's address book list
- */
- private void initAddressbookList () {
- // Get user instance
- User user = this.loginController.getLoggedInUser();
-
- // Fill list with entries
- this.usersAddressbooks = this.addressbookBean.getUsersAddressbookList(user);
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.addressbook;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.List;
-import org.mxchange.jaddressbookcore.events.addressbook.AddressbookLoadedEvent;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.entry.AddressbookEntry;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * An interface for address book beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookWebSessionController extends Serializable {
-
- /**
- * Checks whether the user has created addressbooks. For this method to work
- * it is vital that the user is logged into his/her account.
- * <p>
- * @return Whether the user has created at least one addressbook
- */
- boolean hasCreatedAddressbooks ();
-
- /**
- * Creates a new address book with a name and redirects to proper target.
- * For this method to work it is vital that the user is logged into his/her
- * account.
- * <p>
- * @return Target to redirect to
- */
- String addAddressbook ();
-
- /**
- * Getter for address book name
- * <p>
- * @return Address book name
- */
- String getAddressbookName ();
-
- /**
- * Setter for address book name
- * <p>
- * @param addressbookName Address book name
- */
- void setAddressbookName (final String addressbookName);
-
- /**
- * Checks if the given address book name is already used by the user.
- * <p>
- * @param addressbookName Address book name to check
- * <p>
- * @return Whether the name has already been used by the user
- */
- boolean isAddressbookNameUsed (final String addressbookName);
-
- /**
- * Returns all address books with this user
- * <p>
- * @return A list of all address books by this user
- */
- List<Addressbook> allAddressbooks ();
-
- /**
- * Returns a list of all address book entries for given address book
- * <p>
- * @param addressbook Address book instance
- * <p>
- * @return List of all entries
- */
- List<AddressbookEntry> allEntries (final Addressbook addressbook);
-
- /**
- * Size of all entries in given address book
- * <p>
- * @param addressbook Address book instance
- * <p>
- * @return Size of the entries in address book
- */
- int allEntriesSize (final Addressbook addressbook);
-
- /**
- * Getter for address book id number
- * <p>
- * @return Address book id number
- */
- Long getAddressbookId ();
-
- /**
- * Setter for address book id number
- * <p>
- * @param addressbookId Address book id number
- */
- void setAddressbookId (final Long addressbookId);
-
- /**
- * Getter for address book user (owner)
- * <p>
- * @return Address book user (owner)
- */
- User getAddressbookUser ();
-
- /**
- * Setter for address book user (owner)
- * <p>
- * @param addressbookUser Address book user (owner)
- */
- void setAddressbookUser (final User addressbookUser);
-
- /**
- * Getter for when the address book has been created
- * <p>
- * @return When the address book has been created
- */
- Calendar getAddressbookCreated ();
-
- /**
- * Setter for when the address book has been created
- * <p>
- * @param addressbookCreated When the address book has been created
- */
- void setAddressbookCreated (final Calendar addressbookCreated);
-
- /**
- * This method is called when an address book has been successfully loaded
- * from JPA.
- * <p>
- * @param event Event with address book instance
- */
- void afterAddressbookLoadedEvent (final AddressbookLoadedEvent event);
-
- /**
- * Count all shared address books by given user id
- * <p>
- * @param user User instance to look for
- * <p>
- * @return Count of user's shared address books
- */
- Integer countAllUserSharedAddressbooks (final User user);
-
- /**
- * This method is called when a user has successfully logged in his/her
- * account.
- * <p>
- * @param event
- */
- void afterLoginEvent (final UserLoggedInEvent event);
-
- /**
- * Checks if the user is logged in and if so if it matches the current
- * address book owner.
- * <p>
- * @return Whether the owner matches currently logged-in user
- */
- boolean isOwnAddressbook ();
-
- /**
- * Checks if the owner of the current address book is NOT matching the
- * logged-in user.
- * <p>
- * @return Whether the user does NOT match
- */
- boolean isOtherAddressbook ();
-
- /**
- * Getter for address book instance
- * <p>
- * @return Address book instance
- */
- Addressbook getAddressbook ();
-
- /**
- * Setter for address book instance
- * <p>
- * @param addressbook Address book instance
- */
- void setAddressbook (final Addressbook addressbook);
-
- /**
- * Retrieves a list of all users this user is not sharing this address book
- * with.
- * <p>
- * @return List of not sharing users
- */
- List<User> allUsersNotSharing ();
-
- /**
- * Checks wether an address book has been loaded by checking the id number.
- * <p>
- * @return Whether the address book is loaded
- */
- boolean isAddressbookLoaded ();
-
- /**
- * Loads address book from current id
- * <p>
- * @return Whether the address book was found
- */
- boolean loadAddressbook ();
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.confirmlink;
-
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.helper.AddressbookWebRequestController;
-import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
-import org.mxchange.jcoreee.utils.FacesUtils;
-import org.mxchange.jusercore.events.confirmation.ConfirmedUserAccountEvent;
-import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
-import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-
-/**
- * A web request bean for confirmation link handling
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("confirmationLinkController")
-@RequestScoped
-public class AddressbookConfirmationLinkWebRequestBean extends BaseAddressbookController implements AddressbookConfirmationLinkWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 57_637_182_796_370L;
-
- /**
- * Admin helper instance
- */
- @Inject
- private AddressbookWebRequestController beanHelper;
-
- /**
- * Confirmation key
- */
- private String confirmationKey;
-
- /**
- * Remote user bean
- */
- private final UserSessionBeanRemote userBean;
-
- /**
- * User controller
- */
- @Inject
- private AddressbookUserWebSessionController userController;
-
- /**
- * Event being fired when a user has confirmed the account
- */
- @Inject
- @Any
- private Event<UserConfirmedAccountEvent> userConfirmedEvent;
-
- /**
- * Default constructor
- */
- public AddressbookConfirmationLinkWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public String getConfirmationKey () {
- return this.confirmationKey;
- }
-
- @Override
- public void setConfirmationKey (final String confirmationKey) {
- this.confirmationKey = confirmationKey;
- }
-
- @Override
- public void maybeConfirmUserAccount () {
- // Is the confirmation key set?
- if (this.getConfirmationKey() == null) {
- // May be null if not set
- return;
- } else if (this.getConfirmationKey().isEmpty()) {
- // Is empty string
- return;
- }
-
- // Now try to find the user in user list, first get the whole list
- List<User> users = this.userController.allUsers();
-
- // Get iterator from it
- Iterator<User> iterator = users.iterator();
-
- // Init instance
- User user = null;
-
- // Then loop through all
- while (iterator.hasNext()) {
- // Get next user
- User next = iterator.next();
-
- // Same confirmation key?
- if (Objects.equals(this.getConfirmationKey(), next.getUserConfirmKey())) {
- // Found it, then set it and abort loop
- user = next;
- break;
- }
- }
-
- // Is the user instance null?
- if ((null == user) || (user.getUserAccountStatus() != UserAccountStatus.UNCONFIRMED)) {
- // Then clear this bean and the helper
- this.beanHelper.setUser(null);
- } else {
- // Set user ...
- this.beanHelper.setUser(user);
-
- // ... and copy it to the controller
- this.beanHelper.copyUserToController();
-
- // Try to confirm it
- this.confirmUserAccount();
- }
- }
-
- /**
- * Tries to confirm the currently set user instance (in helper).
- */
- private void confirmUserAccount () {
- // Get user instance
- User user = this.beanHelper.getUser();
-
- // Should be set
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null");
- } else if (user.getUserId() == null) {
- // Abort here
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Invalid number
- throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", user.getUserId())); //NOI18N
- } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
- // Account is already confirmed
- throw new FaceletException(new UserStatusConfirmedException(user));
- } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
- // Account is already confirmed
- throw new FaceletException(new UserStatusLockedException(user));
- } else if (user.getUserConfirmKey() == null) {
- // Throw NPE
- throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
- }
-
- // Updated user instance
- User updatedUser;
-
- try {
- // Get base URL
- String baseUrl = FacesUtils.generateBaseUrl();
-
- // Confirm account
- updatedUser = this.userBean.confirmAccount(user, baseUrl);
- } catch (final UserStatusConfirmedException | UserStatusLockedException ex) {
- // Something unexpected happened
- throw new FaceletException(MessageFormat.format("Cannot confirm user account {0}", user.getUserName()), ex); //NOI18N
- }
-
- // Fire event that the user has confirmed account
- this.userConfirmedEvent.fire(new ConfirmedUserAccountEvent(updatedUser));
-
- // Set it again in helper
- this.beanHelper.setUser(updatedUser);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.confirmlink;
-
-import java.io.Serializable;
-
-/**
- * An interface for an email change controller
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookConfirmationLinkWebRequestController extends Serializable {
-
- /**
- * Getter for confirmation key
- * <p>
- * @return Confirmation key
- */
- String getConfirmationKey ();
-
- /**
- * Setter for confirmation key
- * <p>
- * @param confirmationKey Confirmation key
- */
- void setConfirmationKey (final String confirmationKey);
-
- /**
- * Tries to lookup the user by currently set confirmation key and if found
- * tries to confirm it. If no user is found, the instance beanHelper.user is
- * set to null. Other methods or JSF pages should then respond on this
- * accordingly.
- */
- void maybeConfirmUserAccount ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.contact;
-
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.Iterator;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.faces.context.FacesContext;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.helper.AddressbookWebRequestController;
-import org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
-import org.mxchange.jcontacts.contact.UserContact;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcontacts.contact.utils.ContactUtils;
-import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.add.AdminContactAddedEvent;
-import org.mxchange.jcontacts.events.contact.update.AdminContactUpdatedEvent;
-import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
-import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.phonenumbers.DialableNumber;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-
-/**
- * An administrative user bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminContactController")
-@RequestScoped
-public class AddressbookAdminContactWebRequestBean extends BaseAddressbookController implements AddressbookAdminContactWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 542_145_347_916L;
-
- /**
- * An event fired when the administrator has added a new contact
- */
- @Inject
- @Any
- private Event<AdminAddedContactEvent> addedContactEvent;
-
- /**
- * Administrative contact EJB
- */
- private AdminContactSessionBeanRemote adminContactBean;
-
- /**
- * Admin helper instance
- */
- @Inject
- private AddressbookWebRequestController beanHelper;
-
- /**
- * Birth day
- */
- private Date birthday;
-
- /**
- * City
- */
- private String city;
-
- /**
- * Optional comments
- */
- private String comment;
-
- /**
- * Remote contact bean
- */
- private final ContactSessionBeanRemote contactBean;
-
- /**
- * General contact controller
- */
- @Inject
- private AddressbookContactWebSessionController contactController;
-
- /**
- * Contact id
- */
- private Long contactId;
-
- /**
- * Country instance
- */
- private Country country;
-
- /**
- * Email address
- */
- private String emailAddress;
-
- /**
- * Family name
- */
- private String familyName;
-
- /**
- * Fax number's area code
- */
- private Integer faxAreaCode;
-
- /**
- * Country instance for fax number
- */
- private Country faxCountry;
-
- /**
- * Fax id number
- */
- private Long faxId;
-
- /**
- * Fax number
- */
- private Long faxNumber;
-
- /**
- * First name
- */
- private String firstName;
-
- /**
- * Gender instance
- */
- private Gender gender;
-
- /**
- * House number
- */
- private Short houseNumber;
-
- /**
- * House number extension
- */
- private String houseNumberExtension;
-
- /**
- * Whether a fax entry has been unlinked
- */
- private boolean isFaxUnlinked;
-
- /**
- * Whether a land-line number has been unlinked
- */
- private boolean isLandLineUnlinked;
-
- /**
- * Whether a mobile entry has been unlinked
- */
- private boolean isMobileUnlinked;
-
- /**
- * Land-line id number
- */
- private Long landLineId;
-
- /**
- * Mobile number's carrier
- */
- private MobileProvider mobileCarrier;
-
- /**
- * Mobile id number
- */
- private Long mobileId;
-
- /**
- * Mobile number
- */
- private Long mobileNumber;
-
- /**
- * Phone number area code
- */
- private Integer phoneAreaCode;
-
- /**
- * Country instance for phone number
- */
- private Country phoneCountry;
-
- /**
- * Phone number
- */
- private Long phoneNumber;
-
- /**
- * Street
- */
- private String street;
-
- /**
- * Title
- */
- private String title;
-
- /**
- * An event fired when the administrator has updated contact data
- */
- @Inject
- @Any
- private Event<AdminUpdatedContactEvent> updatedContactEvent;
-
- /**
- * ZIP code
- */
- private Integer zipCode;
-
- /**
- * Default constructor
- */
- public AddressbookAdminContactWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public String addContact () {
- // Are all minimum fields set?
- if (this.getGender() == null) {
- // Throw NPE
- throw new NullPointerException("gender is null"); //NOI18N
- } else if (this.getFirstName() == null) {
- // Throw NPE
- throw new NullPointerException("firstName is null"); //NOI18N
- } else if (this.getFirstName().isEmpty()) {
- // Empty string
- throw new IllegalStateException("firstName is empty"); //NOI18N
- } else if (this.getFamilyName() == null) {
- // Throw NPE
- throw new NullPointerException("familyName is null"); //NOI18N
- } else if (this.getFamilyName().isEmpty()) {
- // Empty string
- throw new IllegalStateException("familyName is empty"); //NOI18N
- }
-
- // Create new contact instance
- Contact contact = this.createContactInstance();
-
- // Default is not same contact
- if (this.isSameContactFound(contact)) {
- // Already registered
- throw new FaceletException(new ContactAlreadyAddedException(contact));
- }
-
- // Init contact
- Contact updatedContact;
-
- // Try to call EJB
- try {
- // Call EJB
- updatedContact = this.adminContactBean.addContact(contact);
- } catch (final ContactAlreadyAddedException ex) {
- // Throw again
- throw new FaceletException(ex);
- }
-
- // Fire event
- this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact));
-
- // Clear this bean
- this.clear();
-
- // Return outcome
- return "admin_list_contact"; //NOI18N
- }
-
- @Override
- public void copyContactToController (final Contact contact) {
- // The contact instance must be valid
- if (null == contact) {
- // Throw NPE again
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw NPE again
- throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
- } else if (contact.getContactId() < 1) {
- // Not valid
- throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
- }
-
- // Set all fields: contact
- this.setContactId(contact.getContactId());
- this.setTitle(contact.getContactTitle());
- this.setBirthday(contact.getContactBirthday());
- this.setCity(contact.getContactCity());
- this.setComment(contact.getContactComment());
- this.setCountry(contact.getContactCountry());
- this.setEmailAddress(contact.getContactEmailAddress());
- this.setFamilyName(contact.getContactFamilyName());
- this.setFirstName(contact.getContactFirstName());
- this.setGender(contact.getContactGender());
- this.setHouseNumber(contact.getContactHouseNumber());
- this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
- this.setStreet(contact.getContactStreet());
- this.setZipCode(contact.getContactZipCode());
-
- // ... mobile data
- if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
- this.setMobileId(contact.getContactMobileNumber().getPhoneId());
- this.setMobileCarrier(contact.getContactMobileNumber().getMobileProvider());
- this.setMobileNumber(contact.getContactMobileNumber().getPhoneNumber());
- }
-
- // ... fax data
- if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
- this.setFaxId(contact.getContactFaxNumber().getPhoneId());
- this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
- this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
- this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
- }
-
- // .. land-line data
- if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
- this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
- this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
- this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
- this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
- }
- }
-
- @Override
- public Contact createContactInstance () {
- // Generate phone number
- DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
- DialableMobileNumber mobile = new MobileNumber(this.getMobileCarrier(), this.getMobileNumber());
- DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
-
- // Create new instance
- Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
-
- // Check if contact instance is in helper and valid
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("beanHelper.contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw NPE again
- throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N
- } else if (contact.getContactId() < 1) {
- // Invalid id
- throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
- }
-
- // Update all data in contact
- this.updateContactData(contact);
-
- // Call EJB for updating contact data
- Contact updatedContact = this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
-
- // Fire event
- this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
-
- // Clear bean
- this.clear();
-
- // Return it
- return contact;
- }
-
- @Override
- public String editContactData () {
- // Get contact instance
- Contact contact = this.beanHelper.getContact();
-
- // Check if contact instance is in helper and valid
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("beanHelper.contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw NPE again
- throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N
- } else if (contact.getContactId() < 1) {
- // Invalid id
- throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
- }
-
- // Update all data in contact
- this.updateContactData(contact);
-
- // Call EJB for updating contact data
- Contact updatedContact = this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
-
- // Fire event
- this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
-
- // Clear bean
- this.clear();
-
- // Return to contact list (for now)
- return "admin_list_contact"; //NOI18N
- }
-
- @Override
- public String generateMobileNumber (final DialableMobileNumber mobileNumber) {
- // Is it null?
- if (null == mobileNumber) {
- // Return null
- return null;
- }
-
- // Get all data
- String number = String.format(
- "%s%d%d", //NOI18N
- mobileNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(),
- mobileNumber.getMobileProvider().getProviderDialPrefix(),
- mobileNumber.getPhoneNumber()
- );
-
- // Return it
- return number;
- }
-
- @Override
- public String generatePhoneNumber (final DialableNumber phoneNumber) {
- // Is it null?
- if (null == phoneNumber) {
- // Return null
- return null;
- }
-
- // Generate it
- String number = String.format(
- "%s%d%d", //NOI18N
- phoneNumber.getPhoneCountry().getCountryExternalDialPrefix(),
- phoneNumber.getPhoneAreaCode(),
- phoneNumber.getPhoneNumber()
- );
-
- // Return it
- return number;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfDateField")
- public Date getBirthday () {
- return this.birthday;
- }
-
- @Override
- @SuppressWarnings ("AssignmentToDateFieldFromParameter")
- public void setBirthday (final Date birthday) {
- this.birthday = birthday;
- }
-
- @Override
- public String getCity () {
- return this.city;
- }
-
- @Override
- public void setCity (final String city) {
- this.city = city;
- }
-
- @Override
- public String getComment () {
- return this.comment;
- }
-
- @Override
- public void setComment (final String comment) {
- this.comment = comment;
- }
-
- @Override
- public Long getContactId () {
- return this.contactId;
- }
-
- @Override
- public void setContactId (final Long contactId) {
- this.contactId = contactId;
- }
-
- @Override
- public Country getCountry () {
- return this.country;
- }
-
- @Override
- public void setCountry (final Country country) {
- this.country = country;
- }
-
- @Override
- public String getEmailAddress () {
- return this.emailAddress;
- }
-
- @Override
- public void setEmailAddress (final String emailAddress) {
- this.emailAddress = emailAddress;
- }
-
- @Override
- public String getFamilyName () {
- return this.familyName;
- }
-
- @Override
- public void setFamilyName (final String familyName) {
- this.familyName = familyName;
- }
-
- @Override
- public Integer getFaxAreaCode () {
- return this.faxAreaCode;
- }
-
- @Override
- public void setFaxAreaCode (final Integer faxAreaCode) {
- this.faxAreaCode = faxAreaCode;
- }
-
- @Override
- public Country getFaxCountry () {
- return this.faxCountry;
- }
-
- @Override
- public void setFaxCountry (final Country faxCountry) {
- this.faxCountry = faxCountry;
- }
-
- @Override
- public Long getFaxId () {
- return this.faxId;
- }
-
- @Override
- public void setFaxId (final Long faxId) {
- this.faxId = faxId;
- }
-
- @Override
- public Long getFaxNumber () {
- return this.faxNumber;
- }
-
- @Override
- public void setFaxNumber (final Long faxNumber) {
- this.faxNumber = faxNumber;
- }
-
- @Override
- public String getFirstName () {
- return this.firstName;
- }
-
- @Override
- public void setFirstName (final String firstName) {
- this.firstName = firstName;
- }
-
- @Override
- public Gender getGender () {
- return this.gender;
- }
-
- @Override
- public void setGender (final Gender gender) {
- this.gender = gender;
- }
-
- @Override
- public Short getHouseNumber () {
- return this.houseNumber;
- }
-
- @Override
- public void setHouseNumber (final Short houseNumber) {
- this.houseNumber = houseNumber;
- }
-
- @Override
- public String getHouseNumberExtension () {
- return this.houseNumberExtension;
- }
-
- @Override
- public void setHouseNumberExtension (final String houseNumberExtension) {
- this.houseNumberExtension = houseNumberExtension;
- }
-
- @Override
- public Long getLandLineId () {
- return this.landLineId;
- }
-
- @Override
- public void setLandLineId (final Long landLineId) {
- this.landLineId = landLineId;
- }
-
- @Override
- public MobileProvider getMobileCarrier () {
- return this.mobileCarrier;
- }
-
- @Override
- public void setMobileCarrier (final MobileProvider mobileCarrier) {
- this.mobileCarrier = mobileCarrier;
- }
-
- @Override
- public Long getMobileId () {
- return this.mobileId;
- }
-
- @Override
- public void setMobileId (final Long mobileId) {
- this.mobileId = mobileId;
- }
-
- @Override
- public Long getMobileNumber () {
- return this.mobileNumber;
- }
-
- @Override
- public void setMobileNumber (Long mobileNumber) {
- this.mobileNumber = mobileNumber;
- }
-
- @Override
- public Integer getPhoneAreaCode () {
- return this.phoneAreaCode;
- }
-
- @Override
- public void setPhoneAreaCode (final Integer phoneAreaCode) {
- this.phoneAreaCode = phoneAreaCode;
- }
-
- @Override
- public Country getPhoneCountry () {
- return this.phoneCountry;
- }
-
- @Override
- public void setPhoneCountry (final Country phoneCountry) {
- this.phoneCountry = phoneCountry;
- }
-
- @Override
- public Long getPhoneNumber () {
- return this.phoneNumber;
- }
-
- @Override
- public void setPhoneNumber (final Long phoneNumber) {
- this.phoneNumber = phoneNumber;
- }
-
- @Override
- public String getStreet () {
- return this.street;
- }
-
- @Override
- public void setStreet (final String street) {
- this.street = street;
- }
-
- @Override
- public String getTitle () {
- return this.title;
- }
-
- @Override
- public void setTitle (final String title) {
- this.title = title;
- }
-
- @Override
- public Integer getZipCode () {
- return this.zipCode;
- }
-
- @Override
- public void setZipCode (final Integer zipCode) {
- this.zipCode = zipCode;
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- }
-
- @Override
- public boolean isGenderRequired () {
- // Get context parameter
- String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_admin_gender_enabled"); //NOI18N
-
- // Is it set?
- boolean isRequired = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
-
- // Return value
- return isRequired;
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- // - personal data
- this.setGender(null);
- this.setTitle(null);
- this.setFirstName(null);
- this.setFamilyName(null);
- this.setStreet(null);
- this.setHouseNumber(null);
- this.setHouseNumberExtension(null);
- this.setZipCode(null);
- this.setCity(null);
- this.setCountry(null);
-
- // - contact data
- this.setEmailAddress(null);
- this.setPhoneCountry(null);
- this.setPhoneAreaCode(null);
- this.setPhoneNumber(null);
- this.setMobileCarrier(null);
- this.setMobileNumber(null);
- this.setFaxCountry(null);
- this.setFaxAreaCode(null);
- this.setFaxNumber(null);
-
- // - other data
- this.setBirthday(null);
- this.setComment(null);
- }
-
- /**
- * Checks whether the given contact is found
- * <p>
- * @param contact Contact inastance
- *
- * @return Wether contact has been found
- */
- private boolean isSameContactFound (final Contact contact) {
- // Default is not found
- boolean IsFound = false;
-
- // Get iterator
- Iterator<Contact> iterator = this.contactController.allContacts().iterator();
-
- // Loop through all
- while (iterator.hasNext()) {
- // Get next contact
- Contact next = iterator.next();
-
- // Is the same?
- if (ContactUtils.isSameContact(contact, next)) {
- // Yes, then abort loop
- IsFound = false;
- break;
- }
- }
-
- // Return status
- return IsFound;
- }
-
- /**
- * Updates all data in contact instance.
- * <p>
- * @param contact Contact instance
- */
- private void updateContactData (final Contact contact) {
- // Contact instance should be valid
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw NPE again
- throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
- } else if (contact.getContactId() < 1) {
- // Invalid id
- throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
- }
-
- // Update all fields
- contact.setContactGender(this.getGender());
- contact.setContactTitle(this.getTitle());
- contact.setContactFirstName(this.getFirstName());
- contact.setContactFamilyName(this.getFamilyName());
- contact.setContactStreet(this.getStreet());
- contact.setContactHouseNumber(this.getHouseNumber());
- contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
- contact.setContactZipCode(this.getZipCode());
- contact.setContactCity(this.getCity());
- contact.setContactCountry(this.getCountry());
-
- // Update contact's mobile number
- this.isMobileUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getMobileCarrier(), this.getMobileNumber());
-
- // Update contact's land-line number
- this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
-
- // Update contact's fax number
- this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.contact;
-
-import java.io.Serializable;
-import java.util.Date;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.phonenumbers.DialableNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-
-/**
- * An administrative interface for user beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookAdminContactWebRequestController extends Serializable {
-
- /**
- * Adds contact data to database and redirects on success. If the contact is
- * already found, a proper exception is thrown.
- * <p>
- * @return Redirect outcome
- */
- String addContact ();
-
- /**
- * Creates an instance from contact data
- * <p>
- * @return New contact instance
- */
- Contact createContactInstance ();
-
- /**
- * Copies given contact's data to this controller
- * <p>
- * @param contact Contact instance
- */
- void copyContactToController (final Contact contact);
-
- /**
- * Edits currently loaded contact's data in database.
- * <p>
- * @return Redirect outcome
- */
- String editContactData ();
-
- /**
- * Getter for mobile id
- * <p>
- * @return Mobile id
- */
- Long getMobileId ();
-
- /**
- * Setter for mobile id
- * <p>
- * @param mobileId Mobile id
- */
- void setMobileId (final Long mobileId);
-
- /**
- * Getter for fax id
- * <p>
- * @return Fax id
- */
- Long getFaxId ();
-
- /**
- * Setter for fax id
- * <p>
- * @param faxId Fax id
- */
- void setFaxId (final Long faxId);
-
- /**
- * Getter for land-line id
- * <p>
- * @return Land-line id
- */
- Long getLandLineId ();
-
- /**
- * Setter for land-line id
- * <p>
- * @param landLineId Land-line id
- */
- void setLandLineId (final Long landLineId);
-
- /**
- * Getter for birth day
- * <p>
- * @return Birth day
- */
- Date getBirthday ();
-
- /**
- * Setter for birth day
- * <p>
- * @param birthday Birth day
- */
- void setBirthday (final Date birthday);
-
- /**
- * Getter for mobile number's carrier
- * <p>
- * @return Mobile number's carrier
- */
- MobileProvider getMobileCarrier ();
-
- /**
- * Setter for mobile number's carrier prefix
- * <p>
- * @param mobileCarrier Mobile number's carrier prefix
- */
- void setMobileCarrier (final MobileProvider mobileCarrier);
-
- /**
- * Getter for mobile number
- * <p>
- * @return Mobile number
- */
- Long getMobileNumber ();
-
- /**
- * Setter for mobile number
- * <p>
- * @param mobileNumber Mobile number
- */
- void setMobileNumber (final Long mobileNumber);
-
- /**
- * City
- * <p>
- * @return the city
- */
- String getCity ();
-
- /**
- * City
- * <p>
- * @param city the city to set
- */
- void setCity (final String city);
-
- /**
- * Getter for comments
- * <p>
- * @return Comments
- */
- String getComment ();
-
- /**
- * Setter for comment
- * <p>
- * @param comment Comments
- */
- void setComment (final String comment);
-
- /**
- * Getter for contact id
- * <p>
- * @return Contact id
- */
- Long getContactId ();
-
- /**
- * Setter for contact id
- * <p>
- * @param contactId Contact id
- */
- void setContactId (final Long contactId);
-
- /**
- * Getter for country instance
- * <p>
- * @return Country instance
- */
- Country getCountry ();
-
- /**
- * Setter for country instance
- * <p>
- * @param country Country instance
- */
- void setCountry (final Country country);
-
- /**
- * Getter for email address
- * <p>
- * @return Email address
- */
- String getEmailAddress ();
-
- /**
- * Setter for email address
- * <p>
- * @param emailAddress Email address
- */
- void setEmailAddress (final String emailAddress);
-
- /**
- * Family name
- * <p>
- * @return the familyName
- */
- String getFamilyName ();
-
- /**
- * Family name
- * <p>
- * @param familyName the familyName to set
- */
- void setFamilyName (final String familyName);
-
- /**
- * Getter for fax number's area code
- * <p>
- * @return Fax number's area code
- */
- Integer getFaxAreaCode ();
-
- /**
- * Setter for fax number's area code
- * <p>
- * @param faxAreaCode Fax number's area code
- */
- void setFaxAreaCode (final Integer faxAreaCode);
-
- /**
- * Getter for fax's country instance
- * <p>
- * @return Fax' country instance
- */
- Country getFaxCountry ();
-
- /**
- * Setter for fax's country instance
- * <p>
- * @param faxCountry Fax' country instance
- */
- void setFaxCountry (final Country faxCountry);
-
- /**
- * Getter for fax number
- * <p>
- * @return Fax number
- */
- Long getFaxNumber ();
-
- /**
- * Setter for fax number
- * <p>
- * @param faxNumber Fax number
- */
- void setFaxNumber (final Long faxNumber);
-
- /**
- * First name
- * <p>
- * @return the first name
- */
- String getFirstName ();
-
- /**
- * First name
- * <p>
- * @param firstName the first name to set
- */
- void setFirstName (final String firstName);
-
- /**
- * Gender of the contact
- * <p>
- * @return the gender
- */
- Gender getGender ();
-
- /**
- * Gender of the contact
- * <p>
- * @param gender the gender to set
- */
- void setGender (final Gender gender);
-
- /**
- * House number
- * <p>
- * @return the houseNumber
- */
- Short getHouseNumber ();
-
- /**
- * House number
- * <p>
- * @param houseNumber the houseNumber to set
- */
- void setHouseNumber (final Short houseNumber);
-
- /**
- * Getter for house number extension, example: 123a 'a' is then the
- * extension and 123 is the house number.
- * <p>
- * @return House number extension
- */
- String getHouseNumberExtension ();
-
- /**
- * Setter for house number extension
- * <p>
- * @param houseNumberExtension House number extension
- */
- void setHouseNumberExtension (final String houseNumberExtension);
-
- /**
- * Getter for phone number's area code
- * <p>
- * @return Phone number's area code
- */
- Integer getPhoneAreaCode ();
-
- /**
- * Setter for phone number's area code
- * <p>
- * @param phoneAreaCode Phone number's area code
- */
- void setPhoneAreaCode (final Integer phoneAreaCode);
-
- /**
- * Getter for phone number's country instance
- * <p>
- * @return Phone number's country instance
- */
- Country getPhoneCountry ();
-
- /**
- * Setter for phone number's country instance
- * <p>
- * @param phoneCountry Phone number's country instance
- */
- void setPhoneCountry (final Country phoneCountry);
-
- /**
- * Getter for phone number
- * <p>
- * @return Phone number
- */
- Long getPhoneNumber ();
-
- /**
- * Setter for phone number
- * <p>
- * @param phoneNumber Phone number
- */
- void setPhoneNumber (final Long phoneNumber);
-
- /**
- * Street
- * <p>
- * @return the street
- */
- String getStreet ();
-
- /**
- * Street
- * <p>
- * @param street the street to set
- */
- void setStreet (final String street);
-
- /**
- * Getter for title
- * <p>
- * @return title
- */
- String getTitle ();
-
- /**
- * Setter for title
- * <p>
- * @param title Title
- */
- void setTitle (final String title);
-
- /**
- * ZIP code
- * <p>
- * @return the zipCode
- */
- Integer getZipCode ();
-
- /**
- * ZIP code
- * <p>
- * @param zipCode the zipCode to set
- */
- void setZipCode (final Integer zipCode);
-
- /**
- * Returns a text respresentation of given phone number or null if not set.
- * <p>
- * @param phoneNumber Phone number
- * <p>
- * @return Text respresentation or null
- */
- String generatePhoneNumber (final DialableNumber phoneNumber);
-
- /**
- * Returns a text representation of given mobile number or null if not
- * set.
- * <p>
- * @param mobileNumber Mobile number
- * <p>
- * @return Text respresentation or null
- */
- String generateMobileNumber (final DialableMobileNumber mobileNumber);
-
- /**
- * Checks/returns whether the gender/salutation is required for this
- * controller.
- * <p>
- * @return Whether gender is required
- */
- boolean isGenderRequired ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.contact;
-
-import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
-import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
-import org.mxchange.jcontacts.contact.UserContact;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcontacts.contact.utils.ContactUtils;
-import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
-import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
-import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
-import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A general contact bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("contactController")
-@SessionScoped
-public class AddressbookContactWebSessionBean extends BaseAddressbookController implements AddressbookContactWebSessionController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 542_145_347_916L;
-
- /**
- * Birth day
- */
- private Date birthday;
-
- /**
- * Mobile number's carrier
- */
- private MobileProvider mobileCarrier;
-
- /**
- * Mobile number
- */
- private Long mobileNumber;
-
- /**
- * City
- */
- private String city;
-
- /**
- * Optional comments
- */
- private String comment;
-
- /**
- * Remote contact bean
- */
- private final ContactSessionBeanRemote contactBean;
-
- /**
- * Contact list
- */
- private final List<Contact> contactList;
-
- /**
- * Country instance
- */
- private Country country;
-
- /**
- * Email address
- */
- private String emailAddress;
-
- /**
- * Email address list
- */
- private final List<String> emailAddressList;
-
- /**
- * Email address repeated
- */
- private String emailAddressRepeat;
-
- /**
- * Family name
- */
- private String familyName;
-
- /**
- * Fax number's area code
- */
- private Integer faxAreaCode;
-
- /**
- * Country instance for fax number
- */
- private Country faxCountry;
-
- /**
- * Fax number
- */
- private Long faxNumber;
-
- /**
- * First name
- */
- private String firstName;
-
- /**
- * Gender instance
- */
- private Gender gender;
-
- /**
- * House number
- */
- private Short houseNumber;
-
- /**
- * House number extension
- */
- private String houseNumberExtension;
-
- /**
- * Whether a mobile entry has been unlinked
- */
- private boolean isMobileUnlinked;
-
- /**
- * Whether a fax entry has been unlinked
- */
- private boolean isFaxUnlinked;
-
- /**
- * Whether a land-line number has been unlinked
- */
- private boolean isLandLineUnlinked;
-
- /**
- * Phone number area code
- */
- private Integer phoneAreaCode;
-
- /**
- * Country instance for phone number
- */
- private Country phoneCountry;
-
- /**
- * Phone number
- */
- private Long phoneNumber;
-
- /**
- * A list of all selectable contacts
- */
- private List<Contact> selectableContacts;
-
- /**
- * Street
- */
- private String street;
-
- /**
- * Title
- */
- private String title;
-
- /**
- * Regular user controller
- */
- @Inject
- private AddressbookUserWebSessionController userController;
-
- /**
- * Login bean (controller)
- */
- @Inject
- private AddressbookUserLoginWebSessionController userLoginController;
-
- /**
- * ZIP code
- */
- private Integer zipCode;
-
- /**
- * Default constructor
- */
- public AddressbookContactWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
-
- // Init lists/maps
- this.contactList = new LinkedList<>();
- this.emailAddressList = new LinkedList<>();
- }
-
- @Override
- public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("contactController.afterAdminAddedContact(): event={0} - CALLED!", event)); //NOI18N
-
- // The event must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.addedContact is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() == null) {
- // ... and again
- throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
- }
-
- // Clear this bean
- this.clear();
-
- // Call other method
- this.uniqueAddContact(event.getAddedContact());
-
- // Add to selectable contacts
- this.selectableContacts.add(event.getAddedContact());
- }
-
- @Override
- public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("contactController.afterAdminAddedUserEvent(): event={0} - CALLED!", event)); //NOI18N
-
- // event 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
- }
-
- // Clear all data
- this.clear();
- }
-
- @Override
- public void afterAdminLinkedUser (@Observes final AdminLinkedUserEvent event) {
- // event 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().getUserContact() == null) {
- // Throw NPE again
- throw new NullPointerException("event.linkedUser.userContact is null"); //NOI18N
- } else if (event.getLinkedUser().getUserContact().getContactId() == null) {
- // userId is null
- throw new NullPointerException("event.linkedUser.userContact.contactId is null"); //NOI18N
- } else if (event.getLinkedUser().getUserContact().getContactId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserContact().getContactId())); //NOI18N
- }
-
- // Remove contact from list available contacts list
- this.selectableContacts.remove(event.getLinkedUser().getUserContact());
-
- // Clear all data
- this.clear();
- }
-
- @Override
- public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedContact() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedContact is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() == null) {
- // userId is null
- throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
- }
-
- // Add contact instance only once
- this.uniqueAddContact(event.getUpdatedContact());
-
- // Add email address to list
- this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress());
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("contactController.afterAdminUpdatedContactDataEvent(): EXIT!"); //NOI18N
- }
-
- @Override
- public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
- // event 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
- }
-
- // Get user instance
- Contact registeredContact = event.getRegisteredUser().getUserContact();
-
- // Copy all data from registered->user
- this.copyContact(registeredContact);
-
- // Add contact instance only once
- this.uniqueAddContact(registeredContact);
-
- // Add user name and email address
- this.addUserNameEmailAddress(registeredContact);
-
- // Clear all data
- this.clear();
- }
-
- @Override
- public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent 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
- }
-
- // Add contact instance only once
- this.uniqueAddContact(event.getConfirmedUser().getUserContact());
- }
-
- @Override
- public void afterUserLogin (@Observes final UserLoggedInEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLoggedInUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.loggedInUser is null"); //NOI18N
- } else if (event.getLoggedInUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
- } else if (event.getLoggedInUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
- }
-
- // Copy all data to this bean
- this.copyContact(event.getLoggedInUser().getUserContact());
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<Contact> allContacts () {
- // Debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactController.allContacts: contactList.size()={0} - EXIT!", this.contactList.size()));
-
- // Return un-modified list
- return this.contactList;
- }
-
- @Override
- public Contact createContactInstance () {
- // User message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: CALLED!", this.getClass().getSimpleName()));
-
- // Is all required data set?
- if (!this.isRequiredPersonalDataSet()) {
- // No, then abort here
- throw new FaceletException(new IllegalArgumentException("Not all personal data is set, but createContactInstance() is called.")); //NOI18N
- }
-
- // Required personal data must be set
- assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
-
- // Generate phone number
- DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
- DialableMobileNumber mobile = new MobileNumber(this.getMobileCarrier(), this.getMobileNumber());
- DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
-
- // Create new contact
- Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
- contact.setContactStreet(this.getStreet());
- contact.setContactHouseNumber(this.getHouseNumber());
- contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
- contact.setContactZipCode(this.getZipCode());
- contact.setContactCity(this.getCity());
- contact.setContactCountry(this.getCountry());
- contact.setContactEmailAddress(this.getEmailAddress());
- contact.setContactBirthday(this.getBirthday());
- contact.setContactComment(this.getComment());
-
- // Debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: this.emailAddress={1}", this.getClass().getSimpleName(), this.getEmailAddress()));
-
- // Don't set null or wrong references
- if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
- // Now the number must be given
- if (phone.getPhoneAreaCode() == null) {
- // Is null
- throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
- } else if (phone.getPhoneAreaCode() < 1) {
- // Abort here
- throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
- } else if (phone.getPhoneNumber() == null) {
- // Is null
- throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
- } else if (phone.getPhoneNumber() < 1) {
- // Abort here
- throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
- }
-
- // Set phone number
- contact.setContactLandLineNumber(phone);
- }
-
- // Don't set null or wrong references
- if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
- // Now the number must be given
- if (fax.getPhoneAreaCode() == null) {
- // Is null
- throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
- } else if (fax.getPhoneAreaCode() < 1) {
- // Abort here
- throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
- } else if (fax.getPhoneNumber() == null) {
- // Is null
- throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
- } else if (fax.getPhoneNumber() < 1) {
- // Abort here
- throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
- }
-
- // Set fax number
- contact.setContactFaxNumber(fax);
- }
-
- // Is the provider set?
- if ((mobile instanceof DialableMobileNumber) && (this.getMobileCarrier() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
- // Is the number set?
- if (mobile.getPhoneNumber() == null) {
- // Is null
- throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
- } else if (mobile.getPhoneNumber() < 1) {
- // Abort here
- throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
- }
-
- // Set mobile number
- contact.setContactMobileNumber(mobile);
- }
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: contact={1} - EXIT!", this.getClass().getSimpleName(), contact));
-
- // Return it
- return contact;
- }
-
- @Override
- public String doChangePersonalContactData () {
- // This method shall only be called if the user is logged-in
- if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged-in
- throw new IllegalStateException("User is not logged-in"); //NOI18N
- } else if (!this.isRequiredChangePersonalDataSet()) {
- // Not all required fields are set
- throw new FaceletException("Not all required fields are set."); //NOI18N
- } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
- // Password not matching
- this.showFacesMessage("form_login_change_personal:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); //NOI18N
- return ""; //NOI18N
- }
-
- // Get contact instance
- Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
-
- // It should be there, so run some tests on it
- assert (contact instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
- assert (contact.getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
- assert (contact.getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
-
- // Update all fields
- contact.setContactGender(this.getGender());
- contact.setContactFirstName(this.getFirstName());
- contact.setContactFamilyName(this.getFamilyName());
- contact.setContactStreet(this.getStreet());
- contact.setContactHouseNumber(this.getHouseNumber());
- contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
- contact.setContactZipCode(this.getZipCode());
- contact.setContactCity(this.getCity());
- contact.setContactCountry(this.getCountry());
-
- // Update contact's mobile number
- this.isMobileUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getMobileCarrier(), this.getMobileNumber());
-
- // Update contact's land-line number
- this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
-
- // Update contact's fax number
- this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
-
- // Send it to the EJB
- this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
-
- // All fine
- return "contact_data_saved"; //NOI18N
- }
-
- @Override
- @SuppressWarnings ("ReturnOfDateField")
- public Date getBirthday () {
- return this.birthday;
- }
-
- @Override
- @SuppressWarnings ("AssignmentToDateFieldFromParameter")
- public void setBirthday (final Date birthday) {
- this.birthday = birthday;
- }
-
- @Override
- public MobileProvider getMobileCarrier () {
- return this.mobileCarrier;
- }
-
- @Override
- public void setMobileCarrier (final MobileProvider mobileCarrier) {
- this.mobileCarrier = mobileCarrier;
- }
-
- @Override
- public Long getMobileNumber () {
- return this.mobileNumber;
- }
-
- @Override
- public void setMobileNumber (final Long mobileNumber) {
- this.mobileNumber = mobileNumber;
- }
-
- @Override
- public String getCity () {
- return this.city;
- }
-
- @Override
- public void setCity (final String city) {
- this.city = city;
- }
-
- @Override
- public String getComment () {
- return this.comment;
- }
-
- @Override
- public void setComment (final String comment) {
- this.comment = comment;
- }
-
- @Override
- public String getControllerType () {
- return "general"; //NOI18N
- }
-
- @Override
- @Deprecated
- public void setControllerType (final String controllerType) {
- throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
- }
-
- @Override
- public Country getCountry () {
- return this.country;
- }
-
- @Override
- public void setCountry (final Country country) {
- this.country = country;
- }
-
- @Override
- public String getEmailAddress () {
- return this.emailAddress;
- }
-
- @Override
- public void setEmailAddress (final String emailAddress) {
- this.emailAddress = emailAddress;
- }
-
- @Override
- public String getEmailAddressRepeat () {
- return this.emailAddressRepeat;
- }
-
- @Override
- public void setEmailAddressRepeat (final String emailAddressRepeat) {
- this.emailAddressRepeat = emailAddressRepeat;
- }
-
- @Override
- public String getFamilyName () {
- return this.familyName;
- }
-
- @Override
- public void setFamilyName (final String familyName) {
- this.familyName = familyName;
- }
-
- @Override
- public Integer getFaxAreaCode () {
- return this.faxAreaCode;
- }
-
- @Override
- public void setFaxAreaCode (final Integer faxAreaCode) {
- this.faxAreaCode = faxAreaCode;
- }
-
- @Override
- public Country getFaxCountry () {
- return this.faxCountry;
- }
-
- @Override
- public void setFaxCountry (final Country faxCountry) {
- this.faxCountry = faxCountry;
- }
-
- @Override
- public Long getFaxNumber () {
- return this.faxNumber;
- }
-
- @Override
- public void setFaxNumber (final Long faxNumber) {
- this.faxNumber = faxNumber;
- }
-
- @Override
- public String getFirstName () {
- return this.firstName;
- }
-
- @Override
- public void setFirstName (final String firstName) {
- this.firstName = firstName;
- }
-
- @Override
- public Gender getGender () {
- return this.gender;
- }
-
- @Override
- public void setGender (final Gender gender) {
- this.gender = gender;
- }
-
- @Override
- public Short getHouseNumber () {
- return this.houseNumber;
- }
-
- @Override
- public void setHouseNumber (final Short houseNumber) {
- this.houseNumber = houseNumber;
- }
-
- @Override
- public String getHouseNumberExtension () {
- return this.houseNumberExtension;
- }
-
- @Override
- public void setHouseNumberExtension (final String houseNumberExtension) {
- this.houseNumberExtension = houseNumberExtension;
- }
-
- @Override
- public Integer getPhoneAreaCode () {
- return this.phoneAreaCode;
- }
-
- @Override
- public void setPhoneAreaCode (final Integer phoneAreaCode) {
- this.phoneAreaCode = phoneAreaCode;
- }
-
- @Override
- public Country getPhoneCountry () {
- return this.phoneCountry;
- }
-
- @Override
- public void setPhoneCountry (final Country phoneCountry) {
- this.phoneCountry = phoneCountry;
- }
-
- @Override
- public Long getPhoneNumber () {
- return this.phoneNumber;
- }
-
- @Override
- public void setPhoneNumber (final Long phoneNumber) {
- this.phoneNumber = phoneNumber;
- }
-
- @Override
- public String getStreet () {
- return this.street;
- }
-
- @Override
- public void setStreet (final String street) {
- this.street = street;
- }
-
- @Override
- public String getTitle () {
- return this.title;
- }
-
- @Override
- public void setTitle (final String title) {
- this.title = title;
- }
-
- @Override
- public Integer getZipCode () {
- return this.zipCode;
- }
-
- @Override
- public void setZipCode (final Integer zipCode) {
- this.zipCode = zipCode;
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- // Get full email address list for reducing EJB calls
- this.emailAddressList.addAll(this.contactBean.getEmailAddressList());
-
- // Get full contact list
- this.contactList.addAll(this.contactBean.getAllContacts());
-
- // Get all users
- List<User> allUsers = this.userController.allUsers();
-
- // Get all contacts
- List<Contact> allContacts = this.contactBean.getAllContacts();
-
- // Get iterator
- Iterator<Contact> iterator = allContacts.iterator();
-
- // Loop through it
- while (iterator.hasNext()) {
- // Get next element
- Contact next = iterator.next();
-
- // Get iterator
- Iterator<User> userIterator = allUsers.iterator();
-
- // Loop through all users
- while (userIterator.hasNext()) {
- // Get user instance
- User nextUser = userIterator.next();
-
- // Is contact same?
- if (Objects.equals(next, nextUser.getUserContact())) {
- // Found same
- iterator.remove();
- break;
- }
- }
- }
-
- // Set contact list
- this.selectableContacts = allContacts;
- }
-
- @Override
- public boolean isEmailAddressRegistered (final Contact contact) {
- // Cherck parameter
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactEmailAddress() == null) {
- // Throw again
- throw new NullPointerException("contact.contactEmailAddress is null"); //NOI18N
- } else if (contact.getContactEmailAddress().isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("contact.contactEmailAddress is empty."); //NOI18N
- }
-
- // Determine it
- return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress())));
- }
-
- @Override
- public boolean isRequiredChangePersonalDataSet () {
- return ((this.getGender() != null) &&
- (this.getFirstName() != null) &&
- (this.getFamilyName() != null) &&
- (this.getStreet() != null) &&
- (this.getHouseNumber() != null) &&
- (this.getZipCode() != null) &&
- (this.getCity() != null));
- }
-
- @Override
- public boolean isRequiredPersonalDataSet () {
- return ((this.getGender() != null) &&
- (this.getFirstName() != null) &&
- (this.getFamilyName() != null) &&
- (this.getStreet() != null) &&
- (this.getHouseNumber() != null) &&
- (this.getZipCode() != null) &&
- (this.getCity() != null) &&
- (this.getEmailAddress() != null) &&
- (this.getEmailAddressRepeat() != null));
- }
-
- @Override
- public boolean isSameEmailAddressEntered () {
- return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
- }
-
- @Override
- public Contact lookupContactById (final Long contactId) throws ContactNotFoundException {
- // Init variable
- Contact localContact = null;
-
- // Clear this bean
- this.clear();
-
- // Try to lookup it in visible user list
- for (final Iterator<Contact> iterator = this.contactList.iterator(); iterator.hasNext();) {
- // Get next user
- Contact next = iterator.next();
-
- // Is the user id found?
- if (Objects.equals(next.getContactId(), contactId)) {
- // Copy to other variable
- localContact = next;
- break;
- }
- }
-
- // Is it still null?
- if (null == localContact) {
- // Not visible for the current user
- throw new ContactNotFoundException(contactId);
- }
-
- // Copy all data to this bean
- this.copyContact(localContact);
-
- // Return it
- return localContact;
- }
-
- @Override
- public List<Contact> selectableContacts () {
- return Collections.unmodifiableList(this.selectableContacts);
- }
-
- @Override
- public void updateContactDataFromController (final Contact contact) {
- // Is the instance valid?
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw NPE
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Not valid id number
- throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
- }
-
- // Set all
- this.copyContact(contact);
- }
-
- /**
- * Adds email address to bean's internal list.
- * <p>
- * @param contact Contact instance
- */
- private void addUserNameEmailAddress (final Contact contact) {
- // Make sure the entry is not added yet
- if (this.emailAddressList.contains(contact.getContactEmailAddress())) {
- // Already added
- throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N
- }
-
- // Add email addres
- this.emailAddressList.add(contact.getContactEmailAddress());
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- // - personal data
- this.setGender(null);
- this.setTitle(null);
- this.setFirstName(null);
- this.setFamilyName(null);
- this.setStreet(null);
- this.setHouseNumber(null);
- this.setHouseNumberExtension(null);
- this.setZipCode(null);
- this.setCity(null);
- this.setCountry(null);
-
- // - contact data
- this.setEmailAddress(null);
- this.setEmailAddressRepeat(null);
- this.setPhoneAreaCode(null);
- this.setPhoneCountry(null);
- this.setPhoneNumber(null);
- this.setMobileCarrier(null);
- this.setMobileNumber(null);
- this.setFaxAreaCode(null);
- this.setFaxCountry(null);
- this.setFaxNumber(null);
-
- // - other data
- this.setBirthday(null);
- this.setComment(null);
- }
-
- /**
- * Copies given contact into the controller
- * <p>
- * @param contact Contact instance
- */
- private void copyContact (final Contact contact) {
- // Is the instance valid?
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw NPE
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Not valid id number
- throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
- }
-
- // Copy all fields:
- // - base data
- this.setGender(contact.getContactGender());
- this.setTitle(contact.getContactTitle());
- this.setFirstName(contact.getContactFirstName());
- this.setFamilyName(contact.getContactFamilyName());
- this.setStreet(contact.getContactStreet());
- this.setHouseNumber(contact.getContactHouseNumber());
- this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
- this.setZipCode(contact.getContactZipCode());
- this.setCity(contact.getContactCity());
- this.setCountry(contact.getContactCountry());
- this.setEmailAddress(contact.getContactEmailAddress());
- this.setBirthday(contact.getContactBirthday());
- this.setComment(contact.getContactComment());
-
- // Get mobile, phone and fax instance
- DialableMobileNumber mobile = contact.getContactMobileNumber();
- DialableFaxNumber fax = contact.getContactFaxNumber();
- DialableLandLineNumber phone = contact.getContactLandLineNumber();
-
- // - contact data
- if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
- this.setPhoneCountry(phone.getPhoneCountry());
- this.setPhoneAreaCode(phone.getPhoneAreaCode());
- this.setPhoneNumber(phone.getPhoneNumber());
- }
-
- if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
- this.setMobileCarrier(mobile.getMobileProvider());
- this.setMobileNumber(mobile.getPhoneNumber());
- }
-
- if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
- this.setFaxCountry(fax.getPhoneCountry());
- this.setFaxAreaCode(fax.getPhoneAreaCode());
- this.setFaxNumber(fax.getPhoneNumber());
- }
- }
-
- /**
- * Removes given contact from all lists
- * <p>
- * @param contact Contact instance to remove
- */
- private void removeContact (final Contact contact) {
- // Is the instance valid?
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw NPE
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Not valid id number
- throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
- }
-
- // Remove from general list
- if (!this.contactList.remove(contact)) {
- // Did not remove contact
- throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N
- }
-
- // Remove from other lists
- this.emailAddressList.remove(contact.getContactEmailAddress());
- }
-
- /**
- * Adds unique instance to contact list. First any existing instance is
- * being removed, then the new instance is added.
- * <p>
- * @param contact Contact instance to add uniquely
- */
- private void uniqueAddContact (final Contact contact) {
- // Is the instance valid?
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null"); //NOI18N
- } else if (contact.getContactId() == null) {
- // Throw NPE
- throw new NullPointerException("contact.contactId is null"); //NOI18N
- } else if (contact.getContactId() < 1) {
- // Not valid id number
- throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
- }
-
- // Get iterator from list
- Iterator<Contact> iterator = this.contactList.iterator();
-
- // "Walk" through all entries
- while (iterator.hasNext()) {
- // Get next element
- Contact next = iterator.next();
-
- // Is id number the same?
- if (Objects.equals(contact.getContactId(), next.getContactId())) {
- // Found entry, so remove it and abort
- this.removeContact(next);
- break;
- }
- }
-
- // Add contact to list
- this.contactList.add(contact);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.contact;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-import javax.ejb.Local;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
-import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
-import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
-import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
-
-/**
- * An interface for user beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Local
-public interface AddressbookContactWebSessionController extends Serializable {
-
- /**
- * Minimum password length
- */
- public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
-
- /**
- * Returns a list of all found contacts
- * <p>
- * @return A list of all contacts.
- */
- List<Contact> allContacts ();
-
- /**
- * Event observer for newly added users by adminstrator
- * <p>
- * @param event Event being fired
- */
- void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
-
- /**
- * Event observer when user confirmed account.
- * <p>
- * @param event Event being fired
- */
- void afterUserConfirmedAccount (final UserConfirmedAccountEvent event);
-
- /**
- * Updates all data from bean in given contact instance
- * <p>
- * @param userContact Contact instance to update
- */
- void updateContactDataFromController (final Contact userContact);
-
- /**
- * Tries to lookup contact by given id number. If the user is not found a
- * proper exceptions are thrown.
- * <p>
- * @param contactId Contact id
- * <p>
- * @return Contact instance
- * <p>
- * @throws ContactNotFoundException If the user is not found
- */
- Contact lookupContactById (final Long contactId) throws ContactNotFoundException;
-
- /**
- * Event observer for new user registrations
- * <p>
- * @param event User registration event
- */
- void afterRegistrationEvent (final UserRegisteredEvent event);
-
- /**
- * Observes events being fired when an administrator has added a new
- * contact.
- * <p>
- * @param event Event being fired
- */
- void afterAdminAddedContact (final AdminAddedContactEvent event);
-
- /**
- * Observes events being fired when an administrator has linked a new user
- * with existing contact data.
- * <p>
- * @param event Event being fired
- */
- void afterAdminLinkedUser (final AdminLinkedUserEvent event);
-
- /**
- * Event observer for updated contact data by administrators
- * <p>
- * @param event Updated contact data event
- */
- void afterAdminUpdatedContactDataEvent (final AdminUpdatedContactEvent event);
-
- /**
- * Event observer for logged-in user
- * <p>
- * @param event Event instance
- */
- void afterUserLogin (final UserLoggedInEvent event);
-
- /**
- * Creates an instance from all properties
- * <p>
- * @return A contact instance
- */
- Contact createContactInstance ();
-
- /**
- * Getter for birth day
- * <p>
- * @return Birth day
- */
- Date getBirthday ();
-
- /**
- * Setter for birth day
- * <p>
- * @param birthday Birth day
- */
- void setBirthday (final Date birthday);
-
- /**
- * Getter for mobile number's carrier
- * <p>
- * @return Mobile number's carrier
- */
- MobileProvider getMobileCarrier ();
-
- /**
- * Setter for mobile number's carrier prefix
- * <p>
- * @param mobileCarrier Mobile number's carrier prefix
- */
- void setMobileCarrier (final MobileProvider mobileCarrier);
-
- /**
- * Getter for mobile number
- * <p>
- * @return Mobile number
- */
- Long getMobileNumber ();
-
- /**
- * Setter for mobile number
- * <p>
- * @param mobileNumber Mobile number
- */
- void setMobileNumber (final Long mobileNumber);
-
- /**
- * City
- * <p>
- * @return the city
- */
- String getCity ();
-
- /**
- * City
- * <p>
- * @param city the city to set
- */
- void setCity (final String city);
-
- /**
- * Getter for comments
- * <p>
- * @return Comments
- */
- String getComment ();
-
- /**
- * Setter for comment
- * <p>
- * @param comment Comments
- */
- void setComment (final String comment);
-
- /**
- * Getter for country instance
- * <p>
- * @return Country instance
- */
- Country getCountry ();
-
- /**
- * Setter for country instance
- * <p>
- * @param country Country instance
- */
- void setCountry (final Country country);
-
- /**
- * Getter for email address
- * <p>
- * @return Email address
- */
- String getEmailAddress ();
-
- /**
- * Setter for email address
- * <p>
- * @param emailAddress Email address
- */
- void setEmailAddress (final String emailAddress);
-
- /**
- * Getter for email address, repeated
- * <p>
- * @return the emailAddress, repeated
- */
- String getEmailAddressRepeat ();
-
- /**
- * Setter for email address repeated
- * <p>
- * @param emailAddressRepeat the emailAddress to set
- */
- void setEmailAddressRepeat (final String emailAddressRepeat);
-
- /**
- * Family name
- * <p>
- * @return the familyName
- */
- String getFamilyName ();
-
- /**
- * Family name
- * <p>
- * @param familyName the familyName to set
- */
- void setFamilyName (final String familyName);
-
- /**
- * Getter for fax number's area code
- * <p>
- * @return Fax number's area code
- */
- Integer getFaxAreaCode ();
-
- /**
- * Setter for fax number's area code
- * <p>
- * @param faxAreaCode Fax number's area code
- */
- void setFaxAreaCode (final Integer faxAreaCode);
-
- /**
- * Getter for fax's country instance
- * <p>
- * @return Fax' country instance
- */
- Country getFaxCountry ();
-
- /**
- * Setter for fax's country instance
- * <p>
- * @param faxCountry Fax' country instance
- */
- void setFaxCountry (final Country faxCountry);
-
- /**
- * Getter for fax number
- * <p>
- * @return Fax number
- */
- Long getFaxNumber ();
-
- /**
- * Setter for fax number
- * <p>
- * @param faxNumber Fax number
- */
- void setFaxNumber (final Long faxNumber);
-
- /**
- * First name
- * <p>
- * @return the first name
- */
- String getFirstName ();
-
- /**
- * First name
- * <p>
- * @param firstName the first name to set
- */
- void setFirstName (final String firstName);
-
- /**
- * Gender of the contact
- * <p>
- * @return the gender
- */
- Gender getGender ();
-
- /**
- * Gender of the contact
- * <p>
- * @param gender the gender to set
- */
- void setGender (final Gender gender);
-
- /**
- * House number
- * <p>
- * @return the houseNumber
- */
- Short getHouseNumber ();
-
- /**
- * House number
- * <p>
- * @param houseNumber the houseNumber to set
- */
- void setHouseNumber (final Short houseNumber);
-
- /**
- * Getter for house number extension, example: 123a 'a' is then the
- * extension and 123 is the house number.
- * <p>
- * @return House number extension
- */
- String getHouseNumberExtension ();
-
- /**
- * Setter for house number extension
- * <p>
- * @param houseNumberExtension House number extension
- */
- void setHouseNumberExtension (final String houseNumberExtension);
-
- /**
- * Getter for phone number's area code
- * <p>
- * @return Phone number's area code
- */
- Integer getPhoneAreaCode ();
-
- /**
- * Setter for phone number's area code
- * <p>
- * @param phoneAreaCode Phone number's area code
- */
- void setPhoneAreaCode (final Integer phoneAreaCode);
-
- /**
- * Getter for phone number's country instance
- * <p>
- * @return Phone number's country instance
- */
- Country getPhoneCountry ();
-
- /**
- * Setter for phone number's country instance
- * <p>
- * @param phoneCountry Phone number's country instance
- */
- void setPhoneCountry (final Country phoneCountry);
-
- /**
- * Getter for phone number
- * <p>
- * @return Phone number
- */
- Long getPhoneNumber ();
-
- /**
- * Setter for phone number
- * <p>
- * @param phoneNumber Phone number
- */
- void setPhoneNumber (final Long phoneNumber);
-
- /**
- * Street
- * <p>
- * @return the street
- */
- String getStreet ();
-
- /**
- * Street
- * <p>
- * @param street the street to set
- */
- void setStreet (final String street);
-
- /**
- * Titöe
- * <p>
- * @return the title
- */
- String getTitle ();
-
- /**
- * Title
- * <p>
- * @param title the title to set
- */
- void setTitle (final String title);
-
- /**
- * ZIP code
- * <p>
- * @return the zipCode
- */
- Integer getZipCode ();
-
- /**
- * ZIP code
- * <p>
- * @param zipCode the zipCode to set
- */
- void setZipCode (final Integer zipCode);
-
- /**
- * Getter for controller type
- * <p>
- * @return controller type
- */
- String getControllerType ();
-
- /**
- * Setter for controller type
- * <p>
- * @param controllerType Controller type
- * @deprecated Don't use this method.
- */
- @Deprecated
- void setControllerType (final String controllerType);
-
- /**
- * Checks whether contact instance's email address is used
- * <p>
- * @param contact Contact instance's email address to check
- * <p>
- * @return Whether it is already used
- */
- boolean isEmailAddressRegistered (final Contact contact);
-
- /**
- * Checks whether all required personal data is set
- * <p>
- * @return Whether the required personal data is set
- */
- boolean isRequiredPersonalDataSet ();
-
- /**
- * Checks whether all required personal data is set for changing them
- * <p>
- * @return Whether the required personal data is set
- */
- boolean isRequiredChangePersonalDataSet ();
-
- /**
- * Checks whether same email addresses have been entered
- * <p>
- * @return Whether same email addresses have been entered
- */
- boolean isSameEmailAddressEntered ();
-
- /**
- * Changes logged-in user's personal data if the current password matches
- * and TAC + privacy statement has been accepted.
- * <p>
- * @return New target page
- */
- String doChangePersonalContactData ();
-
- /**
- * Returns a list of all selectable contacts for user creation. Contacts
- * from already existing users are excluded in this list.
- * <p>
- * @return A list of all selectable contacts
- */
- List<Contact> selectableContacts ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.contact.phone;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
-import org.mxchange.addressbook.beans.phone.AddressbookAdminPhoneWebRequestController;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
-import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote;
-import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
-
-/**
- * A general contact bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("contactPhoneController")
-@SessionScoped
-public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookController implements AddressbookContactPhoneWebSessionController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 542_145_347_916L;
-
- /**
- * Remote EJB for phone number (administrative)
- */
- private AdminPhoneSessionBeanRemote adminPhoneBean;
-
- /**
- * Administrative phone controller
- */
- @Inject
- private AddressbookAdminPhoneWebRequestController adminPhoneController;
-
- /**
- * General contact controller
- */
- @Inject
- private AddressbookContactWebSessionController contactController;
-
- /**
- * "Cache" for contact lists, mostly only one is assigned. So this cache
- * shouldn't grow beyond control.
- */
- private final Map<Long, List<Contact>> contacts;
-
- /**
- * Default constructor
- */
- public AddressbookContactPhoneWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the beans
- this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminphone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
-
- // Init lists/maps
- this.contacts = new HashMap<>(10);
- }
-
- @Override
- public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
- // The event must be valid
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedContact() == null) {
- // Throw again ...
- throw new NullPointerException("event.addedContact is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() == null) {
- // ... and again
- throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
- } else if (event.getAddedContact().getContactId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
- }
-
- // Clear this bean
- this.clear();
- }
-
- @Override
- public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
- // event 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
- }
-
- // Clear all data
- this.clear();
- }
-
- @Override
- public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getUpdatedContact() == null) {
- // Throw NPE again
- throw new NullPointerException("event.updatedContact is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() == null) {
- // userId is null
- throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
- } else if (event.getUpdatedContact().getContactId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
- }
- }
-
- @Override
- public List<Contact> allMobileContacts () {
- // Get id
- Long phoneId = this.adminPhoneController.getMobileNumber().getPhoneId();
-
- // Is cache there?
- if (this.contacts.containsKey(phoneId)) {
- // Return cached version
- return this.contacts.get(phoneId);
- } else {
- // Ask bean
- List<Contact> list = new LinkedList<>();
-
- // "Walk" through all contacts
- for (final Contact contact : this.contactController.allContacts()) {
- // Is mobile instance the same?
- if (Objects.equals(contact.getContactMobileNumber(), this.adminPhoneController.getMobileNumber())) {
- // Found one
- list.add(contact);
- }
- }
-
- // Store result in cache
- this.contacts.put(phoneId, list);
-
- // Return now-cached list
- return list;
- }
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.contact.phone;
-
-import java.io.Serializable;
-import java.util.List;
-import javax.ejb.Local;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
-import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
-import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
-
-/**
- * An interface for user beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Local
-public interface AddressbookContactPhoneWebSessionController extends Serializable {
-
- /**
- * Minimum password length
- */
- public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
-
- /**
- * Getter for all contacts having current cellphone instance linked
- * <p>
- * @return List of all linked contacts
- */
- List<Contact> allMobileContacts ();
-
- /**
- * Event observer for newly added users by adminstrator
- * <p>
- * @param event Event being fired
- */
- void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
-
- /**
- * Observes events being fired when an administrator has added a new
- * contact.
- * <p>
- * @param event Event being fired
- */
- void afterAdminAddedContact (final AdminAddedContactEvent event);
-
- /**
- * Event observer for updated contact data by administrators
- * <p>
- * @param event Updated contact data event
- */
- void afterAdminUpdatedContactDataEvent (final AdminUpdatedContactEvent event);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.country;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jcountry.data.CountryData;
-import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
-import org.mxchange.jcountry.events.AdminAddedCountryEvent;
-import org.mxchange.jcountry.events.AdminEventCountryAdded;
-import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
-
-/**
- * An administrative country bean
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminCountryController")
-@RequestScoped
-public class AddressbookAdminCountryWebRequestBean extends BaseAddressbookController implements AddressbookAdminCountryWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 18_598_175_719_603L;
-
- /**
- * An event triggered when the administrator has added a country
- */
- @Inject
- @Any
- private Event<AdminAddedCountryEvent> addedCountryEvent;
-
- /**
- * Abroad dial prefix
- */
- private String countryAbroadDialPrefix;
-
- /**
- * Remote country EJB
- */
- private CountrySingletonBeanRemote countryBean;
-
- /**
- * 2-letter country code
- */
- private String countryCode;
-
- /**
- * Regular country controller
- */
- @Inject
- private AddressbookCountryWebApplicationController countryController;
-
- /**
- * Local dial prefix
- */
- private String countryExternalDialPrefix;
-
- /**
- * i18n bundle key
- */
- private String countryI18nKey;
-
- /**
- * Whether the local dial prefix is required to use
- */
- private Boolean countryIsLocalPrefixRequired;
-
- /**
- * Phone code
- */
- private Short countryPhoneCode;
-
- /**
- * Default constructor
- */
- public AddressbookAdminCountryWebRequestBean () {
- // Try this
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the bean
- this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
- }
-
- @Override
- public String addCountry () {
- // Create new country object
- Country country = new CountryData();
-
- // Add all data
- country.setCountryAbroadDialPrefix(this.getCountryAbroadDialPrefix());
- country.setCountryCode(this.getCountryCode());
- country.setCountryExternalDialPrefix(this.getCountryExternalDialPrefix());
- country.setCountryI18nKey(this.getCountryI18nKey());
- country.setCountryIsLocalPrefixRequired(this.getCountryIsLocalPrefixRequired());
- country.setCountryPhoneCode(this.getCountryPhoneCode());
-
- // Does it already exist?
- if (this.isCountryAdded(country)) {
- // Yes, then abort here
- throw new FaceletException(new CountryAlreadyAddedException(country));
- }
-
- // Init variable
- Country updatedCountry = null;
-
- try {
- // Send country to bean
- updatedCountry = this.countryBean.addCountry(country);
- } catch (final CountryAlreadyAddedException ex) {
- // Throw again
- throw new FaceletException(ex);
- }
-
- // Fire event
- this.addedCountryEvent.fire(new AdminEventCountryAdded(updatedCountry));
-
- // Clear this bean
- this.clear();
-
- // Redirect to list
- return "admin_list_country"; //NOI18N
- }
-
- @Override
- public String getCountryAbroadDialPrefix () {
- return this.countryAbroadDialPrefix;
- }
-
- @Override
- public void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix) {
- this.countryAbroadDialPrefix = countryAbroadDialPrefix;
- }
-
- @Override
- public String getCountryCode () {
- return this.countryCode;
- }
-
- @Override
- public void setCountryCode (final String countryCode) {
- this.countryCode = countryCode;
- }
-
- @Override
- public String getCountryExternalDialPrefix () {
- return this.countryExternalDialPrefix;
- }
-
- @Override
- public void setCountryExternalDialPrefix (final String countryExternalDialPrefix) {
- this.countryExternalDialPrefix = countryExternalDialPrefix;
- }
-
- @Override
- public String getCountryI18nKey () {
- return this.countryI18nKey;
- }
-
- @Override
- public void setCountryI18nKey (final String countryI18nKey) {
- this.countryI18nKey = countryI18nKey;
- }
-
- @Override
- public Boolean getCountryIsLocalPrefixRequired () {
- return this.countryIsLocalPrefixRequired;
- }
-
- @Override
- public void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired) {
- this.countryIsLocalPrefixRequired = countryIsLocalPrefixRequired;
- }
-
- @Override
- public Short getCountryPhoneCode () {
- return this.countryPhoneCode;
- }
-
- @Override
- public void setCountryPhoneCode (final Short countryPhoneCode) {
- this.countryPhoneCode = countryPhoneCode;
- }
-
- /**
- * Clears this bean's data. This should be called after a form has been
- * submitted and the processing of the form was successful.
- */
- private void clear () {
- // Clear fields
- this.setCountryAbroadDialPrefix(null);
- this.setCountryCode(null);
- this.setCountryExternalDialPrefix(null);
- this.setCountryI18nKey(null);
- this.setCountryIsLocalPrefixRequired(null);
- this.setCountryPhoneCode(null);
- }
-
- /**
- * Checks if given country is already added by iterating over the whole list
- * and try to find it.
- * <p>
- * @param country Country instance to look for
- * <p>
- * @return Whether the country was already found
- */
- private boolean isCountryAdded (final Country country) {
- // Default is not found
- boolean isAdded = false;
-
- // Now get whole ist
- List<Country> countries = this.countryController.allCountries();
-
- // Get iterator from it
- Iterator<Country> iterator = countries.iterator();
-
- // Check whole list
- while (iterator.hasNext()) {
- // Get next country
- Country next = iterator.next();
-
- // Is country code or i18n the same?
- if ((Objects.equals(country.getCountryCode(), next.getCountryCode())) || (Objects.equals(country.getCountryI18nKey(), next.getCountryI18nKey()))) {
- // Yes, then abort search
- isAdded = true;
- break;
- }
- }
-
- // Return result
- return isAdded;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.country;
-
-import java.io.Serializable;
-
-/**
- * An interface for administrative country beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookAdminCountryWebRequestController extends Serializable {
-
- /**
- * Adds country to all relevant beans and sends it to the EJB. A redirect
- * should happen after successfull creation.
- * <p>
- * @return Redirect outcome
- */
- String addCountry ();
-
- /**
- * Getter for abroad dial prefix
- * <p>
- * @return Abroad dial prefix
- */
- String getCountryAbroadDialPrefix ();
-
- /**
- * Setter for abroad dial prefix
- * <p>
- * @param countryAbroadDialPrefix Abroad dial prefix
- */
- void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix);
-
- /**
- * Getter for 2-characters country code
- * <p>
- * @return Country code
- */
- String getCountryCode ();
-
- /**
- * Setter for 2-characters country code
- * <p>
- * @param countryCode Country code
- */
- void setCountryCode (final String countryCode);
-
- /**
- * Getter for i18n key for country name
- * <p>
- * @return i18n key for country name
- */
- String getCountryI18nKey ();
-
- /**
- * Setter for i18n key for country name
- * <p>
- * @param countryI18nKey i18n key for country name
- */
- void setCountryI18nKey (final String countryI18nKey);
-
- /**
- * Getter for whether the local dial prefix is required for local calls
- * <p>
- * @return Whether the local dial prefix is required
- */
- Boolean getCountryIsLocalPrefixRequired ();
-
- /**
- * Setter for whether the local dial prefix is required for local calls
- * <p>
- * @param countryIsLocalPrefixRequired Whether the local dial prefix is
- * required
- */
- void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired);
-
- /**
- * Getter for external dial prefix
- * <p>
- * @return External dial prefix
- */
- String getCountryExternalDialPrefix ();
-
- /**
- * Setter for external dial prefix
- * <p>
- * @param countryExternalDialPrefix External dial prefix
- */
- void setCountryExternalDialPrefix (final String countryExternalDialPrefix);
-
- /**
- * Getter for country code (example: 49 for Germany, 63 for Philippines)
- * <p>
- * @return Dial number without prefix
- */
- Short getCountryPhoneCode ();
-
- /**
- * Setter for country code (example: 49 for Germany, 63 for Philippines)
- * <p>
- * @param countryPhoneCode Country code
- */
- void setCountryPhoneCode (final Short countryPhoneCode);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.country;
-
-import java.text.MessageFormat;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
-import org.mxchange.jcountry.events.AdminAddedCountryEvent;
-
-/**
- * A country bean
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("countryController")
-@ApplicationScoped
-public class AddressbookCountryWebApplicationBean extends BaseAddressbookController implements AddressbookCountryWebApplicationController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 176_985_298_681_742_960L;
-
- /**
- * Remote country EJB
- */
- private CountrySingletonBeanRemote countryBean;
-
- /**
- * List of all countries
- */
- private List<Country> countryList;
-
- /**
- * Default constructor
- */
- public AddressbookCountryWebApplicationBean () {
- // Try this
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the bean
- this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
- }
-
- @Override
- public void afterAdminAddedCountry (@Observes final AdminAddedCountryEvent event) {
- // Is all valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedCountry() == null) {
- // Throw again ...
- throw new NullPointerException("event.addedCountry is null"); //NOI18N
- } else if (event.getAddedCountry().getCountryId() == null) {
- // And again ...
- throw new NullPointerException("event.addedCountry.countryId is null"); //NOI18N
- } else if (event.getAddedCountry().getCountryId() < 1) {
- // Id is invalid
- throw new IllegalArgumentException(MessageFormat.format("event.addedCountry.countryId={0} is not valid.", event.getAddedCountry().getCountryId())); //NOI18N
- }
-
- // Add the event
- this.countryList.add(event.getAddedCountry());
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<Country> allCountries () {
- // Return "cached" version
- return this.countryList;
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- // "Cache" country list as this will not change so often.
- this.countryList = this.countryBean.allCountries();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.country;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jcountry.events.AdminAddedCountryEvent;
-
-/**
- * An interface for country beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookCountryWebApplicationController extends Serializable {
-
- /**
- * A list of all countries
- * <p>
- * @return All countries
- */
- List<Country> allCountries ();
-
- /**
- * Observing method when the event is fired that an administrator added a
- * new country
- * <p>
- * @param event Event instance
- */
- void afterAdminAddedCountry (final AdminAddedCountryEvent event);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.email_address;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Objects;
-import javax.enterprise.context.SessionScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.features.AddressbookFeaturesWebApplicationController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcoreee.utils.FacesUtils;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
-import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress;
-import org.mxchange.jusercore.model.email_address.EmailAddressChange;
-import org.mxchange.jusercore.model.email_address.UserEmailChangeSessionBeanRemote;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A web session bean for changing email addresses
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("emailChangeController")
-@SessionScoped
-public class AddressbookEmailChangeWebSessionBean extends BaseAddressbookController implements AddressbookEmailChangeWebSessionController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 186_078_724_659_153L;
-
- /**
- * Email address 1 (changing)
- */
- private String emailAddress;
-
- /**
- * Email address 2 (repeat in changing)
- */
- private String emailAddressRepeat;
-
- /**
- * Local list of already queued email addresses
- */
- private List<String> emailAddresses;
-
- /**
- * Remote email change bean
- */
- private final UserEmailChangeSessionBeanRemote emailBean;
-
- /**
- * Features controller
- */
- @Inject
- private AddressbookFeaturesWebApplicationController featureController;
-
- /**
- * Login bean (controller)
- */
- @Inject
- private AddressbookUserLoginWebSessionController userLoginController;
-
- /**
- * Default constructor
- */
- public AddressbookEmailChangeWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.emailBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/addressbook-ejb/email-change!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N
-
- // Init list
- this.emailAddresses = this.emailBean.allQueuedAddresses();
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public String doChangeEmailAddress () {
- // This method shall only be called if the user is logged-in
- if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged-in
- throw new IllegalStateException("User is not logged-in"); //NOI18N
- } else if (!this.isRequiredChangeEmailAddressSet()) {
- // Not all required fields are set
- throw new FaceletException("Not all required fields are set."); //NOI18N
- } else if (!Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat())) {
- // Email address 1+2 mismatch
- throw new FaceletException("Email address 1/2 are mismatching."); //NOI18N
- } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
- // Password not matching
- this.showFacesMessage("form_login_change_email_address:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); //NOI18N
- return ""; //NOI18N
- } else if (!this.featureController.isFeatureEnabled("edit_user_data")) { //NOI18N
- // Editing is not allowed
- throw new IllegalStateException("User tried to edit personal data"); //NOI18N
- }
-
- // Get user instance
- User user = this.userLoginController.getLoggedInUser();
-
- // It should be there, so run some tests on it
- assert (user instanceof User) : "Instance loginController.loggedInUser is null"; //NOI18N
- assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; //NOI18N
- assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
- assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
- assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
- assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
-
- // Check if the email address is already enqueued
- if (this.isEmailAddressQueued(this.getEmailAddress())) {
- // Yes, then abort here
- return "login_email_already_added"; //NOI18N
- }
-
- // Create change object, to save EJB calls, the hash is not generated here
- ChangeableEmailAddress emailChange = new EmailAddressChange(user, this.getEmailAddress());
-
- // Get base URL
- String baseUrl = FacesUtils.generateBaseUrl();
-
- // Call EJB
- this.emailBean.enqueueEmailAddressForChange(emailChange, baseUrl);
-
- // Unset all so the user is forced to re-enter it
- this.clear();
-
- // All fine
- return "login_email_change_queued"; //NOI18N
- }
-
- @Override
- public String getEmailAddress () {
- return this.emailAddress;
- }
-
- @Override
- public void setEmailAddress (final String emailAddress) {
- this.emailAddress = emailAddress;
- }
-
- @Override
- public String getEmailAddressRepeat () {
- return this.emailAddressRepeat;
- }
-
- @Override
- public void setEmailAddressRepeat (final String emailAddressRepeat) {
- this.emailAddressRepeat = emailAddressRepeat;
- }
-
- @Override
- public boolean isRequiredChangeEmailAddressSet () {
- return ((this.getEmailAddress() != null) &&
- (this.getEmailAddressRepeat() != null));
- }
-
- /**
- * Clears email address fields so the user has to re-enter them
- */
- private void clear () {
- // Clear fields
- this.setEmailAddress(null);
- this.setEmailAddressRepeat(null);
- }
-
- /**
- * Checks if given email address has already been queued. First a local list
- * is being checked, if not found, the EJB is called. Only if found, the
- * result is "cached" in the list.
- * <p>
- * @param emailAddress Email address to verify
- * <p>
- * @return Whether the email address in field emailAddress is already queued
- */
- private boolean isEmailAddressQueued (final String emailAddress) {
- // It should be there
- assert (emailAddress != null) : "emailAddress should not be null"; //NOI18N
- assert (!emailAddress.trim().isEmpty()) : "emailAddress should not be empty"; //NOI18N
-
- // Check list
- if (this.emailAddresses.contains(emailAddress)) {
- // Okay, found it
- return true;
- }
-
- // Check EJB
- boolean isQueued = this.emailBean.isEmailAddressEnqueued(emailAddress);
-
- // Is it there?
- if (isQueued) {
- // Add to list
- this.emailAddresses.add(emailAddress);
- }
-
- // Return status
- return isQueued;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.email_address;
-
-import java.io.Serializable;
-
-/**
- * An interface for an email change controller
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookEmailChangeWebSessionController extends Serializable {
-
- /**
- * Getter for email address 1 (changing)
- * <p>
- * @return Email address
- */
- String getEmailAddress ();
-
- /**
- * Setter for email address 1 (changing)
- * <p>
- * @param emailAddress Email address 1
- */
- void setEmailAddress (final String emailAddress);
-
- /**
- * Getter for email address 2 (repeat changing)
- * <p>
- * @return Email address 2
- */
- String getEmailAddressRepeat ();
-
- /**
- * Setter for email address 2 (repeat changing)
- * <p>
- * @param emailAddressRepeat Email address 2
- */
- void setEmailAddressRepeat (final String emailAddressRepeat);
-
- /**
- * Checks whether all required are set for changing email address
- * <p>
- * @return Whether the required personal data is set
- */
- boolean isRequiredChangeEmailAddressSet ();
-
- /**
- * Changes logged-in user's email address if the current password matches.
- * <p>
- * @return New target page
- */
- String doChangeEmailAddress ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.features;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Named;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-
-/**
- * A feature bean
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("featureController")
-@ApplicationScoped
-public class AddressbookFeatureWebApplicationBean extends BaseAddressbookController implements AddressbookFeaturesWebApplicationController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 64_237_512_690_168_674L;
-
- @Override
- public boolean isFeatureEnabled (final String feature) {
- // The parameter must be set
- if (null == feature) {
- // Throw NPE
- throw new NullPointerException("feature is null"); //NOI18N
- } else if (feature.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("feature is empty"); //NOI18N
- }
-
- // Default is not enabled
- boolean isEnabled = false;
-
- // Try it as an NPE may come
- try {
- // Get value from property
- String value = this.getStringContextParameter(String.format("is_feature_%s_enabled", feature)); //NOI18N
-
- // Is it set?
- isEnabled = (value.toLowerCase().equals("true")); //NOI18N
- } catch (final NullPointerException ex) {
- // Ignored
- }
-
- // Return value
- return isEnabled;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.features;
-
-import java.io.Serializable;
-import javax.ejb.Local;
-
-/**
- * An interface for country beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Local
-public interface AddressbookFeaturesWebApplicationController extends Serializable {
-
- /**
- * Checks if given feature is enabled.
- * <p>
- * @param feature Feature to be checked
- * <p>
- * @return Whether given feature is enabled
- */
- boolean isFeatureEnabled (final String feature);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.gender;
-
-import java.util.List;
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Named;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.jcontacts.contact.gender.Gender;
-import org.mxchange.jcontacts.contact.gender.GenderUtils;
-
-/**
- * A gender bean
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("genderController")
-@ApplicationScoped
-public class AddressbookGenderWebApplicationBean extends BaseAddressbookController implements AddressbookGenderWebApplicationController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 835_482_364_189L;
-
- /**
- * Default constructor
- */
- public AddressbookGenderWebApplicationBean () {
- }
-
- @Override
- public Gender[] getAllGenders () {
- // Return it
- return Gender.values();
- }
-
- @Override
- public List<Gender> getSelectableGenders () {
- // Init array
- List<Gender> genders = GenderUtils.selectableGenders();
-
- // Return it
- return genders;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.gender;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontacts.contact.gender.Gender;
-
-/**
- * An interface for data beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookGenderWebApplicationController extends Serializable {
-
- /**
- * Getter for all genders as array
- * <p>
- * @return All genders as array
- */
- Gender[] getAllGenders ();
-
- /**
- * Getter for only selectable genders as array, UNKNOWN is not selectable
- * <p>
- * @return All genders as array
- */
- List<Gender> getSelectableGenders ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder GmbH
- *
- * 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.addressbook.beans.helper;
-
-import java.io.Serializable;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * An interface for general bean helper
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookWebRequestController extends Serializable {
-
- /**
- * Getter for user instance
- * <p>
- * @return User instance
- */
- User getUser ();
-
- /**
- * Setter for user instance
- * <p>
- * @param user User instance
- */
- void setUser (final User user);
-
- /**
- * Copies currently set user instance's data to adminUserController
- */
- void copyUserToController ();
-
- /**
- * Returns a message key depending on if this contact is a user and/or a
- * contact. If this contact is unused, a default key is returned.
- * <p>
- * @param contact Contact instance to check
- * <p>
- * @return Message key
- */
- String getContactUsageMessageKey (final Contact contact);
-
- /**
- * Getter for contact instance
- * <p>
- * @return Contact instance
- */
- Contact getContact ();
-
- /**
- * Setter for contact instance
- * <p>
- * @param contact Contact instance
- */
- void setContact (final Contact contact);
-
- /**
- * Copies currently set contact instance's data to adminContactController
- */
- void copyContactToController ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder GmbH
- *
- * 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.addressbook.beans.helper;
-
-import java.text.MessageFormat;
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.addressbook.beans.contact.AddressbookAdminContactWebRequestController;
-import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.addressbook.beans.phone.AddressbookAdminPhoneWebRequestController;
-
-/**
- * A general helper for beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminHelper")
-@RequestScoped
-public class AddressbookWebRequestHelper implements AddressbookWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 17_258_793_567_145_701L;
-
- /**
- * Administrative contact controller
- */
- @Inject
- private AddressbookAdminContactWebRequestController adminContactController;
-
- /**
- * Administrative phone controller
- */
- @Inject
- private AddressbookAdminPhoneWebRequestController adminPhoneController;
-
- /**
- * Contact instance
- */
- private Contact contact;
-
- /**
- * User instance
- */
- private User user;
-
- /**
- * Regular user controller
- */
- @Inject
- private AddressbookUserWebSessionController userController;
-
- /**
- * Default constructor
- */
- public AddressbookWebRequestHelper () {
- }
-
- @Override
- public void copyContactToController () {
- // Log message
- //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - CALLED!"); //NOI18N
-
- // Validate user instance
- if (this.getContact() == null) {
- // Throw NPE
- throw new NullPointerException("this.contact is null"); //NOI18N
- } else if (this.getContact().getContactId() == null) {
- // Throw NPE again
- throw new NullPointerException("this.contact.contactId is null"); //NOI18N
- } else if (this.getContact().getContactId() < 1) {
- // Not valid
- throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N
- }
-
- // Set all phone instances
- this.setPhoneInstances(this.getContact());
-
- // Set all fields: user
- this.adminContactController.copyContactToController(this.getContact());
-
- // Log message
- //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - EXIT!"); //NOI18N
- }
-
- @Override
- public void copyUserToController () {
- // Log message
- //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N
-
- // Validate user instance
- if (this.getUser() == null) {
- // Throw NPE
- throw new NullPointerException("this.user is null"); //NOI18N
- } else if (this.getUser().getUserId() == null) {
- // Throw NPE again
- throw new NullPointerException("this.user.userId is null"); //NOI18N
- } else if (this.getUser().getUserId() < 1) {
- // Not valid
- throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
- }
-
- // Get contact
- Contact userContact = this.getUser().getUserContact();
-
- // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs.
- this.setContact(userContact);
-
- // Set all phone instances
- this.setPhoneInstances(userContact);
-
- // Set all fields: user
- this.userController.setUserName(this.getUser().getUserName());
-
- // Log message
- //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N
- }
-
- @Override
- public Contact getContact () {
- return this.contact;
- }
-
- @Override
- public void setContact (final Contact contact) {
- this.contact = contact;
- }
-
- @Override
- public String getContactUsageMessageKey (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 key is "unused"
- String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
-
- // Check user
- boolean isUserContact = this.userController.isContactFound(contact);
-
- // Check user first
- if (isUserContact) {
- // Only user
- messageKey = "CONTACT_IS_USER"; //NOI18N
- }
-
- // Return message key
- return messageKey;
- }
-
- @Override
- public User getUser () {
- return this.user;
- }
-
- @Override
- public void setUser (final User user) {
- this.user = user;
- }
-
- /**
- * Set's all given contact's phone instances: land-line, cellphone and fax
- * <p>
- * @param contact Contact to set phone instances for
- */
- private void setPhoneInstances (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
- }
-
- // Is cellphone set?
- if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
- // Yes, then set it in admin controller
- this.adminPhoneController.setCellPhone(contact.getContactMobileNumber());
- }
-
- // Is land-line set?
- if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
- // Yes, then set it in admin controller
- this.adminPhoneController.setLandLine(contact.getContactLandLineNumber());
- }
-
- // Is fax set?
- if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
- // Yes, then set it in admin controller
- this.adminPhoneController.setFax(contact.getContactFaxNumber());
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.localization;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Observes;
-import javax.faces.context.FacesContext;
-import javax.inject.Named;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.logout.ObserveableUserLogoutEvent;
-
-/**
- * A session bean for handling localization/internationalization changes. This
- * class is based on an example at [1] from mkyong.
- * <p>
- * 1: http://www.mkyong.com/jsf2/jsf-2-internationalization-example/
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("localizationController")
-@SessionScoped
-public class AddressbookLocalizationSessionBean extends BaseAddressbookController implements AddressbookLocalizationSessionController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 158_768_216_759_107L;
-
- /**
- * Current Locale
- */
- private Locale locale;
-
- @Override
- public void afterUserLogin (@Observes final UserLoggedInEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("LandingLocalizationSessionBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
-
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLoggedInUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.loggedInUser is null"); //NOI18N
- } else if (event.getLoggedInUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
- } else if (event.getLoggedInUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
- }
-
- // Set locale here
- this.setLocale(event.getLoggedInUser().getUserLocale());
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("LandingLocalizationSessionBean:afterUserLogin - EXIT!"); //NOI18N
- }
-
- @Override
- public void afterUserLogout (@Observes final ObserveableUserLogoutEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ReportsLocalizationSessionBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
-
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLoggedOutUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.loggedOutUser is null"); //NOI18N
- } else if (event.getLoggedOutUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.loggedOutUser.userId is null"); //NOI18N
- } else if (event.getLoggedOutUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedOutUser(), event.getLoggedOutUser().getUserId())); //NOI18N
- }
-
- // Clear this bean as well
- this.clear();
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("ReportsLocalizationSessionBean:afterUserLogin - EXIT!"); //NOI18N
- }
-
- @Override
- public String getLanguage () {
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AddressbookLocalizationSessionBean::getLanguage(): locale.language={0} - EXIT!", this.getLocale().getLanguage())); //NOI18N
- return this.getLocale().getLanguage().toLowerCase();
- }
-
- @Override
- public void setLanguage (final String language) {
- // Log trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AddressbookLocalizationSessionBean::setLanguage: language={0} - CALLED!", language)); //NOI18N
-
- // Is the language null?
- if (null == language) {
- // This may sometimes happen, so abort here
- return;
- }
-
- // Language splits
- String[] splits = language.split("_"); //NOI18N
- if (null == splits[1]) {
- splits[1] = ""; //NOI18N
- }
-
- // Get new locale with upper-case country code
- Locale loc = new Locale(splits[0], splits[1]);
-
- // Log debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AddressbookLocalizationSessionBean::setLanguage: loc={0}", loc)); //NOI18N
- // Set it here and in the JSF context
- this.setLocale(loc);
- FacesContext.getCurrentInstance().getViewRoot().setLocale(loc);
-
- // Log trace message
- //* NOISY-DEBUG: */ System.out.println("AddressbookLocalizationSessionBean::setLanguage: EXIT!"); //NOI18N
- }
-
- @Override
- public Locale getLocale () {
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AddressbookLocalizationSessionBean::getLocale(): locale={0} - EXIT!", this.locale)); //NOI18N
- return this.locale;
- }
-
- @Override
- public void setLocale (final Locale locale) {
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AddressbookLocalizationSessionBean::setLocale(): locale={0} - CALLED!", locale)); //NOI18N
- this.locale = locale;
- }
-
- @Override
- public Locale[] getSelectableLocalizations () {
- Locale[] locales = {
- Locale.GERMANY,
- Locale.US
- };
- return locales;
- }
-
- /**
- * Initializer for this bean
- */
- @PostConstruct
- public void init () {
- // Log trace message
- //* NOISY-DEBUG: */ System.out.println("AddressbookLocalizationSessionBean::init: CALLED!"); //NOI18N
-
- // Create locale instance from context
- Locale loc = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
-
- // Log debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AddressbookLocalizationSessionBean::init: loc={0}", loc)); //NOI18N
- // Set it here
- this.setLocale(loc);
-
- // Log trace message
- //* NOISY-DEBUG: */ System.out.println("AddressbookLocalizationSessionBean::init: EXIT!"); //NOI18N
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all fields
- this.setLanguage(null);
- this.setLocale(null);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.localization;
-
-import java.io.Serializable;
-import java.util.Locale;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.logout.ObserveableUserLogoutEvent;
-
-/**
- * An interface for localization change beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookLocalizationSessionController extends Serializable {
-
- /**
- * Event observer for logged-in user
- * <p>
- * @param event Event instance
- */
- void afterUserLogin (final UserLoggedInEvent event);
-
- /**
- * Event observer for logged-out user
- * <p>
- * @param event Event instance
- */
- void afterUserLogout (final ObserveableUserLogoutEvent event);
-
- /**
- * Getter for locale
- * <p>
- * @return Locale
- */
- Locale getLocale ();
-
- /**
- * Setter for locale
- * <p>
- * @param locale Locale
- */
- void setLocale (final Locale locale);
-
- /**
- * Getter for language code
- * <p>
- * @return Language code
- */
- String getLanguage ();
-
- /**
- * Setter for language code
- * <p>
- * @param language Language code
- */
- void setLanguage (final String language);
-
- /**
- * Getter for selectable localizations
- * <p>
- * @return Selectable localizations
- */
- Locale[] getSelectableLocalizations ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.login;
-
-import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.faces.context.FacesContext;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
-import org.mxchange.jusercore.container.login.LoginContainer;
-import org.mxchange.jusercore.container.login.UserLoginContainer;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.login.UserLoginEvent;
-import org.mxchange.jusercore.events.logout.ObserveableUserLogoutEvent;
-import org.mxchange.jusercore.events.logout.UserLogoutEvent;
-import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
-import org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserUtils;
-import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
-import org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-
-/**
- * A web bean for user registration
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("loginController")
-@SessionScoped
-public class AddressbookUserLoginWebSessionBean extends BaseAddressbookController implements AddressbookUserLoginWebSessionController {
-
- /**
- * Path name for guest base template
- */
- private static final String GUEST_BASE_TEMPLATE_NAME = "guest/guest"; //NOI18N
-
- /**
- * Path name for logged-in user base template
- */
- private static final String USER_BASE_TEMPLATE_NAME = "login/user/user"; //NOI18N
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 47_828_986_719_691_592L;
-
- /**
- * Template type for pages that might be displayed in guest area and login
- * area.
- */
- private String baseTemplatePathName;
-
- /**
- * Current password
- */
- private String currentPassword;
-
- /**
- * Logged-in user instance
- */
- private User loggedInUser;
-
- /**
- * User controller
- */
- @Inject
- private AddressbookUserWebSessionController userController;
-
- /**
- * Flag whether the user has logged-in, set only from inside
- */
- private boolean userLoggedIn;
-
- /**
- * EJB for user-login
- */
- private UserLoginSessionBeanRemote userLoginBean;
-
- /**
- * Event fired when user has logged in
- */
- @Inject
- @Any
- private Event<UserLoggedInEvent> userLoginEvent;
-
- /**
- * Event fired when user has logged out
- */
- @Inject
- @Any
- private Event<ObserveableUserLogoutEvent> userLogoutEvent;
-
- /**
- * User's password history
- */
- private List<PasswordHistory> userPasswordHistory;
-
- /**
- * EJB for user's password history
- */
- private UserPasswordHistorySessionBeanRemote userPasswordHistoryBean;
-
- /**
- * Default constructor
- */
- public AddressbookUserLoginWebSessionBean () {
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userLoginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/addressbook-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
-
- // Also find this
- this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/addressbook-ejb/userPasswordHistory!org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote"); //NOI18N
-
- // Defaul template is guest
- this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
- } catch (final NamingException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
- }
-
- @Override
- public void afterUserUpdatedPasswordEvent (@Observes final UpdatedUserPasswordEvent 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
- }
-
- // All fine, so update list
- this.updatePasswordHistory(event.getPasswordHistory());
- }
-
- @Override
- public String doAdminLogout () {
- // Is a user logged-in?
- if (this.isUserLoggedIn()) {
- // Call other logout
- return this.doUserLogout();
- }
-
- // Invalidate session
- FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
-
- // Set template type to guest
- this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
-
- // Redirect to index
- return "index?faces-redirect=true"; //NOI18N
- }
-
- @Override
- public String doUserLogin () {
- // Get user instance
- User user = this.userController.createUserLogin();
-
- // Create login container
- LoginContainer container = new UserLoginContainer(user, this.userController.getUserPassword());
-
- try {
- // Call bean
- User confirmedUser = this.userLoginBean.validateUserAccountStatus(container);
-
- // All fine here so set it here
- this.setLoggedInUser(confirmedUser);
-
- // Retrieve user's password list
- this.userPasswordHistory = this.userPasswordHistoryBean.getUserPasswordHistory(confirmedUser);
-
- // Set template to "login"
- this.setBaseTemplatePathName(USER_BASE_TEMPLATE_NAME); //NOI18N
-
- // Fire event away. Keep this last before return statement.
- this.userLoginEvent.fire(new UserLoginEvent(confirmedUser));
-
- // Clear this bean
- this.clear();
-
- // All fine
- return "login"; //NOI18N
- } catch (final UserNotFoundException | UserStatusLockedException | UserStatusUnconfirmedException ex) {
- // Show JSF message
- this.showFacesMessage("form_user_login:userName", ex); //NOI18N
- return ""; //NOI18N
- } catch (final UserPasswordMismatchException ex) {
- // Show JSF message
- this.showFacesMessage("form_user_login:userPassword", ex); //NOI18N
- return ""; //NOI18N
- }
- }
-
- @Override
- public String doUserLogout () {
- // Is loggedInUser set?
- if (this.getLoggedInUser() == null) {
- // Throw NPE
- throw new NullPointerException("this.loggedInUser is null"); //NOI18N
- } else if (this.getLoggedInUser().getUserId() == null) {
- // Throw again
- throw new NullPointerException("this.loggedInUser.userId is null"); //NOI18N
- } else if (this.getLoggedInUser().getUserId() < 1) {
- // Invalid user id
- throw new IllegalStateException(MessageFormat.format("this.loggedInUser.userId={0} is not valid.", this.getLoggedInUser().getUserId())); //NOI18N
- }
-
- // Fire event
- this.userLogoutEvent.fire(new UserLogoutEvent(this.getLoggedInUser()));
-
- // Invalidate session
- FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
-
- // Unset any user instances
- this.setLoggedInUser(null);
- this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
-
- // Redirect to index
- return "index"; //NOI18N
- }
-
- @Override
- public String getBaseTemplatePathName () {
- return this.baseTemplatePathName;
- }
-
- @Override
- public void setBaseTemplatePathName (final String baseTemplatePathName) {
- this.baseTemplatePathName = baseTemplatePathName;
- }
-
- @Override
- public String getCurrentPassword () {
- return this.currentPassword;
- }
-
- @Override
- public void setCurrentPassword (final String currentPassword) {
- this.currentPassword = currentPassword;
- }
-
- @Override
- public User getLoggedInUser () {
- return this.loggedInUser;
- }
-
- @Override
- public void setLoggedInUser (final User loggedInUser) {
- this.loggedInUser = loggedInUser;
- }
-
- @Override
- public List<PasswordHistory> getUserPasswordHistory () {
- return Collections.unmodifiableList(this.userPasswordHistory);
- }
-
- @Override
- public boolean ifCurrentPasswordMatches () {
- // The current password must be set and not empty
- if (this.getCurrentPassword() == null) {
- // Is not set
- throw new NullPointerException("this.currentPassword is null"); //NOI18N
- } else if (this.getCurrentPassword().isEmpty()) {
- // Is set empty
- throw new IllegalStateException("this.currentPassword is empty."); //NOI18N
- }
-
- // Create "container"
- LoginContainer container = new UserLoginContainer(this.getLoggedInUser(), this.getCurrentPassword());
-
- // Now check if it matches
- return UserUtils.ifPasswordMatches(container, this.getLoggedInUser());
- }
-
- @Override
- public boolean ifUserMustChangePassword () {
- return (this.isUserLoggedIn() && this.getLoggedInUser().getUserMustChangePassword());
- }
-
- @Override
- public boolean isInvisible () {
- // Check on login
- if (!this.isUserLoggedIn()) {
- // Not logged in!
- throw new IllegalStateException("isInvisible() has been invoked for a guest."); //NOI18N
- }
-
- // Check logged-in first, then invisibility
- return this.getLoggedInUser().getUserProfileMode().equals(ProfileMode.INVISIBLE);
- }
-
- @Override
- public boolean isPasswordInHistory (final String userPassword) {
- // Default is not found
- boolean isPasswordInHistory = false;
-
- // Init variables
- int count = 1;
- int maxEntries = this.getIntegerContextParameter("max_user_password_history"); //NOI18N
-
- // Check all passwords
- for (final PasswordHistory entry : this.getUserPasswordHistory()) {
- // Is password the same?
- if (UserUtils.ifPasswordMatches(userPassword, entry.getUserPasswordHistoryUser())) {
- // Yes, found it
- isPasswordInHistory = true;
- break;
- } else if (count == maxEntries) {
- // Maximum reached
- break;
- }
-
- // Count up
- count++;
- }
-
- // Return status
- return isPasswordInHistory;
- }
-
- @Override
- public boolean isUserLoggedIn () {
- this.userLoggedIn = ((this.getLoggedInUser() instanceof User) && (Objects.equals(this.getLoggedInUser().getUserAccountStatus(), UserAccountStatus.CONFIRMED)));
-
- // Return it
- return this.userLoggedIn;
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all fields
- this.setCurrentPassword(null);
- }
-
- /**
- * Updates password history by adding given entry to it as long as it is not
- * there.
- * <p>
- * @param passwordHistory Password history entry
- */
- private void updatePasswordHistory (final PasswordHistory passwordHistory) {
- if (null == passwordHistory) {
- // Throw NPE
- throw new NullPointerException("passwordHistory is null"); //NOI18N
- } else if (passwordHistory.getUserPasswordHistoryId() == null) {
- // Throw NPE again
- throw new NullPointerException("passwordHistory.userPasswordHistoryId is null"); //NOI18N
- } else if (passwordHistory.getUserPasswordHistoryId() < 1) {
- // Invalid id
- throw new IllegalArgumentException(MessageFormat.format("passwordHistory.userPasswordHistoryId={0} is not valid.", passwordHistory.getUserPasswordHistoryId())); //NOI18N
- }
-
- // Is it there?
- if (this.userPasswordHistory.contains(passwordHistory)) {
- // Excact copy found
- return;
- }
-
- // Check all entries
- for (final PasswordHistory entry : this.userPasswordHistory) {
- // Is same id number?
- if (Objects.equals(entry.getUserPasswordHistoryId(), passwordHistory.getUserPasswordHistoryId())) {
- // Found it
- return;
- }
- }
-
- // Not found, so add it
- this.userPasswordHistory.add(passwordHistory);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.login;
-
-import java.io.Serializable;
-import java.util.List;
-import javax.ejb.Local;
-import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
-
-/**
- * An interface for registration web controllers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Local
-public interface AddressbookUserLoginWebSessionController extends Serializable {
-
- /**
- * Method being call after user's password has been updated (and history
- * entry has been created).
- * <p>
- * @param event Event being observed
- */
- void afterUserUpdatedPasswordEvent (final UpdatedUserPasswordEvent event);
-
- /**
- * Checks whether given clear-text password is in user's password history.
- * <p>
- * @param userPassword Clear-text password
- * <p>
- * @return Whether clear-text password is in user's password history
- */
- boolean isPasswordInHistory (final String userPassword);
-
- /**
- * Getter for template type
- * <p>
- * @return Template type
- */
- String getBaseTemplatePathName ();
-
- /**
- * Setter for template type
- * <p>
- * @param baseTemplatePathName Template type
- */
- void setBaseTemplatePathName (final String baseTemplatePathName);
-
- /**
- * Logout for administrator area. If a logged-in user instance exists, it is
- * being logged-out, too.
- * <p>
- * @return Outcome (should be redirected)
- */
- String doAdminLogout ();
-
- /**
- * Logins the user, if the account is found, confirmed and unlocked.
- * <p>
- * @return Redirect target
- */
- String doUserLogin ();
-
- /**
- * Logout for current user by invalidating the current session.
- * <p>
- * @return Outcome (should be redirected)
- */
- String doUserLogout ();
-
- /**
- * Getter for logged-in user instance
- * <p>
- * @return Logged-in user instance
- */
- User getLoggedInUser ();
-
- /**
- * Setter for logged-in user instance
- * <p>
- * @param loggedInUser Logged-in user instance
- */
- void setLoggedInUser (final User loggedInUser);
-
- /**
- * Checks whether the user is logged-in
- * <p>
- * @return Whether the user is logged-in
- */
- boolean isUserLoggedIn ();
-
- /**
- * Checks whether the user needs to change password
- * <p>
- * @return Whether the user needs to change password
- */
- boolean ifUserMustChangePassword ();
-
- /**
- * Whether the currently logged-in user is invisible
- * <p>
- * @return Whether the currently logged-in user is invisible
- */
- boolean isInvisible ();
-
- /**
- * Setter for current password (clear text)
- * <p>
- * @param currentPassword Current password
- */
- void setCurrentPassword (final String currentPassword);
-
- /**
- * Getter for current password (clear text)
- * <p>
- * @return Current password
- */
- String getCurrentPassword ();
-
- /**
- * Checks whether the (previously entered) current password matches with
- * from the user instance.
- * <p>
- * @return If current password matches
- */
- boolean ifCurrentPasswordMatches ();
-
- /**
- * Getter for user's password history
- * <p>
- * @return User's password history
- */
- List<PasswordHistory> getUserPasswordHistory ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.mobileprovider;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
-import org.mxchange.jphone.events.mobileprovider.added.AdminMobileProviderAddedEvent;
-import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
-import org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote;
-import org.mxchange.jphone.phonenumbers.mobileprovider.CellphoneProvider;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-
-/**
- * Administrative bean (controller) for mobile provider
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminMobileProviderController")
-@RequestScoped
-public class AddressbookAdminMobileProviderWebRequestBean extends BaseAddressbookController implements AddressbookAdminMobileProviderWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 184_598_175_371_269_016L;
-
- /**
- * Remote EJB for mobile providers (administrative)
- */
- private AdminMobileProviderSessionBeanRemote adminRemoteBean;
-
- /**
- * Regular bean
- */
- @Inject
- private AddressbookMobileProviderWebRequestController mobileController;
-
- /**
- * Event being fired when the mobile provider was added
- */
- @Inject
- @Any
- private Event<AdminAddedMobileProviderEvent> providerAddedEvent;
-
- /**
- * Country instance ('s dial data)
- */
- private Country providerCountry;
-
- /**
- * Provider dial prefix (example: 0177 for German E+)
- */
- private Long providerDialPrefix;
-
- /**
- * Pattern for mail gateway
- */
- private String providerMailPattern;
-
- /**
- * Name of the provider
- */
- private String providerName;
-
- /**
- * Default constructor
- */
- public AddressbookAdminMobileProviderWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the beans
- this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminmobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw it again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public String addMobileProvider () {
- // Create mobile provider instance
- MobileProvider mobileProvider = new CellphoneProvider(this.getProviderDialPrefix(), this.getProviderName(), this.getProviderCountry(), this.getProviderMailPattern());
-
- // Is the provider already created?
- if (this.isMobileProviderCreated(mobileProvider)) {
- // Then throw exception
- this.showFacesMessage("form_add_mobile_provider:providerDialPrefix", new MobileProviderAlreadyAddedException(mobileProvider)); //NOI18N
- return ""; //NOI18N
- }
-
- // Init variable
- MobileProvider updatedProvider = null;
-
- try {
- // Call remote EJB and get back an updated instance
- updatedProvider = this.adminRemoteBean.addMobileProvider(mobileProvider);
- } catch (final MobileProviderAlreadyAddedException ex) {
- // Throw again
- throw new FaceletException(ex);
- }
-
- // Fire event
- this.providerAddedEvent.fire(new AdminMobileProviderAddedEvent(updatedProvider));
-
- // Redirect to list
- return "admin_list_mobile_provider"; //NOI18N
- }
-
- @Override
- public Country getProviderCountry () {
- return this.providerCountry;
- }
-
- @Override
- public void setProviderCountry (final Country providerCountry) {
- this.providerCountry = providerCountry;
- }
-
- @Override
- public Long getProviderDialPrefix () {
- return this.providerDialPrefix;
- }
-
- @Override
- public void setProviderDialPrefix (final Long providerDialPrefix) {
- this.providerDialPrefix = providerDialPrefix;
- }
-
- @Override
- public String getProviderMailPattern () {
- return this.providerMailPattern;
- }
-
- @Override
- public void setProviderMailPattern (final String providerMailPattern) {
- this.providerMailPattern = providerMailPattern;
- }
-
- @Override
- public String getProviderName () {
- return this.providerName;
- }
-
- @Override
- public void setProviderName (final String providerName) {
- this.providerName = providerName;
- }
-
- /**
- * Checks whether if the given mobile provider is already created by
- * checking both dial prefix and country.
- * <p>
- * @param mobileProvider Mobile provider instance to check
- * <p>
- * @return Whether the given mobile provider instance is found
- */
- private boolean isMobileProviderCreated (final MobileProvider mobileProvider) {
- // Default is not found
- boolean isFound = false;
-
- // Get list of all providers
- List<MobileProvider> providers = this.mobileController.allMobileProvider();
-
- // Get iterator from it
- Iterator<MobileProvider> iterator = providers.iterator();
-
- // Loop through all
- while (iterator.hasNext()) {
- // Get next element
- MobileProvider next = iterator.next();
-
- // Is the provider's dial prefix and country the same?
- if ((Objects.equals(mobileProvider.getProviderDialPrefix(), next.getProviderDialPrefix())) && (Objects.equals(mobileProvider.getProviderCountry(), next.getProviderCountry()))) {
- // Is the same, abort loop
- isFound = true;
- break;
- }
- }
-
- // Return result
- return isFound;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.mobileprovider;
-
-import java.io.Serializable;
-import org.mxchange.jcountry.data.Country;
-
-/**
- * An interface for a request web controller (bean) for administrative mobile
- * provider purposes.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookAdminMobileProviderWebRequestController extends Serializable {
-
- /**
- * Adds a mobile provider to database by calling the EJB. A pre-check on
- * dial-prefix and country combination is done, if found, an exception is
- * thrown. A redirect should take place after successfull creation.
- * <p>
- * @return Redirect outcome
- */
- String addMobileProvider ();
-
- /**
- * Getter for provider dial prefix
- * <p>
- * @return Provider dial prefix
- */
- Long getProviderDialPrefix ();
-
- /**
- * Setter for provider dial prefix
- * <p>
- * @param providerDialPrefix Provider dial prefix
- */
- void setProviderDialPrefix (final Long providerDialPrefix);
-
- /**
- * Getter for provider name
- * <p>
- * @return Provider name
- */
- String getProviderName ();
-
- /**
- * Setter for provider name
- * <p>
- * @param providerName Provider name
- */
- void setProviderName (final String providerName);
-
- /**
- * Getter for country instance ('s dial data)
- * <p>
- * @return Country instance
- */
- Country getProviderCountry ();
-
- /**
- * Setter for country instance ('s dial data)
- * <p>
- * @param country Country instance
- */
- void setProviderCountry (final Country country);
-
- /**
- * Getter for pattern for mail gateway
- * <p>
- * @return Pattern for mail gateway
- */
- String getProviderMailPattern ();
-
- /**
- * Setter for pattern for mail gateway
- * <p>
- * @param providerMailPattern Pattern for mail gateway
- */
- void setProviderMailPattern (final String providerMailPattern);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.mobileprovider;
-
-import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Observes;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
-
-/**
- * A general bean for mobile providers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("mobileProviderController")
-@SessionScoped
-public class AddressbookMobileProviderWebRequestBean extends BaseAddressbookController implements AddressbookMobileProviderWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 15_869_423_671_950_276L;
-
- /**
- * "Cached" list of mobile providers
- */
- private List<MobileProvider> mobileProviders;
-
- /**
- * Remote EJB for mobile providers (regular)
- */
- private MobileProviderSingletonBeanRemote mobileRemoteBean;
-
- /**
- * Default constructor
- */
- public AddressbookMobileProviderWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the beans
- this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/addressbook-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw it again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public void afterAdminAddedMobileProvider (@Observes final AdminAddedMobileProviderEvent event) {
- // Is all valid?
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getAddedMobileProvider()== null) {
- // Throw again ...
- throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N
- } else if (event.getAddedMobileProvider().getProviderId()== null) {
- // And again ...
- throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N
- } else if (event.getAddedMobileProvider().getProviderId() < 1) {
- // Id is invalid
- throw new IllegalArgumentException(MessageFormat.format("event.addedMobileProvider.providerId={0} is not valid.", event.getAddedMobileProvider().getProviderId())); //NOI18N
- }
-
- // Add it to the list
- this.mobileProviders.add(event.getAddedMobileProvider());
- }
-
- @Override
- public List<MobileProvider> allMobileProvider () {
- return Collections.unmodifiableList(this.mobileProviders);
- }
-
- @Override
- public boolean hasMobileProvider () {
- return (!this.mobileProviders.isEmpty());
- }
-
- /**
- * Initializer method
- */
- @PostConstruct
- public void init () {
- // Init list of mobile providers
- this.mobileProviders = this.mobileRemoteBean.allMobileProvider();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.mobileprovider;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-
-/**
- * An interface for general mobile provider controller
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookMobileProviderWebRequestController extends Serializable {
-
- /**
- * Returns a list of all mobile providers
- * <p>
- * @return A list of all mobile providers
- */
- List<MobileProvider> allMobileProvider ();
-
- /**
- * Checks whether mobile providers are registered
- * <p>
- * @return Whether mobile providers are registered
- */
- boolean hasMobileProvider ();
-
- /**
- * Observes events being fired after the administrator has added a new
- * mobile provider
- * <p>
- * @param event Event being fired
- */
- void afterAdminAddedMobileProvider (final AdminAddedMobileProviderEvent event);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.phone;
-
-import javax.enterprise.context.RequestScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-
-/**
- * Administrative bean (controller) for phone numbers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminPhoneController")
-@RequestScoped
-public class AddressbookAdminPhoneWebRequestBean extends BaseAddressbookController implements AddressbookAdminPhoneWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 184_598_175_371_269_016L;
-
- /**
- * Remote EJB for phone number (administrative)
- */
- private AdminContactsPhoneSessionBeanRemote adminPhoneBean;
-
- /**
- * Cell phone number
- */
- private DialableMobileNumber cellPhone;
-
- /**
- * Fax number
- */
- private DialableFaxNumber fax;
-
- /**
- * Land-line number
- */
- private DialableLandLineNumber landLine;
-
- /**
- * Default constructor
- */
- public AddressbookAdminPhoneWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup the beans
- this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/admincontactphone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw it again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public DialableMobileNumber getMobileNumber () {
- return this.cellPhone;
- }
-
- @Override
- public void setCellPhone (final DialableMobileNumber cellPhone) {
- this.cellPhone = cellPhone;
- }
-
- @Override
- public DialableFaxNumber getFax () {
- return this.fax;
- }
-
- @Override
- public void setFax (final DialableFaxNumber fax) {
- this.fax = fax;
- }
-
- @Override
- public DialableLandLineNumber getLandLine () {
- return this.landLine;
- }
-
- @Override
- public void setLandLine (final DialableLandLineNumber landLine) {
- this.landLine = landLine;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.phone;
-
-import java.io.Serializable;
-import javax.ejb.Local;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-
-/**
- * An interface for a request web controller (bean) for administrative phone
- * number purposes.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Local
-public interface AddressbookAdminPhoneWebRequestController extends Serializable {
-
- /**
- * Setter for dialable cellphone number instance
- * <p>
- * @param cellPhone Dialable cellphone number instance
- */
- void setCellPhone (final DialableMobileNumber cellPhone);
-
- /**
- * Getter for dialable cellphone number instance
- * <p>
- * @return Dialable cellphone number instance
- */
- DialableMobileNumber getMobileNumber ();
-
- /**
- * Setter for dialable land-line number instance
- * <p>
- * @param landLine Dialable land-line number instance
- */
- void setLandLine (final DialableLandLineNumber landLine);
-
- /**
- * Getter for dialable land-line number instance
- * <p>
- * @return Dialable land-line number instance
- */
- DialableLandLineNumber getLandLine ();
-
- /**
- * Setter for dialable fax number instance
- * <p>
- * @param fax Dialable fax number instance
- */
- void setFax (final DialableFaxNumber fax);
-
- /**
- * Getter for dialable fax number instance
- * <p>
- * @return Dialable fax number instance
- */
- DialableFaxNumber getFax ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.profile;
-
-import java.text.MessageFormat;
-import javax.enterprise.context.RequestScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
-import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-
-/**
- * A web request bean for user profiles
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named (value = "profileController")
-@RequestScoped
-public class AddressbookUserProfileWebRequestBean extends BaseAddressbookController implements AddressbookUserProfileWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 187_687_145_286_710L;
-
- /**
- * Login controller
- */
- @Inject
- private AddressbookUserLoginWebSessionController loginController;
-
- /**
- * User controller
- */
- @Inject
- private AddressbookUserWebSessionController userController;
-
- @Override
- public boolean isProfileLinkVisibleById (final Long userId) {
- // Init user instance
- User user = null;
-
- try {
- // Try to get it
- user = this.userController.lookupUserById(userId);
- } catch (final UserNotFoundException ex) {
- // Throw again
- throw new FaceletException(ex);
- }
-
- // Is it null?
- if (null == user) {
- // Not found, not visible.
- return false;
- }
-
- // Ask other method
- return this.isProfileLinkVisibleByUser(user);
- }
-
- @Override
- public boolean isProfileLinkVisibleByUser (final User user) {
- // Check on user
- if (null == user) {
- /*
- * Not set, means wrong invocation of this method as the user
- * instance needs to be set first.
- */
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- /*
- * If the id number is not set it means that the user instance has
- * not been persisted and the JPA has not been flushed. Or a
- * "virgin" instance (e.g. from registration) has been used.
- */
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- /*
- * The id number is set invalid for an unknown reason.
- */
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
- } else if (user.getUserProfileMode() == null) {
- /*
- * Possibly an out-dated user profile is being used. This should not
- * happen.
- */
- throw new NullPointerException("user.userProfileMode is null"); //NOI18N
- }
-
- // Get profile mode from user instance (safe now)
- ProfileMode profileMode = user.getUserProfileMode();
-
- // Check all conditions (except for admin)
- return ((profileMode.equals(ProfileMode.PUBLIC)) ||
- (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS)));
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.profile;
-
-import java.io.Serializable;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A bean interface for user profiles
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookUserProfileWebRequestController extends Serializable {
-
- /**
- * Checks if the user profile link is visible
- * <p>
- * @param userId User id
- * <p>
- * @return Whether the profile link is visible
- */
- boolean isProfileLinkVisibleById (final Long userId);
-
- /**
- * Checks if given user's profile is visible
- * <p>
- * @param user User instance to check
- * <p>
- * @return Whether the user's profile is visible
- */
- boolean isProfileLinkVisibleByUser (final User user);
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.profilemode;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Named;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-
-/**
- * A profile mode bean
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("profileMode")
-@ApplicationScoped
-public class AddressbookProfileModeWebApplicationBean extends BaseAddressbookController implements AddressbookProfileModeWebApplicationController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 835_482_364_189L;
-
- /**
- * Default constructor
- */
- public AddressbookProfileModeWebApplicationBean () {
- }
-
- @Override
- public ProfileMode[] getAllProfileModes () {
- // Return it
- return ProfileMode.values();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.profilemode;
-
-import java.io.Serializable;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-
-/**
- * An interface for data beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookProfileModeWebApplicationController extends Serializable {
-
- /**
- * Getter for all genders as array
- * <p>
- * @return All genders as array
- */
- ProfileMode[] getAllProfileModes ();
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.register;
-
-import java.text.MessageFormat;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
-import org.mxchange.addressbook.beans.features.AddressbookFeaturesWebApplicationController;
-import org.mxchange.addressbook.beans.user.AddressbookAdminUserWebRequestController;
-import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.UserContact;
-import org.mxchange.jcoreee.utils.FacesUtils;
-import org.mxchange.jusercore.events.registration.RegisteredUserEvent;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
-import org.mxchange.jusercore.exceptions.DataRepeatMismatchException;
-import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
-import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
-import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserUtils;
-import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-
-/**
- * A web bean for user registration
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("registerController")
-@SessionScoped
-public class AddressbookUserRegisterWebSessionBean extends BaseAddressbookController implements AddressbookUserRegisterWebSessionController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 47_828_986_719_691_592L;
-
- /**
- * Administrative user controller
- */
- @Inject
- private AddressbookAdminUserWebRequestController adminUserController;
-
- /**
- * Contact controller
- */
- @Inject
- private AddressbookContactWebSessionController contactController;
-
- /**
- * Features controller
- */
- @Inject
- private AddressbookFeaturesWebApplicationController featureController;
-
- /**
- * Reemote register session bean
- */
- private UserRegistrationSessionBeanRemote registerBean;
-
- /**
- * An en event fireable when a new user has registered
- */
- @Inject
- @Any
- private Event<UserRegisteredEvent> registeredEvent;
-
- /**
- * User controller
- */
- @Inject
- private AddressbookUserWebSessionController userController;
-
- /**
- * Default constructor
- */
- public AddressbookUserRegisterWebSessionBean () {
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.registerBean = (UserRegistrationSessionBeanRemote) context.lookup("java:global/addressbook-ejb/register!org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
- }
-
- @Override
- public String doFinishRegistration () {
- // Is registration enabled?
- if (!this.featureController.isFeatureEnabled("user_registration")) { //NOI18N
- // Is not enabled
- throw new FaceletException("Registration is disabled."); //NOI18N
- }
-
- // Get user instance
- User user = this.userController.createUserInstance(true);
-
- // Is the user already used?
- if (null == user) {
- // user must be set
- throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
- } 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_name_required")) && (this.userController.isUserNameRegistered(user))) { //NOI18N
- // User name is already used
- throw new FaceletException(new UserNameAlreadyRegisteredException(user));
- } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
- // Email address has already been taken
- throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
- } else if (!this.contactController.isSameEmailAddressEntered()) {
- // Not same email address entered
- throw new FaceletException(new DataRepeatMismatchException(MessageFormat.format("Email addresses not matching: {0} != {1}", this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat()))); //NOI18N
- } else if (!this.userController.isSamePasswordEntered()) {
- // Not same password entered
- throw new FaceletException(new DataRepeatMismatchException("Passwords not matching.")); //NOI18N
- }
-
- // Encrypt password
- String encryptedPassword = UserUtils.encryptPassword(this.userController.getUserPassword());
-
- // Set it here
- user.setUserEncryptedPassword(encryptedPassword);
-
- // Is developer mode?
- if (this.isDebugModeEnabled("register")) { //NOI18N
- // For debugging/programming only:
- user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
- } else {
- // No debugging of this part
- user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
-
- // Ask EJB for generating a not-existing confirmation key
- String confirmKey = this.registerBean.generateConfirmationKey(user);
-
- // Set it in user
- user.setUserConfirmKey(confirmKey);
- }
-
- try {
- // Get base URL
- String baseUrl = FacesUtils.generateBaseUrl();
-
- // Call bean
- User registeredUser = this.registerBean.registerUser(user, baseUrl);
-
- // The id number should be set
- assert (registeredUser.getUserId() instanceof Long) : "registeredUser.userId is null after registerUser() was called."; //NOI18N
-
- // Fire event
- this.registeredEvent.fire(new RegisteredUserEvent(registeredUser));
-
- // All fine, redirect to proper page
- return "register_done"; //NOI18N
- } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
- }
-
- @Override
- public String doRegisterMultiPage1 () {
- // Is registration enabled?
- if (!this.featureController.isFeatureEnabled("user_registration")) { //NOI18N
- // Is not enabled
- throw new FaceletException("Registration is disabled."); //NOI18N
- }
-
- // Get user instance
- User user = this.userController.createUserInstance(false);
-
- // First check if user is not null and user name is not used + if same email address is entered
- if (null == user) {
- // user must be set
- throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
- } else if ((this.featureController.isFeatureEnabled("user_name_required")) && (this.userController.isUserNameRegistered(user))) { //NOI18N
- // User name is already used
- throw new FaceletException(new UserNameAlreadyRegisteredException(user));
- } else if (!this.contactController.isSameEmailAddressEntered()) {
- // Not same email address entered
- throw new FaceletException(new DataRepeatMismatchException(MessageFormat.format("Email addresses not matching: {0} != {1}", this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat()))); //NOI18N
- }
-
- // Create half contact instance with email address
- Contact contact = new UserContact();
- contact.setContactEmailAddress(this.contactController.getEmailAddress());
-
- // Set contact in user
- user.setUserContact(contact);
-
- // Check if email address is registered
- if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
- // Email address has already been taken
- throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
- }
-
- // Now only redirect to next page as the JSF does it
- return "register_page2"; //NOI18N
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.register;
-
-import java.io.Serializable;
-
-/**
- * An interface for registration web controllers
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookUserRegisterWebSessionController extends Serializable {
-
- /**
- * Registers the user, if not found. Otherwise this method should throw an
- * exception.
- * <p>
- * @return Redirection target
- */
- String doFinishRegistration ();
-
- /**
- * Handles registration request send from first page. The (maybe) entered
- * user name and email address is not used and that privacy and T&C are
- * accepted.
- * <p>
- * @return Redirect
- */
- String doRegisterMultiPage1 ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.resendlink;
-
-import java.text.MessageFormat;
-import javax.enterprise.context.SessionScoped;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.localization.AddressbookLocalizationSessionController;
-import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController;
-import org.mxchange.jcoreee.utils.FacesUtils;
-import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
-import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-
-/**
- * A web session bean for resending confirmation link
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("resendController")
-@SessionScoped
-public class AddressbookResendLinkWebSessionBean extends BaseAddressbookController implements AddressbookResendLinkWebSessionController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 186_078_724_659_153L;
-
- /**
- * Email address
- */
- private String emailAddress;
-
- /**
- * EJB for resending confirmation link
- */
- private ResendLinkSessionBeanRemote emailBean;
-
- /**
- * Localization controller
- */
- @Inject
- private AddressbookLocalizationSessionController localizationController;
-
- /**
- * Regular user controller
- */
- @Inject
- private AddressbookUserWebSessionController userController;
-
- /**
- * Default constructor
- */
- public AddressbookResendLinkWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.emailBean = (ResendLinkSessionBeanRemote) context.lookup("java:global/addressbook-ejb/resendLink!org.mxchange.addressbook.beans.resendlink.ResendLinkSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public String doResendLink () {
- // The email address should not be empty as the JSF validates this
- if (this.getEmailAddress() == null) {
- // Throw NPE
- throw new NullPointerException("this.emailAddress is null"); //NOI18N
- }
-
- // Init user instance
- User user;
-
- try {
- // Is the email address really not used?
- user = this.userController.lookupUserByEmailAddress(this.getEmailAddress());
- } catch (final UserEmailAddressNotFoundException ex) {
- // Always clear bean
- this.clear();
-
- // Not found, should not happen as the registered validator should find it
- throw new FaceletException(MessageFormat.format("this.emailAddress={0} should be resolveable into User instance.", this.getEmailAddress()), ex); //NOI18N
- }
-
- // Is the user account already confirmed?
- if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
- // Always clear bean
- this.clear();
-
- // Then abort here
- this.showFacesMessage("form_resend_link:resendEmailAddress", new UserStatusConfirmedException(user)); //NOI18N
- return ""; //NOI18N
- } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
- // Always clear bean
- this.clear();
-
- // User account is locked
- this.showFacesMessage("form_resend_link:resendEmailAddress", new UserStatusLockedException(user)); //NOI18N
- return ""; //NOI18N
- } else if (user.getUserConfirmKey() == null) {
- // Status is UNCONFIRMED but confirmation key is NULL
- throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
- }
-
- // Get base URL
- String baseUrl = FacesUtils.generateBaseUrl();
-
- // Call EJB and return redirect target
- this.emailBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
-
- // Clear this bean
- this.clear();
-
- // Return redirect target
- return "resend_done"; //NOI18N
- }
-
- @Override
- public String getEmailAddress () {
- return this.emailAddress;
- }
-
- @Override
- public void setEmailAddress (final String emailAddress) {
- this.emailAddress = emailAddress;
- }
-
- /**
- * Clears email address fields so the user has to re-enter them
- */
- private void clear () {
- // Clear fields
- this.setEmailAddress(null);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.resendlink;
-
-import java.io.Serializable;
-
-/**
- * An interface for an email change controller
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookResendLinkWebSessionController extends Serializable {
-
- /**
- * Getter for email address 1 (changing)
- * <p>
- * @return Email address
- */
- String getEmailAddress ();
-
- /**
- * Setter for email address 1 (changing)
- * <p>
- * @param emailAddress Email address 1
- */
- void setEmailAddress (final String emailAddress);
-
- /**
- * Resends (new) confirmation link to given email address, if found.
- * Otherwise an exception is thrown. On success a redirect takes place.
- * <p>
- * @return Redirection target
- */
- String doResendLink ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.shares;
-
-import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
-import org.mxchange.addressbook.model.shared.SharedAddressbooksSessionBeanRemote;
-import org.mxchange.jaddressbookcore.events.sharing.AddressbookSharingEvent;
-import org.mxchange.jaddressbookcore.events.sharing.StartedAddressbookSharingEvent;
-import org.mxchange.jaddressbookcore.events.sharing.type.SharingType;
-import org.mxchange.jaddressbookcore.exceptions.UserAlreadySharingAddressbookException;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.shared.ShareableAddressbook;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-
-/**
- * A bean for sharing address books with other users
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named (value = "shareController")
-@SessionScoped
-public class AddressbookSharesWebSessionBean extends BaseAddressbookController implements AddressbookSharesWebSessionController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 19_868_976_871_976_780L;
-
- /**
- * Cached flag whether the user is sharing address books
- */
- private Boolean isUserSharing = null;
-
- /**
- * Login controller injection
- */
- @Inject
- private AddressbookUserLoginWebSessionController loginController;
-
- /**
- * Share instance
- */
- private ShareableAddressbook share;
-
- /**
- * Remote bean for sharing address books
- */
- private SharedAddressbooksSessionBeanRemote shareBean;
-
- /**
- * A list of all user's shared (with others) address books
- */
- private List<ShareableAddressbook> sharedAddressbooks;
-
- /**
- * User id of sharee
- */
- private Long shareeUserId;
-
- /**
- * An event triggered when address book sharing starts or ends
- */
- @Inject
- @Any
- private Event<AddressbookSharingEvent> sharingEvent;
-
- /**
- * Default constructor
- */
- public AddressbookSharesWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Look up bean
- this.shareBean = (SharedAddressbooksSessionBeanRemote) context.lookup("ejb/stateless-addressbook-share"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw
- throw new FaceletException(ex);
- }
- }
-
- @Override
- public void afterAdressbookShareEnded (@Observes final AddressbookSharingEvent event) {
- // Validate parameter
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getSharingType() == null) {
- // Throw NPE
- throw new NullPointerException("event.sharingType is null"); //NOI18N
- } else if (event.getSharingType() != SharingType.ENDED) {
- // Wrong event
- return;
- }
-
- // Validate event
- this.validateEvent(event);
-
- // Add it to list
- this.sharedAddressbooks.remove(event.getShareableAddressbook());
- }
-
- @Override
- public void afterAdressbookShareStarted (@Observes final AddressbookSharingEvent event) {
- // Validate parameter
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getSharingType() == null) {
- // Throw NPE
- throw new NullPointerException("event.sharingType is null"); //NOI18N
- } else if (event.getSharingType() != SharingType.STARTED) {
- // Wrong event
- return;
- }
-
- // Validate event
- this.validateEvent(event);
-
- // Add it to list
- this.sharedAddressbooks.add(event.getShareableAddressbook());
- }
-
- @Override
- public void afterLoginEvent (@Observes final UserLoggedInEvent event) {
- // Is the user logged in?
- if (null == event) {
- // Is null
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLoggedInUser() == null) {
- // user is null
- throw new NullPointerException("event.user is null"); //NOI18N
- }
-
- // Init share list
- this.sharedAddressbooks = this.shareBean.allSharedAddressbooks(event.getLoggedInUser());
- }
-
- @Override
- public List<ShareableAddressbook> allShares () {
- // Is the user logged in?
- if (!this.loginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- }
-
- return Collections.unmodifiableList(this.sharedAddressbooks);
- }
-
- @Override
- public ShareableAddressbook getShare () {
- return this.share;
- }
-
- @Override
- public void setShare (final ShareableAddressbook share) {
- this.share = share;
- }
-
- @Override
- public Long getShareeUserId () {
- return this.shareeUserId;
- }
-
- @Override
- public void setShareeUserId (final Long shareeUserId) {
- this.shareeUserId = shareeUserId;
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- }
-
- @Override
- public boolean isShareeUserIdEmpty () {
- return (!this.isShareeUserIdSet());
- }
-
- @Override
- public boolean isShareeUserIdSet () {
- return ((this.getShareeUserId() instanceof Long) && (this.getShareeUserId() > 0));
- }
-
- @Override
- public boolean isSharingAddressbooks () {
- // Only to be called for logged-in users
- if (!this.loginController.isUserLoggedIn()) {
- // Not logged in
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- } else if (this.isUserSharing instanceof Boolean) {
- // Return cached value
- return this.isUserSharing;
- }
-
- // Call the proper bean
- this.isUserSharing = this.shareBean.isUserSharingAddressbooks(this.loginController.getLoggedInUser());
-
- // Return it
- return this.isUserSharing;
- }
-
- @Override
- public String startSharing (final User user, final Addressbook addressbook) {
- // Check conditions
- if (!this.loginController.isUserLoggedIn()) {
- // No, then throw exception
- throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
- } else if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // Throw NPE again
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Invalid id number
- throw new IllegalStateException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
- } else if (Objects.equals(user, this.loginController.getLoggedInUser())) {
- // Sharing with yourself!
- throw new IllegalStateException("User tries to share with himself."); //NOI18N
- } else if (null == addressbook) {
- // Throw NPE again
- throw new NullPointerException("addressbook is null"); //NOI18N
- } else if (addressbook.getAddressbookId() == null) {
- // Throw NPE again
- throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N
- } else if (addressbook.getAddressbookId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N
- } else if (!Objects.equals(addressbook.getAddressbookUser(), this.loginController.getLoggedInUser())) {
- // Not the same user!
- throw new IllegalStateException(MessageFormat.format("Address book id {0} owner id {1} mismatching logged-in user id {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), this.loginController.getLoggedInUser().getUserId())); //NOI18N
- } else if (this.loginController.getLoggedInUser().getUserProfileMode() == ProfileMode.INVISIBLE) {
- // User is invisible
- throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot start sharing address books.", this.loginController.getLoggedInUser().getUserId())); //NOI18N
- } else if (user.getUserProfileMode() == ProfileMode.INVISIBLE) {
- // User is invisible
- throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot be selected for sharing.", user.getUserId())); //NOI18N
- }
-
- try {
- // Init sharing
- ShareableAddressbook shared = this.shareBean.startSharing(user, addressbook);
-
- // TODO Set it here
- this.setShare(shared);
-
- /// Trigger event
- this.sharingEvent.fire(new StartedAddressbookSharingEvent(shared));
- } catch (final UserAlreadySharingAddressbookException ex) {
- // Throw again
- throw new FaceletException(ex);
- }
-
- // TODO Unfinished
- return null;
- }
-
- /**
- * Validates given event for all values and throws exceptions
- * <p>
- * @param event Event to validate
- */
- private void validateEvent (final AddressbookSharingEvent event) {
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getSharingType() == null) {
- // Throw NPE
- throw new NullPointerException("event.sharingType is null"); //NOI18N
- } else if (event.getShareableAddressbook() == null) {
- // Throw NPE again
- throw new NullPointerException("event.shareableAddressbook is null"); //NOI18N
- } else if (event.getShareableAddressbook().getShareId() == null) {
- // Throw NPE again
- throw new NullPointerException("event.shareableAddressbook.shareId is null"); //NOI18N
- } else if (event.getShareableAddressbook().getShareId() < 1) {
- // Throw NPE again
- throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareId={0} is invalid", event.getShareableAddressbook().getShareId())); //NOI18N
- } else if (event.getShareableAddressbook().getShareAddressbook() == null) {
- // Throw NPE again
- throw new NullPointerException("event.shareableAddressbook.shareAddressbook is null"); //NOI18N
- } else if (event.getShareableAddressbook().getShareAddressbook().getAddressbookId() == null) {
- // Throw NPE again
- throw new NullPointerException("event.shareableAddressbook.shareAddressbook.addressbookId is null"); //NOI18N
- } else if (event.getShareableAddressbook().getShareAddressbook().getAddressbookId() < 1) {
- // Throw NPE again
- throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareAddressbook.addressbookId={0} is invalid", event.getShareableAddressbook().getShareAddressbook().getAddressbookId())); //NOI18N
- } else if (event.getShareableAddressbook().getShareUserOwner() == null) {
- // Throw NPE again
- throw new NullPointerException("event.shareableAddressbook.shareUserOwner is null"); //NOI18N
- } else if (event.getShareableAddressbook().getShareUserOwner().getUserId() == null) {
- // Throw NPE again
- throw new NullPointerException("event.shareableAddressbook.shareUserOwner.userId is null"); //NOI18N
- } else if (event.getShareableAddressbook().getShareUserOwner().getUserId() < 1) {
- // Throw NPE again
- throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareUserOwner.userId={0} is invalid", event.getShareableAddressbook().getShareUserOwner().getUserId())); //NOI18N
- } else if (event.getShareableAddressbook().getShareUserSharee() == null) {
- // Throw NPE again
- throw new NullPointerException("event.shareableAddressbook.shareUserSharee is null"); //NOI18N
- } else if (event.getShareableAddressbook().getShareUserSharee().getUserId() == null) {
- // Throw NPE again
- throw new NullPointerException("event.shareableAddressbook.shareUserSharee.userId is null"); //NOI18N
- } else if (event.getShareableAddressbook().getShareUserSharee().getUserId() < 1) {
- // Throw NPE again
- throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareUserSharee.userId={0} is invalid", event.getShareableAddressbook().getShareUserOwner().getUserId())); //NOI18N
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.shares;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jaddressbookcore.events.sharing.AddressbookSharingEvent;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.shared.ShareableAddressbook;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * Controller interface sharing address books
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookSharesWebSessionController extends Serializable {
-
- /**
- * Observer method for ended sharing events
- * <p>
- * @param event Event instance
- */
- void afterAdressbookShareEnded (final AddressbookSharingEvent event);
-
- /**
- * Observer method for started sharing events
- * <p>
- * @param event Event instance
- */
- void afterAdressbookShareStarted (final AddressbookSharingEvent event);
-
- /**
- * This method is called when a user has successfully logged in his/her
- * account.
- * <p>
- * @param event
- */
- void afterLoginEvent (final UserLoggedInEvent event);
-
- /**
- * Returns a list of all address books the user is sharing with others.
- * <p>
- * @return List of all shared address books
- */
- List<ShareableAddressbook> allShares ();
-
- /**
- * Getter for share instance
- * <p>
- * @return Share instance
- */
- ShareableAddressbook getShare ();
-
- /**
- * Setter for share instance
- * <p>
- * @param share Share instance
- */
- void setShare (final ShareableAddressbook share);
-
- /**
- * Getter for sharee's user id
- * <p>
- * @return Sharee's user id
- */
- Long getShareeUserId ();
-
- /**
- * Setter for sharee's user id
- * <p>
- * @param shareeUserId Sharee's user id
- */
- void setShareeUserId (final Long shareeUserId);
-
- /**
- * Checks if the sharee's user id is empty.
- * <p>
- * @return Whether the sharee's user id is empty.
- */
- boolean isShareeUserIdEmpty ();
-
- /**
- * Checks whether the sharee's user id is set
- * <p>
- * @return Whether the sharee's user id is set
- */
- boolean isShareeUserIdSet ();
-
- /**
- * Checks wether the current user is sharing address books with others
- * <p>
- * @return Whether the current user is sharing address books
- */
- boolean isSharingAddressbooks ();
-
- /**
- * Starts an address book share between currently logged-in user and
- * assigned user for current address book.
- * <p>
- * @param user User instance
- * @param addressbook Address book instance
- * <p>
- * @return Redirect target
- */
- String startSharing (final User user, final Addressbook addressbook);
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.user;
-
-import java.text.MessageFormat;
-import java.util.Objects;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.faces.FacesException;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.contact.AddressbookAdminContactWebRequestController;
-import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
-import org.mxchange.addressbook.beans.helper.AddressbookWebRequestController;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcoreee.utils.FacesUtils;
-import org.mxchange.jusercore.container.login.UserLoginContainer;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
-import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
-import org.mxchange.jusercore.events.user.add.AdminUserAddedEvent;
-import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
-import org.mxchange.jusercore.events.user.linked.AdminUserLinkedEvent;
-import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
-import org.mxchange.jusercore.events.user.update.AdminUserDataUpdatedEvent;
-import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
-import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserPasswordRepeatMismatchException;
-import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
-import org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote;
-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.UserUtils;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-import org.mxchange.jusercore.model.user.status.UserAccountStatus;
-
-/**
- * A user bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminUserController")
-@RequestScoped
-public class AddressbookAdminUserWebRequestBean extends BaseAddressbookController implements AddressbookAdminUserWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 542_145_347_916L;
-
- /**
- * An event fired when the administrator has added a new user
- */
- @Inject
- @Any
- private Event<AdminAddedUserEvent> addedUserEvent;
-
- /**
- * Regular contact controller
- */
- @Inject
- private AddressbookAdminContactWebRequestController adminContactController;
-
- /**
- * Administrative user EJB
- */
- private final AdminUserSessionBeanRemote adminUserBean;
-
- /**
- * Admin helper instance
- */
- @Inject
- private AddressbookWebRequestController beanHelper;
-
- /**
- * Regular contact controller
- */
- @Inject
- private AddressbookContactWebSessionController contactController;
-
- /**
- * An event fired when the administrator has updated a new user
- */
- @Inject
- @Any
- private Event<AdminUpdatedUserDataEvent> updatedUserDataEvent;
-
- /**
- * General user EJB
- */
- private final UserSessionBeanRemote userBean;
-
- /**
- * Regular user controller
- */
- @Inject
- private AddressbookUserWebSessionController userController;
-
- /**
- * An event fired when the administrator has linked a user with existing
- * contact data.
- */
- @Inject
- @Any
- private Event<AdminLinkedUserEvent> userLinkedEvent;
-
- /**
- * User lock reason
- */
- private String userLockReason;
-
- /**
- * Flag whether user must change password after login
- */
- private Boolean userMustChangePassword;
-
- /**
- * User name
- */
- private String userName;
-
- /**
- * User password (unencrypted from web form)
- */
- private String userPassword;
-
- /**
- * User password repeated (unencrypted from web form)
- */
- private String userPasswordRepeat;
-
- /**
- * Default constructor
- */
- public AddressbookAdminUserWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
- this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public String addUser () {
- // Create new user instance
- User user = new LoginUser();
-
- // As the form cannot validate the data (required="true"), check it here
- if (this.getUserName() == null) {
- // Throw NPE
- throw new NullPointerException("userName is null"); //NOI18N
- } else if (this.getUserName().isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("userName is null"); //NOI18N
- } else if (this.beanHelper.getContact() == null) {
- // No contact instance set, so test required fields: gender, first name and family name
- if (this.contactController.getGender() == null) {
- // Throw NPE again
- throw new NullPointerException("contactController.gender is null"); //NOI18N
- } else if (this.contactController.getFirstName() == null) {
- // ... and again
- throw new NullPointerException("contactController.firstName is null"); //NOI18N //NOI18N
- } else if (this.contactController.getFirstName().isEmpty()) {
- // ... and again
- throw new IllegalArgumentException("contactController.firstName is empty"); //NOI18N
- } else if (this.adminContactController.getFamilyName() == null) {
- // ... and again
- throw new NullPointerException("contactController.familyName is null"); //NOI18N
- } else if (this.contactController.getFamilyName().isEmpty()) {
- // ... and again
- throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N //NOI18N
- } else if (this.contactController.getEmailAddress() == null) {
- // ... and again
- throw new NullPointerException("contactController.emailAddress is null"); //NOI18N
- } else if (this.adminContactController.getEmailAddress().isEmpty()) {
- // ... and again
- throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N //NOI18N
- } else if (this.contactController.getEmailAddressRepeat() == null) {
- // ... and again
- throw new NullPointerException("contactController.emailAddressRepeat is null");
- } else if (this.contactController.getEmailAddressRepeat().isEmpty()) {
- // ... and again
- throw new IllegalArgumentException("contactController.emailAddressRepeat is empty"); //NOI18N //NOI18N
- } else if (!Objects.equals(this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat())) {
- // Is not same email address
- throw new IllegalArgumentException("Both entered email addresses don't match.");
- }
- }
-
- // Set user name, CONFIRMED and INVISIBLE
- user.setUserName(this.getUserName());
- user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
- user.setUserProfileMode(ProfileMode.INVISIBLE);
-
- // Init instance
- Contact contact;
-
- // Is a contact instance in helper set?
- if (this.beanHelper.getContact() instanceof Contact) {
- // Then use it for contact linking
- contact = this.beanHelper.getContact();
- } else {
- // Create contact instance
- contact = this.contactController.createContactInstance();
- }
-
- // Set contact in user
- user.setUserContact(contact);
-
- // Init variable for password
- String password = null;
-
- // Is the user name or email address used already?
- // @TODO Add password length check
- if (this.userController.isUserNameRegistered(user)) {
- // User name is already used
- throw new FaceletException(new UserNameAlreadyRegisteredException(user));
- } else if ((this.beanHelper.getContact() == null) && (this.contactController.isEmailAddressRegistered(user.getUserContact()))) {
- // Email address is already used
- throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
- } else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) {
- // Empty password entered, then generate one
- password = UserUtils.createRandomPassword(AddressbookUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
- } else if (!this.isSamePasswordEntered()) {
- // Both passwords don't match
- throw new FaceletException(new UserPasswordRepeatMismatchException(user));
- } else {
- // Both match, so get it from this bean
- password = this.getUserPassword();
- }
-
- // The password should not be null and at least 5 characters long
- assert (password != null) : "password is null"; //NOI18N
- assert (password.length() >= AddressbookUserWebSessionController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N
-
- // Encrypt password and set it
- user.setUserEncryptedPassword(UserUtils.encryptPassword(password));
-
- try {
- // Now, that all is set, call EJB
- if (this.beanHelper.getContact() instanceof Contact) {
- // Link contact with this user
- User updatedUser = this.adminUserBean.linkUser(user);
-
- // Fire event
- this.userLinkedEvent.fire(new AdminUserLinkedEvent(updatedUser));
-
- // Remove contact instance
- this.beanHelper.setContact(null);
- } else {
- // Add new contact
- User updatedUser = this.adminUserBean.addUser(user);
-
- // Fire event
- this.addedUserEvent.fire(new AdminUserAddedEvent(updatedUser));
- }
- } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
- // Throw again
- throw new FaceletException(ex);
- }
-
- // Clear this bean
- this.clear();
-
- // Return to user list (for now)
- return "admin_list_user"; //NOI18N
- }
-
- @Override
- public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminUserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
-
- // event 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.user is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.user.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
- }
-
- // Get user instance
- User registeredUser = event.getRegisteredUser();
-
- // Debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
-
- // Clear all data
- this.clear();
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("AdminUserWebBean:afterRegistration: EXIT!"); //NOI18N
- }
-
- @Override
- public String editUserData () {
- // Get user instance
- User user = this.beanHelper.getUser();
-
- // Null password means not setting it
- String encryptedPassword = null;
-
- // Check if user instance is in helper and valid
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("beanHelper.user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // Throw NPE again
- throw new NullPointerException("beanHelper.user.userId is null"); //NOI18N //NOI18N
- } else if (user.getUserId() < 1) {
- // Invalid id
- throw new IllegalStateException(MessageFormat.format("beanHelper.user.userId={0} is invalid", user.getUserId())); //NOI18N //NOI18N
- } else if (this.getUserName() == null) {
- // Not all required fields are set
- throw new NullPointerException("this.userName is null"); //NOI18N
- } else if (this.getUserName().isEmpty()) {
- // Not all required fields are set
- throw new IllegalArgumentException("this.userName is empty"); //NOI18N
- } else if (((!this.getUserPassword().isEmpty()) || (!this.getUserPasswordRepeat().isEmpty())) && (!this.isSamePasswordEntered())) {
- // Not same password entered
- this.setUserPassword(null);
- this.setUserPasswordRepeat(null);
-
- // Throw exception
- throw new FaceletException("Not same password entered"); //NOI18N
- } else if (this.userBean.ifUserNameExists(this.getUserName())) {
- // User name already exists
- throw new FaceletException(new UserNameAlreadyRegisteredException(this.getUserName()));
- } else if (this.isSamePasswordEntered()) {
- // Same password entered, create container
- if (UserUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword()))) {
- // Same password entered
- throw new FaceletException("Same password as stored entered."); //NOI18N
- }
-
- // Encrypt password
- encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
- }
-
- // Set user name and flag
- user.setUserName(this.getUserName());
- user.setUserMustChangePassword(this.getUserMustChangePassword());
-
- // Is a password set?
- if (encryptedPassword != null) {
- // Set it as well
- user.setUserEncryptedPassword(encryptedPassword);
- }
-
- // Call EJB for updating user data
- User updatedUser = this.userBean.updateUserData(user);
-
- // Fire event
- this.updatedUserDataEvent.fire(new AdminUserDataUpdatedEvent(updatedUser));
-
- // Return to user list (for now)
- return "admin_list_user"; //NOI18N
- }
-
- @Override
- public String getUserLockReason () {
- return this.userLockReason;
- }
-
- @Override
- public void setUserLockReason (final String userLockReason) {
- this.userLockReason = userLockReason;
- }
-
- @Override
- public Boolean getUserMustChangePassword () {
- return this.userMustChangePassword;
- }
-
- @Override
- public void setUserMustChangePassword (final Boolean userMustChangePassword) {
- this.userMustChangePassword = userMustChangePassword;
- }
-
- @Override
- public String getUserName () {
- return this.userName;
- }
-
- @Override
- public void setUserName (final String userName) {
- this.userName = userName;
- }
-
- @Override
- public String getUserPassword () {
- return this.userPassword;
- }
-
- @Override
- public void setUserPassword (final String userPassword) {
- this.userPassword = userPassword;
- }
-
- @Override
- public String getUserPasswordRepeat () {
- return this.userPasswordRepeat;
- }
-
- @Override
- public void setUserPasswordRepeat (final String userPasswordRepeat) {
- this.userPasswordRepeat = userPasswordRepeat;
- }
-
- @Override
- public String lockUserAccount (final User user) {
- // Is the user instance valid and CONFIRMED?
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // Throw again
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
- } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
- // User account is locked
- throw new FacesException(new UserStatusLockedException(user));
- } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) {
- // User account is locked
- throw new FaceletException(new UserStatusUnconfirmedException(user));
- } else if (this.getUserLockReason() == null) {
- // Throw NPE again
- throw new NullPointerException("this.userLockReason is null"); //NOI18N
- } else if (this.getUserLockReason().isEmpty()) {
- // Empty lock reason
- throw new IllegalArgumentException("this.userLockReason is empty"); //NOI18N
- }
-
- try {
- // Get base URL
- String baseUrl = FacesUtils.generateBaseUrl();
-
- // Call EJB to lock account
- this.adminUserBean.lockUserAccount(user, this.getUserLockReason(), baseUrl);
- } catch (final UserStatusLockedException | UserStatusUnconfirmedException | UserNotFoundException ex) {
- // Throw again
- throw new FaceletException(ex);
- }
-
- // Should go fine at this point, redirect to user profile
- return "admin_show_user?faces-redirect=true&includeViewParams=true"; //NOI18N
- }
-
- @Override
- public String unlockUserAccount (final User user) {
- // Is the user instance valid and CONFIRMED?
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // Throw again
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
- } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
- // User account is locked
- throw new FacesException(new UserStatusConfirmedException(user));
- } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) {
- // User account is locked
- throw new FaceletException(new UserStatusUnconfirmedException(user));
- }
-
- try {
- // Get base URL
- String baseUrl = FacesUtils.generateBaseUrl();
-
- // Call EJB to unlock account
- this.adminUserBean.unlockUserAccount(user, baseUrl);
- } catch (final UserStatusConfirmedException | UserStatusUnconfirmedException | UserNotFoundException ex) {
- // Throw again
- throw new FaceletException(ex);
- }
-
- // Should go fine at this point, redirect to user profile
- return "admin_show_user?faces-redirect=true&includeViewParams=true"; //NOI18N
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- // - other data
- this.setUserName(null);
- this.setUserPassword(null);
- this.setUserPasswordRepeat(null);
- this.setUserMustChangePassword(null);
- }
-
- /**
- * Checks if same password is entered and that they are not empty.
- * <p>
- * @return Whether the same password was entered
- */
- private boolean isSamePasswordEntered () {
- return ((!this.getUserPassword().isEmpty()) && (Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())));
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.user;
-
-import java.io.Serializable;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * An interface for user beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookAdminUserWebRequestController extends Serializable {
-
- /**
- * Event observer for new user registrations
- * <p>
- * @param event User registration event
- */
- void afterRegistrationEvent (final UserRegisteredEvent event);
-
- /**
- * Adds user instance to database by preparing a complete user instance and
- * sending it to the EJB. The data set in the controller is being verified,
- * e.g. if the user name or email address is not used yet.
- * <p>
- * @return Redirect outcome
- */
- String addUser ();
-
- /**
- * Edits currently loaded user's data in database.
- * <p>
- * @return Redirect outcome
- */
- String editUserData ();
-
- /**
- * Locks selected user's account. This method makes sure that a lock reason
- * is provided that th user later can read on login attempts.
- * <p>
- * @param user User instance to be locked
- * <p>
- * @return Redirect outcome
- */
- String lockUserAccount (final User user);
-
- /**
- * Unlocks selected user's account. This method makes sure that the account
- * is locked.
- * <p>
- * @param user User instance to be unlocked
- * <p>
- * @return Redirect outcome
- */
- String unlockUserAccount (final User user);
-
- /**
- * Getter for user name
- * <p>
- * @return User name
- */
- String getUserName ();
-
- /**
- * Setter for user name
- * <p>
- * @param userName User name
- */
- void setUserName (final String userName);
-
- /**
- * Getter for unencrypted user password
- * <p>
- * @return Unencrypted user password
- */
- String getUserPassword ();
-
- /**
- * Setter for unencrypted user password
- * <p>
- * @param userPassword Unencrypted user password
- */
- void setUserPassword (final String userPassword);
-
- /**
- * Getter for unencrypted user password repeated
- * <p>
- * @return Unencrypted user password repeated
- */
- String getUserPasswordRepeat ();
-
- /**
- * Setter for unencrypted user password repeated
- * <p>
- * @param userPasswordRepeat Unencrypted user password repeated
- */
- void setUserPasswordRepeat (final String userPasswordRepeat);
-
- /**
- * Getter for flag if user needs to change password
- * <p>
- * @return Flag if user needs to change password
- */
- Boolean getUserMustChangePassword ();
-
- /**
- * Setter for flag if user needs to change password
- * <p>
- * @param userMustChangePassword Flag if user needs to change password
- */
- void setUserMustChangePassword (final Boolean userMustChangePassword);
-
- /**
- * Getter for user lock reason
- * <p>
- * @return User lock reason
- */
- String getUserLockReason ();
-
- /**
- * Setter for user lock reason
- * <p>
- * @param userLockReason User lock reason
- */
- void setUserLockReason (final String userLockReason);
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.user;
-
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.faces.context.FacesContext;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
-import org.mxchange.addressbook.beans.features.AddressbookFeaturesWebApplicationController;
-import org.mxchange.addressbook.beans.localization.AddressbookLocalizationSessionController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
-import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
-import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
-import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
-import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
-import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
-import org.mxchange.jusercore.events.user.update.UserUpdatedPersonalDataEvent;
-import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
-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.UserUtils;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-
-/**
- * A user bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("userController")
-@SessionScoped
-public class AddressbookUserWebSessionBean extends BaseAddressbookController implements AddressbookUserWebSessionController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 542_145_347_916L;
-
- /**
- * Contact EJB
- */
- private ContactSessionBeanRemote contactBean;
-
- /**
- * General contact controller
- */
- @Inject
- private AddressbookContactWebSessionController contactController;
-
- /**
- * Features controller
- */
- @Inject
- private AddressbookFeaturesWebApplicationController featureController;
-
- /**
- * Localization controller
- */
- @Inject
- private AddressbookLocalizationSessionController localizationController;
-
- /**
- * Event being fired when user updated personal data
- */
- @Inject
- @Any
- private Event<UpdatedUserPersonalDataEvent> updatedPersonalDataEvent;
-
- /**
- * Remote user bean
- */
- private final UserSessionBeanRemote userBean;
-
- /**
- * User id
- */
- private Long userId;
-
- /**
- * A list of all user profiles
- */
- private List<User> userList;
-
- /**
- * Login bean (controller)
- */
- @Inject
- private AddressbookUserLoginWebSessionController userLoginController;
-
- /**
- * User name
- */
- private String userName;
-
- /**
- * User name list
- */
- private List<String> userNameList;
-
- /**
- * User password (unencrypted from web form)
- */
- private String userPassword;
-
- /**
- * User password repeated (unencrypted from web form)
- */
- private String userPasswordRepeat;
-
- /**
- * Whether the user wants a public profile
- */
- private ProfileMode userProfileMode;
-
- /**
- * A list of all public user profiles
- * <p>
- * @TODO Hmm, makes that sense? Having visible user list in current
- * (session-scoped) user's visible user list?
- */
- private List<User> visibleUserList;
-
- /**
- * Default constructor
- */
- public AddressbookUserWebSessionBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
-
- // Try to lookup
- this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminAddedUserEvent: event={0} - CALLED!", event)); //NOI18N
-
- // event 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
- }
-
- // Add user uniquely
- this.uniqueAddUser(event.getAddedUser());
-
- // Clear all data
- this.clear();
-
- // Set user id again
- this.setUserId(event.getAddedUser().getUserId());
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminAddedUserEvent: EXIT!"); //NOI18N
- }
-
- @Override
- public void afterAdminUpdatedUserDataEvent (@Observes final AdminUpdatedUserDataEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminUpdatedUserEvent: event={0} - CALLED!", event)); //NOI18N
-
- // 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 list
- this.updateList(event.getUpdatedUser());
-
- // Clear all data
- this.clear();
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminUpdatedUserEvent: EXIT!"); //NOI18N
- }
-
- @Override
- public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
-
- // event 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
- }
-
- // Get user instance
- User registeredUser = event.getRegisteredUser();
-
- // Debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
-
- // Copy all data from registered->user
- this.copyUser(registeredUser);
-
- // Clear all data
- this.clear();
-
- // Add user uniquely
- this.uniqueAddUser(registeredUser);
-
- // Add user name
- this.addUserName(registeredUser);
-
- // Is the account public?
- if (Objects.equals(registeredUser.getUserProfileMode(), ProfileMode.PUBLIC)) {
- // Also add it to this list
- this.visibleUserList.add(registeredUser);
- }
-
- // Set user id again
- this.setUserId(registeredUser.getUserId());
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterRegistration: EXIT!"); //NOI18N
- }
-
- @Override
- public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
-
- // 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
- }
-
- // Add user uniquely
- this.uniqueAddUser(event.getConfirmedUser());
- }
-
- @Override
- public void afterUserLogin (@Observes final UserLoggedInEvent event) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
-
- // event should not be null
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLoggedInUser() == null) {
- // Throw NPE again
- throw new NullPointerException("event.registeredUser is null"); //NOI18N
- } else if (event.getLoggedInUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
- } else if (event.getLoggedInUser().getUserId() < 1) {
- // Not avalid id
- throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
- }
-
- // "Cache" user instance
- User loggedInUser = event.getLoggedInUser();
-
- // Copy all data to this bean
- this.copyUser(loggedInUser);
-
- // Is the user visible?
- if (Objects.equals(loggedInUser.getUserProfileMode(), ProfileMode.PUBLIC)) {
- // Yes, then add user
- this.visibleUserList.add(loggedInUser);
- }
- }
-
- @Override
- public void afterUserUpdatedPasswordEvent (@Observes final UpdatedUserPasswordEvent 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
- }
-
- // All fine, so update list
- this.updateList(event.getPasswordHistory().getUserPasswordHistoryUser());
- }
-
- @Override
- public void afterUserUpdatedPersonalData (@Observes final UpdatedUserPersonalDataEvent 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
- }
-
- // All fine, so update list
- this.updateList(event.getUpdatedUser());
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<User> allUsers () {
- // Return it
- return this.userList;
- }
-
- @Override
- @SuppressWarnings ("ReturnOfCollectionOrArrayField")
- public List<User> allVisibleUsers () {
- // Return it
- return this.visibleUserList;
- }
-
- @Override
- public User createUserInstance (final boolean createContactData) {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: CALLED!", this.getClass().getSimpleName()));
-
- // Required personal data must be set
- assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
-
- // Create new user instance
- User user = new LoginUser();
-
- // Is user name required?
- if (!this.isUserNameRequired()) {
- // Generate pseudo-random user name
- String randomName = this.userBean.generateRandomUserName();
-
- // Set it and inivisible profile
- this.setUserName(randomName);
- this.setUserProfileMode(ProfileMode.INVISIBLE);
-
- // Generate random password
- String randomPassword = UserUtils.createRandomPassword(AddressbookUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
-
- // Set random password
- this.setUserPassword(randomPassword);
- this.setUserPasswordRepeat(randomPassword);
- }
-
- // Set local, user name and mode
- user.setUserLocale(this.localizationController.getLocale());
- user.setUserName(this.getUserName());
- user.setUserProfileMode(this.getUserProfileMode());
-
- // Is multiple registration page
- if ((createContactData) || (!this.featureController.isFeatureEnabled("user_register_multiple_page"))) { //NOI18N
- // Create contact instance
- Contact contact = this.contactController.createContactInstance();
-
- // Debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: contact={1}", this.getClass().getSimpleName(), contact));
-
- // Set contact in user
- user.setUserContact(contact);
- }
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: user={1} - EXIT!", this.getClass().getSimpleName(), user));
-
- // Return it
- return user;
- }
-
- @Override
- public User createUserLogin () {
- // Trace message
- //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: CALLED!", this.getClass().getSimpleName()));
-
- // Is all data set?
- if (this.getUserName() == null) {
- // Throw NPE
- throw new NullPointerException("recruiterName is null"); //NOI18N
- } else if (this.getUserName().isEmpty()) {
- // Is empty
- throw new IllegalStateException("recruiterName is empty."); //NOI18N
- }
-
- // Create new recruiter instance
- User recruiter = new LoginUser();
-
- // Update all data ...
- recruiter.setUserName(this.getUserName());
-
- // Trace message
- //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: recruiter={1} - EXIT!", this.getClass().getSimpleName(), recruiter));
-
- // Return the new instance
- return recruiter;
- }
-
- @Override
- public String doChangePersonalData () {
- // This method shall only be called if the user is logged-in
- if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged-in
- throw new IllegalStateException("User is not logged-in"); //NOI18N
- } else if (!this.isRequiredChangePersonalDataSet()) {
- // Not all required fields are set
- throw new FaceletException("Not all required fields are set."); //NOI18N
- } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
- // Password not matching
- throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
- } else if (!this.featureController.isFeatureEnabled("edit_user_data")) {
- // Editing is not allowed
- throw new IllegalStateException("User tried to edit personal data."); //NOI18N
- }
-
- // Get user instance
- User user = this.userLoginController.getLoggedInUser();
-
- // Copy contact data to contact instance
- this.contactController.updateContactDataFromController(user.getUserContact());
-
- // It should be there, so run some tests on it
- assert (user instanceof User) : "Instance loginController.loggedInUser is null";
- assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null";
- assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId());
- assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null";
- assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null";
- assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId());
-
- // Update all fields
- user.setUserProfileMode(this.getUserProfileMode());
-
- // Send it to the EJB
- User updatedUser = this.userBean.updateUserPersonalData(user);
-
- // Fire event
- this.updatedPersonalDataEvent.fire(new UserUpdatedPersonalDataEvent(updatedUser));
-
- // All fine
- return "contact_data_saved"; //NOI18N
- }
-
- @Override
- public Long getUserId () {
- return this.userId;
- }
-
- @Override
- public void setUserId (final Long userId) {
- this.userId = userId;
- }
-
- @Override
- public String getUserName () {
- return this.userName;
- }
-
- @Override
- public void setUserName (final String userName) {
- this.userName = userName;
- }
-
- @Override
- public String getUserPassword () {
- return this.userPassword;
- }
-
- @Override
- public void setUserPassword (final String userPassword) {
- this.userPassword = userPassword;
- }
-
- @Override
- public String getUserPasswordRepeat () {
- return this.userPasswordRepeat;
- }
-
- @Override
- public void setUserPasswordRepeat (final String userPasswordRepeat) {
- this.userPasswordRepeat = userPasswordRepeat;
- }
-
- @Override
- public ProfileMode getUserProfileMode () {
- return this.userProfileMode;
- }
-
- @Override
- public void setUserProfileMode (final ProfileMode userProfileMode) {
- this.userProfileMode = userProfileMode;
- }
-
- /**
- * Post-initialization of this class
- */
- @PostConstruct
- public void init () {
- // Initialize user list
- this.userList = this.userBean.allUsers();
-
- // Get full user name list for reducing EJB calls
- this.userNameList = this.userBean.getUserNameList();
-
- // Is the user logged-in?
- if (this.userLoginController.isUserLoggedIn()) {
- // Is logged-in, so load also users visible to memebers
- this.visibleUserList = this.userBean.allMemberPublicVisibleUsers();
- } else {
- // Initialize user list
- this.visibleUserList = this.userBean.allPublicUsers();
- }
- }
-
- @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;
-
- // Get iterator
- Iterator<User> iterator = this.allUsers().iterator();
-
- // Loop through all entries
- while (iterator.hasNext()) {
- // Get user
- User next = iterator.next();
-
- // Compare both objects
- if (Objects.equals(contact, next.getUserContact())) {
- // Found it
- isFound = true;
- break;
- }
- }
-
- // Return status
- return isFound;
- }
-
- @Override
- public boolean isPublicUserProfileEnabled () {
- // Get context parameter
- String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_public_profile_enabled"); //NOI18N
-
- // Is it set?
- boolean isEnabled = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
-
- // This requires user names being enabled, too.
- if ((isEnabled) && (!this.isUserNameRequired())) {
- // Not valid state, users must be able to modify their profile, especially when it is public
- throw new IllegalStateException("Public user profiles are enabled but user name requirement is disabled, this is not possible."); //NOI18N
- }
-
- // Return value
- return isEnabled;
- }
-
- @Override
- public boolean isRequiredChangePersonalDataSet () {
- return ((this.getUserProfileMode() != null) &&
- (this.getUserName() != null) && (!this.getUserName().isEmpty()) &&
- (this.contactController.isRequiredChangePersonalDataSet()));
- }
-
- @Override
- public boolean isRequiredPersonalDataSet () {
- if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
- // Multiple registration page
- return this.contactController.isRequiredPersonalDataSet();
- } else {
- // Single registration page
- return (((this.getUserName() != null) || (!this.isUserNameRequired())) &&
- (this.getUserProfileMode() != null) &&
- (this.contactController.isRequiredPersonalDataSet()) &&
- (this.getUserPassword() != null) &&
- (this.getUserPasswordRepeat() != null));
- }
- }
-
- @Override
- public boolean isSamePasswordEntered () {
- return ((!this.getUserPassword().isEmpty()) && (Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())));
- }
-
- @Override
- public boolean isUserIdEmpty () {
- return ((this.getUserId() == null) || (this.getUserId() == 0));
- }
-
- @Override
- public boolean isUserNameRegistered (final User user) {
- return ((this.userNameList instanceof List) && (this.userNameList.contains(user.getUserName())));
- }
-
- @Override
- public boolean isUserNameRequired () {
- // Get context parameter
- String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_user_name_required"); //NOI18N
-
- // Is it set?
- boolean isRequired = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
-
- // Return value
- return isRequired;
- }
-
- @Override
- public boolean isVisibleUserFound () {
- return ((this.visibleUserList instanceof List) && (!this.visibleUserList.isEmpty()));
- }
-
- @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 Iterator<User> iterator = this.userList.iterator(); iterator.hasNext();) {
- // Get next user
- User next = iterator.next();
-
- // Contact should be set
- if (next.getUserContact() == null) {
- // Contact is null
- throw new NullPointerException(MessageFormat.format("next.userContact is null for user id {0}", next.getUserId())); //NOI18N
- } else if (next.getUserContact().getContactEmailAddress() == null) {
- // Email address should be set
- throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getUserId())); //NOI18N //NOI18N
- }
-
- // Is the email address found?
- if (Objects.equals(next.getUserContact().getContactEmailAddress(), emailAddress)) {
- // Copy to other variable
- user = next;
- 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 Iterator<User> iterator = this.userList.iterator(); iterator.hasNext();) {
- // Get next user
- User next = iterator.next();
-
- // Is the user id found?
- if (Objects.equals(next.getUserId(), userId)) {
- // Copy to other variable
- user = next;
- break;
- }
- }
-
- // Is it still null?
- if (null == user) {
- // Not visible for the current user
- throw new UserNotFoundException(userId);
- }
-
- // Return it
- return user;
- }
-
- /**
- * Adds user's name to bean's internal list. It also updates the public user
- * list if the user has decided to have a public account,
- * <p>
- * @param user User instance
- */
- private void addUserName (final User user) {
- // Make sure the entry is not added yet
- if (this.userNameList.contains(user.getUserName())) {
- // Abort here
- throw new IllegalArgumentException(MessageFormat.format("User name {0} already added.", user.getUserName())); //NOI18N
- } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
- // Already added
- throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", user.getUserContact().getContactEmailAddress())); //NOI18N
- }
-
- // Add user name
- this.userNameList.add(user.getUserName());
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- // - personal data
- this.setUserId(null);
- this.setUserProfileMode(null);
-
- // - other data
- this.setUserName(null);
- this.setUserPassword(null);
- this.setUserPasswordRepeat(null);
- }
-
- /**
- * Copies given user into the controller
- * <p>
- * @param user User instance
- */
- private void copyUser (final User user) {
- // Make sure the instance is valid
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserContact() == null) {
- // Throw again ...
- throw new NullPointerException("user.userContact is null"); //NOI18N
- }
-
- // Copy all fields:
- // - base data
- this.setUserId(user.getUserId());
- this.setUserProfileMode(user.getUserProfileMode());
- }
-
- /**
- * Uniquely adds given user instance to user list. First an existing
- * instance will be removed, then the given instance is being added.
- * <p>
- * @param user User instance to add
- */
- private void uniqueAddUser (final User user) {
- // Make sure the instance is valid
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserContact() == null) {
- // Throw again ...
- throw new NullPointerException("user.userContact is null"); //NOI18N
- }
-
- // Get iterator from list
- Iterator<User> iterator = this.userList.iterator();
-
- // "Walk" through all entries
- while (iterator.hasNext()) {
- // Get next element
- User next = iterator.next();
-
- // Is id number the same?
- if (Objects.equals(user.getUserId(), next.getUserId())) {
- // Found entry, so remove it and abort
- this.userList.remove(next);
- break;
- }
- }
-
- // Add contact to list
- this.userList.add(user);
- }
-
- /**
- * 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
- }
-
- // Get iterator
- Iterator<User> iterator = this.userList.iterator();
-
- // Look whole list
- while (iterator.hasNext()) {
- // Get next element
- User next = iterator.next();
-
- // Is the same user id?
- if (Objects.equals(user.getUserId(), next.getUserId())) {
- // Found it, so remove it
- this.userList.remove(next);
- break;
- }
- }
-
- // Re-add item
- this.userList.add(user);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.user;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
-import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
-import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
-import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
-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.User;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-
-/**
- * An interface for user beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookUserWebSessionController extends Serializable {
-
- /**
- * Minimum password length
- */
- public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
-
- /**
- * Event observer for newly added users by adminstrator
- * <p>
- * @param event Event being fired
- */
- void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
-
- /**
- * Event observer for updated user data by administrator
- * <p>
- * @param event Event being updated
- */
- void afterAdminUpdatedUserDataEvent (final AdminUpdatedUserDataEvent event);
-
- /**
- * Event observer when user confirmed account.
- * <p>
- * @param event Event being fired
- */
- void afterUserConfirmedAccount (final UserConfirmedAccountEvent event);
-
- /**
- * Method being call after user's password has been updated (and history
- * entry has been created).
- * <p>
- * @param event Event being observed
- */
- void afterUserUpdatedPasswordEvent (final UpdatedUserPasswordEvent event);
-
- /**
- * Listens to fired event when user updated personal data
- * <p>
- * @param event Event being fired
- */
- void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
-
- /**
- * Event observer for new user registrations
- * <p>
- * @param event User registration event
- */
- void afterRegistrationEvent (final UserRegisteredEvent event);
-
- /**
- * Event observer for logged-in user
- * <p>
- * @param event Event instance
- */
- void afterUserLogin (final UserLoggedInEvent event);
-
- /**
- * All users
- * <p>
- * @return A list of all public user profiles
- */
- List<User> allUsers ();
-
- /**
- * All public user profiles
- * <p>
- * @return A list of all public user profiles
- */
- List<User> allVisibleUsers ();
-
- /**
- * Checks whether the given contact is a user
- * <p>
- * @param contact Contact to check
- * <p>
- * @return Whether the contact is a user
- */
- boolean isContactFound (final Contact contact);
-
- /**
- * Checks whether a public user account is registered. This means that at
- * least one user profile has its flag "public user profile" enabled.
- * <p>
- * @return Whether at least one user has a public profile
- */
- boolean isVisibleUserFound ();
-
- /**
- * Checks whether given user instance's name is used
- * <p>
- * @param user User instance's name to check
- * <p>
- * @return Whether it is already used
- */
- boolean isUserNameRegistered (final User user);
-
- /**
- * Tries to lookup user by given id number. If the user is not found or the
- * account status is not CONFIRMED proper exceptions are thrown.
- * <p>
- * @param userId User id
- * <p>
- * @return User instance
- * <p>
- * @throws UserNotFoundException If the user is not found
- */
- User lookupUserById (final Long userId) throws UserNotFoundException;
-
- /**
- * Tries to lookup user by given email address. If the user is not found a
- * proper exceptions is thrown.
- * <p>
- * @param emailAddress Email address
- * <p>
- * @return User instance
- * <p>
- * @throws UserEmailAddressNotFoundException If the user's email address is not found
- */
- User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException;
-
- /**
- * Creates an instance from all properties
- * <p>
- * @param createContactData Whether contact data should be created
- * <p>
- * @return A user instance
- */
- User createUserInstance (final boolean createContactData);
-
- /**
- * Creates a user instance for login phase
- * <p>
- * @return User instance
- */
- User createUserLogin ();
-
- /**
- * Getter for user id
- * <p>
- * @return User id
- */
- Long getUserId ();
-
- /**
- * Setter for user id
- * <p>
- * @param userId User id
- */
- void setUserId (final Long userId);
-
- /**
- * Getter for user name
- * <p>
- * @return User name
- */
- String getUserName ();
-
- /**
- * Setter for user name
- * <p>
- * @param userName User name
- */
- void setUserName (final String userName);
-
- /**
- * Getter for unencrypted user password
- * <p>
- * @return Unencrypted user password
- */
- String getUserPassword ();
-
- /**
- * Setter for unencrypted user password
- * <p>
- * @param userPassword Unencrypted user password
- */
- void setUserPassword (final String userPassword);
-
- /**
- * Getter for unencrypted user password repeated
- * <p>
- * @return Unencrypted user password repeated
- */
- String getUserPasswordRepeat ();
-
- /**
- * Setter for unencrypted user password repeated
- * <p>
- * @param userPasswordRepeat Unencrypted user password repeated
- */
- void setUserPasswordRepeat (final String userPasswordRepeat);
-
- /**
- * Getter for user profile mode
- * <p>
- * @return User profile mode
- */
- ProfileMode getUserProfileMode ();
-
- /**
- * Setter for user profile mode
- * <p>
- * @param userProfileMode User profile mode
- */
- void setUserProfileMode (final ProfileMode userProfileMode);
-
- /**
- * Checks whether all required personal data is set
- * <p>
- * @return Whether the required personal data is set
- */
- boolean isRequiredPersonalDataSet ();
-
- /**
- * Checks whether all required personal data is set for changing them
- * <p>
- * @return Whether the required personal data is set
- */
- boolean isRequiredChangePersonalDataSet ();
-
- /**
- * Checks whether same passwords has been entered
- * <p>
- * @return Whether same passwords has been entered
- */
- boolean isSamePasswordEntered ();
-
- /**
- * Checks if the user id is empty
- * <p>
- * @return Whether the user id is empty
- */
- boolean isUserIdEmpty ();
-
- /**
- * Changes logged-in user's personal data if the current password matches
- * and TAC + privacy statement has been accepted.
- * <p>
- * @return New target page
- */
- String doChangePersonalData ();
-
- /**
- * Checks whether this application requires a user name to be entered.
- * Otherwise a random name like "userXXXXX" is generated
- * <p>
- * @return Whether this application requires a user name
- */
- boolean isUserNameRequired ();
-
- /**
- * Checks wether public user profiles are enabled. This requires that user
- * names are also enabled.
- * <p>
- * @return Whether public user profiles are enabled
- */
- boolean isPublicUserProfileEnabled ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.user.password;
-
-import java.util.Objects;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.features.AddressbookFeaturesWebApplicationController;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
-import org.mxchange.jcoreee.utils.FacesUtils;
-import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
-import org.mxchange.jusercore.events.user.password_change.UserUpdatedPasswordEvent;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
-import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-import org.mxchange.jusercore.model.user.UserUtils;
-import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
-
-/**
- * A user password (change) bean (controller)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("userPasswordController")
-@RequestScoped
-public class AddressbookUserPasswordWebRequestBean extends BaseAddressbookController implements AddressbookUserPasswordWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 15_267_867_367_501L;
-
- /**
- * Features controller
- */
- @Inject
- private AddressbookFeaturesWebApplicationController featureController;
-
- /**
- * Remote user bean
- */
- private final UserSessionBeanRemote userBean;
-
- /**
- * Current password (for confirmation of password change)
- */
- private String userCurrentPassword;
-
- /**
- * Login bean (controller)
- */
- @Inject
- private AddressbookUserLoginWebSessionController userLoginController;
-
- /**
- * User password (unencrypted from web form)
- */
- private String userPassword;
-
- /**
- * User password repeated (unencrypted from web form)
- */
- private String userPasswordRepeat;
-
- /**
- * Event being fired when user's password has been updated
- */
- @Any
- @Inject
- private Event<UpdatedUserPasswordEvent> userUpdatedPasswordEvent;
-
- /**
- * Default constructor
- */
- public AddressbookUserPasswordWebRequestBean () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public String doChangePassword () {
- // This method shall only be called if the user is logged-in
- if (!this.userLoginController.isUserLoggedIn()) {
- // Not logged-in
- throw new IllegalStateException("User is not logged-in"); //NOI18N
- } else if (!this.isRequiredChangePasswordSet()) {
- // Not all required fields are set
- throw new FaceletException("Not all required fields are set."); //NOI18N
- } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
- // Password not matching
- throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
- } else if (!this.featureController.isFeatureEnabled("change_user_password")) { //NOI18N
- // Editing is not allowed
- throw new IllegalStateException("User tried to change password."); //NOI18N
- } else if (!UserUtils.ifPasswordMatches(this.getUserCurrentPassword(), this.userLoginController.getLoggedInUser())) {
- // Password mismatches
- this.showFacesMessage("form_user_change_password:userCurrentPassword", "Entered current password does not matched stored password."); //NOI18N
-
- // Clear bean
- this.clear();
-
- // No redirect
- return ""; //NOI18N
- } else if (!Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())) {
- // Both entered passwords don't match
- this.showFacesMessage("form_user_change_password:userPasswordRepeat", "Entered new passwords mismatch."); //NOI18N
-
- // Clear bean
- this.clear();
-
- // No redirect
- return ""; //NOI18N
- } else if (Objects.equals(this.getUserCurrentPassword(), this.getUserPassword())) {
- // New password matches current
- this.showFacesMessage("form_user_change_password:userPassword", "Entered new password is same as current password."); //NOI18N
-
- // Clear bean
- this.clear();
-
- // No redirect
- return ""; //NOI18N
- } else if (this.userLoginController.isPasswordInHistory(this.getUserPassword())) {
- // Is already in list (to old passwords are ignored)
- this.showFacesMessage("form_user_change_password:userPassword", "Entered new password is has already been used some time ago."); //NOI18N
-
- // Clear bean
- this.clear();
-
- // No redirect
- return ""; //NOI18N
- }
-
- // Get user instance
- User user = this.userLoginController.getLoggedInUser();
-
- // Encrypt password
- String encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
-
- // Set it in user
- user.setUserEncryptedPassword(encryptedPassword);
-
- try {
- // Get base URL
- String baseUrl = FacesUtils.generateBaseUrl();
-
- // All is set, then update password
- PasswordHistory passwordHistory = this.userBean.updateUserPassword(user, baseUrl);
-
- // Fire event
- this.userUpdatedPasswordEvent.fire(new UserUpdatedPasswordEvent(passwordHistory));
- } catch (final UserNotFoundException | UserStatusUnconfirmedException | UserStatusLockedException ex) {
- // Clear bean
- this.clear();
-
- // Throw again
- throw new FaceletException(ex);
- }
-
- // Clear bean
- this.clear();
-
- // Return outcome
- return "login_data_saved"; //NOI18N
- }
-
- @Override
- public String getUserCurrentPassword () {
- return this.userCurrentPassword;
- }
-
- @Override
- public void setUserCurrentPassword (final String userCurrentPassword) {
- this.userCurrentPassword = userCurrentPassword;
- }
-
- @Override
- public String getUserPassword () {
- return this.userPassword;
- }
-
- @Override
- public void setUserPassword (final String userPassword) {
- this.userPassword = userPassword;
- }
-
- @Override
- public String getUserPasswordRepeat () {
- return this.userPasswordRepeat;
- }
-
- @Override
- public void setUserPasswordRepeat (final String userPasswordRepeat) {
- this.userPasswordRepeat = userPasswordRepeat;
- }
-
- public boolean isRequiredChangePasswordSet () {
- // Is all data set?
- return ((this.getUserCurrentPassword() != null) &&
- (!this.getUserCurrentPassword().isEmpty()) &&
- (this.getUserPassword() != null) &&
- (!this.getUserPassword().isEmpty()) &&
- (this.getUserPasswordRepeat() != null) &&
- (!this.getUserPasswordRepeat().isEmpty()));
- }
-
- /**
- * Clears this bean
- */
- private void clear () {
- // Clear all data
- this.setUserPassword(null);
- this.setUserPasswordRepeat(null);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.beans.user.password;
-
-import java.io.Serializable;
-import javax.ejb.Local;
-
-/**
- * An interface for user beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Local
-public interface AddressbookUserPasswordWebRequestController extends Serializable {
-
- /**
- * Getter for unencrypted user password
- * <p>
- * @return Unencrypted user password
- */
- String getUserPassword ();
-
- /**
- * Setter for unencrypted user password
- * <p>
- * @param userPassword Unencrypted user password
- */
- void setUserPassword (final String userPassword);
-
- /**
- * Getter for current unencrypted user password
- * <p>
- * @return Current unencrypted user password
- */
- String getUserCurrentPassword ();
-
- /**
- * Setter for current unencrypted user password
- * <p>
- * @param userCurrentPassword Current unencrypted user password
- */
- void setUserCurrentPassword (final String userCurrentPassword);
-
- /**
- * Getter for unencrypted user password repeated
- * <p>
- * @return Unencrypted user password repeated
- */
- String getUserPasswordRepeat ();
-
- /**
- * Setter for unencrypted user password repeated
- * <p>
- * @param userPasswordRepeat Unencrypted user password repeated
- */
- void setUserPasswordRepeat (final String userPasswordRepeat);
-
- /**
- * Changes logged-in user's password. It must not match with current password and should not appear in password history list for X (configurable) entries.
- * <p>
- * @return Redirect outcome
- */
- String doChangePassword ();
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.converter.cellphone;
-
-import java.text.MessageFormat;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
-import org.mxchange.jphone.phonenumbers.DialableNumber;
-import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
-
-/**
- * Converter for cellphone id <-> valid cellphone instance
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesConverter (value = "CellphoneConverter")
-public class AddressbookCellphoneConverter implements Converter {
-
- /**
- * Logger instance
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * Phone EJB
- */
- private PhoneSessionBeanRemote phoneBean;
-
- /**
- * Initialization of this converter
- */
- public AddressbookCellphoneConverter () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-
- // ... and user controller
- this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- @Override
- public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
-
- // Is the value null or empty?
- if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
- // Return null
- return null;
- }
-
- // Init instance
- DialableMobileNumber cellphone = null;
-
- try {
- // Try to parse the value as long
- Long cellphoneId = Long.valueOf(submittedValue);
-
- // Debug message
- // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId)); //NOI18N
-
- // Try to get cellphone instance from it
- cellphone = this.phoneBean.findMobileNumberById(cellphoneId);
-
- // Debug message
- // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: cellphone={0}", cellphone)); //NOI18N
- } catch (final NumberFormatException ex) {
- // Throw again
- throw new ConverterException(ex);
- } catch (final PhoneEntityNotFoundException ex) {
- // Debug message
- this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
- }
-
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: cellphone={0} - EXIT!", cellphone)); //NOI18N
-
- // Return it
- return cellphone;
- }
-
- @Override
- public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
- // Is the object null?
- if ((null == value) || ((String.valueOf(value)).isEmpty())) {
- // Is null
- return ""; //NOI18N
- } else if (!(value instanceof DialableNumber)) {
- // Not same interface
- throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N
- }
-
- // Return category id
- return String.valueOf(((DialableNumber) value).getPhoneId());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.converter.contact;
-
-import java.text.MessageFormat;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
-import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-
-/**
- * Converter for contact id <-> valid contact instance
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesConverter (value = "ContactConverter")
-public class AddressbookContactConverter implements Converter {
-
- /**
- * User EJB
- */
- private ContactSessionBeanRemote contactBean;
-
- /**
- * Logger instance
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * Initialization of this converter
- */
- public AddressbookContactConverter () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-
- // ... and user controller
- this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- @Override
- public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
-
- // Is the value null or empty?
- if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
- // Return null
- return null;
- }
-
- // Init instance
- Contact contact = null;
-
- try {
- // Try to parse the value as long
- Long contactId = Long.valueOf(submittedValue);
-
- // Debug message
- // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: contactId{0}", contactId)); //NOI18N
-
- // Try to get user instance from it
- contact = this.contactBean.findContactById(contactId);
-
- // Debug message
- // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: contact={0}", contact)); //NOI18N
- } catch (final NumberFormatException ex) {
- // Throw again
- throw new ConverterException(ex);
- } catch (final ContactNotFoundException ex) {
- // Debug message
- this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
- }
-
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contact={0} - EXIT!", contact)); //NOI18N
-
- // Return it
- return contact;
- }
-
- @Override
- public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
- // Is the object null?
- if ((null == value) || ((String.valueOf(value)).isEmpty())) {
- // Is null
- return ""; //NOI18N
- } else if (!(value instanceof Contact)) {
- // Not same interface
- throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement Contact.", value)); //NOI18N
- }
-
- // Return category id
- return String.valueOf(((Contact) value).getContactId());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.converter.country;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Objects;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
-
-/**
- * Converter for country instance
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesConverter (value = "CountryConverter")
-public class AddressbookCountryConverter implements Converter {
-
- /**
- * Country bean
- */
- private CountrySingletonBeanRemote countryBean;
-
- /**
- * Logger instance
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * Initialization of this converter
- */
- public AddressbookCountryConverter () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-
- // ... and country bean
- this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- @Override
- public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2},this.countryBean={3} - CALLED!", context, component, submittedValue, this.countryBean)); //NOI18N
-
- // Is the value null or empty?
- if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
- // Return null
- return null;
- }
-
- // Get full list
- List<Country> countryList = this.countryBean.allCountries();
-
- // Init value
- Country country = null;
-
- // Try this better
- try {
- // Convert it to long
- Long countryId = Long.parseLong(submittedValue);
-
- // Category id should not be below 1
- assert (countryId > 0) : "countryId is smaller than one: " + countryId; //NOI18N
-
- // Debug message
- // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: countryId={0}", countryId)); //NOI18N
-
- // Try to find it
- for (final Country cntry : countryList) {
- // Is the id the same? (null-safe)
- if (Objects.equals(cntry.getCountryId(), countryId)) {
- // Found it
- country = cntry;
- break;
- }
- }
- } catch (final NumberFormatException ex) {
- // Log exception (maybe to much?)
- this.loggerBeanLocal.logException(ex);
- }
-
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: country={0} - EXIT!", country)); //NOI18N
-
- // Return it
- return country;
- }
-
- @Override
- public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
- // Is the object null?
- if ((null == value) || ((String.valueOf(value)).isEmpty())) {
- // Is null
- return ""; //NOI18N
- } else if (!(value instanceof Country)) {
- // Not same interface
- throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement Country.", value)); //NOI18N
- }
-
- // Return category id
- return String.valueOf(((Country) value).getCountryId());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.converter.mobileprovider;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Objects;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
-
-/**
- * Converter for SMS provider instance
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesConverter (value = "MobileProviderConverter")
-public class AddressbookMobileProviderConverter implements Converter {
-
- /**
- * Logger instance
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * Mobile provider bean
- */
- private MobileProviderSingletonBeanRemote mobileRemoteBean;
-
- /**
- * Initialization of this converter
- */
- public AddressbookMobileProviderConverter () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-
- /// and mobile provider controller
- this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/addressbook-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.MobileProvider.MobileProviderSingletonBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- @Override
- public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
-
- // Is the value null or empty?
- if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
- // Return null
- return null;
- }
-
- // Get full list
- List<MobileProvider> providerList = this.mobileRemoteBean.allMobileProvider();
-
- // Init value
- MobileProvider provider = null;
-
- // Try this better
- try {
- // Convert it to long
- Long providerId = Long.parseLong(submittedValue);
-
- // Category id should not be below 1
- assert (providerId > 0) : "providerId is smaller than one: " + providerId; //NOI18N
-
- // Debug message
- // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: providerId={0}", providerId)); //NOI18N
-
- // Try to find it
- for (final MobileProvider prov : providerList) {
- // Is the id the same? (null-safe)
- if (Objects.equals(prov.getProviderId(), providerId)) {
- // Found it
- provider = prov;
- break;
- }
- }
- } catch (final NumberFormatException ex) {
- // Log exception (maybe to much?)
- this.loggerBeanLocal.logException(ex);
- }
-
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: provider={0} - EXIT!", provider)); //NOI18N
-
- // Return it
- return provider;
- }
-
- @Override
- public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
- // Is the object null?
- if ((null == value) || ((String.valueOf(value)).isEmpty())) {
- // Is null
- return ""; //NOI18N
- } else if (!(value instanceof MobileProvider)) {
- // Not same interface
- throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement MobileProvider.", value)); //NOI18N
- }
-
- // Return category id
- return String.valueOf(((MobileProvider) value).getProviderId());
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.converter.user;
-
-import java.text.MessageFormat;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.convert.FacesConverter;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-
-/**
- * Converter for user id <-> valid user instance
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesConverter (value = "UserConverter")
-public class AddressbookUserConverter implements Converter {
-
- /**
- * Logger instance
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * User EJB
- */
- private UserSessionBeanRemote userBean;
-
- /**
- * Initialization of this converter
- */
- public AddressbookUserConverter () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-
- // ... and user controller
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- @Override
- public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
-
- // Is the value null or empty?
- if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
- // Warning message
- this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
- // Return null
- return null;
- }
-
- // Init instance
- User user = null;
-
- try {
- // Try to parse the value as long
- Long userId = Long.valueOf(submittedValue);
-
- // Debug message
- // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId)); //NOI18N
-
- // Try to get user instance from it
- user = this.userBean.findUserById(userId);
-
- // Debug message
- // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: user={0}", user)); //NOI18N
- } catch (final NumberFormatException ex) {
- // Throw again
- throw new ConverterException(ex);
- } catch (final UserNotFoundException ex) {
- // Debug message
- this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: Exception: {0} - Returning null ...", ex)); //NOI18N
- }
-
- // Trace message
- // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: user={0} - EXIT!", user)); //NOI18N
-
- // Return it
- return user;
- }
-
- @Override
- public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
- // Is the object null?
- if ((null == value) || ((String.valueOf(value)).isEmpty())) {
- // Is null
- return ""; //NOI18N
- } else if (!(value instanceof User)) {
- // Not same interface
- throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement User.", value)); //NOI18N
- }
-
- // Return category id
- return String.valueOf(((User) value).getUserId());
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.validator.addressbook;
-
-import java.text.MessageFormat;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.FacesValidator;
-import javax.faces.validator.ValidatorException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
-import org.mxchange.jaddressbookcore.exceptions.AddressbookNotFoundException;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jcoreee.validator.number.BaseLongValidator;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-
-/**
- * A validator for address book id verification
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesValidator (value = "AddressbookIdValidator")
-public class AddressbookIdValidator extends BaseLongValidator {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 158_768_467_186_951_809L;
-
- /**
- * Remote bean
- */
- private AddressbookSessionBeanRemote addressbookBean;
-
- /**
- * Logger instance
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * Public consutructor
- */
- public AddressbookIdValidator () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-
- // ... and user controller
- this.addressbookBean = (AddressbookSessionBeanRemote) context.lookup("java:global/addressbook-ejb/addressbook!org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- @Override
- public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
- // Trace message
- this.loggerBeanLocal.logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
-
- // All accepted, required fields
- String[] requiredFields = {"addressbookId"}; //NOI18N
-
- // Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFields, false);
-
- // Cast to long
- Long addressbookId = (Long) value;
-
- // Is the address book id valid?
- if (!this.addressbookBean.isAddressbookIdUsed(addressbookId)) {
- // Is not valid
- throw new ValidatorException(new FacesMessage(MessageFormat.format("No address book found with id {0}. Please check your link.", addressbookId))); //NOI18N
- }
-
- // Init variable
- Addressbook addressbook;
-
- // Try it
- try {
- // Get full data
- addressbook = this.addressbookBean.getAddressbookById(addressbookId);
-
- // Is it set?
- if (null == addressbook) {
- // Is null?!
- throw new NullPointerException(MessageFormat.format("addressbook for id={0} is null", addressbookId)); //NOI18N
- }
- } catch (final AddressbookNotFoundException ex) {
- // Continue to throw
- throw new ValidatorException(new FacesMessage(MessageFormat.format("Cannot find address book with id {0}", addressbookId)), ex); //NOI18N
- }
-
- // Trace message
- this.loggerBeanLocal.logTrace("validate: EXIT!"); //NOI18N
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.validator.birthday;
-
-import java.text.MessageFormat;
-import java.util.Date;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.FacesValidator;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcoreee.validator.date.BaseDateValidator;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-
-/**
- * A birthday validator
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesValidator("BirthdayValidator")
-public class AddressbookBirthdayValidator extends BaseDateValidator implements Validator {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 28_735_756_819_460L;
-
- /**
- * Logger bean
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * Default constructor
- */
- public AddressbookBirthdayValidator () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- @Override
- public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
- // Trace message
- this.loggerBeanLocal.logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
-
- // All accepted, required fields
- String[] requiredFields = {"birthday", "contactBirthday"}; //NOI18N
-
- // Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFields, false);
-
- // Cast value
- Date birthday = (Date) value;
-
- // @TODO Finish this, e.g. load maximum,minimum birthday from properties file
-
- // Trace message
- this.loggerBeanLocal.logTrace("validate: EXIT!"); //NOI18N
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.validator.emailaddress;
-
-import java.text.MessageFormat;
-import java.util.regex.Pattern;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.FacesValidator;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-import javax.faces.view.facelets.FaceletException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
-import org.mxchange.jcoreee.validator.string.BaseStringValidator;
-
-/**
- * A validator for email address validation
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesValidator ("EmailAddressValidator")
-public class AddressbookEmailAddressValidator extends BaseStringValidator implements Validator {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 187_536_745_607_192L;
-
- /**
- * Contact session bean
- */
- private final ContactSessionBeanRemote contactBean;
-
- /**
- * Default constructor
- */
- public AddressbookEmailAddressValidator () {
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
- }
-
- @Override
- public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
-
- // The required field
- String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N
-
- // Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFields, false);
-
- // Get string from object ... ;-)
- // @TODO Add IDN support (GNU lib?) Search for emailAddressRepeat
- String emailAddress = String.valueOf(value);
-
- // Checks if the email address matches a regex ("low-level" check, should also be done by <f:validatorRegex />)
- boolean matches = Pattern.matches("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$", emailAddress); //NOI18N
-
- // Is the email address valid?
- if (!matches) {
- // Generate message
- String message = MessageFormat.format("Email address {0} does not match regular expression.", emailAddress); //NOI18N
-
- // Not matching
- throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
- }
-
- // Get client id (aka form id)
- String clientId = component.getClientId();
-
- // Is the email address already registered?
- if ((!clientId.endsWith("resendEmailAddress")) && (this.contactBean.isEmailAddressRegistered(emailAddress))) { //NOI18N
- // Generate message
- String message = MessageFormat.format("Email address {0} is already registered.", emailAddress); //NOI18N
-
- // No, then abort here
- throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
- } else if ((clientId.endsWith("resendEmailAddress")) && (!this.contactBean.isEmailAddressRegistered(emailAddress))) { //NOI18N
- // Generate message
- String message = MessageFormat.format("Email address {0} is not registered.", emailAddress); //NOI18N
-
- // No, then abort here
- throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
- }
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("validate: EXIT!"); //NOI18N
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.validator.names;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.FacesValidator;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-import org.mxchange.jcoreee.validator.string.BaseStringValidator;
-
-/**
- * A validation class for addressbook names, such as first name or family name.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesValidator (value = "NameValidator")
-public class AddressbookNameValidator extends BaseStringValidator implements Validator {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 27_587_896_710_689_451L;
-
- @Override
- public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
-
- // All accepted, required fields
- String[] requiredFields = {"addressbookName"}; //NOI18N
-
- // Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFields, false);
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("validate: EXIT!"); //NOI18N
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * 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.addressbook.validator.password;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.FacesValidator;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-import javax.inject.Inject;
-import org.mxchange.jcoreee.validator.string.BaseStringValidator;
-import org.mxchange.jusercore.container.login.LoginContainer;
-import org.mxchange.jusercore.container.login.UserLoginContainer;
-import org.mxchange.jusercore.model.user.UserUtils;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
-
-/**
- * A validator for validating passwords (if they match with stored)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesValidator (value = "UserPasswordValidator")
-public class AddressbookUserPasswordValidator extends BaseStringValidator implements Validator {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 48_581_795_687_317L;
-
- /**
- * User login controller
- */
- @Inject
- private AddressbookUserLoginWebSessionController loginController;
-
- @Override
- public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
- // Trace message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
-
- // The required field
- String[] requiredFields = {"currentPassword"}; //NOI18N
-
- // Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFields, false);
-
- // value is known to be an entered password, so instance login container
- LoginContainer container = new UserLoginContainer(this.loginController.getLoggedInUser(), (String) value);
-
- // Test it here
- if (!UserUtils.ifPasswordMatches(container, this.loginController.getLoggedInUser())) {
- // Password mismatches
- throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password mismatching.", "The password the user has entered does not match the stored password.")); //NOI18N
- }
-
- // Trace message
- //* NOISY-DEBUG: */ System.out.println("validate: EXIT!"); //NOI18N
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.validator.user;
-
-import java.text.MessageFormat;
-import java.util.Set;
-import java.util.TreeSet;
-import javax.enterprise.event.Observes;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.FacesValidator;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.jcoreee.validator.number.BaseLongValidator;
-import org.mxchange.jcoreeelogger.beans.local.logger.Log;
-import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-
-/**
- * A validator for user ids
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@FacesValidator (value = "UserIdValidator")
-public class AddressbookUserIdValidator extends BaseLongValidator implements Validator {
-
- /**
- * Cached user status
- */
- private static final Set<Long> cachedStatus = new TreeSet<>();
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 12_869_569_314_764_690L;
-
- /**
- * Logger instance
- */
- @Log
- private LoggerBeanLocal loggerBeanLocal;
-
- /**
- * Remote bean
- */
- private UserSessionBeanRemote userBean;
-
- /**
- * Initialization of this converter
- */
- public AddressbookUserIdValidator () {
- // Try to get it
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Lookup logger
- this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
-
- // ... and user controller
- this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
- } catch (final NamingException ex) {
- // Continue to throw it
- throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
- }
- }
-
- /**
- * Event fired when the user registration is complete
- * <p>
- * @param event User registration event
- */
- public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
- // Trace message
- this.loggerBeanLocal.logTrace(MessageFormat.format("UserIdValidator:afterRegistrationEvent: event={0} - CALLED!", event)); //NOI18N
-
- // event 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.user is null"); //NOI18N
- } else if (event.getRegisteredUser().getUserId() == null) {
- // userId is null
- throw new NullPointerException("event.user.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
- }
-
- // Get user instance
- User registeredUser = event.getRegisteredUser();
-
- // Debug message
- this.loggerBeanLocal.logDebug(MessageFormat.format("UserIdValidator:afterRegistrationEvent: registeredUser={0}", registeredUser)); //NOI18N
-
- // Update cache
- AddressbookUserIdValidator.cachedStatus.add(registeredUser.getUserId());
-
- // Trace message
- this.loggerBeanLocal.logTrace("UserIdValidator:afterRegistrationEvent: EXIT!"); //NOI18N
- }
-
- @Override
- public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
- // Trace message
- this.loggerBeanLocal.logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
-
- // All accepted, required fields
- String[] requiredFields = {"userId"}; //NOI18N
-
- // Pre-validation (example: not null, not a string, empty string ...)
- super.preValidate(context, component, value, requiredFields, false);
-
- // Cast value
- Long userId = (Long) value;
-
- // Define variable
- Boolean ifUserExists;
-
- // Is a map entry there?
- if (AddressbookUserIdValidator.cachedStatus.contains(userId)) {
- // Get from cache
- ifUserExists = Boolean.TRUE;
- } else {
- // Get status
- ifUserExists = this.userBean.ifUserIdExists(userId);
- }
-
- // Is the user id valid?
- if (!ifUserExists) {
- // Is not valid
- throw new ValidatorException(new FacesMessage(MessageFormat.format("No user found with id {0}. Please check your link.", userId))); //NOI18N
- }
-
- // Add to cache if valid
- AddressbookUserIdValidator.cachedStatus.add(userId);
-
- // Trace message
- this.loggerBeanLocal.logTrace("validate: EXIT!"); //NOI18N
- }
-
-}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+
+/**
+ * A general controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public abstract class BaseFinancialsController implements Serializable {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 50_837_597_127_567_140L;
+
+ /**
+ * Returns given property key or throws an exception if not found.
+ * <p>
+ * @param parameterKey Property key
+ * <p>
+ * @return Property value
+ * <p>
+ * @throws NullPointerException If given key is not found
+ * @throws NumberFormatException If no number is given in context parameter
+ */
+ protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException {
+ // Get context parameter
+ Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey));
+
+ // Return it
+ return contextValue;
+ }
+
+ /**
+ * Returns given property key or throws an exception if not found.
+ * <p>
+ * @param parameterKey Property key
+ * <p>
+ * @return Property value
+ * <p>
+ * @throws NullPointerException If given key is not found
+ */
+ protected String getStringContextParameter (final String parameterKey) throws NullPointerException {
+ // Get context parameter
+ String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey);
+
+ // Is it null?
+ if (null == contextValue) {
+ // Throw NPE
+ throw new NullPointerException("parameterKey=" + parameterKey + " is not set.");
+ }
+
+ // Return it
+ return contextValue;
+ }
+
+ /**
+ * Checks whether debug mode is enabled for given controller
+ * <p>
+ * @param controllerName Name of controller
+ * <p>
+ * @return Whether debug mode is enabled
+ */
+ protected boolean isDebugModeEnabled (final String controllerName) {
+ // Parameters should be valid
+ if (null == controllerName) {
+ // Throw NPE
+ throw new NullPointerException("controllerName is null"); //NOI18N
+ } else if (controllerName.isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("controllerName is empty"); //NOI18N
+ }
+
+ // Try to get context parameter
+ String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N
+
+ // Is it set and true?
+ boolean isEnabled = ((contextParameter instanceof String) && (contextParameter.equals("true"))); //NOI18N
+
+ // Return it
+ return isEnabled;
+ }
+
+ /**
+ * Shows a faces message for given causing exception. The message from the
+ * exception is being inserted into the message.
+ * <p>
+ * @param clientId Client id to send message to
+ * @param cause Causing exception
+ */
+ protected void showFacesMessage (final String clientId, final Throwable cause) {
+ // Trace message
+ System.out.println(MessageFormat.format("showFacesMessage: clientId={0},cause={1} - CALLED!", clientId, cause));
+
+ // Get context and add message
+ this.showFacesMessage(clientId, cause.getMessage());
+ }
+
+ /**
+ * Shows a faces message with given message.
+ * <p>
+ * @param clientId Client id to send message to
+ * @param message Causing exception
+ */
+ protected void showFacesMessage (final String clientId, final String message) {
+ // Get context and add message
+ FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.confirmlink;
+
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcoreee.utils.FacesUtils;
+import org.mxchange.jusercore.events.confirmation.ConfirmedUserAccountEvent;
+import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
+import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
+import org.mxchange.jusercore.exceptions.UserStatusLockedException;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.jfinancials.beans.helper.FinancialsWebRequestController;
+import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
+
+/**
+ * A web request bean for confirmation link handling
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("confirmationLinkController")
+@RequestScoped
+public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsController implements FinancialsConfirmationLinkWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 57_637_182_796_370L;
+
+ /**
+ * Admin helper instance
+ */
+ @Inject
+ private FinancialsWebRequestController beanHelper;
+
+ /**
+ * Confirmation key
+ */
+ private String confirmationKey;
+
+ /**
+ * Remote user bean
+ */
+ private final UserSessionBeanRemote userBean;
+
+ /**
+ * User controller
+ */
+ @Inject
+ private FinancialsUserWebSessionController userController;
+
+ /**
+ * Event being fired when a user has confirmed the account
+ */
+ @Inject
+ @Any
+ private Event<UserConfirmedAccountEvent> userConfirmedEvent;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsConfirmationLinkWebRequestBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public String getConfirmationKey () {
+ return this.confirmationKey;
+ }
+
+ @Override
+ public void setConfirmationKey (final String confirmationKey) {
+ this.confirmationKey = confirmationKey;
+ }
+
+ @Override
+ public void maybeConfirmUserAccount () {
+ // Is the confirmation key set?
+ if (this.getConfirmationKey() == null) {
+ // May be null if not set
+ return;
+ } else if (this.getConfirmationKey().isEmpty()) {
+ // Is empty string
+ return;
+ }
+
+ // Now try to find the user in user list, first get the whole list
+ List<User> users = this.userController.allUsers();
+
+ // Get iterator from it
+ Iterator<User> iterator = users.iterator();
+
+ // Init instance
+ User user = null;
+
+ // Then loop through all
+ while (iterator.hasNext()) {
+ // Get next user
+ User next = iterator.next();
+
+ // Same confirmation key?
+ if (Objects.equals(this.getConfirmationKey(), next.getUserConfirmKey())) {
+ // Found it, then set it and abort loop
+ user = next;
+ break;
+ }
+ }
+
+ // Is the user instance null?
+ if ((null == user) || (user.getUserAccountStatus() != UserAccountStatus.UNCONFIRMED)) {
+ // Then clear this bean and the helper
+ this.beanHelper.setUser(null);
+ } else {
+ // Set user ...
+ this.beanHelper.setUser(user);
+
+ // ... and copy it to the controller
+ this.beanHelper.copyUserToController();
+
+ // Try to confirm it
+ this.confirmUserAccount();
+ }
+ }
+
+ /**
+ * Tries to confirm the currently set user instance (in helper).
+ */
+ private void confirmUserAccount () {
+ // Get user instance
+ User user = this.beanHelper.getUser();
+
+ // Should be set
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null");
+ } else if (user.getUserId() == null) {
+ // Abort here
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid number
+ throw new IllegalArgumentException(MessageFormat.format("userId is not valid: {0}", user.getUserId())); //NOI18N
+ } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
+ // Account is already confirmed
+ throw new FaceletException(new UserStatusConfirmedException(user));
+ } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
+ // Account is already confirmed
+ throw new FaceletException(new UserStatusLockedException(user));
+ } else if (user.getUserConfirmKey() == null) {
+ // Throw NPE
+ throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
+ }
+
+ // Updated user instance
+ User updatedUser;
+
+ try {
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // Confirm account
+ updatedUser = this.userBean.confirmAccount(user, baseUrl);
+ } catch (final UserStatusConfirmedException | UserStatusLockedException ex) {
+ // Something unexpected happened
+ throw new FaceletException(MessageFormat.format("Cannot confirm user account {0}", user.getUserName()), ex); //NOI18N
+ }
+
+ // Fire event that the user has confirmed account
+ this.userConfirmedEvent.fire(new ConfirmedUserAccountEvent(updatedUser));
+
+ // Set it again in helper
+ this.beanHelper.setUser(updatedUser);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.confirmlink;
+
+import java.io.Serializable;
+
+/**
+ * An interface for an email change controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsConfirmationLinkWebRequestController extends Serializable {
+
+ /**
+ * Getter for confirmation key
+ * <p>
+ * @return Confirmation key
+ */
+ String getConfirmationKey ();
+
+ /**
+ * Setter for confirmation key
+ * <p>
+ * @param confirmationKey Confirmation key
+ */
+ void setConfirmationKey (final String confirmationKey);
+
+ /**
+ * Tries to lookup the user by currently set confirmation key and if found
+ * tries to confirm it. If no user is found, the instance beanHelper.user is
+ * set to null. Other methods or JSF pages should then respond on this
+ * accordingly.
+ */
+ void maybeConfirmUserAccount ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.contact;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.Iterator;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.context.FacesContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
+import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.contact.utils.ContactUtils;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.add.AdminContactAddedEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminContactUpdatedEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.DialableNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jfinancials.beans.helper.FinancialsWebRequestController;
+
+/**
+ * An administrative user bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminContactController")
+@RequestScoped
+public class FinancialsAdminContactWebRequestBean extends BaseFinancialsController implements FinancialsAdminContactWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_916L;
+
+ /**
+ * An event fired when the administrator has added a new contact
+ */
+ @Inject
+ @Any
+ private Event<AdminAddedContactEvent> addedContactEvent;
+
+ /**
+ * Administrative contact EJB
+ */
+ private AdminContactSessionBeanRemote adminContactBean;
+
+ /**
+ * Admin helper instance
+ */
+ @Inject
+ private FinancialsWebRequestController beanHelper;
+
+ /**
+ * Birth day
+ */
+ private Date birthday;
+
+ /**
+ * City
+ */
+ private String city;
+
+ /**
+ * Optional comments
+ */
+ private String comment;
+
+ /**
+ * Remote contact bean
+ */
+ private final ContactSessionBeanRemote contactBean;
+
+ /**
+ * General contact controller
+ */
+ @Inject
+ private FinancialsContactWebSessionController contactController;
+
+ /**
+ * Contact id
+ */
+ private Long contactId;
+
+ /**
+ * Country instance
+ */
+ private Country country;
+
+ /**
+ * Email address
+ */
+ private String emailAddress;
+
+ /**
+ * Family name
+ */
+ private String familyName;
+
+ /**
+ * Fax number's area code
+ */
+ private Integer faxAreaCode;
+
+ /**
+ * Country instance for fax number
+ */
+ private Country faxCountry;
+
+ /**
+ * Fax id number
+ */
+ private Long faxId;
+
+ /**
+ * Fax number
+ */
+ private Long faxNumber;
+
+ /**
+ * First name
+ */
+ private String firstName;
+
+ /**
+ * Gender instance
+ */
+ private Gender gender;
+
+ /**
+ * House number
+ */
+ private Short houseNumber;
+
+ /**
+ * House number extension
+ */
+ private String houseNumberExtension;
+
+ /**
+ * Whether a fax entry has been unlinked
+ */
+ private boolean isFaxUnlinked;
+
+ /**
+ * Whether a land-line number has been unlinked
+ */
+ private boolean isLandLineUnlinked;
+
+ /**
+ * Whether a mobile entry has been unlinked
+ */
+ private boolean isMobileUnlinked;
+
+ /**
+ * Land-line id number
+ */
+ private Long landLineId;
+
+ /**
+ * Mobile number's carrier
+ */
+ private MobileProvider mobileCarrier;
+
+ /**
+ * Mobile id number
+ */
+ private Long mobileId;
+
+ /**
+ * Mobile number
+ */
+ private Long mobileNumber;
+
+ /**
+ * Phone number area code
+ */
+ private Integer phoneAreaCode;
+
+ /**
+ * Country instance for phone number
+ */
+ private Country phoneCountry;
+
+ /**
+ * Phone number
+ */
+ private Long phoneNumber;
+
+ /**
+ * Street
+ */
+ private String street;
+
+ /**
+ * Title
+ */
+ private String title;
+
+ /**
+ * An event fired when the administrator has updated contact data
+ */
+ @Inject
+ @Any
+ private Event<AdminUpdatedContactEvent> updatedContactEvent;
+
+ /**
+ * ZIP code
+ */
+ private Integer zipCode;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsAdminContactWebRequestBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public String addContact () {
+ // Are all minimum fields set?
+ if (this.getGender() == null) {
+ // Throw NPE
+ throw new NullPointerException("gender is null"); //NOI18N
+ } else if (this.getFirstName() == null) {
+ // Throw NPE
+ throw new NullPointerException("firstName is null"); //NOI18N
+ } else if (this.getFirstName().isEmpty()) {
+ // Empty string
+ throw new IllegalStateException("firstName is empty"); //NOI18N
+ } else if (this.getFamilyName() == null) {
+ // Throw NPE
+ throw new NullPointerException("familyName is null"); //NOI18N
+ } else if (this.getFamilyName().isEmpty()) {
+ // Empty string
+ throw new IllegalStateException("familyName is empty"); //NOI18N
+ }
+
+ // Create new contact instance
+ Contact contact = this.createContactInstance();
+
+ // Default is not same contact
+ if (this.isSameContactFound(contact)) {
+ // Already registered
+ throw new FaceletException(new ContactAlreadyAddedException(contact));
+ }
+
+ // Init contact
+ Contact updatedContact;
+
+ // Try to call EJB
+ try {
+ // Call EJB
+ updatedContact = this.adminContactBean.addContact(contact);
+ } catch (final ContactAlreadyAddedException ex) {
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Fire event
+ this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact));
+
+ // Clear this bean
+ this.clear();
+
+ // Return outcome
+ return "admin_list_contact"; //NOI18N
+ }
+
+ @Override
+ public void copyContactToController (final Contact contact) {
+ // The contact instance must be valid
+ if (null == contact) {
+ // Throw NPE again
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ }
+
+ // Set all fields: contact
+ this.setContactId(contact.getContactId());
+ this.setTitle(contact.getContactTitle());
+ this.setBirthday(contact.getContactBirthday());
+ this.setCity(contact.getContactCity());
+ this.setComment(contact.getContactComment());
+ this.setCountry(contact.getContactCountry());
+ this.setEmailAddress(contact.getContactEmailAddress());
+ this.setFamilyName(contact.getContactFamilyName());
+ this.setFirstName(contact.getContactFirstName());
+ this.setGender(contact.getContactGender());
+ this.setHouseNumber(contact.getContactHouseNumber());
+ this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
+ this.setStreet(contact.getContactStreet());
+ this.setZipCode(contact.getContactZipCode());
+
+ // ... mobile data
+ if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+ this.setMobileId(contact.getContactMobileNumber().getPhoneId());
+ this.setMobileCarrier(contact.getContactMobileNumber().getMobileProvider());
+ this.setMobileNumber(contact.getContactMobileNumber().getPhoneNumber());
+ }
+
+ // ... fax data
+ if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+ this.setFaxId(contact.getContactFaxNumber().getPhoneId());
+ this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
+ this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
+ this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
+ }
+
+ // .. land-line data
+ if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+ this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
+ this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
+ this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
+ this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
+ }
+ }
+
+ @Override
+ public Contact createContactInstance () {
+ // Generate phone number
+ DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+ DialableMobileNumber mobile = new MobileNumber(this.getMobileCarrier(), this.getMobileNumber());
+ DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+
+ // Create new instance
+ Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
+
+ // Check if contact instance is in helper and valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("beanHelper.contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Invalid id
+ throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
+ }
+
+ // Update all data in contact
+ this.updateContactData(contact);
+
+ // Call EJB for updating contact data
+ Contact updatedContact = this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
+
+ // Fire event
+ this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
+
+ // Clear bean
+ this.clear();
+
+ // Return it
+ return contact;
+ }
+
+ @Override
+ public String editContactData () {
+ // Get contact instance
+ Contact contact = this.beanHelper.getContact();
+
+ // Check if contact instance is in helper and valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("beanHelper.contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Invalid id
+ throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
+ }
+
+ // Update all data in contact
+ this.updateContactData(contact);
+
+ // Call EJB for updating contact data
+ Contact updatedContact = this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
+
+ // Fire event
+ this.updatedContactEvent.fire(new AdminContactUpdatedEvent(updatedContact));
+
+ // Clear bean
+ this.clear();
+
+ // Return to contact list (for now)
+ return "admin_list_contact"; //NOI18N
+ }
+
+ @Override
+ public String generateMobileNumber (final DialableMobileNumber mobileNumber) {
+ // Is it null?
+ if (null == mobileNumber) {
+ // Return null
+ return null;
+ }
+
+ // Get all data
+ String number = String.format(
+ "%s%d%d", //NOI18N
+ mobileNumber.getMobileProvider().getProviderCountry().getCountryExternalDialPrefix(),
+ mobileNumber.getMobileProvider().getProviderDialPrefix(),
+ mobileNumber.getPhoneNumber()
+ );
+
+ // Return it
+ return number;
+ }
+
+ @Override
+ public String generatePhoneNumber (final DialableNumber phoneNumber) {
+ // Is it null?
+ if (null == phoneNumber) {
+ // Return null
+ return null;
+ }
+
+ // Generate it
+ String number = String.format(
+ "%s%d%d", //NOI18N
+ phoneNumber.getPhoneCountry().getCountryExternalDialPrefix(),
+ phoneNumber.getPhoneAreaCode(),
+ phoneNumber.getPhoneNumber()
+ );
+
+ // Return it
+ return number;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfDateField")
+ public Date getBirthday () {
+ return this.birthday;
+ }
+
+ @Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setBirthday (final Date birthday) {
+ this.birthday = birthday;
+ }
+
+ @Override
+ public String getCity () {
+ return this.city;
+ }
+
+ @Override
+ public void setCity (final String city) {
+ this.city = city;
+ }
+
+ @Override
+ public String getComment () {
+ return this.comment;
+ }
+
+ @Override
+ public void setComment (final String comment) {
+ this.comment = comment;
+ }
+
+ @Override
+ public Long getContactId () {
+ return this.contactId;
+ }
+
+ @Override
+ public void setContactId (final Long contactId) {
+ this.contactId = contactId;
+ }
+
+ @Override
+ public Country getCountry () {
+ return this.country;
+ }
+
+ @Override
+ public void setCountry (final Country country) {
+ this.country = country;
+ }
+
+ @Override
+ public String getEmailAddress () {
+ return this.emailAddress;
+ }
+
+ @Override
+ public void setEmailAddress (final String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ @Override
+ public String getFamilyName () {
+ return this.familyName;
+ }
+
+ @Override
+ public void setFamilyName (final String familyName) {
+ this.familyName = familyName;
+ }
+
+ @Override
+ public Integer getFaxAreaCode () {
+ return this.faxAreaCode;
+ }
+
+ @Override
+ public void setFaxAreaCode (final Integer faxAreaCode) {
+ this.faxAreaCode = faxAreaCode;
+ }
+
+ @Override
+ public Country getFaxCountry () {
+ return this.faxCountry;
+ }
+
+ @Override
+ public void setFaxCountry (final Country faxCountry) {
+ this.faxCountry = faxCountry;
+ }
+
+ @Override
+ public Long getFaxId () {
+ return this.faxId;
+ }
+
+ @Override
+ public void setFaxId (final Long faxId) {
+ this.faxId = faxId;
+ }
+
+ @Override
+ public Long getFaxNumber () {
+ return this.faxNumber;
+ }
+
+ @Override
+ public void setFaxNumber (final Long faxNumber) {
+ this.faxNumber = faxNumber;
+ }
+
+ @Override
+ public String getFirstName () {
+ return this.firstName;
+ }
+
+ @Override
+ public void setFirstName (final String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Override
+ public Gender getGender () {
+ return this.gender;
+ }
+
+ @Override
+ public void setGender (final Gender gender) {
+ this.gender = gender;
+ }
+
+ @Override
+ public Short getHouseNumber () {
+ return this.houseNumber;
+ }
+
+ @Override
+ public void setHouseNumber (final Short houseNumber) {
+ this.houseNumber = houseNumber;
+ }
+
+ @Override
+ public String getHouseNumberExtension () {
+ return this.houseNumberExtension;
+ }
+
+ @Override
+ public void setHouseNumberExtension (final String houseNumberExtension) {
+ this.houseNumberExtension = houseNumberExtension;
+ }
+
+ @Override
+ public Long getLandLineId () {
+ return this.landLineId;
+ }
+
+ @Override
+ public void setLandLineId (final Long landLineId) {
+ this.landLineId = landLineId;
+ }
+
+ @Override
+ public MobileProvider getMobileCarrier () {
+ return this.mobileCarrier;
+ }
+
+ @Override
+ public void setMobileCarrier (final MobileProvider mobileCarrier) {
+ this.mobileCarrier = mobileCarrier;
+ }
+
+ @Override
+ public Long getMobileId () {
+ return this.mobileId;
+ }
+
+ @Override
+ public void setMobileId (final Long mobileId) {
+ this.mobileId = mobileId;
+ }
+
+ @Override
+ public Long getMobileNumber () {
+ return this.mobileNumber;
+ }
+
+ @Override
+ public void setMobileNumber (Long mobileNumber) {
+ this.mobileNumber = mobileNumber;
+ }
+
+ @Override
+ public Integer getPhoneAreaCode () {
+ return this.phoneAreaCode;
+ }
+
+ @Override
+ public void setPhoneAreaCode (final Integer phoneAreaCode) {
+ this.phoneAreaCode = phoneAreaCode;
+ }
+
+ @Override
+ public Country getPhoneCountry () {
+ return this.phoneCountry;
+ }
+
+ @Override
+ public void setPhoneCountry (final Country phoneCountry) {
+ this.phoneCountry = phoneCountry;
+ }
+
+ @Override
+ public Long getPhoneNumber () {
+ return this.phoneNumber;
+ }
+
+ @Override
+ public void setPhoneNumber (final Long phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ @Override
+ public String getStreet () {
+ return this.street;
+ }
+
+ @Override
+ public void setStreet (final String street) {
+ this.street = street;
+ }
+
+ @Override
+ public String getTitle () {
+ return this.title;
+ }
+
+ @Override
+ public void setTitle (final String title) {
+ this.title = title;
+ }
+
+ @Override
+ public Integer getZipCode () {
+ return this.zipCode;
+ }
+
+ @Override
+ public void setZipCode (final Integer zipCode) {
+ this.zipCode = zipCode;
+ }
+
+ /**
+ * Post-initialization of this class
+ */
+ @PostConstruct
+ public void init () {
+ }
+
+ @Override
+ public boolean isGenderRequired () {
+ // Get context parameter
+ String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_admin_gender_enabled"); //NOI18N
+
+ // Is it set?
+ boolean isRequired = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
+
+ // Return value
+ return isRequired;
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ // - personal data
+ this.setGender(null);
+ this.setTitle(null);
+ this.setFirstName(null);
+ this.setFamilyName(null);
+ this.setStreet(null);
+ this.setHouseNumber(null);
+ this.setHouseNumberExtension(null);
+ this.setZipCode(null);
+ this.setCity(null);
+ this.setCountry(null);
+
+ // - contact data
+ this.setEmailAddress(null);
+ this.setPhoneCountry(null);
+ this.setPhoneAreaCode(null);
+ this.setPhoneNumber(null);
+ this.setMobileCarrier(null);
+ this.setMobileNumber(null);
+ this.setFaxCountry(null);
+ this.setFaxAreaCode(null);
+ this.setFaxNumber(null);
+
+ // - other data
+ this.setBirthday(null);
+ this.setComment(null);
+ }
+
+ /**
+ * Checks whether the given contact is found
+ * <p>
+ * @param contact Contact inastance
+ *
+ * @return Wether contact has been found
+ */
+ private boolean isSameContactFound (final Contact contact) {
+ // Default is not found
+ boolean IsFound = false;
+
+ // Get iterator
+ Iterator<Contact> iterator = this.contactController.allContacts().iterator();
+
+ // Loop through all
+ while (iterator.hasNext()) {
+ // Get next contact
+ Contact next = iterator.next();
+
+ // Is the same?
+ if (ContactUtils.isSameContact(contact, next)) {
+ // Yes, then abort loop
+ IsFound = false;
+ break;
+ }
+ }
+
+ // Return status
+ return IsFound;
+ }
+
+ /**
+ * Updates all data in contact instance.
+ * <p>
+ * @param contact Contact instance
+ */
+ private void updateContactData (final Contact contact) {
+ // Contact instance should be valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Invalid id
+ throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
+ }
+
+ // Update all fields
+ contact.setContactGender(this.getGender());
+ contact.setContactTitle(this.getTitle());
+ contact.setContactFirstName(this.getFirstName());
+ contact.setContactFamilyName(this.getFamilyName());
+ contact.setContactStreet(this.getStreet());
+ contact.setContactHouseNumber(this.getHouseNumber());
+ contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
+ contact.setContactZipCode(this.getZipCode());
+ contact.setContactCity(this.getCity());
+ contact.setContactCountry(this.getCountry());
+
+ // Update contact's mobile number
+ this.isMobileUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getMobileCarrier(), this.getMobileNumber());
+
+ // Update contact's land-line number
+ this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+
+ // Update contact's fax number
+ this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.contact;
+
+import java.io.Serializable;
+import java.util.Date;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.DialableNumber;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+
+/**
+ * An administrative interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsAdminContactWebRequestController extends Serializable {
+
+ /**
+ * Adds contact data to database and redirects on success. If the contact is
+ * already found, a proper exception is thrown.
+ * <p>
+ * @return Redirect outcome
+ */
+ String addContact ();
+
+ /**
+ * Creates an instance from contact data
+ * <p>
+ * @return New contact instance
+ */
+ Contact createContactInstance ();
+
+ /**
+ * Copies given contact's data to this controller
+ * <p>
+ * @param contact Contact instance
+ */
+ void copyContactToController (final Contact contact);
+
+ /**
+ * Edits currently loaded contact's data in database.
+ * <p>
+ * @return Redirect outcome
+ */
+ String editContactData ();
+
+ /**
+ * Getter for mobile id
+ * <p>
+ * @return Mobile id
+ */
+ Long getMobileId ();
+
+ /**
+ * Setter for mobile id
+ * <p>
+ * @param mobileId Mobile id
+ */
+ void setMobileId (final Long mobileId);
+
+ /**
+ * Getter for fax id
+ * <p>
+ * @return Fax id
+ */
+ Long getFaxId ();
+
+ /**
+ * Setter for fax id
+ * <p>
+ * @param faxId Fax id
+ */
+ void setFaxId (final Long faxId);
+
+ /**
+ * Getter for land-line id
+ * <p>
+ * @return Land-line id
+ */
+ Long getLandLineId ();
+
+ /**
+ * Setter for land-line id
+ * <p>
+ * @param landLineId Land-line id
+ */
+ void setLandLineId (final Long landLineId);
+
+ /**
+ * Getter for birth day
+ * <p>
+ * @return Birth day
+ */
+ Date getBirthday ();
+
+ /**
+ * Setter for birth day
+ * <p>
+ * @param birthday Birth day
+ */
+ void setBirthday (final Date birthday);
+
+ /**
+ * Getter for mobile number's carrier
+ * <p>
+ * @return Mobile number's carrier
+ */
+ MobileProvider getMobileCarrier ();
+
+ /**
+ * Setter for mobile number's carrier prefix
+ * <p>
+ * @param mobileCarrier Mobile number's carrier prefix
+ */
+ void setMobileCarrier (final MobileProvider mobileCarrier);
+
+ /**
+ * Getter for mobile number
+ * <p>
+ * @return Mobile number
+ */
+ Long getMobileNumber ();
+
+ /**
+ * Setter for mobile number
+ * <p>
+ * @param mobileNumber Mobile number
+ */
+ void setMobileNumber (final Long mobileNumber);
+
+ /**
+ * City
+ * <p>
+ * @return the city
+ */
+ String getCity ();
+
+ /**
+ * City
+ * <p>
+ * @param city the city to set
+ */
+ void setCity (final String city);
+
+ /**
+ * Getter for comments
+ * <p>
+ * @return Comments
+ */
+ String getComment ();
+
+ /**
+ * Setter for comment
+ * <p>
+ * @param comment Comments
+ */
+ void setComment (final String comment);
+
+ /**
+ * Getter for contact id
+ * <p>
+ * @return Contact id
+ */
+ Long getContactId ();
+
+ /**
+ * Setter for contact id
+ * <p>
+ * @param contactId Contact id
+ */
+ void setContactId (final Long contactId);
+
+ /**
+ * Getter for country instance
+ * <p>
+ * @return Country instance
+ */
+ Country getCountry ();
+
+ /**
+ * Setter for country instance
+ * <p>
+ * @param country Country instance
+ */
+ void setCountry (final Country country);
+
+ /**
+ * Getter for email address
+ * <p>
+ * @return Email address
+ */
+ String getEmailAddress ();
+
+ /**
+ * Setter for email address
+ * <p>
+ * @param emailAddress Email address
+ */
+ void setEmailAddress (final String emailAddress);
+
+ /**
+ * Family name
+ * <p>
+ * @return the familyName
+ */
+ String getFamilyName ();
+
+ /**
+ * Family name
+ * <p>
+ * @param familyName the familyName to set
+ */
+ void setFamilyName (final String familyName);
+
+ /**
+ * Getter for fax number's area code
+ * <p>
+ * @return Fax number's area code
+ */
+ Integer getFaxAreaCode ();
+
+ /**
+ * Setter for fax number's area code
+ * <p>
+ * @param faxAreaCode Fax number's area code
+ */
+ void setFaxAreaCode (final Integer faxAreaCode);
+
+ /**
+ * Getter for fax's country instance
+ * <p>
+ * @return Fax' country instance
+ */
+ Country getFaxCountry ();
+
+ /**
+ * Setter for fax's country instance
+ * <p>
+ * @param faxCountry Fax' country instance
+ */
+ void setFaxCountry (final Country faxCountry);
+
+ /**
+ * Getter for fax number
+ * <p>
+ * @return Fax number
+ */
+ Long getFaxNumber ();
+
+ /**
+ * Setter for fax number
+ * <p>
+ * @param faxNumber Fax number
+ */
+ void setFaxNumber (final Long faxNumber);
+
+ /**
+ * First name
+ * <p>
+ * @return the first name
+ */
+ String getFirstName ();
+
+ /**
+ * First name
+ * <p>
+ * @param firstName the first name to set
+ */
+ void setFirstName (final String firstName);
+
+ /**
+ * Gender of the contact
+ * <p>
+ * @return the gender
+ */
+ Gender getGender ();
+
+ /**
+ * Gender of the contact
+ * <p>
+ * @param gender the gender to set
+ */
+ void setGender (final Gender gender);
+
+ /**
+ * House number
+ * <p>
+ * @return the houseNumber
+ */
+ Short getHouseNumber ();
+
+ /**
+ * House number
+ * <p>
+ * @param houseNumber the houseNumber to set
+ */
+ void setHouseNumber (final Short houseNumber);
+
+ /**
+ * Getter for house number extension, example: 123a 'a' is then the
+ * extension and 123 is the house number.
+ * <p>
+ * @return House number extension
+ */
+ String getHouseNumberExtension ();
+
+ /**
+ * Setter for house number extension
+ * <p>
+ * @param houseNumberExtension House number extension
+ */
+ void setHouseNumberExtension (final String houseNumberExtension);
+
+ /**
+ * Getter for phone number's area code
+ * <p>
+ * @return Phone number's area code
+ */
+ Integer getPhoneAreaCode ();
+
+ /**
+ * Setter for phone number's area code
+ * <p>
+ * @param phoneAreaCode Phone number's area code
+ */
+ void setPhoneAreaCode (final Integer phoneAreaCode);
+
+ /**
+ * Getter for phone number's country instance
+ * <p>
+ * @return Phone number's country instance
+ */
+ Country getPhoneCountry ();
+
+ /**
+ * Setter for phone number's country instance
+ * <p>
+ * @param phoneCountry Phone number's country instance
+ */
+ void setPhoneCountry (final Country phoneCountry);
+
+ /**
+ * Getter for phone number
+ * <p>
+ * @return Phone number
+ */
+ Long getPhoneNumber ();
+
+ /**
+ * Setter for phone number
+ * <p>
+ * @param phoneNumber Phone number
+ */
+ void setPhoneNumber (final Long phoneNumber);
+
+ /**
+ * Street
+ * <p>
+ * @return the street
+ */
+ String getStreet ();
+
+ /**
+ * Street
+ * <p>
+ * @param street the street to set
+ */
+ void setStreet (final String street);
+
+ /**
+ * Getter for title
+ * <p>
+ * @return title
+ */
+ String getTitle ();
+
+ /**
+ * Setter for title
+ * <p>
+ * @param title Title
+ */
+ void setTitle (final String title);
+
+ /**
+ * ZIP code
+ * <p>
+ * @return the zipCode
+ */
+ Integer getZipCode ();
+
+ /**
+ * ZIP code
+ * <p>
+ * @param zipCode the zipCode to set
+ */
+ void setZipCode (final Integer zipCode);
+
+ /**
+ * Returns a text respresentation of given phone number or null if not set.
+ * <p>
+ * @param phoneNumber Phone number
+ * <p>
+ * @return Text respresentation or null
+ */
+ String generatePhoneNumber (final DialableNumber phoneNumber);
+
+ /**
+ * Returns a text representation of given mobile number or null if not
+ * set.
+ * <p>
+ * @param mobileNumber Mobile number
+ * <p>
+ * @return Text respresentation or null
+ */
+ String generateMobileNumber (final DialableMobileNumber mobileNumber);
+
+ /**
+ * Checks/returns whether the gender/salutation is required for this
+ * controller.
+ * <p>
+ * @return Whether gender is required
+ */
+ boolean isGenderRequired ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.contact;
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
+import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.contact.utils.ContactUtils;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController;
+import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
+
+/**
+ * A general contact bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("contactController")
+@SessionScoped
+public class FinancialsContactWebSessionBean extends BaseFinancialsController implements FinancialsContactWebSessionController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_916L;
+
+ /**
+ * Birth day
+ */
+ private Date birthday;
+
+ /**
+ * Mobile number's carrier
+ */
+ private MobileProvider mobileCarrier;
+
+ /**
+ * Mobile number
+ */
+ private Long mobileNumber;
+
+ /**
+ * City
+ */
+ private String city;
+
+ /**
+ * Optional comments
+ */
+ private String comment;
+
+ /**
+ * Remote contact bean
+ */
+ private final ContactSessionBeanRemote contactBean;
+
+ /**
+ * Contact list
+ */
+ private final List<Contact> contactList;
+
+ /**
+ * Country instance
+ */
+ private Country country;
+
+ /**
+ * Email address
+ */
+ private String emailAddress;
+
+ /**
+ * Email address list
+ */
+ private final List<String> emailAddressList;
+
+ /**
+ * Email address repeated
+ */
+ private String emailAddressRepeat;
+
+ /**
+ * Family name
+ */
+ private String familyName;
+
+ /**
+ * Fax number's area code
+ */
+ private Integer faxAreaCode;
+
+ /**
+ * Country instance for fax number
+ */
+ private Country faxCountry;
+
+ /**
+ * Fax number
+ */
+ private Long faxNumber;
+
+ /**
+ * First name
+ */
+ private String firstName;
+
+ /**
+ * Gender instance
+ */
+ private Gender gender;
+
+ /**
+ * House number
+ */
+ private Short houseNumber;
+
+ /**
+ * House number extension
+ */
+ private String houseNumberExtension;
+
+ /**
+ * Whether a mobile entry has been unlinked
+ */
+ private boolean isMobileUnlinked;
+
+ /**
+ * Whether a fax entry has been unlinked
+ */
+ private boolean isFaxUnlinked;
+
+ /**
+ * Whether a land-line number has been unlinked
+ */
+ private boolean isLandLineUnlinked;
+
+ /**
+ * Phone number area code
+ */
+ private Integer phoneAreaCode;
+
+ /**
+ * Country instance for phone number
+ */
+ private Country phoneCountry;
+
+ /**
+ * Phone number
+ */
+ private Long phoneNumber;
+
+ /**
+ * A list of all selectable contacts
+ */
+ private List<Contact> selectableContacts;
+
+ /**
+ * Street
+ */
+ private String street;
+
+ /**
+ * Title
+ */
+ private String title;
+
+ /**
+ * Regular user controller
+ */
+ @Inject
+ private FinancialsUserWebSessionController userController;
+
+ /**
+ * Login bean (controller)
+ */
+ @Inject
+ private FinancialsUserLoginWebSessionController userLoginController;
+
+ /**
+ * ZIP code
+ */
+ private Integer zipCode;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsContactWebSessionBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+
+ // Init lists/maps
+ this.contactList = new LinkedList<>();
+ this.emailAddressList = new LinkedList<>();
+ }
+
+ @Override
+ public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("contactController.afterAdminAddedContact(): event={0} - CALLED!", event)); //NOI18N
+
+ // The event must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedContact is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() == null) {
+ // ... and again
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+ }
+
+ // Clear this bean
+ this.clear();
+
+ // Call other method
+ this.uniqueAddContact(event.getAddedContact());
+
+ // Add to selectable contacts
+ this.selectableContacts.add(event.getAddedContact());
+ }
+
+ @Override
+ public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("contactController.afterAdminAddedUserEvent(): event={0} - CALLED!", event)); //NOI18N
+
+ // event 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
+ }
+
+ // Clear all data
+ this.clear();
+ }
+
+ @Override
+ public void afterAdminLinkedUser (@Observes final AdminLinkedUserEvent event) {
+ // event 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().getUserContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.linkedUser.userContact is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserContact().getContactId() == null) {
+ // userId is null
+ throw new NullPointerException("event.linkedUser.userContact.contactId is null"); //NOI18N
+ } else if (event.getLinkedUser().getUserContact().getContactId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserContact().getContactId())); //NOI18N
+ }
+
+ // Remove contact from list available contacts list
+ this.selectableContacts.remove(event.getLinkedUser().getUserContact());
+
+ // Clear all data
+ this.clear();
+ }
+
+ @Override
+ public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedContact is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() == null) {
+ // userId is null
+ throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+ }
+
+ // Add contact instance only once
+ this.uniqueAddContact(event.getUpdatedContact());
+
+ // Add email address to list
+ this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress());
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("contactController.afterAdminUpdatedContactDataEvent(): EXIT!"); //NOI18N
+ }
+
+ @Override
+ public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
+ // event 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
+ }
+
+ // Get user instance
+ Contact registeredContact = event.getRegisteredUser().getUserContact();
+
+ // Copy all data from registered->user
+ this.copyContact(registeredContact);
+
+ // Add contact instance only once
+ this.uniqueAddContact(registeredContact);
+
+ // Add user name and email address
+ this.addUserNameEmailAddress(registeredContact);
+
+ // Clear all data
+ this.clear();
+ }
+
+ @Override
+ public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent 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
+ }
+
+ // Add contact instance only once
+ this.uniqueAddContact(event.getConfirmedUser().getUserContact());
+ }
+
+ @Override
+ public void afterUserLogin (@Observes final UserLoggedInEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getLoggedInUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.loggedInUser is null"); //NOI18N
+ } else if (event.getLoggedInUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
+ } else if (event.getLoggedInUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
+ }
+
+ // Copy all data to this bean
+ this.copyContact(event.getLoggedInUser().getUserContact());
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<Contact> allContacts () {
+ // Debug message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactController.allContacts: contactList.size()={0} - EXIT!", this.contactList.size()));
+
+ // Return un-modified list
+ return this.contactList;
+ }
+
+ @Override
+ public Contact createContactInstance () {
+ // User message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: CALLED!", this.getClass().getSimpleName()));
+
+ // Is all required data set?
+ if (!this.isRequiredPersonalDataSet()) {
+ // No, then abort here
+ throw new FaceletException(new IllegalArgumentException("Not all personal data is set, but createContactInstance() is called.")); //NOI18N
+ }
+
+ // Required personal data must be set
+ assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
+
+ // Generate phone number
+ DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+ DialableMobileNumber mobile = new MobileNumber(this.getMobileCarrier(), this.getMobileNumber());
+ DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+
+ // Create new contact
+ Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
+ contact.setContactStreet(this.getStreet());
+ contact.setContactHouseNumber(this.getHouseNumber());
+ contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
+ contact.setContactZipCode(this.getZipCode());
+ contact.setContactCity(this.getCity());
+ contact.setContactCountry(this.getCountry());
+ contact.setContactEmailAddress(this.getEmailAddress());
+ contact.setContactBirthday(this.getBirthday());
+ contact.setContactComment(this.getComment());
+
+ // Debug message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: this.emailAddress={1}", this.getClass().getSimpleName(), this.getEmailAddress()));
+
+ // Don't set null or wrong references
+ if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneCountry() instanceof Country) && (this.getPhoneAreaCode() != null) && (this.getPhoneNumber() != null) && (this.getPhoneAreaCode() > 0) && (this.getPhoneNumber() > 0)) {
+ // Now the number must be given
+ if (phone.getPhoneAreaCode() == null) {
+ // Is null
+ throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
+ } else if (phone.getPhoneAreaCode() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
+ } else if (phone.getPhoneNumber() == null) {
+ // Is null
+ throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
+ } else if (phone.getPhoneNumber() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
+ }
+
+ // Set phone number
+ contact.setContactLandLineNumber(phone);
+ }
+
+ // Don't set null or wrong references
+ if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
+ // Now the number must be given
+ if (fax.getPhoneAreaCode() == null) {
+ // Is null
+ throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
+ } else if (fax.getPhoneAreaCode() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
+ } else if (fax.getPhoneNumber() == null) {
+ // Is null
+ throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
+ } else if (fax.getPhoneNumber() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
+ }
+
+ // Set fax number
+ contact.setContactFaxNumber(fax);
+ }
+
+ // Is the provider set?
+ if ((mobile instanceof DialableMobileNumber) && (this.getMobileCarrier() instanceof MobileProvider) && (this.getMobileNumber() != null) && (this.getMobileNumber() > 0)) {
+ // Is the number set?
+ if (mobile.getPhoneNumber() == null) {
+ // Is null
+ throw new NullPointerException("mobile.phoneNumber is null"); //NOI18N
+ } else if (mobile.getPhoneNumber() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("mobile.phoneNumber is zero or below."); //NOI18N
+ }
+
+ // Set mobile number
+ contact.setContactMobileNumber(mobile);
+ }
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: contact={1} - EXIT!", this.getClass().getSimpleName(), contact));
+
+ // Return it
+ return contact;
+ }
+
+ @Override
+ public String doChangePersonalContactData () {
+ // This method shall only be called if the user is logged-in
+ if (!this.userLoginController.isUserLoggedIn()) {
+ // Not logged-in
+ throw new IllegalStateException("User is not logged-in"); //NOI18N
+ } else if (!this.isRequiredChangePersonalDataSet()) {
+ // Not all required fields are set
+ throw new FaceletException("Not all required fields are set."); //NOI18N
+ } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
+ // Password not matching
+ this.showFacesMessage("form_login_change_personal:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); //NOI18N
+ return ""; //NOI18N
+ }
+
+ // Get contact instance
+ Contact contact = this.userLoginController.getLoggedInUser().getUserContact();
+
+ // It should be there, so run some tests on it
+ assert (contact instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
+ assert (contact.getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
+ assert (contact.getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
+
+ // Update all fields
+ contact.setContactGender(this.getGender());
+ contact.setContactFirstName(this.getFirstName());
+ contact.setContactFamilyName(this.getFamilyName());
+ contact.setContactStreet(this.getStreet());
+ contact.setContactHouseNumber(this.getHouseNumber());
+ contact.setContactHouseNumberExtension(this.getHouseNumberExtension());
+ contact.setContactZipCode(this.getZipCode());
+ contact.setContactCity(this.getCity());
+ contact.setContactCountry(this.getCountry());
+
+ // Update contact's mobile number
+ this.isMobileUnlinked = ContactUtils.updateCellPhoneNumber(contact, this.getMobileCarrier(), this.getMobileNumber());
+
+ // Update contact's land-line number
+ this.isLandLineUnlinked = ContactUtils.updateLandLineNumber(contact, this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+
+ // Update contact's fax number
+ this.isFaxUnlinked = ContactUtils.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+
+ // Send it to the EJB
+ this.contactBean.updateContactData(contact, this.isMobileUnlinked, this.isLandLineUnlinked, this.isFaxUnlinked);
+
+ // All fine
+ return "contact_data_saved"; //NOI18N
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfDateField")
+ public Date getBirthday () {
+ return this.birthday;
+ }
+
+ @Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setBirthday (final Date birthday) {
+ this.birthday = birthday;
+ }
+
+ @Override
+ public MobileProvider getMobileCarrier () {
+ return this.mobileCarrier;
+ }
+
+ @Override
+ public void setMobileCarrier (final MobileProvider mobileCarrier) {
+ this.mobileCarrier = mobileCarrier;
+ }
+
+ @Override
+ public Long getMobileNumber () {
+ return this.mobileNumber;
+ }
+
+ @Override
+ public void setMobileNumber (final Long mobileNumber) {
+ this.mobileNumber = mobileNumber;
+ }
+
+ @Override
+ public String getCity () {
+ return this.city;
+ }
+
+ @Override
+ public void setCity (final String city) {
+ this.city = city;
+ }
+
+ @Override
+ public String getComment () {
+ return this.comment;
+ }
+
+ @Override
+ public void setComment (final String comment) {
+ this.comment = comment;
+ }
+
+ @Override
+ public String getControllerType () {
+ return "general"; //NOI18N
+ }
+
+ @Override
+ @Deprecated
+ public void setControllerType (final String controllerType) {
+ throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
+ }
+
+ @Override
+ public Country getCountry () {
+ return this.country;
+ }
+
+ @Override
+ public void setCountry (final Country country) {
+ this.country = country;
+ }
+
+ @Override
+ public String getEmailAddress () {
+ return this.emailAddress;
+ }
+
+ @Override
+ public void setEmailAddress (final String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ @Override
+ public String getEmailAddressRepeat () {
+ return this.emailAddressRepeat;
+ }
+
+ @Override
+ public void setEmailAddressRepeat (final String emailAddressRepeat) {
+ this.emailAddressRepeat = emailAddressRepeat;
+ }
+
+ @Override
+ public String getFamilyName () {
+ return this.familyName;
+ }
+
+ @Override
+ public void setFamilyName (final String familyName) {
+ this.familyName = familyName;
+ }
+
+ @Override
+ public Integer getFaxAreaCode () {
+ return this.faxAreaCode;
+ }
+
+ @Override
+ public void setFaxAreaCode (final Integer faxAreaCode) {
+ this.faxAreaCode = faxAreaCode;
+ }
+
+ @Override
+ public Country getFaxCountry () {
+ return this.faxCountry;
+ }
+
+ @Override
+ public void setFaxCountry (final Country faxCountry) {
+ this.faxCountry = faxCountry;
+ }
+
+ @Override
+ public Long getFaxNumber () {
+ return this.faxNumber;
+ }
+
+ @Override
+ public void setFaxNumber (final Long faxNumber) {
+ this.faxNumber = faxNumber;
+ }
+
+ @Override
+ public String getFirstName () {
+ return this.firstName;
+ }
+
+ @Override
+ public void setFirstName (final String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Override
+ public Gender getGender () {
+ return this.gender;
+ }
+
+ @Override
+ public void setGender (final Gender gender) {
+ this.gender = gender;
+ }
+
+ @Override
+ public Short getHouseNumber () {
+ return this.houseNumber;
+ }
+
+ @Override
+ public void setHouseNumber (final Short houseNumber) {
+ this.houseNumber = houseNumber;
+ }
+
+ @Override
+ public String getHouseNumberExtension () {
+ return this.houseNumberExtension;
+ }
+
+ @Override
+ public void setHouseNumberExtension (final String houseNumberExtension) {
+ this.houseNumberExtension = houseNumberExtension;
+ }
+
+ @Override
+ public Integer getPhoneAreaCode () {
+ return this.phoneAreaCode;
+ }
+
+ @Override
+ public void setPhoneAreaCode (final Integer phoneAreaCode) {
+ this.phoneAreaCode = phoneAreaCode;
+ }
+
+ @Override
+ public Country getPhoneCountry () {
+ return this.phoneCountry;
+ }
+
+ @Override
+ public void setPhoneCountry (final Country phoneCountry) {
+ this.phoneCountry = phoneCountry;
+ }
+
+ @Override
+ public Long getPhoneNumber () {
+ return this.phoneNumber;
+ }
+
+ @Override
+ public void setPhoneNumber (final Long phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ @Override
+ public String getStreet () {
+ return this.street;
+ }
+
+ @Override
+ public void setStreet (final String street) {
+ this.street = street;
+ }
+
+ @Override
+ public String getTitle () {
+ return this.title;
+ }
+
+ @Override
+ public void setTitle (final String title) {
+ this.title = title;
+ }
+
+ @Override
+ public Integer getZipCode () {
+ return this.zipCode;
+ }
+
+ @Override
+ public void setZipCode (final Integer zipCode) {
+ this.zipCode = zipCode;
+ }
+
+ /**
+ * Post-initialization of this class
+ */
+ @PostConstruct
+ public void init () {
+ // Get full email address list for reducing EJB calls
+ this.emailAddressList.addAll(this.contactBean.getEmailAddressList());
+
+ // Get full contact list
+ this.contactList.addAll(this.contactBean.getAllContacts());
+
+ // Get all users
+ List<User> allUsers = this.userController.allUsers();
+
+ // Get all contacts
+ List<Contact> allContacts = this.contactBean.getAllContacts();
+
+ // Get iterator
+ Iterator<Contact> iterator = allContacts.iterator();
+
+ // Loop through it
+ while (iterator.hasNext()) {
+ // Get next element
+ Contact next = iterator.next();
+
+ // Get iterator
+ Iterator<User> userIterator = allUsers.iterator();
+
+ // Loop through all users
+ while (userIterator.hasNext()) {
+ // Get user instance
+ User nextUser = userIterator.next();
+
+ // Is contact same?
+ if (Objects.equals(next, nextUser.getUserContact())) {
+ // Found same
+ iterator.remove();
+ break;
+ }
+ }
+ }
+
+ // Set contact list
+ this.selectableContacts = allContacts;
+ }
+
+ @Override
+ public boolean isEmailAddressRegistered (final Contact contact) {
+ // Cherck parameter
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactEmailAddress() == null) {
+ // Throw again
+ throw new NullPointerException("contact.contactEmailAddress is null"); //NOI18N
+ } else if (contact.getContactEmailAddress().isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("contact.contactEmailAddress is empty."); //NOI18N
+ }
+
+ // Determine it
+ return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress())));
+ }
+
+ @Override
+ public boolean isRequiredChangePersonalDataSet () {
+ return ((this.getGender() != null) &&
+ (this.getFirstName() != null) &&
+ (this.getFamilyName() != null) &&
+ (this.getStreet() != null) &&
+ (this.getHouseNumber() != null) &&
+ (this.getZipCode() != null) &&
+ (this.getCity() != null));
+ }
+
+ @Override
+ public boolean isRequiredPersonalDataSet () {
+ return ((this.getGender() != null) &&
+ (this.getFirstName() != null) &&
+ (this.getFamilyName() != null) &&
+ (this.getStreet() != null) &&
+ (this.getHouseNumber() != null) &&
+ (this.getZipCode() != null) &&
+ (this.getCity() != null) &&
+ (this.getEmailAddress() != null) &&
+ (this.getEmailAddressRepeat() != null));
+ }
+
+ @Override
+ public boolean isSameEmailAddressEntered () {
+ return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
+ }
+
+ @Override
+ public Contact lookupContactById (final Long contactId) throws ContactNotFoundException {
+ // Init variable
+ Contact localContact = null;
+
+ // Clear this bean
+ this.clear();
+
+ // Try to lookup it in visible user list
+ for (final Iterator<Contact> iterator = this.contactList.iterator(); iterator.hasNext();) {
+ // Get next user
+ Contact next = iterator.next();
+
+ // Is the user id found?
+ if (Objects.equals(next.getContactId(), contactId)) {
+ // Copy to other variable
+ localContact = next;
+ break;
+ }
+ }
+
+ // Is it still null?
+ if (null == localContact) {
+ // Not visible for the current user
+ throw new ContactNotFoundException(contactId);
+ }
+
+ // Copy all data to this bean
+ this.copyContact(localContact);
+
+ // Return it
+ return localContact;
+ }
+
+ @Override
+ public List<Contact> selectableContacts () {
+ return Collections.unmodifiableList(this.selectableContacts);
+ }
+
+ @Override
+ public void updateContactDataFromController (final Contact contact) {
+ // Is the instance valid?
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ }
+
+ // Set all
+ this.copyContact(contact);
+ }
+
+ /**
+ * Adds email address to bean's internal list.
+ * <p>
+ * @param contact Contact instance
+ */
+ private void addUserNameEmailAddress (final Contact contact) {
+ // Make sure the entry is not added yet
+ if (this.emailAddressList.contains(contact.getContactEmailAddress())) {
+ // Already added
+ throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N
+ }
+
+ // Add email addres
+ this.emailAddressList.add(contact.getContactEmailAddress());
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ // - personal data
+ this.setGender(null);
+ this.setTitle(null);
+ this.setFirstName(null);
+ this.setFamilyName(null);
+ this.setStreet(null);
+ this.setHouseNumber(null);
+ this.setHouseNumberExtension(null);
+ this.setZipCode(null);
+ this.setCity(null);
+ this.setCountry(null);
+
+ // - contact data
+ this.setEmailAddress(null);
+ this.setEmailAddressRepeat(null);
+ this.setPhoneAreaCode(null);
+ this.setPhoneCountry(null);
+ this.setPhoneNumber(null);
+ this.setMobileCarrier(null);
+ this.setMobileNumber(null);
+ this.setFaxAreaCode(null);
+ this.setFaxCountry(null);
+ this.setFaxNumber(null);
+
+ // - other data
+ this.setBirthday(null);
+ this.setComment(null);
+ }
+
+ /**
+ * Copies given contact into the controller
+ * <p>
+ * @param contact Contact instance
+ */
+ private void copyContact (final Contact contact) {
+ // Is the instance valid?
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ }
+
+ // Copy all fields:
+ // - base data
+ this.setGender(contact.getContactGender());
+ this.setTitle(contact.getContactTitle());
+ this.setFirstName(contact.getContactFirstName());
+ this.setFamilyName(contact.getContactFamilyName());
+ this.setStreet(contact.getContactStreet());
+ this.setHouseNumber(contact.getContactHouseNumber());
+ this.setHouseNumberExtension(contact.getContactHouseNumberExtension());
+ this.setZipCode(contact.getContactZipCode());
+ this.setCity(contact.getContactCity());
+ this.setCountry(contact.getContactCountry());
+ this.setEmailAddress(contact.getContactEmailAddress());
+ this.setBirthday(contact.getContactBirthday());
+ this.setComment(contact.getContactComment());
+
+ // Get mobile, phone and fax instance
+ DialableMobileNumber mobile = contact.getContactMobileNumber();
+ DialableFaxNumber fax = contact.getContactFaxNumber();
+ DialableLandLineNumber phone = contact.getContactLandLineNumber();
+
+ // - contact data
+ if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
+ this.setPhoneCountry(phone.getPhoneCountry());
+ this.setPhoneAreaCode(phone.getPhoneAreaCode());
+ this.setPhoneNumber(phone.getPhoneNumber());
+ }
+
+ if ((mobile instanceof DialableMobileNumber) && (mobile.getMobileProvider() instanceof MobileProvider)) {
+ this.setMobileCarrier(mobile.getMobileProvider());
+ this.setMobileNumber(mobile.getPhoneNumber());
+ }
+
+ if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
+ this.setFaxCountry(fax.getPhoneCountry());
+ this.setFaxAreaCode(fax.getPhoneAreaCode());
+ this.setFaxNumber(fax.getPhoneNumber());
+ }
+ }
+
+ /**
+ * Removes given contact from all lists
+ * <p>
+ * @param contact Contact instance to remove
+ */
+ private void removeContact (final Contact contact) {
+ // Is the instance valid?
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ }
+
+ // Remove from general list
+ if (!this.contactList.remove(contact)) {
+ // Did not remove contact
+ throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N
+ }
+
+ // Remove from other lists
+ this.emailAddressList.remove(contact.getContactEmailAddress());
+ }
+
+ /**
+ * Adds unique instance to contact list. First any existing instance is
+ * being removed, then the new instance is added.
+ * <p>
+ * @param contact Contact instance to add uniquely
+ */
+ private void uniqueAddContact (final Contact contact) {
+ // Is the instance valid?
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw NPE
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid id number
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+ }
+
+ // Get iterator from list
+ Iterator<Contact> iterator = this.contactList.iterator();
+
+ // "Walk" through all entries
+ while (iterator.hasNext()) {
+ // Get next element
+ Contact next = iterator.next();
+
+ // Is id number the same?
+ if (Objects.equals(contact.getContactId(), next.getContactId())) {
+ // Found entry, so remove it and abort
+ this.removeContact(next);
+ break;
+ }
+ }
+
+ // Add contact to list
+ this.contactList.add(contact);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.contact;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+import javax.ejb.Local;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Local
+public interface FinancialsContactWebSessionController extends Serializable {
+
+ /**
+ * Minimum password length
+ */
+ public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
+
+ /**
+ * Returns a list of all found contacts
+ * <p>
+ * @return A list of all contacts.
+ */
+ List<Contact> allContacts ();
+
+ /**
+ * Event observer for newly added users by adminstrator
+ * <p>
+ * @param event Event being fired
+ */
+ void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
+
+ /**
+ * Event observer when user confirmed account.
+ * <p>
+ * @param event Event being fired
+ */
+ void afterUserConfirmedAccount (final UserConfirmedAccountEvent event);
+
+ /**
+ * Updates all data from bean in given contact instance
+ * <p>
+ * @param userContact Contact instance to update
+ */
+ void updateContactDataFromController (final Contact userContact);
+
+ /**
+ * Tries to lookup contact by given id number. If the user is not found a
+ * proper exceptions are thrown.
+ * <p>
+ * @param contactId Contact id
+ * <p>
+ * @return Contact instance
+ * <p>
+ * @throws ContactNotFoundException If the user is not found
+ */
+ Contact lookupContactById (final Long contactId) throws ContactNotFoundException;
+
+ /**
+ * Event observer for new user registrations
+ * <p>
+ * @param event User registration event
+ */
+ void afterRegistrationEvent (final UserRegisteredEvent event);
+
+ /**
+ * Observes events being fired when an administrator has added a new
+ * contact.
+ * <p>
+ * @param event Event being fired
+ */
+ void afterAdminAddedContact (final AdminAddedContactEvent event);
+
+ /**
+ * Observes events being fired when an administrator has linked a new user
+ * with existing contact data.
+ * <p>
+ * @param event Event being fired
+ */
+ void afterAdminLinkedUser (final AdminLinkedUserEvent event);
+
+ /**
+ * Event observer for updated contact data by administrators
+ * <p>
+ * @param event Updated contact data event
+ */
+ void afterAdminUpdatedContactDataEvent (final AdminUpdatedContactEvent event);
+
+ /**
+ * Event observer for logged-in user
+ * <p>
+ * @param event Event instance
+ */
+ void afterUserLogin (final UserLoggedInEvent event);
+
+ /**
+ * Creates an instance from all properties
+ * <p>
+ * @return A contact instance
+ */
+ Contact createContactInstance ();
+
+ /**
+ * Getter for birth day
+ * <p>
+ * @return Birth day
+ */
+ Date getBirthday ();
+
+ /**
+ * Setter for birth day
+ * <p>
+ * @param birthday Birth day
+ */
+ void setBirthday (final Date birthday);
+
+ /**
+ * Getter for mobile number's carrier
+ * <p>
+ * @return Mobile number's carrier
+ */
+ MobileProvider getMobileCarrier ();
+
+ /**
+ * Setter for mobile number's carrier prefix
+ * <p>
+ * @param mobileCarrier Mobile number's carrier prefix
+ */
+ void setMobileCarrier (final MobileProvider mobileCarrier);
+
+ /**
+ * Getter for mobile number
+ * <p>
+ * @return Mobile number
+ */
+ Long getMobileNumber ();
+
+ /**
+ * Setter for mobile number
+ * <p>
+ * @param mobileNumber Mobile number
+ */
+ void setMobileNumber (final Long mobileNumber);
+
+ /**
+ * City
+ * <p>
+ * @return the city
+ */
+ String getCity ();
+
+ /**
+ * City
+ * <p>
+ * @param city the city to set
+ */
+ void setCity (final String city);
+
+ /**
+ * Getter for comments
+ * <p>
+ * @return Comments
+ */
+ String getComment ();
+
+ /**
+ * Setter for comment
+ * <p>
+ * @param comment Comments
+ */
+ void setComment (final String comment);
+
+ /**
+ * Getter for country instance
+ * <p>
+ * @return Country instance
+ */
+ Country getCountry ();
+
+ /**
+ * Setter for country instance
+ * <p>
+ * @param country Country instance
+ */
+ void setCountry (final Country country);
+
+ /**
+ * Getter for email address
+ * <p>
+ * @return Email address
+ */
+ String getEmailAddress ();
+
+ /**
+ * Setter for email address
+ * <p>
+ * @param emailAddress Email address
+ */
+ void setEmailAddress (final String emailAddress);
+
+ /**
+ * Getter for email address, repeated
+ * <p>
+ * @return the emailAddress, repeated
+ */
+ String getEmailAddressRepeat ();
+
+ /**
+ * Setter for email address repeated
+ * <p>
+ * @param emailAddressRepeat the emailAddress to set
+ */
+ void setEmailAddressRepeat (final String emailAddressRepeat);
+
+ /**
+ * Family name
+ * <p>
+ * @return the familyName
+ */
+ String getFamilyName ();
+
+ /**
+ * Family name
+ * <p>
+ * @param familyName the familyName to set
+ */
+ void setFamilyName (final String familyName);
+
+ /**
+ * Getter for fax number's area code
+ * <p>
+ * @return Fax number's area code
+ */
+ Integer getFaxAreaCode ();
+
+ /**
+ * Setter for fax number's area code
+ * <p>
+ * @param faxAreaCode Fax number's area code
+ */
+ void setFaxAreaCode (final Integer faxAreaCode);
+
+ /**
+ * Getter for fax's country instance
+ * <p>
+ * @return Fax' country instance
+ */
+ Country getFaxCountry ();
+
+ /**
+ * Setter for fax's country instance
+ * <p>
+ * @param faxCountry Fax' country instance
+ */
+ void setFaxCountry (final Country faxCountry);
+
+ /**
+ * Getter for fax number
+ * <p>
+ * @return Fax number
+ */
+ Long getFaxNumber ();
+
+ /**
+ * Setter for fax number
+ * <p>
+ * @param faxNumber Fax number
+ */
+ void setFaxNumber (final Long faxNumber);
+
+ /**
+ * First name
+ * <p>
+ * @return the first name
+ */
+ String getFirstName ();
+
+ /**
+ * First name
+ * <p>
+ * @param firstName the first name to set
+ */
+ void setFirstName (final String firstName);
+
+ /**
+ * Gender of the contact
+ * <p>
+ * @return the gender
+ */
+ Gender getGender ();
+
+ /**
+ * Gender of the contact
+ * <p>
+ * @param gender the gender to set
+ */
+ void setGender (final Gender gender);
+
+ /**
+ * House number
+ * <p>
+ * @return the houseNumber
+ */
+ Short getHouseNumber ();
+
+ /**
+ * House number
+ * <p>
+ * @param houseNumber the houseNumber to set
+ */
+ void setHouseNumber (final Short houseNumber);
+
+ /**
+ * Getter for house number extension, example: 123a 'a' is then the
+ * extension and 123 is the house number.
+ * <p>
+ * @return House number extension
+ */
+ String getHouseNumberExtension ();
+
+ /**
+ * Setter for house number extension
+ * <p>
+ * @param houseNumberExtension House number extension
+ */
+ void setHouseNumberExtension (final String houseNumberExtension);
+
+ /**
+ * Getter for phone number's area code
+ * <p>
+ * @return Phone number's area code
+ */
+ Integer getPhoneAreaCode ();
+
+ /**
+ * Setter for phone number's area code
+ * <p>
+ * @param phoneAreaCode Phone number's area code
+ */
+ void setPhoneAreaCode (final Integer phoneAreaCode);
+
+ /**
+ * Getter for phone number's country instance
+ * <p>
+ * @return Phone number's country instance
+ */
+ Country getPhoneCountry ();
+
+ /**
+ * Setter for phone number's country instance
+ * <p>
+ * @param phoneCountry Phone number's country instance
+ */
+ void setPhoneCountry (final Country phoneCountry);
+
+ /**
+ * Getter for phone number
+ * <p>
+ * @return Phone number
+ */
+ Long getPhoneNumber ();
+
+ /**
+ * Setter for phone number
+ * <p>
+ * @param phoneNumber Phone number
+ */
+ void setPhoneNumber (final Long phoneNumber);
+
+ /**
+ * Street
+ * <p>
+ * @return the street
+ */
+ String getStreet ();
+
+ /**
+ * Street
+ * <p>
+ * @param street the street to set
+ */
+ void setStreet (final String street);
+
+ /**
+ * Titöe
+ * <p>
+ * @return the title
+ */
+ String getTitle ();
+
+ /**
+ * Title
+ * <p>
+ * @param title the title to set
+ */
+ void setTitle (final String title);
+
+ /**
+ * ZIP code
+ * <p>
+ * @return the zipCode
+ */
+ Integer getZipCode ();
+
+ /**
+ * ZIP code
+ * <p>
+ * @param zipCode the zipCode to set
+ */
+ void setZipCode (final Integer zipCode);
+
+ /**
+ * Getter for controller type
+ * <p>
+ * @return controller type
+ */
+ String getControllerType ();
+
+ /**
+ * Setter for controller type
+ * <p>
+ * @param controllerType Controller type
+ * @deprecated Don't use this method.
+ */
+ @Deprecated
+ void setControllerType (final String controllerType);
+
+ /**
+ * Checks whether contact instance's email address is used
+ * <p>
+ * @param contact Contact instance's email address to check
+ * <p>
+ * @return Whether it is already used
+ */
+ boolean isEmailAddressRegistered (final Contact contact);
+
+ /**
+ * Checks whether all required personal data is set
+ * <p>
+ * @return Whether the required personal data is set
+ */
+ boolean isRequiredPersonalDataSet ();
+
+ /**
+ * Checks whether all required personal data is set for changing them
+ * <p>
+ * @return Whether the required personal data is set
+ */
+ boolean isRequiredChangePersonalDataSet ();
+
+ /**
+ * Checks whether same email addresses have been entered
+ * <p>
+ * @return Whether same email addresses have been entered
+ */
+ boolean isSameEmailAddressEntered ();
+
+ /**
+ * Changes logged-in user's personal data if the current password matches
+ * and TAC + privacy statement has been accepted.
+ * <p>
+ * @return New target page
+ */
+ String doChangePersonalContactData ();
+
+ /**
+ * Returns a list of all selectable contacts for user creation. Contacts
+ * from already existing users are excluded in this list.
+ * <p>
+ * @return A list of all selectable contacts
+ */
+ List<Contact> selectableContacts ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.contact.phone;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+import org.mxchange.jfinancials.beans.contact.FinancialsContactWebSessionController;
+import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestController;
+
+/**
+ * A general contact bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("contactPhoneController")
+@SessionScoped
+public class FinancialsContactPhoneWebSessionBean extends BaseFinancialsController implements FinancialsContactPhoneWebSessionController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_916L;
+
+ /**
+ * Remote EJB for phone number (administrative)
+ */
+ private AdminPhoneSessionBeanRemote adminPhoneBean;
+
+ /**
+ * Administrative phone controller
+ */
+ @Inject
+ private FinancialsAdminPhoneWebRequestController adminPhoneController;
+
+ /**
+ * General contact controller
+ */
+ @Inject
+ private FinancialsContactWebSessionController contactController;
+
+ /**
+ * "Cache" for contact lists, mostly only one is assigned. So this cache
+ * shouldn't grow beyond control.
+ */
+ private final Map<Long, List<Contact>> contacts;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsContactPhoneWebSessionBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the beans
+ this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminphone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+
+ // Init lists/maps
+ this.contacts = new HashMap<>(10);
+ }
+
+ @Override
+ public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
+ // The event must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedContact is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() == null) {
+ // ... and again
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+ }
+
+ // Clear this bean
+ this.clear();
+ }
+
+ @Override
+ public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
+ // event 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
+ }
+
+ // Clear all data
+ this.clear();
+ }
+
+ @Override
+ public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedContact is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() == null) {
+ // userId is null
+ throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+ }
+ }
+
+ @Override
+ public List<Contact> allMobileContacts () {
+ // Get id
+ Long phoneId = this.adminPhoneController.getMobileNumber().getPhoneId();
+
+ // Is cache there?
+ if (this.contacts.containsKey(phoneId)) {
+ // Return cached version
+ return this.contacts.get(phoneId);
+ } else {
+ // Ask bean
+ List<Contact> list = new LinkedList<>();
+
+ // "Walk" through all contacts
+ for (final Contact contact : this.contactController.allContacts()) {
+ // Is mobile instance the same?
+ if (Objects.equals(contact.getContactMobileNumber(), this.adminPhoneController.getMobileNumber())) {
+ // Found one
+ list.add(contact);
+ }
+ }
+
+ // Store result in cache
+ this.contacts.put(phoneId, list);
+
+ // Return now-cached list
+ return list;
+ }
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.contact.phone;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.ejb.Local;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Local
+public interface FinancialsContactPhoneWebSessionController extends Serializable {
+
+ /**
+ * Minimum password length
+ */
+ public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
+
+ /**
+ * Getter for all contacts having current mobile instance linked
+ * <p>
+ * @return List of all linked contacts
+ */
+ List<Contact> allMobileContacts ();
+
+ /**
+ * Event observer for newly added users by adminstrator
+ * <p>
+ * @param event Event being fired
+ */
+ void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
+
+ /**
+ * Observes events being fired when an administrator has added a new
+ * contact.
+ * <p>
+ * @param event Event being fired
+ */
+ void afterAdminAddedContact (final AdminAddedContactEvent event);
+
+ /**
+ * Event observer for updated contact data by administrators
+ * <p>
+ * @param event Updated contact data event
+ */
+ void afterAdminUpdatedContactDataEvent (final AdminUpdatedContactEvent event);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.country;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.data.CountryData;
+import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
+import org.mxchange.jcountry.events.AdminAddedCountryEvent;
+import org.mxchange.jcountry.events.AdminEventCountryAdded;
+import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
+
+/**
+ * An administrative country bean
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminCountryController")
+@RequestScoped
+public class FinancialsAdminCountryWebRequestBean extends BaseFinancialsController implements FinancialsAdminCountryWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 18_598_175_719_603L;
+
+ /**
+ * An event triggered when the administrator has added a country
+ */
+ @Inject
+ @Any
+ private Event<AdminAddedCountryEvent> addedCountryEvent;
+
+ /**
+ * Abroad dial prefix
+ */
+ private String countryAbroadDialPrefix;
+
+ /**
+ * Remote country EJB
+ */
+ private CountrySingletonBeanRemote countryBean;
+
+ /**
+ * 2-letter country code
+ */
+ private String countryCode;
+
+ /**
+ * Regular country controller
+ */
+ @Inject
+ private FinancialsCountryWebApplicationController countryController;
+
+ /**
+ * Local dial prefix
+ */
+ private String countryExternalDialPrefix;
+
+ /**
+ * i18n bundle key
+ */
+ private String countryI18nKey;
+
+ /**
+ * Whether the local dial prefix is required to use
+ */
+ private Boolean countryIsLocalPrefixRequired;
+
+ /**
+ * Phone code
+ */
+ private Short countryPhoneCode;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsAdminCountryWebRequestBean () {
+ // Try this
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the bean
+ this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jfinancials-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw
+ throw new FaceletException(ex);
+ }
+ }
+
+ @Override
+ public String addCountry () {
+ // Create new country object
+ Country country = new CountryData();
+
+ // Add all data
+ country.setCountryAbroadDialPrefix(this.getCountryAbroadDialPrefix());
+ country.setCountryCode(this.getCountryCode());
+ country.setCountryExternalDialPrefix(this.getCountryExternalDialPrefix());
+ country.setCountryI18nKey(this.getCountryI18nKey());
+ country.setCountryIsLocalPrefixRequired(this.getCountryIsLocalPrefixRequired());
+ country.setCountryPhoneCode(this.getCountryPhoneCode());
+
+ // Does it already exist?
+ if (this.isCountryAdded(country)) {
+ // Yes, then abort here
+ throw new FaceletException(new CountryAlreadyAddedException(country));
+ }
+
+ // Init variable
+ Country updatedCountry = null;
+
+ try {
+ // Send country to bean
+ updatedCountry = this.countryBean.addCountry(country);
+ } catch (final CountryAlreadyAddedException ex) {
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Fire event
+ this.addedCountryEvent.fire(new AdminEventCountryAdded(updatedCountry));
+
+ // Clear this bean
+ this.clear();
+
+ // Redirect to list
+ return "admin_list_country"; //NOI18N
+ }
+
+ @Override
+ public String getCountryAbroadDialPrefix () {
+ return this.countryAbroadDialPrefix;
+ }
+
+ @Override
+ public void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix) {
+ this.countryAbroadDialPrefix = countryAbroadDialPrefix;
+ }
+
+ @Override
+ public String getCountryCode () {
+ return this.countryCode;
+ }
+
+ @Override
+ public void setCountryCode (final String countryCode) {
+ this.countryCode = countryCode;
+ }
+
+ @Override
+ public String getCountryExternalDialPrefix () {
+ return this.countryExternalDialPrefix;
+ }
+
+ @Override
+ public void setCountryExternalDialPrefix (final String countryExternalDialPrefix) {
+ this.countryExternalDialPrefix = countryExternalDialPrefix;
+ }
+
+ @Override
+ public String getCountryI18nKey () {
+ return this.countryI18nKey;
+ }
+
+ @Override
+ public void setCountryI18nKey (final String countryI18nKey) {
+ this.countryI18nKey = countryI18nKey;
+ }
+
+ @Override
+ public Boolean getCountryIsLocalPrefixRequired () {
+ return this.countryIsLocalPrefixRequired;
+ }
+
+ @Override
+ public void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired) {
+ this.countryIsLocalPrefixRequired = countryIsLocalPrefixRequired;
+ }
+
+ @Override
+ public Short getCountryPhoneCode () {
+ return this.countryPhoneCode;
+ }
+
+ @Override
+ public void setCountryPhoneCode (final Short countryPhoneCode) {
+ this.countryPhoneCode = countryPhoneCode;
+ }
+
+ /**
+ * Clears this bean's data. This should be called after a form has been
+ * submitted and the processing of the form was successful.
+ */
+ private void clear () {
+ // Clear fields
+ this.setCountryAbroadDialPrefix(null);
+ this.setCountryCode(null);
+ this.setCountryExternalDialPrefix(null);
+ this.setCountryI18nKey(null);
+ this.setCountryIsLocalPrefixRequired(null);
+ this.setCountryPhoneCode(null);
+ }
+
+ /**
+ * Checks if given country is already added by iterating over the whole list
+ * and try to find it.
+ * <p>
+ * @param country Country instance to look for
+ * <p>
+ * @return Whether the country was already found
+ */
+ private boolean isCountryAdded (final Country country) {
+ // Default is not found
+ boolean isAdded = false;
+
+ // Now get whole ist
+ List<Country> countries = this.countryController.allCountries();
+
+ // Get iterator from it
+ Iterator<Country> iterator = countries.iterator();
+
+ // Check whole list
+ while (iterator.hasNext()) {
+ // Get next country
+ Country next = iterator.next();
+
+ // Is country code or i18n the same?
+ if ((Objects.equals(country.getCountryCode(), next.getCountryCode())) || (Objects.equals(country.getCountryI18nKey(), next.getCountryI18nKey()))) {
+ // Yes, then abort search
+ isAdded = true;
+ break;
+ }
+ }
+
+ // Return result
+ return isAdded;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.country;
+
+import java.io.Serializable;
+
+/**
+ * An interface for administrative country beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsAdminCountryWebRequestController extends Serializable {
+
+ /**
+ * Adds country to all relevant beans and sends it to the EJB. A redirect
+ * should happen after successfull creation.
+ * <p>
+ * @return Redirect outcome
+ */
+ String addCountry ();
+
+ /**
+ * Getter for abroad dial prefix
+ * <p>
+ * @return Abroad dial prefix
+ */
+ String getCountryAbroadDialPrefix ();
+
+ /**
+ * Setter for abroad dial prefix
+ * <p>
+ * @param countryAbroadDialPrefix Abroad dial prefix
+ */
+ void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix);
+
+ /**
+ * Getter for 2-characters country code
+ * <p>
+ * @return Country code
+ */
+ String getCountryCode ();
+
+ /**
+ * Setter for 2-characters country code
+ * <p>
+ * @param countryCode Country code
+ */
+ void setCountryCode (final String countryCode);
+
+ /**
+ * Getter for i18n key for country name
+ * <p>
+ * @return i18n key for country name
+ */
+ String getCountryI18nKey ();
+
+ /**
+ * Setter for i18n key for country name
+ * <p>
+ * @param countryI18nKey i18n key for country name
+ */
+ void setCountryI18nKey (final String countryI18nKey);
+
+ /**
+ * Getter for whether the local dial prefix is required for local calls
+ * <p>
+ * @return Whether the local dial prefix is required
+ */
+ Boolean getCountryIsLocalPrefixRequired ();
+
+ /**
+ * Setter for whether the local dial prefix is required for local calls
+ * <p>
+ * @param countryIsLocalPrefixRequired Whether the local dial prefix is
+ * required
+ */
+ void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired);
+
+ /**
+ * Getter for external dial prefix
+ * <p>
+ * @return External dial prefix
+ */
+ String getCountryExternalDialPrefix ();
+
+ /**
+ * Setter for external dial prefix
+ * <p>
+ * @param countryExternalDialPrefix External dial prefix
+ */
+ void setCountryExternalDialPrefix (final String countryExternalDialPrefix);
+
+ /**
+ * Getter for country code (example: 49 for Germany, 63 for Philippines)
+ * <p>
+ * @return Dial number without prefix
+ */
+ Short getCountryPhoneCode ();
+
+ /**
+ * Setter for country code (example: 49 for Germany, 63 for Philippines)
+ * <p>
+ * @param countryPhoneCode Country code
+ */
+ void setCountryPhoneCode (final Short countryPhoneCode);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.country;
+
+import java.text.MessageFormat;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
+import org.mxchange.jcountry.events.AdminAddedCountryEvent;
+
+/**
+ * A country bean
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("countryController")
+@ApplicationScoped
+public class FinancialsCountryWebApplicationBean extends BaseFinancialsController implements FinancialsCountryWebApplicationController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 176_985_298_681_742_960L;
+
+ /**
+ * Remote country EJB
+ */
+ private CountrySingletonBeanRemote countryBean;
+
+ /**
+ * List of all countries
+ */
+ private List<Country> countryList;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsCountryWebApplicationBean () {
+ // Try this
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the bean
+ this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jfinancials-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw
+ throw new FaceletException(ex);
+ }
+ }
+
+ @Override
+ public void afterAdminAddedCountry (@Observes final AdminAddedCountryEvent event) {
+ // Is all valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedCountry() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedCountry is null"); //NOI18N
+ } else if (event.getAddedCountry().getCountryId() == null) {
+ // And again ...
+ throw new NullPointerException("event.addedCountry.countryId is null"); //NOI18N
+ } else if (event.getAddedCountry().getCountryId() < 1) {
+ // Id is invalid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedCountry.countryId={0} is not valid.", event.getAddedCountry().getCountryId())); //NOI18N
+ }
+
+ // Add the event
+ this.countryList.add(event.getAddedCountry());
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<Country> allCountries () {
+ // Return "cached" version
+ return this.countryList;
+ }
+
+ /**
+ * Post-initialization of this class
+ */
+ @PostConstruct
+ public void init () {
+ // "Cache" country list as this will not change so often.
+ this.countryList = this.countryBean.allCountries();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.country;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.events.AdminAddedCountryEvent;
+
+/**
+ * An interface for country beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsCountryWebApplicationController extends Serializable {
+
+ /**
+ * A list of all countries
+ * <p>
+ * @return All countries
+ */
+ List<Country> allCountries ();
+
+ /**
+ * Observing method when the event is fired that an administrator added a
+ * new country
+ * <p>
+ * @param event Event instance
+ */
+ void afterAdminAddedCountry (final AdminAddedCountryEvent event);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.email_address;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Objects;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcoreee.utils.FacesUtils;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
+import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress;
+import org.mxchange.jusercore.model.email_address.EmailAddressChange;
+import org.mxchange.jusercore.model.email_address.UserEmailChangeSessionBeanRemote;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController;
+
+/**
+ * A web session bean for changing email addresses
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("emailChangeController")
+@SessionScoped
+public class FinancialsEmailChangeWebSessionBean extends BaseFinancialsController implements FinancialsEmailChangeWebSessionController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 186_078_724_659_153L;
+
+ /**
+ * Email address 1 (changing)
+ */
+ private String emailAddress;
+
+ /**
+ * Email address 2 (repeat in changing)
+ */
+ private String emailAddressRepeat;
+
+ /**
+ * Local list of already queued email addresses
+ */
+ private List<String> emailAddresses;
+
+ /**
+ * Remote email change bean
+ */
+ private final UserEmailChangeSessionBeanRemote emailBean;
+
+ /**
+ * Features controller
+ */
+ @Inject
+ private FinancialsFeaturesWebApplicationController featureController;
+
+ /**
+ * Login bean (controller)
+ */
+ @Inject
+ private FinancialsUserLoginWebSessionController userLoginController;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsEmailChangeWebSessionBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.emailBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/email-change!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N
+
+ // Init list
+ this.emailAddresses = this.emailBean.allQueuedAddresses();
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public String doChangeEmailAddress () {
+ // This method shall only be called if the user is logged-in
+ if (!this.userLoginController.isUserLoggedIn()) {
+ // Not logged-in
+ throw new IllegalStateException("User is not logged-in"); //NOI18N
+ } else if (!this.isRequiredChangeEmailAddressSet()) {
+ // Not all required fields are set
+ throw new FaceletException("Not all required fields are set."); //NOI18N
+ } else if (!Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat())) {
+ // Email address 1+2 mismatch
+ throw new FaceletException("Email address 1/2 are mismatching."); //NOI18N
+ } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
+ // Password not matching
+ this.showFacesMessage("form_login_change_email_address:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); //NOI18N
+ return ""; //NOI18N
+ } else if (!this.featureController.isFeatureEnabled("edit_user_data")) { //NOI18N
+ // Editing is not allowed
+ throw new IllegalStateException("User tried to edit personal data"); //NOI18N
+ }
+
+ // Get user instance
+ User user = this.userLoginController.getLoggedInUser();
+
+ // It should be there, so run some tests on it
+ assert (user instanceof User) : "Instance loginController.loggedInUser is null"; //NOI18N
+ assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; //NOI18N
+ assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
+ assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
+ assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
+ assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
+
+ // Check if the email address is already enqueued
+ if (this.isEmailAddressQueued(this.getEmailAddress())) {
+ // Yes, then abort here
+ return "login_email_already_added"; //NOI18N
+ }
+
+ // Create change object, to save EJB calls, the hash is not generated here
+ ChangeableEmailAddress emailChange = new EmailAddressChange(user, this.getEmailAddress());
+
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // Call EJB
+ this.emailBean.enqueueEmailAddressForChange(emailChange, baseUrl);
+
+ // Unset all so the user is forced to re-enter it
+ this.clear();
+
+ // All fine
+ return "login_email_change_queued"; //NOI18N
+ }
+
+ @Override
+ public String getEmailAddress () {
+ return this.emailAddress;
+ }
+
+ @Override
+ public void setEmailAddress (final String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ @Override
+ public String getEmailAddressRepeat () {
+ return this.emailAddressRepeat;
+ }
+
+ @Override
+ public void setEmailAddressRepeat (final String emailAddressRepeat) {
+ this.emailAddressRepeat = emailAddressRepeat;
+ }
+
+ @Override
+ public boolean isRequiredChangeEmailAddressSet () {
+ return ((this.getEmailAddress() != null) &&
+ (this.getEmailAddressRepeat() != null));
+ }
+
+ /**
+ * Clears email address fields so the user has to re-enter them
+ */
+ private void clear () {
+ // Clear fields
+ this.setEmailAddress(null);
+ this.setEmailAddressRepeat(null);
+ }
+
+ /**
+ * Checks if given email address has already been queued. First a local list
+ * is being checked, if not found, the EJB is called. Only if found, the
+ * result is "cached" in the list.
+ * <p>
+ * @param emailAddress Email address to verify
+ * <p>
+ * @return Whether the email address in field emailAddress is already queued
+ */
+ private boolean isEmailAddressQueued (final String emailAddress) {
+ // It should be there
+ assert (emailAddress != null) : "emailAddress should not be null"; //NOI18N
+ assert (!emailAddress.trim().isEmpty()) : "emailAddress should not be empty"; //NOI18N
+
+ // Check list
+ if (this.emailAddresses.contains(emailAddress)) {
+ // Okay, found it
+ return true;
+ }
+
+ // Check EJB
+ boolean isQueued = this.emailBean.isEmailAddressEnqueued(emailAddress);
+
+ // Is it there?
+ if (isQueued) {
+ // Add to list
+ this.emailAddresses.add(emailAddress);
+ }
+
+ // Return status
+ return isQueued;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.email_address;
+
+import java.io.Serializable;
+
+/**
+ * An interface for an email change controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsEmailChangeWebSessionController extends Serializable {
+
+ /**
+ * Getter for email address 1 (changing)
+ * <p>
+ * @return Email address
+ */
+ String getEmailAddress ();
+
+ /**
+ * Setter for email address 1 (changing)
+ * <p>
+ * @param emailAddress Email address 1
+ */
+ void setEmailAddress (final String emailAddress);
+
+ /**
+ * Getter for email address 2 (repeat changing)
+ * <p>
+ * @return Email address 2
+ */
+ String getEmailAddressRepeat ();
+
+ /**
+ * Setter for email address 2 (repeat changing)
+ * <p>
+ * @param emailAddressRepeat Email address 2
+ */
+ void setEmailAddressRepeat (final String emailAddressRepeat);
+
+ /**
+ * Checks whether all required are set for changing email address
+ * <p>
+ * @return Whether the required personal data is set
+ */
+ boolean isRequiredChangeEmailAddressSet ();
+
+ /**
+ * Changes logged-in user's email address if the current password matches.
+ * <p>
+ * @return New target page
+ */
+ String doChangeEmailAddress ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.features;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+
+/**
+ * A feature bean
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("featureController")
+@ApplicationScoped
+public class FinancialsFeatureWebApplicationBean extends BaseFinancialsController implements FinancialsFeaturesWebApplicationController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 64_237_512_690_168_674L;
+
+ @Override
+ public boolean isFeatureEnabled (final String feature) {
+ // The parameter must be set
+ if (null == feature) {
+ // Throw NPE
+ throw new NullPointerException("feature is null"); //NOI18N
+ } else if (feature.isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("feature is empty"); //NOI18N
+ }
+
+ // Default is not enabled
+ boolean isEnabled = false;
+
+ // Try it as an NPE may come
+ try {
+ // Get value from property
+ String value = this.getStringContextParameter(String.format("is_feature_%s_enabled", feature)); //NOI18N
+
+ // Is it set?
+ isEnabled = (value.toLowerCase().equals("true")); //NOI18N
+ } catch (final NullPointerException ex) {
+ // Ignored
+ }
+
+ // Return value
+ return isEnabled;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.features;
+
+import java.io.Serializable;
+import javax.ejb.Local;
+
+/**
+ * An interface for country beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Local
+public interface FinancialsFeaturesWebApplicationController extends Serializable {
+
+ /**
+ * Checks if given feature is enabled.
+ * <p>
+ * @param feature Feature to be checked
+ * <p>
+ * @return Whether given feature is enabled
+ */
+ boolean isFeatureEnabled (final String feature);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.gender;
+
+import java.util.List;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.contact.gender.GenderUtils;
+
+/**
+ * A gender bean
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("genderController")
+@ApplicationScoped
+public class FinancialsGenderWebApplicationBean extends BaseFinancialsController implements FinancialsGenderWebApplicationController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 835_482_364_189L;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsGenderWebApplicationBean () {
+ }
+
+ @Override
+ public Gender[] getAllGenders () {
+ // Return it
+ return Gender.values();
+ }
+
+ @Override
+ public List<Gender> getSelectableGenders () {
+ // Init array
+ List<Gender> genders = GenderUtils.selectableGenders();
+
+ // Return it
+ return genders;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.gender;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcontacts.contact.gender.Gender;
+
+/**
+ * An interface for data beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsGenderWebApplicationController extends Serializable {
+
+ /**
+ * Getter for all genders as array
+ * <p>
+ * @return All genders as array
+ */
+ Gender[] getAllGenders ();
+
+ /**
+ * Getter for only selectable genders as array, UNKNOWN is not selectable
+ * <p>
+ * @return All genders as array
+ */
+ List<Gender> getSelectableGenders ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder GmbH
+ *
+ * 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.helper;
+
+import java.io.Serializable;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An interface for general bean helper
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsWebRequestController extends Serializable {
+
+ /**
+ * Getter for user instance
+ * <p>
+ * @return User instance
+ */
+ User getUser ();
+
+ /**
+ * Setter for user instance
+ * <p>
+ * @param user User instance
+ */
+ void setUser (final User user);
+
+ /**
+ * Copies currently set user instance's data to adminUserController
+ */
+ void copyUserToController ();
+
+ /**
+ * Returns a message key depending on if this contact is a user and/or a
+ * contact. If this contact is unused, a default key is returned.
+ * <p>
+ * @param contact Contact instance to check
+ * <p>
+ * @return Message key
+ */
+ String getContactUsageMessageKey (final Contact contact);
+
+ /**
+ * Getter for contact instance
+ * <p>
+ * @return Contact instance
+ */
+ Contact getContact ();
+
+ /**
+ * Setter for contact instance
+ * <p>
+ * @param contact Contact instance
+ */
+ void setContact (final Contact contact);
+
+ /**
+ * Copies currently set contact instance's data to adminContactController
+ */
+ void copyContactToController ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder GmbH
+ *
+ * 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.helper;
+
+import java.text.MessageFormat;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jfinancials.beans.contact.FinancialsAdminContactWebRequestController;
+import org.mxchange.jfinancials.beans.phone.FinancialsAdminPhoneWebRequestController;
+import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
+
+/**
+ * A general helper for beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminHelper")
+@RequestScoped
+public class FinancialsWebRequestHelper implements FinancialsWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 17_258_793_567_145_701L;
+
+ /**
+ * Administrative contact controller
+ */
+ @Inject
+ private FinancialsAdminContactWebRequestController adminContactController;
+
+ /**
+ * Administrative phone controller
+ */
+ @Inject
+ private FinancialsAdminPhoneWebRequestController adminPhoneController;
+
+ /**
+ * Contact instance
+ */
+ private Contact contact;
+
+ /**
+ * User instance
+ */
+ private User user;
+
+ /**
+ * Regular user controller
+ */
+ @Inject
+ private FinancialsUserWebSessionController userController;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsWebRequestHelper () {
+ }
+
+ @Override
+ public void copyContactToController () {
+ // Log message
+ //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - CALLED!"); //NOI18N
+
+ // Validate user instance
+ if (this.getContact() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.contact is null"); //NOI18N
+ } else if (this.getContact().getContactId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.contact.contactId is null"); //NOI18N
+ } else if (this.getContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N
+ }
+
+ // Set all phone instances
+ this.setPhoneInstances(this.getContact());
+
+ // Set all fields: user
+ this.adminContactController.copyContactToController(this.getContact());
+
+ // Log message
+ //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyContactToController - EXIT!"); //NOI18N
+ }
+
+ @Override
+ public void copyUserToController () {
+ // Log message
+ //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N
+
+ // Validate user instance
+ if (this.getUser() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.user is null"); //NOI18N
+ } else if (this.getUser().getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.user.userId is null"); //NOI18N
+ } else if (this.getUser().getUserId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
+ }
+
+ // Get contact
+ Contact userContact = this.getUser().getUserContact();
+
+ // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs.
+ this.setContact(userContact);
+
+ // Set all phone instances
+ this.setPhoneInstances(userContact);
+
+ // Set all fields: user
+ this.userController.setUserName(this.getUser().getUserName());
+
+ // Log message
+ //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - EXIT!"); //NOI18N
+ }
+
+ @Override
+ public Contact getContact () {
+ return this.contact;
+ }
+
+ @Override
+ public void setContact (final Contact contact) {
+ this.contact = contact;
+ }
+
+ @Override
+ public String getContactUsageMessageKey (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 key is "unused"
+ String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
+
+ // Check user
+ boolean isUserContact = this.userController.isContactFound(contact);
+
+ // Check user first
+ if (isUserContact) {
+ // Only user
+ messageKey = "CONTACT_IS_USER"; //NOI18N
+ }
+
+ // Return message key
+ return messageKey;
+ }
+
+ @Override
+ public User getUser () {
+ return this.user;
+ }
+
+ @Override
+ public void setUser (final User user) {
+ this.user = user;
+ }
+
+ /**
+ * Set's all given contact's phone instances: land-line, mobile and fax
+ * <p>
+ * @param contact Contact to set phone instances for
+ */
+ private void setPhoneInstances (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
+ }
+
+ // Is mobile set?
+ if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+ // Yes, then set it in admin controller
+ this.adminPhoneController.setCellPhone(contact.getContactMobileNumber());
+ }
+
+ // Is land-line set?
+ if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+ // Yes, then set it in admin controller
+ this.adminPhoneController.setLandLine(contact.getContactLandLineNumber());
+ }
+
+ // Is fax set?
+ if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+ // Yes, then set it in admin controller
+ this.adminPhoneController.setFax(contact.getContactFaxNumber());
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.localization;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.context.FacesContext;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.logout.ObserveableUserLogoutEvent;
+
+/**
+ * A session bean for handling localization/internationalization changes. This
+ * class is based on an example at [1] from mkyong.
+ * <p>
+ * 1: http://www.mkyong.com/jsf2/jsf-2-internationalization-example/
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("localizationController")
+@SessionScoped
+public class FinancialsLocalizationSessionBean extends BaseFinancialsController implements FinancialsLocalizationSessionController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 158_768_216_759_107L;
+
+ /**
+ * Current Locale
+ */
+ private Locale locale;
+
+ @Override
+ public void afterUserLogin (@Observes final UserLoggedInEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("LandingLocalizationSessionBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
+
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getLoggedInUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.loggedInUser is null"); //NOI18N
+ } else if (event.getLoggedInUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
+ } else if (event.getLoggedInUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
+ }
+
+ // Set locale here
+ this.setLocale(event.getLoggedInUser().getUserLocale());
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("LandingLocalizationSessionBean:afterUserLogin - EXIT!"); //NOI18N
+ }
+
+ @Override
+ public void afterUserLogout (@Observes final ObserveableUserLogoutEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ReportsLocalizationSessionBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
+
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getLoggedOutUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.loggedOutUser is null"); //NOI18N
+ } else if (event.getLoggedOutUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.loggedOutUser.userId is null"); //NOI18N
+ } else if (event.getLoggedOutUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedOutUser(), event.getLoggedOutUser().getUserId())); //NOI18N
+ }
+
+ // Clear this bean as well
+ this.clear();
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("ReportsLocalizationSessionBean:afterUserLogin - EXIT!"); //NOI18N
+ }
+
+ @Override
+ public String getLanguage () {
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("FinancialsLocalizationSessionBean::getLanguage(): locale.language={0} - EXIT!", this.getLocale().getLanguage())); //NOI18N
+ return this.getLocale().getLanguage().toLowerCase();
+ }
+
+ @Override
+ public void setLanguage (final String language) {
+ // Log trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("FinancialsLocalizationSessionBean::setLanguage: language={0} - CALLED!", language)); //NOI18N
+
+ // Is the language null?
+ if (null == language) {
+ // This may sometimes happen, so abort here
+ return;
+ }
+
+ // Language splits
+ String[] splits = language.split("_"); //NOI18N
+ if (null == splits[1]) {
+ splits[1] = ""; //NOI18N
+ }
+
+ // Get new locale with upper-case country code
+ Locale loc = new Locale(splits[0], splits[1]);
+
+ // Log debug message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("FinancialsLocalizationSessionBean::setLanguage: loc={0}", loc)); //NOI18N
+ // Set it here and in the JSF context
+ this.setLocale(loc);
+ FacesContext.getCurrentInstance().getViewRoot().setLocale(loc);
+
+ // Log trace message
+ //* NOISY-DEBUG: */ System.out.println("FinancialsLocalizationSessionBean::setLanguage: EXIT!"); //NOI18N
+ }
+
+ @Override
+ public Locale getLocale () {
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("FinancialsLocalizationSessionBean::getLocale(): locale={0} - EXIT!", this.locale)); //NOI18N
+ return this.locale;
+ }
+
+ @Override
+ public void setLocale (final Locale locale) {
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("FinancialsLocalizationSessionBean::setLocale(): locale={0} - CALLED!", locale)); //NOI18N
+ this.locale = locale;
+ }
+
+ @Override
+ public Locale[] getSelectableLocalizations () {
+ Locale[] locales = {
+ Locale.GERMANY,
+ Locale.US
+ };
+ return locales;
+ }
+
+ /**
+ * Initializer for this bean
+ */
+ @PostConstruct
+ public void init () {
+ // Log trace message
+ //* NOISY-DEBUG: */ System.out.println("FinancialsLocalizationSessionBean::init: CALLED!"); //NOI18N
+
+ // Create locale instance from context
+ Locale loc = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
+
+ // Log debug message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("FinancialsLocalizationSessionBean::init: loc={0}", loc)); //NOI18N
+ // Set it here
+ this.setLocale(loc);
+
+ // Log trace message
+ //* NOISY-DEBUG: */ System.out.println("FinancialsLocalizationSessionBean::init: EXIT!"); //NOI18N
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all fields
+ this.setLanguage(null);
+ this.setLocale(null);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.localization;
+
+import java.io.Serializable;
+import java.util.Locale;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.logout.ObserveableUserLogoutEvent;
+
+/**
+ * An interface for localization change beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsLocalizationSessionController extends Serializable {
+
+ /**
+ * Event observer for logged-in user
+ * <p>
+ * @param event Event instance
+ */
+ void afterUserLogin (final UserLoggedInEvent event);
+
+ /**
+ * Event observer for logged-out user
+ * <p>
+ * @param event Event instance
+ */
+ void afterUserLogout (final ObserveableUserLogoutEvent event);
+
+ /**
+ * Getter for locale
+ * <p>
+ * @return Locale
+ */
+ Locale getLocale ();
+
+ /**
+ * Setter for locale
+ * <p>
+ * @param locale Locale
+ */
+ void setLocale (final Locale locale);
+
+ /**
+ * Getter for language code
+ * <p>
+ * @return Language code
+ */
+ String getLanguage ();
+
+ /**
+ * Setter for language code
+ * <p>
+ * @param language Language code
+ */
+ void setLanguage (final String language);
+
+ /**
+ * Getter for selectable localizations
+ * <p>
+ * @return Selectable localizations
+ */
+ Locale[] getSelectableLocalizations ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.login;
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.faces.context.FacesContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jusercore.container.login.LoginContainer;
+import org.mxchange.jusercore.container.login.UserLoginContainer;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.login.UserLoginEvent;
+import org.mxchange.jusercore.events.logout.ObserveableUserLogoutEvent;
+import org.mxchange.jusercore.events.logout.UserLogoutEvent;
+import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
+import org.mxchange.jusercore.exceptions.UserStatusLockedException;
+import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
+import org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserUtils;
+import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
+import org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
+
+/**
+ * A web bean for user registration
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("loginController")
+@SessionScoped
+public class FinancialsUserLoginWebSessionBean extends BaseFinancialsController implements FinancialsUserLoginWebSessionController {
+
+ /**
+ * Path name for guest base template
+ */
+ private static final String GUEST_BASE_TEMPLATE_NAME = "guest/guest"; //NOI18N
+
+ /**
+ * Path name for logged-in user base template
+ */
+ private static final String USER_BASE_TEMPLATE_NAME = "login/user/user"; //NOI18N
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 47_828_986_719_691_592L;
+
+ /**
+ * Template type for pages that might be displayed in guest area and login
+ * area.
+ */
+ private String baseTemplatePathName;
+
+ /**
+ * Current password
+ */
+ private String currentPassword;
+
+ /**
+ * Logged-in user instance
+ */
+ private User loggedInUser;
+
+ /**
+ * User controller
+ */
+ @Inject
+ private FinancialsUserWebSessionController userController;
+
+ /**
+ * Flag whether the user has logged-in, set only from inside
+ */
+ private boolean userLoggedIn;
+
+ /**
+ * EJB for user-login
+ */
+ private UserLoginSessionBeanRemote userLoginBean;
+
+ /**
+ * Event fired when user has logged in
+ */
+ @Inject
+ @Any
+ private Event<UserLoggedInEvent> userLoginEvent;
+
+ /**
+ * Event fired when user has logged out
+ */
+ @Inject
+ @Any
+ private Event<ObserveableUserLogoutEvent> userLogoutEvent;
+
+ /**
+ * User's password history
+ */
+ private List<PasswordHistory> userPasswordHistory;
+
+ /**
+ * EJB for user's password history
+ */
+ private UserPasswordHistorySessionBeanRemote userPasswordHistoryBean;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsUserLoginWebSessionBean () {
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userLoginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
+
+ // Also find this
+ this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/jfinancials-ejb/userPasswordHistory!org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote"); //NOI18N
+
+ // Defaul template is guest
+ this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME;
+ } catch (final NamingException ex) {
+ // Continue to throw
+ throw new FaceletException(ex);
+ }
+ }
+
+ @Override
+ public void afterUserUpdatedPasswordEvent (@Observes final UpdatedUserPasswordEvent 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
+ }
+
+ // All fine, so update list
+ this.updatePasswordHistory(event.getPasswordHistory());
+ }
+
+ @Override
+ public String doAdminLogout () {
+ // Is a user logged-in?
+ if (this.isUserLoggedIn()) {
+ // Call other logout
+ return this.doUserLogout();
+ }
+
+ // Invalidate session
+ FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
+
+ // Set template type to guest
+ this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
+
+ // Redirect to index
+ return "index?faces-redirect=true"; //NOI18N
+ }
+
+ @Override
+ public String doUserLogin () {
+ // Get user instance
+ User user = this.userController.createUserLogin();
+
+ // Create login container
+ LoginContainer container = new UserLoginContainer(user, this.userController.getUserPassword());
+
+ try {
+ // Call bean
+ User confirmedUser = this.userLoginBean.validateUserAccountStatus(container);
+
+ // All fine here so set it here
+ this.setLoggedInUser(confirmedUser);
+
+ // Retrieve user's password list
+ this.userPasswordHistory = this.userPasswordHistoryBean.getUserPasswordHistory(confirmedUser);
+
+ // Set template to "login"
+ this.setBaseTemplatePathName(USER_BASE_TEMPLATE_NAME); //NOI18N
+
+ // Fire event away. Keep this last before return statement.
+ this.userLoginEvent.fire(new UserLoginEvent(confirmedUser));
+
+ // Clear this bean
+ this.clear();
+
+ // All fine
+ return "login"; //NOI18N
+ } catch (final UserNotFoundException | UserStatusLockedException | UserStatusUnconfirmedException ex) {
+ // Show JSF message
+ this.showFacesMessage("form_user_login:userName", ex); //NOI18N
+ return ""; //NOI18N
+ } catch (final UserPasswordMismatchException ex) {
+ // Show JSF message
+ this.showFacesMessage("form_user_login:userPassword", ex); //NOI18N
+ return ""; //NOI18N
+ }
+ }
+
+ @Override
+ public String doUserLogout () {
+ // Is loggedInUser set?
+ if (this.getLoggedInUser() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.loggedInUser is null"); //NOI18N
+ } else if (this.getLoggedInUser().getUserId() == null) {
+ // Throw again
+ throw new NullPointerException("this.loggedInUser.userId is null"); //NOI18N
+ } else if (this.getLoggedInUser().getUserId() < 1) {
+ // Invalid user id
+ throw new IllegalStateException(MessageFormat.format("this.loggedInUser.userId={0} is not valid.", this.getLoggedInUser().getUserId())); //NOI18N
+ }
+
+ // Fire event
+ this.userLogoutEvent.fire(new UserLogoutEvent(this.getLoggedInUser()));
+
+ // Invalidate session
+ FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
+
+ // Unset any user instances
+ this.setLoggedInUser(null);
+ this.setBaseTemplatePathName(GUEST_BASE_TEMPLATE_NAME); //NOI18N
+
+ // Redirect to index
+ return "index"; //NOI18N
+ }
+
+ @Override
+ public String getBaseTemplatePathName () {
+ return this.baseTemplatePathName;
+ }
+
+ @Override
+ public void setBaseTemplatePathName (final String baseTemplatePathName) {
+ this.baseTemplatePathName = baseTemplatePathName;
+ }
+
+ @Override
+ public String getCurrentPassword () {
+ return this.currentPassword;
+ }
+
+ @Override
+ public void setCurrentPassword (final String currentPassword) {
+ this.currentPassword = currentPassword;
+ }
+
+ @Override
+ public User getLoggedInUser () {
+ return this.loggedInUser;
+ }
+
+ @Override
+ public void setLoggedInUser (final User loggedInUser) {
+ this.loggedInUser = loggedInUser;
+ }
+
+ @Override
+ public List<PasswordHistory> getUserPasswordHistory () {
+ return Collections.unmodifiableList(this.userPasswordHistory);
+ }
+
+ @Override
+ public boolean ifCurrentPasswordMatches () {
+ // The current password must be set and not empty
+ if (this.getCurrentPassword() == null) {
+ // Is not set
+ throw new NullPointerException("this.currentPassword is null"); //NOI18N
+ } else if (this.getCurrentPassword().isEmpty()) {
+ // Is set empty
+ throw new IllegalStateException("this.currentPassword is empty."); //NOI18N
+ }
+
+ // Create "container"
+ LoginContainer container = new UserLoginContainer(this.getLoggedInUser(), this.getCurrentPassword());
+
+ // Now check if it matches
+ return UserUtils.ifPasswordMatches(container, this.getLoggedInUser());
+ }
+
+ @Override
+ public boolean ifUserMustChangePassword () {
+ return (this.isUserLoggedIn() && this.getLoggedInUser().getUserMustChangePassword());
+ }
+
+ @Override
+ public boolean isInvisible () {
+ // Check on login
+ if (!this.isUserLoggedIn()) {
+ // Not logged in!
+ throw new IllegalStateException("isInvisible() has been invoked for a guest."); //NOI18N
+ }
+
+ // Check logged-in first, then invisibility
+ return this.getLoggedInUser().getUserProfileMode().equals(ProfileMode.INVISIBLE);
+ }
+
+ @Override
+ public boolean isPasswordInHistory (final String userPassword) {
+ // Default is not found
+ boolean isPasswordInHistory = false;
+
+ // Init variables
+ int count = 1;
+ int maxEntries = this.getIntegerContextParameter("max_user_password_history"); //NOI18N
+
+ // Check all passwords
+ for (final PasswordHistory entry : this.getUserPasswordHistory()) {
+ // Is password the same?
+ if (UserUtils.ifPasswordMatches(userPassword, entry.getUserPasswordHistoryUser())) {
+ // Yes, found it
+ isPasswordInHistory = true;
+ break;
+ } else if (count == maxEntries) {
+ // Maximum reached
+ break;
+ }
+
+ // Count up
+ count++;
+ }
+
+ // Return status
+ return isPasswordInHistory;
+ }
+
+ @Override
+ public boolean isUserLoggedIn () {
+ this.userLoggedIn = ((this.getLoggedInUser() instanceof User) && (Objects.equals(this.getLoggedInUser().getUserAccountStatus(), UserAccountStatus.CONFIRMED)));
+
+ // Return it
+ return this.userLoggedIn;
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all fields
+ this.setCurrentPassword(null);
+ }
+
+ /**
+ * Updates password history by adding given entry to it as long as it is not
+ * there.
+ * <p>
+ * @param passwordHistory Password history entry
+ */
+ private void updatePasswordHistory (final PasswordHistory passwordHistory) {
+ if (null == passwordHistory) {
+ // Throw NPE
+ throw new NullPointerException("passwordHistory is null"); //NOI18N
+ } else if (passwordHistory.getUserPasswordHistoryId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("passwordHistory.userPasswordHistoryId is null"); //NOI18N
+ } else if (passwordHistory.getUserPasswordHistoryId() < 1) {
+ // Invalid id
+ throw new IllegalArgumentException(MessageFormat.format("passwordHistory.userPasswordHistoryId={0} is not valid.", passwordHistory.getUserPasswordHistoryId())); //NOI18N
+ }
+
+ // Is it there?
+ if (this.userPasswordHistory.contains(passwordHistory)) {
+ // Excact copy found
+ return;
+ }
+
+ // Check all entries
+ for (final PasswordHistory entry : this.userPasswordHistory) {
+ // Is same id number?
+ if (Objects.equals(entry.getUserPasswordHistoryId(), passwordHistory.getUserPasswordHistoryId())) {
+ // Found it
+ return;
+ }
+ }
+
+ // Not found, so add it
+ this.userPasswordHistory.add(passwordHistory);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.login;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.ejb.Local;
+import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
+
+/**
+ * An interface for registration web controllers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Local
+public interface FinancialsUserLoginWebSessionController extends Serializable {
+
+ /**
+ * Method being call after user's password has been updated (and history
+ * entry has been created).
+ * <p>
+ * @param event Event being observed
+ */
+ void afterUserUpdatedPasswordEvent (final UpdatedUserPasswordEvent event);
+
+ /**
+ * Checks whether given clear-text password is in user's password history.
+ * <p>
+ * @param userPassword Clear-text password
+ * <p>
+ * @return Whether clear-text password is in user's password history
+ */
+ boolean isPasswordInHistory (final String userPassword);
+
+ /**
+ * Getter for template type
+ * <p>
+ * @return Template type
+ */
+ String getBaseTemplatePathName ();
+
+ /**
+ * Setter for template type
+ * <p>
+ * @param baseTemplatePathName Template type
+ */
+ void setBaseTemplatePathName (final String baseTemplatePathName);
+
+ /**
+ * Logout for administrator area. If a logged-in user instance exists, it is
+ * being logged-out, too.
+ * <p>
+ * @return Outcome (should be redirected)
+ */
+ String doAdminLogout ();
+
+ /**
+ * Logins the user, if the account is found, confirmed and unlocked.
+ * <p>
+ * @return Redirect target
+ */
+ String doUserLogin ();
+
+ /**
+ * Logout for current user by invalidating the current session.
+ * <p>
+ * @return Outcome (should be redirected)
+ */
+ String doUserLogout ();
+
+ /**
+ * Getter for logged-in user instance
+ * <p>
+ * @return Logged-in user instance
+ */
+ User getLoggedInUser ();
+
+ /**
+ * Setter for logged-in user instance
+ * <p>
+ * @param loggedInUser Logged-in user instance
+ */
+ void setLoggedInUser (final User loggedInUser);
+
+ /**
+ * Checks whether the user is logged-in
+ * <p>
+ * @return Whether the user is logged-in
+ */
+ boolean isUserLoggedIn ();
+
+ /**
+ * Checks whether the user needs to change password
+ * <p>
+ * @return Whether the user needs to change password
+ */
+ boolean ifUserMustChangePassword ();
+
+ /**
+ * Whether the currently logged-in user is invisible
+ * <p>
+ * @return Whether the currently logged-in user is invisible
+ */
+ boolean isInvisible ();
+
+ /**
+ * Setter for current password (clear text)
+ * <p>
+ * @param currentPassword Current password
+ */
+ void setCurrentPassword (final String currentPassword);
+
+ /**
+ * Getter for current password (clear text)
+ * <p>
+ * @return Current password
+ */
+ String getCurrentPassword ();
+
+ /**
+ * Checks whether the (previously entered) current password matches with
+ * from the user instance.
+ * <p>
+ * @return If current password matches
+ */
+ boolean ifCurrentPasswordMatches ();
+
+ /**
+ * Getter for user's password history
+ * <p>
+ * @return User's password history
+ */
+ List<PasswordHistory> getUserPasswordHistory ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.mobileprovider;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
+import org.mxchange.jphone.events.mobileprovider.added.AdminMobileProviderAddedEvent;
+import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException;
+import org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote;
+import org.mxchange.jphone.phonenumbers.mobileprovider.CellphoneProvider;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+
+/**
+ * Administrative bean (controller) for mobile provider
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminMobileProviderController")
+@RequestScoped
+public class FinancialsAdminMobileProviderWebRequestBean extends BaseFinancialsController implements FinancialsAdminMobileProviderWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 184_598_175_371_269_016L;
+
+ /**
+ * Remote EJB for mobile providers (administrative)
+ */
+ private AdminMobileProviderSessionBeanRemote adminRemoteBean;
+
+ /**
+ * Regular bean
+ */
+ @Inject
+ private FinancialsMobileProviderWebRequestController mobileController;
+
+ /**
+ * Event being fired when the mobile provider was added
+ */
+ @Inject
+ @Any
+ private Event<AdminAddedMobileProviderEvent> providerAddedEvent;
+
+ /**
+ * Country instance ('s dial data)
+ */
+ private Country providerCountry;
+
+ /**
+ * Provider dial prefix (example: 0177 for German E+)
+ */
+ private Long providerDialPrefix;
+
+ /**
+ * Pattern for mail gateway
+ */
+ private String providerMailPattern;
+
+ /**
+ * Name of the provider
+ */
+ private String providerName;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsAdminMobileProviderWebRequestBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the beans
+ this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminmobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw it again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public String addMobileProvider () {
+ // Create mobile provider instance
+ MobileProvider mobileProvider = new CellphoneProvider(this.getProviderDialPrefix(), this.getProviderName(), this.getProviderCountry(), this.getProviderMailPattern());
+
+ // Is the provider already created?
+ if (this.isMobileProviderCreated(mobileProvider)) {
+ // Then throw exception
+ this.showFacesMessage("form_add_mobile_provider:providerDialPrefix", new MobileProviderAlreadyAddedException(mobileProvider)); //NOI18N
+ return ""; //NOI18N
+ }
+
+ // Init variable
+ MobileProvider updatedProvider = null;
+
+ try {
+ // Call remote EJB and get back an updated instance
+ updatedProvider = this.adminRemoteBean.addMobileProvider(mobileProvider);
+ } catch (final MobileProviderAlreadyAddedException ex) {
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Fire event
+ this.providerAddedEvent.fire(new AdminMobileProviderAddedEvent(updatedProvider));
+
+ // Redirect to list
+ return "admin_list_mobile_provider"; //NOI18N
+ }
+
+ @Override
+ public Country getProviderCountry () {
+ return this.providerCountry;
+ }
+
+ @Override
+ public void setProviderCountry (final Country providerCountry) {
+ this.providerCountry = providerCountry;
+ }
+
+ @Override
+ public Long getProviderDialPrefix () {
+ return this.providerDialPrefix;
+ }
+
+ @Override
+ public void setProviderDialPrefix (final Long providerDialPrefix) {
+ this.providerDialPrefix = providerDialPrefix;
+ }
+
+ @Override
+ public String getProviderMailPattern () {
+ return this.providerMailPattern;
+ }
+
+ @Override
+ public void setProviderMailPattern (final String providerMailPattern) {
+ this.providerMailPattern = providerMailPattern;
+ }
+
+ @Override
+ public String getProviderName () {
+ return this.providerName;
+ }
+
+ @Override
+ public void setProviderName (final String providerName) {
+ this.providerName = providerName;
+ }
+
+ /**
+ * Checks whether if the given mobile provider is already created by
+ * checking both dial prefix and country.
+ * <p>
+ * @param mobileProvider Mobile provider instance to check
+ * <p>
+ * @return Whether the given mobile provider instance is found
+ */
+ private boolean isMobileProviderCreated (final MobileProvider mobileProvider) {
+ // Default is not found
+ boolean isFound = false;
+
+ // Get list of all providers
+ List<MobileProvider> providers = this.mobileController.allMobileProvider();
+
+ // Get iterator from it
+ Iterator<MobileProvider> iterator = providers.iterator();
+
+ // Loop through all
+ while (iterator.hasNext()) {
+ // Get next element
+ MobileProvider next = iterator.next();
+
+ // Is the provider's dial prefix and country the same?
+ if ((Objects.equals(mobileProvider.getProviderDialPrefix(), next.getProviderDialPrefix())) && (Objects.equals(mobileProvider.getProviderCountry(), next.getProviderCountry()))) {
+ // Is the same, abort loop
+ isFound = true;
+ break;
+ }
+ }
+
+ // Return result
+ return isFound;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.mobileprovider;
+
+import java.io.Serializable;
+import org.mxchange.jcountry.data.Country;
+
+/**
+ * An interface for a request web controller (bean) for administrative mobile
+ * provider purposes.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsAdminMobileProviderWebRequestController extends Serializable {
+
+ /**
+ * Adds a mobile provider to database by calling the EJB. A pre-check on
+ * dial-prefix and country combination is done, if found, an exception is
+ * thrown. A redirect should take place after successfull creation.
+ * <p>
+ * @return Redirect outcome
+ */
+ String addMobileProvider ();
+
+ /**
+ * Getter for provider dial prefix
+ * <p>
+ * @return Provider dial prefix
+ */
+ Long getProviderDialPrefix ();
+
+ /**
+ * Setter for provider dial prefix
+ * <p>
+ * @param providerDialPrefix Provider dial prefix
+ */
+ void setProviderDialPrefix (final Long providerDialPrefix);
+
+ /**
+ * Getter for provider name
+ * <p>
+ * @return Provider name
+ */
+ String getProviderName ();
+
+ /**
+ * Setter for provider name
+ * <p>
+ * @param providerName Provider name
+ */
+ void setProviderName (final String providerName);
+
+ /**
+ * Getter for country instance ('s dial data)
+ * <p>
+ * @return Country instance
+ */
+ Country getProviderCountry ();
+
+ /**
+ * Setter for country instance ('s dial data)
+ * <p>
+ * @param country Country instance
+ */
+ void setProviderCountry (final Country country);
+
+ /**
+ * Getter for pattern for mail gateway
+ * <p>
+ * @return Pattern for mail gateway
+ */
+ String getProviderMailPattern ();
+
+ /**
+ * Setter for pattern for mail gateway
+ * <p>
+ * @param providerMailPattern Pattern for mail gateway
+ */
+ void setProviderMailPattern (final String providerMailPattern);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.mobileprovider;
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
+
+/**
+ * A general bean for mobile providers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("mobileProviderController")
+@SessionScoped
+public class FinancialsMobileProviderWebRequestBean extends BaseFinancialsController implements FinancialsMobileProviderWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 15_869_423_671_950_276L;
+
+ /**
+ * "Cached" list of mobile providers
+ */
+ private List<MobileProvider> mobileProviders;
+
+ /**
+ * Remote EJB for mobile providers (regular)
+ */
+ private MobileProviderSingletonBeanRemote mobileRemoteBean;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsMobileProviderWebRequestBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the beans
+ this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/jfinancials-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw it again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public void afterAdminAddedMobileProvider (@Observes final AdminAddedMobileProviderEvent event) {
+ // Is all valid?
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedMobileProvider()== null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N
+ } else if (event.getAddedMobileProvider().getProviderId()== null) {
+ // And again ...
+ throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N
+ } else if (event.getAddedMobileProvider().getProviderId() < 1) {
+ // Id is invalid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedMobileProvider.providerId={0} is not valid.", event.getAddedMobileProvider().getProviderId())); //NOI18N
+ }
+
+ // Add it to the list
+ this.mobileProviders.add(event.getAddedMobileProvider());
+ }
+
+ @Override
+ public List<MobileProvider> allMobileProvider () {
+ return Collections.unmodifiableList(this.mobileProviders);
+ }
+
+ @Override
+ public boolean hasMobileProvider () {
+ return (!this.mobileProviders.isEmpty());
+ }
+
+ /**
+ * Initializer method
+ */
+ @PostConstruct
+ public void init () {
+ // Init list of mobile providers
+ this.mobileProviders = this.mobileRemoteBean.allMobileProvider();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.mobileprovider;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+
+/**
+ * An interface for general mobile provider controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsMobileProviderWebRequestController extends Serializable {
+
+ /**
+ * Returns a list of all mobile providers
+ * <p>
+ * @return A list of all mobile providers
+ */
+ List<MobileProvider> allMobileProvider ();
+
+ /**
+ * Checks whether mobile providers are registered
+ * <p>
+ * @return Whether mobile providers are registered
+ */
+ boolean hasMobileProvider ();
+
+ /**
+ * Observes events being fired after the administrator has added a new
+ * mobile provider
+ * <p>
+ * @param event Event being fired
+ */
+ void afterAdminAddedMobileProvider (final AdminAddedMobileProviderEvent event);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.phone;
+
+import javax.enterprise.context.RequestScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+
+/**
+ * Administrative bean (controller) for phone numbers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminPhoneController")
+@RequestScoped
+public class FinancialsAdminPhoneWebRequestBean extends BaseFinancialsController implements FinancialsAdminPhoneWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 184_598_175_371_269_016L;
+
+ /**
+ * Remote EJB for phone number (administrative)
+ */
+ private AdminContactsPhoneSessionBeanRemote adminPhoneBean;
+
+ /**
+ * Cell phone number
+ */
+ private DialableMobileNumber cellPhone;
+
+ /**
+ * Fax number
+ */
+ private DialableFaxNumber fax;
+
+ /**
+ * Land-line number
+ */
+ private DialableLandLineNumber landLine;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsAdminPhoneWebRequestBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the beans
+ this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/admincontactphone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw it again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public DialableMobileNumber getMobileNumber () {
+ return this.cellPhone;
+ }
+
+ @Override
+ public void setCellPhone (final DialableMobileNumber cellPhone) {
+ this.cellPhone = cellPhone;
+ }
+
+ @Override
+ public DialableFaxNumber getFax () {
+ return this.fax;
+ }
+
+ @Override
+ public void setFax (final DialableFaxNumber fax) {
+ this.fax = fax;
+ }
+
+ @Override
+ public DialableLandLineNumber getLandLine () {
+ return this.landLine;
+ }
+
+ @Override
+ public void setLandLine (final DialableLandLineNumber landLine) {
+ this.landLine = landLine;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.phone;
+
+import java.io.Serializable;
+import javax.ejb.Local;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+
+/**
+ * An interface for a request web controller (bean) for administrative phone
+ * number purposes.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Local
+public interface FinancialsAdminPhoneWebRequestController extends Serializable {
+
+ /**
+ * Setter for dialable mobile number instance
+ * <p>
+ * @param cellPhone Dialable mobile number instance
+ */
+ void setCellPhone (final DialableMobileNumber cellPhone);
+
+ /**
+ * Getter for dialable mobile number instance
+ * <p>
+ * @return Dialable mobile number instance
+ */
+ DialableMobileNumber getMobileNumber ();
+
+ /**
+ * Setter for dialable land-line number instance
+ * <p>
+ * @param landLine Dialable land-line number instance
+ */
+ void setLandLine (final DialableLandLineNumber landLine);
+
+ /**
+ * Getter for dialable land-line number instance
+ * <p>
+ * @return Dialable land-line number instance
+ */
+ DialableLandLineNumber getLandLine ();
+
+ /**
+ * Setter for dialable fax number instance
+ * <p>
+ * @param fax Dialable fax number instance
+ */
+ void setFax (final DialableFaxNumber fax);
+
+ /**
+ * Getter for dialable fax number instance
+ * <p>
+ * @return Dialable fax number instance
+ */
+ DialableFaxNumber getFax ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.profile;
+
+import java.text.MessageFormat;
+import javax.enterprise.context.RequestScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController;
+import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
+
+/**
+ * A web request bean for user profiles
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named (value = "profileController")
+@RequestScoped
+public class FinancialsUserProfileWebRequestBean extends BaseFinancialsController implements FinancialsUserProfileWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 187_687_145_286_710L;
+
+ /**
+ * Login controller
+ */
+ @Inject
+ private FinancialsUserLoginWebSessionController loginController;
+
+ /**
+ * User controller
+ */
+ @Inject
+ private FinancialsUserWebSessionController userController;
+
+ @Override
+ public boolean isProfileLinkVisibleById (final Long userId) {
+ // Init user instance
+ User user = null;
+
+ try {
+ // Try to get it
+ user = this.userController.lookupUserById(userId);
+ } catch (final UserNotFoundException ex) {
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Is it null?
+ if (null == user) {
+ // Not found, not visible.
+ return false;
+ }
+
+ // Ask other method
+ return this.isProfileLinkVisibleByUser(user);
+ }
+
+ @Override
+ public boolean isProfileLinkVisibleByUser (final User user) {
+ // Check on user
+ if (null == user) {
+ /*
+ * Not set, means wrong invocation of this method as the user
+ * instance needs to be set first.
+ */
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ /*
+ * If the id number is not set it means that the user instance has
+ * not been persisted and the JPA has not been flushed. Or a
+ * "virgin" instance (e.g. from registration) has been used.
+ */
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ /*
+ * The id number is set invalid for an unknown reason.
+ */
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
+ } else if (user.getUserProfileMode() == null) {
+ /*
+ * Possibly an out-dated user profile is being used. This should not
+ * happen.
+ */
+ throw new NullPointerException("user.userProfileMode is null"); //NOI18N
+ }
+
+ // Get profile mode from user instance (safe now)
+ ProfileMode profileMode = user.getUserProfileMode();
+
+ // Check all conditions (except for admin)
+ return ((profileMode.equals(ProfileMode.PUBLIC)) ||
+ (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS)));
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.profile;
+
+import java.io.Serializable;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A bean interface for user profiles
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsUserProfileWebRequestController extends Serializable {
+
+ /**
+ * Checks if the user profile link is visible
+ * <p>
+ * @param userId User id
+ * <p>
+ * @return Whether the profile link is visible
+ */
+ boolean isProfileLinkVisibleById (final Long userId);
+
+ /**
+ * Checks if given user's profile is visible
+ * <p>
+ * @param user User instance to check
+ * <p>
+ * @return Whether the user's profile is visible
+ */
+ boolean isProfileLinkVisibleByUser (final User user);
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.profilemode;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+
+/**
+ * A profile mode bean
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("profileMode")
+@ApplicationScoped
+public class FinancialsProfileModeWebApplicationBean extends BaseFinancialsController implements FinancialsProfileModeWebApplicationController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 835_482_364_189L;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsProfileModeWebApplicationBean () {
+ }
+
+ @Override
+ public ProfileMode[] getAllProfileModes () {
+ // Return it
+ return ProfileMode.values();
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.profilemode;
+
+import java.io.Serializable;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+
+/**
+ * An interface for data beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsProfileModeWebApplicationController extends Serializable {
+
+ /**
+ * Getter for all genders as array
+ * <p>
+ * @return All genders as array
+ */
+ ProfileMode[] getAllProfileModes ();
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.register;
+
+import java.text.MessageFormat;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jcoreee.utils.FacesUtils;
+import org.mxchange.jusercore.events.registration.RegisteredUserEvent;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.exceptions.DataRepeatMismatchException;
+import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
+import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
+import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserUtils;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.jfinancials.beans.contact.FinancialsContactWebSessionController;
+import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jfinancials.beans.user.FinancialsAdminUserWebRequestController;
+import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
+
+/**
+ * A web bean for user registration
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("registerController")
+@SessionScoped
+public class FinancialsUserRegisterWebSessionBean extends BaseFinancialsController implements FinancialsUserRegisterWebSessionController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 47_828_986_719_691_592L;
+
+ /**
+ * Administrative user controller
+ */
+ @Inject
+ private FinancialsAdminUserWebRequestController adminUserController;
+
+ /**
+ * Contact controller
+ */
+ @Inject
+ private FinancialsContactWebSessionController contactController;
+
+ /**
+ * Features controller
+ */
+ @Inject
+ private FinancialsFeaturesWebApplicationController featureController;
+
+ /**
+ * Reemote register session bean
+ */
+ private UserRegistrationSessionBeanRemote registerBean;
+
+ /**
+ * An en event fireable when a new user has registered
+ */
+ @Inject
+ @Any
+ private Event<UserRegisteredEvent> registeredEvent;
+
+ /**
+ * User controller
+ */
+ @Inject
+ private FinancialsUserWebSessionController userController;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsUserRegisterWebSessionBean () {
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.registerBean = (UserRegistrationSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/register!org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw
+ throw new FaceletException(ex);
+ }
+ }
+
+ @Override
+ public String doFinishRegistration () {
+ // Is registration enabled?
+ if (!this.featureController.isFeatureEnabled("user_registration")) { //NOI18N
+ // Is not enabled
+ throw new FaceletException("Registration is disabled."); //NOI18N
+ }
+
+ // Get user instance
+ User user = this.userController.createUserInstance(true);
+
+ // Is the user already used?
+ if (null == user) {
+ // user must be set
+ throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
+ } 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_name_required")) && (this.userController.isUserNameRegistered(user))) { //NOI18N
+ // User name is already used
+ throw new FaceletException(new UserNameAlreadyRegisteredException(user));
+ } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
+ // Email address has already been taken
+ throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
+ } else if (!this.contactController.isSameEmailAddressEntered()) {
+ // Not same email address entered
+ throw new FaceletException(new DataRepeatMismatchException(MessageFormat.format("Email addresses not matching: {0} != {1}", this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat()))); //NOI18N
+ } else if (!this.userController.isSamePasswordEntered()) {
+ // Not same password entered
+ throw new FaceletException(new DataRepeatMismatchException("Passwords not matching.")); //NOI18N
+ }
+
+ // Encrypt password
+ String encryptedPassword = UserUtils.encryptPassword(this.userController.getUserPassword());
+
+ // Set it here
+ user.setUserEncryptedPassword(encryptedPassword);
+
+ // Is developer mode?
+ if (this.isDebugModeEnabled("register")) { //NOI18N
+ // For debugging/programming only:
+ user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
+ } else {
+ // No debugging of this part
+ user.setUserAccountStatus(UserAccountStatus.UNCONFIRMED);
+
+ // Ask EJB for generating a not-existing confirmation key
+ String confirmKey = this.registerBean.generateConfirmationKey(user);
+
+ // Set it in user
+ user.setUserConfirmKey(confirmKey);
+ }
+
+ try {
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // Call bean
+ User registeredUser = this.registerBean.registerUser(user, baseUrl);
+
+ // The id number should be set
+ assert (registeredUser.getUserId() instanceof Long) : "registeredUser.userId is null after registerUser() was called."; //NOI18N
+
+ // Fire event
+ this.registeredEvent.fire(new RegisteredUserEvent(registeredUser));
+
+ // All fine, redirect to proper page
+ return "register_done"; //NOI18N
+ } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
+ // Continue to throw
+ throw new FaceletException(ex);
+ }
+ }
+
+ @Override
+ public String doRegisterMultiPage1 () {
+ // Is registration enabled?
+ if (!this.featureController.isFeatureEnabled("user_registration")) { //NOI18N
+ // Is not enabled
+ throw new FaceletException("Registration is disabled."); //NOI18N
+ }
+
+ // Get user instance
+ User user = this.userController.createUserInstance(false);
+
+ // First check if user is not null and user name is not used + if same email address is entered
+ if (null == user) {
+ // user must be set
+ throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N
+ } else if ((this.featureController.isFeatureEnabled("user_name_required")) && (this.userController.isUserNameRegistered(user))) { //NOI18N
+ // User name is already used
+ throw new FaceletException(new UserNameAlreadyRegisteredException(user));
+ } else if (!this.contactController.isSameEmailAddressEntered()) {
+ // Not same email address entered
+ throw new FaceletException(new DataRepeatMismatchException(MessageFormat.format("Email addresses not matching: {0} != {1}", this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat()))); //NOI18N
+ }
+
+ // Create half contact instance with email address
+ Contact contact = new UserContact();
+ contact.setContactEmailAddress(this.contactController.getEmailAddress());
+
+ // Set contact in user
+ user.setUserContact(contact);
+
+ // Check if email address is registered
+ if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
+ // Email address has already been taken
+ throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
+ }
+
+ // Now only redirect to next page as the JSF does it
+ return "register_page2"; //NOI18N
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.register;
+
+import java.io.Serializable;
+
+/**
+ * An interface for registration web controllers
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsUserRegisterWebSessionController extends Serializable {
+
+ /**
+ * Registers the user, if not found. Otherwise this method should throw an
+ * exception.
+ * <p>
+ * @return Redirection target
+ */
+ String doFinishRegistration ();
+
+ /**
+ * Handles registration request send from first page. The (maybe) entered
+ * user name and email address is not used and that privacy and T&C are
+ * accepted.
+ * <p>
+ * @return Redirect
+ */
+ String doRegisterMultiPage1 ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.resendlink;
+
+import java.text.MessageFormat;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcoreee.utils.FacesUtils;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController;
+import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
+import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
+import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
+import org.mxchange.jusercore.exceptions.UserStatusLockedException;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+
+/**
+ * A web session bean for resending confirmation link
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("resendController")
+@SessionScoped
+public class FinancialsResendLinkWebSessionBean extends BaseFinancialsController implements FinancialsResendLinkWebSessionController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 186_078_724_659_153L;
+
+ /**
+ * Email address
+ */
+ private String emailAddress;
+
+ /**
+ * EJB for resending confirmation link
+ */
+ private ResendLinkSessionBeanRemote emailBean;
+
+ /**
+ * Localization controller
+ */
+ @Inject
+ private FinancialsLocalizationSessionController localizationController;
+
+ /**
+ * Regular user controller
+ */
+ @Inject
+ private FinancialsUserWebSessionController userController;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsResendLinkWebSessionBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.emailBean = (ResendLinkSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/resendLink!org.mxchange.jfinancials.beans.resendlink.ResendLinkSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public String doResendLink () {
+ // The email address should not be empty as the JSF validates this
+ if (this.getEmailAddress() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.emailAddress is null"); //NOI18N
+ }
+
+ // Init user instance
+ User user;
+
+ try {
+ // Is the email address really not used?
+ user = this.userController.lookupUserByEmailAddress(this.getEmailAddress());
+ } catch (final UserEmailAddressNotFoundException ex) {
+ // Always clear bean
+ this.clear();
+
+ // Not found, should not happen as the registered validator should find it
+ throw new FaceletException(MessageFormat.format("this.emailAddress={0} should be resolveable into User instance.", this.getEmailAddress()), ex); //NOI18N
+ }
+
+ // Is the user account already confirmed?
+ if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
+ // Always clear bean
+ this.clear();
+
+ // Then abort here
+ this.showFacesMessage("form_resend_link:resendEmailAddress", new UserStatusConfirmedException(user)); //NOI18N
+ return ""; //NOI18N
+ } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
+ // Always clear bean
+ this.clear();
+
+ // User account is locked
+ this.showFacesMessage("form_resend_link:resendEmailAddress", new UserStatusLockedException(user)); //NOI18N
+ return ""; //NOI18N
+ } else if (user.getUserConfirmKey() == null) {
+ // Status is UNCONFIRMED but confirmation key is NULL
+ throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
+ }
+
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // Call EJB and return redirect target
+ this.emailBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
+
+ // Clear this bean
+ this.clear();
+
+ // Return redirect target
+ return "resend_done"; //NOI18N
+ }
+
+ @Override
+ public String getEmailAddress () {
+ return this.emailAddress;
+ }
+
+ @Override
+ public void setEmailAddress (final String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ /**
+ * Clears email address fields so the user has to re-enter them
+ */
+ private void clear () {
+ // Clear fields
+ this.setEmailAddress(null);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.resendlink;
+
+import java.io.Serializable;
+
+/**
+ * An interface for an email change controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsResendLinkWebSessionController extends Serializable {
+
+ /**
+ * Getter for email address 1 (changing)
+ * <p>
+ * @return Email address
+ */
+ String getEmailAddress ();
+
+ /**
+ * Setter for email address 1 (changing)
+ * <p>
+ * @param emailAddress Email address 1
+ */
+ void setEmailAddress (final String emailAddress);
+
+ /**
+ * Resends (new) confirmation link to given email address, if found.
+ * Otherwise an exception is thrown. On success a redirect takes place.
+ * <p>
+ * @return Redirection target
+ */
+ String doResendLink ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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;
+
+import java.text.MessageFormat;
+import java.util.Objects;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.faces.FacesException;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcoreee.utils.FacesUtils;
+import org.mxchange.jusercore.container.login.UserLoginContainer;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.add.AdminUserAddedEvent;
+import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
+import org.mxchange.jusercore.events.user.linked.AdminUserLinkedEvent;
+import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
+import org.mxchange.jusercore.events.user.update.AdminUserDataUpdatedEvent;
+import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
+import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.exceptions.UserPasswordRepeatMismatchException;
+import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
+import org.mxchange.jusercore.exceptions.UserStatusLockedException;
+import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
+import org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote;
+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.UserUtils;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.jfinancials.beans.contact.FinancialsAdminContactWebRequestController;
+import org.mxchange.jfinancials.beans.contact.FinancialsContactWebSessionController;
+import org.mxchange.jfinancials.beans.helper.FinancialsWebRequestController;
+
+/**
+ * A user bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminUserController")
+@RequestScoped
+public class FinancialsAdminUserWebRequestBean extends BaseFinancialsController implements FinancialsAdminUserWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_916L;
+
+ /**
+ * An event fired when the administrator has added a new user
+ */
+ @Inject
+ @Any
+ private Event<AdminAddedUserEvent> addedUserEvent;
+
+ /**
+ * Regular contact controller
+ */
+ @Inject
+ private FinancialsAdminContactWebRequestController adminContactController;
+
+ /**
+ * Administrative user EJB
+ */
+ private final AdminUserSessionBeanRemote adminUserBean;
+
+ /**
+ * Admin helper instance
+ */
+ @Inject
+ private FinancialsWebRequestController beanHelper;
+
+ /**
+ * Regular contact controller
+ */
+ @Inject
+ private FinancialsContactWebSessionController contactController;
+
+ /**
+ * An event fired when the administrator has updated a new user
+ */
+ @Inject
+ @Any
+ private Event<AdminUpdatedUserDataEvent> updatedUserDataEvent;
+
+ /**
+ * General user EJB
+ */
+ private final UserSessionBeanRemote userBean;
+
+ /**
+ * Regular user controller
+ */
+ @Inject
+ private FinancialsUserWebSessionController userController;
+
+ /**
+ * An event fired when the administrator has linked a user with existing
+ * contact data.
+ */
+ @Inject
+ @Any
+ private Event<AdminLinkedUserEvent> userLinkedEvent;
+
+ /**
+ * User lock reason
+ */
+ private String userLockReason;
+
+ /**
+ * Flag whether user must change password after login
+ */
+ private Boolean userMustChangePassword;
+
+ /**
+ * User name
+ */
+ private String userName;
+
+ /**
+ * User password (unencrypted from web form)
+ */
+ private String userPassword;
+
+ /**
+ * User password repeated (unencrypted from web form)
+ */
+ private String userPasswordRepeat;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsAdminUserWebRequestBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+ this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public String addUser () {
+ // Create new user instance
+ User user = new LoginUser();
+
+ // As the form cannot validate the data (required="true"), check it here
+ if (this.getUserName() == null) {
+ // Throw NPE
+ throw new NullPointerException("userName is null"); //NOI18N
+ } else if (this.getUserName().isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("userName is null"); //NOI18N
+ } else if (this.beanHelper.getContact() == null) {
+ // No contact instance set, so test required fields: gender, first name and family name
+ if (this.contactController.getGender() == null) {
+ // Throw NPE again
+ throw new NullPointerException("contactController.gender is null"); //NOI18N
+ } else if (this.contactController.getFirstName() == null) {
+ // ... and again
+ throw new NullPointerException("contactController.firstName is null"); //NOI18N //NOI18N
+ } else if (this.contactController.getFirstName().isEmpty()) {
+ // ... and again
+ throw new IllegalArgumentException("contactController.firstName is empty"); //NOI18N
+ } else if (this.adminContactController.getFamilyName() == null) {
+ // ... and again
+ throw new NullPointerException("contactController.familyName is null"); //NOI18N
+ } else if (this.contactController.getFamilyName().isEmpty()) {
+ // ... and again
+ throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N //NOI18N
+ } else if (this.contactController.getEmailAddress() == null) {
+ // ... and again
+ throw new NullPointerException("contactController.emailAddress is null"); //NOI18N
+ } else if (this.adminContactController.getEmailAddress().isEmpty()) {
+ // ... and again
+ throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N //NOI18N
+ } else if (this.contactController.getEmailAddressRepeat() == null) {
+ // ... and again
+ throw new NullPointerException("contactController.emailAddressRepeat is null");
+ } else if (this.contactController.getEmailAddressRepeat().isEmpty()) {
+ // ... and again
+ throw new IllegalArgumentException("contactController.emailAddressRepeat is empty"); //NOI18N //NOI18N
+ } else if (!Objects.equals(this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat())) {
+ // Is not same email address
+ throw new IllegalArgumentException("Both entered email addresses don't match.");
+ }
+ }
+
+ // Set user name, CONFIRMED and INVISIBLE
+ user.setUserName(this.getUserName());
+ user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
+ user.setUserProfileMode(ProfileMode.INVISIBLE);
+
+ // Init instance
+ Contact contact;
+
+ // Is a contact instance in helper set?
+ if (this.beanHelper.getContact() instanceof Contact) {
+ // Then use it for contact linking
+ contact = this.beanHelper.getContact();
+ } else {
+ // Create contact instance
+ contact = this.contactController.createContactInstance();
+ }
+
+ // Set contact in user
+ user.setUserContact(contact);
+
+ // Init variable for password
+ String password = null;
+
+ // Is the user name or email address used already?
+ // @TODO Add password length check
+ if (this.userController.isUserNameRegistered(user)) {
+ // User name is already used
+ throw new FaceletException(new UserNameAlreadyRegisteredException(user));
+ } else if ((this.beanHelper.getContact() == null) && (this.contactController.isEmailAddressRegistered(user.getUserContact()))) {
+ // Email address is already used
+ throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
+ } else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) {
+ // Empty password entered, then generate one
+ password = UserUtils.createRandomPassword(FinancialsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
+ } else if (!this.isSamePasswordEntered()) {
+ // Both passwords don't match
+ throw new FaceletException(new UserPasswordRepeatMismatchException(user));
+ } else {
+ // Both match, so get it from this bean
+ password = this.getUserPassword();
+ }
+
+ // The password should not be null and at least 5 characters long
+ assert (password != null) : "password is null"; //NOI18N
+ assert (password.length() >= FinancialsUserWebSessionController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N
+
+ // Encrypt password and set it
+ user.setUserEncryptedPassword(UserUtils.encryptPassword(password));
+
+ try {
+ // Now, that all is set, call EJB
+ if (this.beanHelper.getContact() instanceof Contact) {
+ // Link contact with this user
+ User updatedUser = this.adminUserBean.linkUser(user);
+
+ // Fire event
+ this.userLinkedEvent.fire(new AdminUserLinkedEvent(updatedUser));
+
+ // Remove contact instance
+ this.beanHelper.setContact(null);
+ } else {
+ // Add new contact
+ User updatedUser = this.adminUserBean.addUser(user);
+
+ // Fire event
+ this.addedUserEvent.fire(new AdminUserAddedEvent(updatedUser));
+ }
+ } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) {
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Clear this bean
+ this.clear();
+
+ // Return to user list (for now)
+ return "admin_list_user"; //NOI18N
+ }
+
+ @Override
+ public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("AdminUserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
+
+ // event 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.user is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.user.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
+ }
+
+ // Get user instance
+ User registeredUser = event.getRegisteredUser();
+
+ // Debug message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
+
+ // Clear all data
+ this.clear();
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("AdminUserWebBean:afterRegistration: EXIT!"); //NOI18N
+ }
+
+ @Override
+ public String editUserData () {
+ // Get user instance
+ User user = this.beanHelper.getUser();
+
+ // Null password means not setting it
+ String encryptedPassword = null;
+
+ // Check if user instance is in helper and valid
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("beanHelper.user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("beanHelper.user.userId is null"); //NOI18N //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id
+ throw new IllegalStateException(MessageFormat.format("beanHelper.user.userId={0} is invalid", user.getUserId())); //NOI18N //NOI18N
+ } else if (this.getUserName() == null) {
+ // Not all required fields are set
+ throw new NullPointerException("this.userName is null"); //NOI18N
+ } else if (this.getUserName().isEmpty()) {
+ // Not all required fields are set
+ throw new IllegalArgumentException("this.userName is empty"); //NOI18N
+ } else if (((!this.getUserPassword().isEmpty()) || (!this.getUserPasswordRepeat().isEmpty())) && (!this.isSamePasswordEntered())) {
+ // Not same password entered
+ this.setUserPassword(null);
+ this.setUserPasswordRepeat(null);
+
+ // Throw exception
+ throw new FaceletException("Not same password entered"); //NOI18N
+ } else if (this.userBean.ifUserNameExists(this.getUserName())) {
+ // User name already exists
+ throw new FaceletException(new UserNameAlreadyRegisteredException(this.getUserName()));
+ } else if (this.isSamePasswordEntered()) {
+ // Same password entered, create container
+ if (UserUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword()))) {
+ // Same password entered
+ throw new FaceletException("Same password as stored entered."); //NOI18N
+ }
+
+ // Encrypt password
+ encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
+ }
+
+ // Set user name and flag
+ user.setUserName(this.getUserName());
+ user.setUserMustChangePassword(this.getUserMustChangePassword());
+
+ // Is a password set?
+ if (encryptedPassword != null) {
+ // Set it as well
+ user.setUserEncryptedPassword(encryptedPassword);
+ }
+
+ // Call EJB for updating user data
+ User updatedUser = this.userBean.updateUserData(user);
+
+ // Fire event
+ this.updatedUserDataEvent.fire(new AdminUserDataUpdatedEvent(updatedUser));
+
+ // Return to user list (for now)
+ return "admin_list_user"; //NOI18N
+ }
+
+ @Override
+ public String getUserLockReason () {
+ return this.userLockReason;
+ }
+
+ @Override
+ public void setUserLockReason (final String userLockReason) {
+ this.userLockReason = userLockReason;
+ }
+
+ @Override
+ public Boolean getUserMustChangePassword () {
+ return this.userMustChangePassword;
+ }
+
+ @Override
+ public void setUserMustChangePassword (final Boolean userMustChangePassword) {
+ this.userMustChangePassword = userMustChangePassword;
+ }
+
+ @Override
+ public String getUserName () {
+ return this.userName;
+ }
+
+ @Override
+ public void setUserName (final String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ public String getUserPassword () {
+ return this.userPassword;
+ }
+
+ @Override
+ public void setUserPassword (final String userPassword) {
+ this.userPassword = userPassword;
+ }
+
+ @Override
+ public String getUserPasswordRepeat () {
+ return this.userPasswordRepeat;
+ }
+
+ @Override
+ public void setUserPasswordRepeat (final String userPasswordRepeat) {
+ this.userPasswordRepeat = userPasswordRepeat;
+ }
+
+ @Override
+ public String lockUserAccount (final User user) {
+ // Is the user instance valid and CONFIRMED?
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
+ } else if (user.getUserAccountStatus() == UserAccountStatus.LOCKED) {
+ // User account is locked
+ throw new FacesException(new UserStatusLockedException(user));
+ } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) {
+ // User account is locked
+ throw new FaceletException(new UserStatusUnconfirmedException(user));
+ } else if (this.getUserLockReason() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.userLockReason is null"); //NOI18N
+ } else if (this.getUserLockReason().isEmpty()) {
+ // Empty lock reason
+ throw new IllegalArgumentException("this.userLockReason is empty"); //NOI18N
+ }
+
+ try {
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // Call EJB to lock account
+ this.adminUserBean.lockUserAccount(user, this.getUserLockReason(), baseUrl);
+ } catch (final UserStatusLockedException | UserStatusUnconfirmedException | UserNotFoundException ex) {
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Should go fine at this point, redirect to user profile
+ return "admin_show_user?faces-redirect=true&includeViewParams=true"; //NOI18N
+ }
+
+ @Override
+ public String unlockUserAccount (final User user) {
+ // Is the user instance valid and CONFIRMED?
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
+ } else if (user.getUserAccountStatus() == UserAccountStatus.CONFIRMED) {
+ // User account is locked
+ throw new FacesException(new UserStatusConfirmedException(user));
+ } else if (user.getUserAccountStatus() == UserAccountStatus.UNCONFIRMED) {
+ // User account is locked
+ throw new FaceletException(new UserStatusUnconfirmedException(user));
+ }
+
+ try {
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // Call EJB to unlock account
+ this.adminUserBean.unlockUserAccount(user, baseUrl);
+ } catch (final UserStatusConfirmedException | UserStatusUnconfirmedException | UserNotFoundException ex) {
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Should go fine at this point, redirect to user profile
+ return "admin_show_user?faces-redirect=true&includeViewParams=true"; //NOI18N
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ // - other data
+ this.setUserName(null);
+ this.setUserPassword(null);
+ this.setUserPasswordRepeat(null);
+ this.setUserMustChangePassword(null);
+ }
+
+ /**
+ * Checks if same password is entered and that they are not empty.
+ * <p>
+ * @return Whether the same password was entered
+ */
+ private boolean isSamePasswordEntered () {
+ return ((!this.getUserPassword().isEmpty()) && (Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())));
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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;
+
+import java.io.Serializable;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsAdminUserWebRequestController extends Serializable {
+
+ /**
+ * Event observer for new user registrations
+ * <p>
+ * @param event User registration event
+ */
+ void afterRegistrationEvent (final UserRegisteredEvent event);
+
+ /**
+ * Adds user instance to database by preparing a complete user instance and
+ * sending it to the EJB. The data set in the controller is being verified,
+ * e.g. if the user name or email address is not used yet.
+ * <p>
+ * @return Redirect outcome
+ */
+ String addUser ();
+
+ /**
+ * Edits currently loaded user's data in database.
+ * <p>
+ * @return Redirect outcome
+ */
+ String editUserData ();
+
+ /**
+ * Locks selected user's account. This method makes sure that a lock reason
+ * is provided that th user later can read on login attempts.
+ * <p>
+ * @param user User instance to be locked
+ * <p>
+ * @return Redirect outcome
+ */
+ String lockUserAccount (final User user);
+
+ /**
+ * Unlocks selected user's account. This method makes sure that the account
+ * is locked.
+ * <p>
+ * @param user User instance to be unlocked
+ * <p>
+ * @return Redirect outcome
+ */
+ String unlockUserAccount (final User user);
+
+ /**
+ * Getter for user name
+ * <p>
+ * @return User name
+ */
+ String getUserName ();
+
+ /**
+ * Setter for user name
+ * <p>
+ * @param userName User name
+ */
+ void setUserName (final String userName);
+
+ /**
+ * Getter for unencrypted user password
+ * <p>
+ * @return Unencrypted user password
+ */
+ String getUserPassword ();
+
+ /**
+ * Setter for unencrypted user password
+ * <p>
+ * @param userPassword Unencrypted user password
+ */
+ void setUserPassword (final String userPassword);
+
+ /**
+ * Getter for unencrypted user password repeated
+ * <p>
+ * @return Unencrypted user password repeated
+ */
+ String getUserPasswordRepeat ();
+
+ /**
+ * Setter for unencrypted user password repeated
+ * <p>
+ * @param userPasswordRepeat Unencrypted user password repeated
+ */
+ void setUserPasswordRepeat (final String userPasswordRepeat);
+
+ /**
+ * Getter for flag if user needs to change password
+ * <p>
+ * @return Flag if user needs to change password
+ */
+ Boolean getUserMustChangePassword ();
+
+ /**
+ * Setter for flag if user needs to change password
+ * <p>
+ * @param userMustChangePassword Flag if user needs to change password
+ */
+ void setUserMustChangePassword (final Boolean userMustChangePassword);
+
+ /**
+ * Getter for user lock reason
+ * <p>
+ * @return User lock reason
+ */
+ String getUserLockReason ();
+
+ /**
+ * Setter for user lock reason
+ * <p>
+ * @param userLockReason User lock reason
+ */
+ void setUserLockReason (final String userLockReason);
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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;
+
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.faces.context.FacesContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
+import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
+import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
+import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
+import org.mxchange.jusercore.events.user.update.UserUpdatedPersonalDataEvent;
+import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
+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.UserUtils;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.jfinancials.beans.contact.FinancialsContactWebSessionController;
+import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jfinancials.beans.localization.FinancialsLocalizationSessionController;
+import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController;
+
+/**
+ * A user bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("userController")
+@SessionScoped
+public class FinancialsUserWebSessionBean extends BaseFinancialsController implements FinancialsUserWebSessionController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_916L;
+
+ /**
+ * Contact EJB
+ */
+ private ContactSessionBeanRemote contactBean;
+
+ /**
+ * General contact controller
+ */
+ @Inject
+ private FinancialsContactWebSessionController contactController;
+
+ /**
+ * Features controller
+ */
+ @Inject
+ private FinancialsFeaturesWebApplicationController featureController;
+
+ /**
+ * Localization controller
+ */
+ @Inject
+ private FinancialsLocalizationSessionController localizationController;
+
+ /**
+ * Event being fired when user updated personal data
+ */
+ @Inject
+ @Any
+ private Event<UpdatedUserPersonalDataEvent> updatedPersonalDataEvent;
+
+ /**
+ * Remote user bean
+ */
+ private final UserSessionBeanRemote userBean;
+
+ /**
+ * User id
+ */
+ private Long userId;
+
+ /**
+ * A list of all user profiles
+ */
+ private List<User> userList;
+
+ /**
+ * Login bean (controller)
+ */
+ @Inject
+ private FinancialsUserLoginWebSessionController userLoginController;
+
+ /**
+ * User name
+ */
+ private String userName;
+
+ /**
+ * User name list
+ */
+ private List<String> userNameList;
+
+ /**
+ * User password (unencrypted from web form)
+ */
+ private String userPassword;
+
+ /**
+ * User password repeated (unencrypted from web form)
+ */
+ private String userPasswordRepeat;
+
+ /**
+ * Whether the user wants a public profile
+ */
+ private ProfileMode userProfileMode;
+
+ /**
+ * A list of all public user profiles
+ * <p>
+ * @TODO Hmm, makes that sense? Having visible user list in current
+ * (session-scoped) user's visible user list?
+ */
+ private List<User> visibleUserList;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsUserWebSessionBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+
+ // Try to lookup
+ this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminAddedUserEvent: event={0} - CALLED!", event)); //NOI18N
+
+ // event 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
+ }
+
+ // Add user uniquely
+ this.uniqueAddUser(event.getAddedUser());
+
+ // Clear all data
+ this.clear();
+
+ // Set user id again
+ this.setUserId(event.getAddedUser().getUserId());
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminAddedUserEvent: EXIT!"); //NOI18N
+ }
+
+ @Override
+ public void afterAdminUpdatedUserDataEvent (@Observes final AdminUpdatedUserDataEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminUpdatedUserEvent: event={0} - CALLED!", event)); //NOI18N
+
+ // 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 list
+ this.updateList(event.getUpdatedUser());
+
+ // Clear all data
+ this.clear();
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminUpdatedUserEvent: EXIT!"); //NOI18N
+ }
+
+ @Override
+ public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
+
+ // event 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
+ }
+
+ // Get user instance
+ User registeredUser = event.getRegisteredUser();
+
+ // Debug message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
+
+ // Copy all data from registered->user
+ this.copyUser(registeredUser);
+
+ // Clear all data
+ this.clear();
+
+ // Add user uniquely
+ this.uniqueAddUser(registeredUser);
+
+ // Add user name
+ this.addUserName(registeredUser);
+
+ // Is the account public?
+ if (Objects.equals(registeredUser.getUserProfileMode(), ProfileMode.PUBLIC)) {
+ // Also add it to this list
+ this.visibleUserList.add(registeredUser);
+ }
+
+ // Set user id again
+ this.setUserId(registeredUser.getUserId());
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterRegistration: EXIT!"); //NOI18N
+ }
+
+ @Override
+ public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
+
+ // 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
+ }
+
+ // Add user uniquely
+ this.uniqueAddUser(event.getConfirmedUser());
+ }
+
+ @Override
+ public void afterUserLogin (@Observes final UserLoggedInEvent event) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
+
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getLoggedInUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.registeredUser is null"); //NOI18N
+ } else if (event.getLoggedInUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
+ } else if (event.getLoggedInUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
+ }
+
+ // "Cache" user instance
+ User loggedInUser = event.getLoggedInUser();
+
+ // Copy all data to this bean
+ this.copyUser(loggedInUser);
+
+ // Is the user visible?
+ if (Objects.equals(loggedInUser.getUserProfileMode(), ProfileMode.PUBLIC)) {
+ // Yes, then add user
+ this.visibleUserList.add(loggedInUser);
+ }
+ }
+
+ @Override
+ public void afterUserUpdatedPasswordEvent (@Observes final UpdatedUserPasswordEvent 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
+ }
+
+ // All fine, so update list
+ this.updateList(event.getPasswordHistory().getUserPasswordHistoryUser());
+ }
+
+ @Override
+ public void afterUserUpdatedPersonalData (@Observes final UpdatedUserPersonalDataEvent 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
+ }
+
+ // All fine, so update list
+ this.updateList(event.getUpdatedUser());
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<User> allUsers () {
+ // Return it
+ return this.userList;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<User> allVisibleUsers () {
+ // Return it
+ return this.visibleUserList;
+ }
+
+ @Override
+ public User createUserInstance (final boolean createContactData) {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: CALLED!", this.getClass().getSimpleName()));
+
+ // Required personal data must be set
+ assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
+
+ // Create new user instance
+ User user = new LoginUser();
+
+ // Is user name required?
+ if (!this.isUserNameRequired()) {
+ // Generate pseudo-random user name
+ String randomName = this.userBean.generateRandomUserName();
+
+ // Set it and inivisible profile
+ this.setUserName(randomName);
+ this.setUserProfileMode(ProfileMode.INVISIBLE);
+
+ // Generate random password
+ String randomPassword = UserUtils.createRandomPassword(FinancialsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
+
+ // Set random password
+ this.setUserPassword(randomPassword);
+ this.setUserPasswordRepeat(randomPassword);
+ }
+
+ // Set local, user name and mode
+ user.setUserLocale(this.localizationController.getLocale());
+ user.setUserName(this.getUserName());
+ user.setUserProfileMode(this.getUserProfileMode());
+
+ // Is multiple registration page
+ if ((createContactData) || (!this.featureController.isFeatureEnabled("user_register_multiple_page"))) { //NOI18N
+ // Create contact instance
+ Contact contact = this.contactController.createContactInstance();
+
+ // Debug message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: contact={1}", this.getClass().getSimpleName(), contact));
+
+ // Set contact in user
+ user.setUserContact(contact);
+ }
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: user={1} - EXIT!", this.getClass().getSimpleName(), user));
+
+ // Return it
+ return user;
+ }
+
+ @Override
+ public User createUserLogin () {
+ // Trace message
+ //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: CALLED!", this.getClass().getSimpleName()));
+
+ // Is all data set?
+ if (this.getUserName() == null) {
+ // Throw NPE
+ throw new NullPointerException("recruiterName is null"); //NOI18N
+ } else if (this.getUserName().isEmpty()) {
+ // Is empty
+ throw new IllegalStateException("recruiterName is empty."); //NOI18N
+ }
+
+ // Create new recruiter instance
+ User recruiter = new LoginUser();
+
+ // Update all data ...
+ recruiter.setUserName(this.getUserName());
+
+ // Trace message
+ //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: recruiter={1} - EXIT!", this.getClass().getSimpleName(), recruiter));
+
+ // Return the new instance
+ return recruiter;
+ }
+
+ @Override
+ public String doChangePersonalData () {
+ // This method shall only be called if the user is logged-in
+ if (!this.userLoginController.isUserLoggedIn()) {
+ // Not logged-in
+ throw new IllegalStateException("User is not logged-in"); //NOI18N
+ } else if (!this.isRequiredChangePersonalDataSet()) {
+ // Not all required fields are set
+ throw new FaceletException("Not all required fields are set."); //NOI18N
+ } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
+ // Password not matching
+ throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
+ } else if (!this.featureController.isFeatureEnabled("edit_user_data")) {
+ // Editing is not allowed
+ throw new IllegalStateException("User tried to edit personal data."); //NOI18N
+ }
+
+ // Get user instance
+ User user = this.userLoginController.getLoggedInUser();
+
+ // Copy contact data to contact instance
+ this.contactController.updateContactDataFromController(user.getUserContact());
+
+ // It should be there, so run some tests on it
+ assert (user instanceof User) : "Instance loginController.loggedInUser is null";
+ assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null";
+ assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId());
+ assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null";
+ assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null";
+ assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId());
+
+ // Update all fields
+ user.setUserProfileMode(this.getUserProfileMode());
+
+ // Send it to the EJB
+ User updatedUser = this.userBean.updateUserPersonalData(user);
+
+ // Fire event
+ this.updatedPersonalDataEvent.fire(new UserUpdatedPersonalDataEvent(updatedUser));
+
+ // All fine
+ return "contact_data_saved"; //NOI18N
+ }
+
+ @Override
+ public Long getUserId () {
+ return this.userId;
+ }
+
+ @Override
+ public void setUserId (final Long userId) {
+ this.userId = userId;
+ }
+
+ @Override
+ public String getUserName () {
+ return this.userName;
+ }
+
+ @Override
+ public void setUserName (final String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ public String getUserPassword () {
+ return this.userPassword;
+ }
+
+ @Override
+ public void setUserPassword (final String userPassword) {
+ this.userPassword = userPassword;
+ }
+
+ @Override
+ public String getUserPasswordRepeat () {
+ return this.userPasswordRepeat;
+ }
+
+ @Override
+ public void setUserPasswordRepeat (final String userPasswordRepeat) {
+ this.userPasswordRepeat = userPasswordRepeat;
+ }
+
+ @Override
+ public ProfileMode getUserProfileMode () {
+ return this.userProfileMode;
+ }
+
+ @Override
+ public void setUserProfileMode (final ProfileMode userProfileMode) {
+ this.userProfileMode = userProfileMode;
+ }
+
+ /**
+ * Post-initialization of this class
+ */
+ @PostConstruct
+ public void init () {
+ // Initialize user list
+ this.userList = this.userBean.allUsers();
+
+ // Get full user name list for reducing EJB calls
+ this.userNameList = this.userBean.getUserNameList();
+
+ // Is the user logged-in?
+ if (this.userLoginController.isUserLoggedIn()) {
+ // Is logged-in, so load also users visible to memebers
+ this.visibleUserList = this.userBean.allMemberPublicVisibleUsers();
+ } else {
+ // Initialize user list
+ this.visibleUserList = this.userBean.allPublicUsers();
+ }
+ }
+
+ @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;
+
+ // Get iterator
+ Iterator<User> iterator = this.allUsers().iterator();
+
+ // Loop through all entries
+ while (iterator.hasNext()) {
+ // Get user
+ User next = iterator.next();
+
+ // Compare both objects
+ if (Objects.equals(contact, next.getUserContact())) {
+ // Found it
+ isFound = true;
+ break;
+ }
+ }
+
+ // Return status
+ return isFound;
+ }
+
+ @Override
+ public boolean isPublicUserProfileEnabled () {
+ // Get context parameter
+ String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_public_profile_enabled"); //NOI18N
+
+ // Is it set?
+ boolean isEnabled = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
+
+ // This requires user names being enabled, too.
+ if ((isEnabled) && (!this.isUserNameRequired())) {
+ // Not valid state, users must be able to modify their profile, especially when it is public
+ throw new IllegalStateException("Public user profiles are enabled but user name requirement is disabled, this is not possible."); //NOI18N
+ }
+
+ // Return value
+ return isEnabled;
+ }
+
+ @Override
+ public boolean isRequiredChangePersonalDataSet () {
+ return ((this.getUserProfileMode() != null) &&
+ (this.getUserName() != null) && (!this.getUserName().isEmpty()) &&
+ (this.contactController.isRequiredChangePersonalDataSet()));
+ }
+
+ @Override
+ public boolean isRequiredPersonalDataSet () {
+ if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
+ // Multiple registration page
+ return this.contactController.isRequiredPersonalDataSet();
+ } else {
+ // Single registration page
+ return (((this.getUserName() != null) || (!this.isUserNameRequired())) &&
+ (this.getUserProfileMode() != null) &&
+ (this.contactController.isRequiredPersonalDataSet()) &&
+ (this.getUserPassword() != null) &&
+ (this.getUserPasswordRepeat() != null));
+ }
+ }
+
+ @Override
+ public boolean isSamePasswordEntered () {
+ return ((!this.getUserPassword().isEmpty()) && (Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())));
+ }
+
+ @Override
+ public boolean isUserIdEmpty () {
+ return ((this.getUserId() == null) || (this.getUserId() == 0));
+ }
+
+ @Override
+ public boolean isUserNameRegistered (final User user) {
+ return ((this.userNameList instanceof List) && (this.userNameList.contains(user.getUserName())));
+ }
+
+ @Override
+ public boolean isUserNameRequired () {
+ // Get context parameter
+ String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_user_name_required"); //NOI18N
+
+ // Is it set?
+ boolean isRequired = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
+
+ // Return value
+ return isRequired;
+ }
+
+ @Override
+ public boolean isVisibleUserFound () {
+ return ((this.visibleUserList instanceof List) && (!this.visibleUserList.isEmpty()));
+ }
+
+ @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 Iterator<User> iterator = this.userList.iterator(); iterator.hasNext();) {
+ // Get next user
+ User next = iterator.next();
+
+ // Contact should be set
+ if (next.getUserContact() == null) {
+ // Contact is null
+ throw new NullPointerException(MessageFormat.format("next.userContact is null for user id {0}", next.getUserId())); //NOI18N
+ } else if (next.getUserContact().getContactEmailAddress() == null) {
+ // Email address should be set
+ throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getUserId())); //NOI18N //NOI18N
+ }
+
+ // Is the email address found?
+ if (Objects.equals(next.getUserContact().getContactEmailAddress(), emailAddress)) {
+ // Copy to other variable
+ user = next;
+ 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 Iterator<User> iterator = this.userList.iterator(); iterator.hasNext();) {
+ // Get next user
+ User next = iterator.next();
+
+ // Is the user id found?
+ if (Objects.equals(next.getUserId(), userId)) {
+ // Copy to other variable
+ user = next;
+ break;
+ }
+ }
+
+ // Is it still null?
+ if (null == user) {
+ // Not visible for the current user
+ throw new UserNotFoundException(userId);
+ }
+
+ // Return it
+ return user;
+ }
+
+ /**
+ * Adds user's name to bean's internal list. It also updates the public user
+ * list if the user has decided to have a public account,
+ * <p>
+ * @param user User instance
+ */
+ private void addUserName (final User user) {
+ // Make sure the entry is not added yet
+ if (this.userNameList.contains(user.getUserName())) {
+ // Abort here
+ throw new IllegalArgumentException(MessageFormat.format("User name {0} already added.", user.getUserName())); //NOI18N
+ } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
+ // Already added
+ throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", user.getUserContact().getContactEmailAddress())); //NOI18N
+ }
+
+ // Add user name
+ this.userNameList.add(user.getUserName());
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ // - personal data
+ this.setUserId(null);
+ this.setUserProfileMode(null);
+
+ // - other data
+ this.setUserName(null);
+ this.setUserPassword(null);
+ this.setUserPasswordRepeat(null);
+ }
+
+ /**
+ * Copies given user into the controller
+ * <p>
+ * @param user User instance
+ */
+ private void copyUser (final User user) {
+ // Make sure the instance is valid
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("user.userContact is null"); //NOI18N
+ }
+
+ // Copy all fields:
+ // - base data
+ this.setUserId(user.getUserId());
+ this.setUserProfileMode(user.getUserProfileMode());
+ }
+
+ /**
+ * Uniquely adds given user instance to user list. First an existing
+ * instance will be removed, then the given instance is being added.
+ * <p>
+ * @param user User instance to add
+ */
+ private void uniqueAddUser (final User user) {
+ // Make sure the instance is valid
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("user.userContact is null"); //NOI18N
+ }
+
+ // Get iterator from list
+ Iterator<User> iterator = this.userList.iterator();
+
+ // "Walk" through all entries
+ while (iterator.hasNext()) {
+ // Get next element
+ User next = iterator.next();
+
+ // Is id number the same?
+ if (Objects.equals(user.getUserId(), next.getUserId())) {
+ // Found entry, so remove it and abort
+ this.userList.remove(next);
+ break;
+ }
+ }
+
+ // Add contact to list
+ this.userList.add(user);
+ }
+
+ /**
+ * 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
+ }
+
+ // Get iterator
+ Iterator<User> iterator = this.userList.iterator();
+
+ // Look whole list
+ while (iterator.hasNext()) {
+ // Get next element
+ User next = iterator.next();
+
+ // Is the same user id?
+ if (Objects.equals(user.getUserId(), next.getUserId())) {
+ // Found it, so remove it
+ this.userList.remove(next);
+ break;
+ }
+ }
+
+ // Re-add item
+ this.userList.add(user);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
+import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
+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.User;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsUserWebSessionController extends Serializable {
+
+ /**
+ * Minimum password length
+ */
+ public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
+
+ /**
+ * Event observer for newly added users by adminstrator
+ * <p>
+ * @param event Event being fired
+ */
+ void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
+
+ /**
+ * Event observer for updated user data by administrator
+ * <p>
+ * @param event Event being updated
+ */
+ void afterAdminUpdatedUserDataEvent (final AdminUpdatedUserDataEvent event);
+
+ /**
+ * Event observer when user confirmed account.
+ * <p>
+ * @param event Event being fired
+ */
+ void afterUserConfirmedAccount (final UserConfirmedAccountEvent event);
+
+ /**
+ * Method being call after user's password has been updated (and history
+ * entry has been created).
+ * <p>
+ * @param event Event being observed
+ */
+ void afterUserUpdatedPasswordEvent (final UpdatedUserPasswordEvent event);
+
+ /**
+ * Listens to fired event when user updated personal data
+ * <p>
+ * @param event Event being fired
+ */
+ void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
+
+ /**
+ * Event observer for new user registrations
+ * <p>
+ * @param event User registration event
+ */
+ void afterRegistrationEvent (final UserRegisteredEvent event);
+
+ /**
+ * Event observer for logged-in user
+ * <p>
+ * @param event Event instance
+ */
+ void afterUserLogin (final UserLoggedInEvent event);
+
+ /**
+ * All users
+ * <p>
+ * @return A list of all public user profiles
+ */
+ List<User> allUsers ();
+
+ /**
+ * All public user profiles
+ * <p>
+ * @return A list of all public user profiles
+ */
+ List<User> allVisibleUsers ();
+
+ /**
+ * Checks whether the given contact is a user
+ * <p>
+ * @param contact Contact to check
+ * <p>
+ * @return Whether the contact is a user
+ */
+ boolean isContactFound (final Contact contact);
+
+ /**
+ * Checks whether a public user account is registered. This means that at
+ * least one user profile has its flag "public user profile" enabled.
+ * <p>
+ * @return Whether at least one user has a public profile
+ */
+ boolean isVisibleUserFound ();
+
+ /**
+ * Checks whether given user instance's name is used
+ * <p>
+ * @param user User instance's name to check
+ * <p>
+ * @return Whether it is already used
+ */
+ boolean isUserNameRegistered (final User user);
+
+ /**
+ * Tries to lookup user by given id number. If the user is not found or the
+ * account status is not CONFIRMED proper exceptions are thrown.
+ * <p>
+ * @param userId User id
+ * <p>
+ * @return User instance
+ * <p>
+ * @throws UserNotFoundException If the user is not found
+ */
+ User lookupUserById (final Long userId) throws UserNotFoundException;
+
+ /**
+ * Tries to lookup user by given email address. If the user is not found a
+ * proper exceptions is thrown.
+ * <p>
+ * @param emailAddress Email address
+ * <p>
+ * @return User instance
+ * <p>
+ * @throws UserEmailAddressNotFoundException If the user's email address is not found
+ */
+ User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException;
+
+ /**
+ * Creates an instance from all properties
+ * <p>
+ * @param createContactData Whether contact data should be created
+ * <p>
+ * @return A user instance
+ */
+ User createUserInstance (final boolean createContactData);
+
+ /**
+ * Creates a user instance for login phase
+ * <p>
+ * @return User instance
+ */
+ User createUserLogin ();
+
+ /**
+ * Getter for user id
+ * <p>
+ * @return User id
+ */
+ Long getUserId ();
+
+ /**
+ * Setter for user id
+ * <p>
+ * @param userId User id
+ */
+ void setUserId (final Long userId);
+
+ /**
+ * Getter for user name
+ * <p>
+ * @return User name
+ */
+ String getUserName ();
+
+ /**
+ * Setter for user name
+ * <p>
+ * @param userName User name
+ */
+ void setUserName (final String userName);
+
+ /**
+ * Getter for unencrypted user password
+ * <p>
+ * @return Unencrypted user password
+ */
+ String getUserPassword ();
+
+ /**
+ * Setter for unencrypted user password
+ * <p>
+ * @param userPassword Unencrypted user password
+ */
+ void setUserPassword (final String userPassword);
+
+ /**
+ * Getter for unencrypted user password repeated
+ * <p>
+ * @return Unencrypted user password repeated
+ */
+ String getUserPasswordRepeat ();
+
+ /**
+ * Setter for unencrypted user password repeated
+ * <p>
+ * @param userPasswordRepeat Unencrypted user password repeated
+ */
+ void setUserPasswordRepeat (final String userPasswordRepeat);
+
+ /**
+ * Getter for user profile mode
+ * <p>
+ * @return User profile mode
+ */
+ ProfileMode getUserProfileMode ();
+
+ /**
+ * Setter for user profile mode
+ * <p>
+ * @param userProfileMode User profile mode
+ */
+ void setUserProfileMode (final ProfileMode userProfileMode);
+
+ /**
+ * Checks whether all required personal data is set
+ * <p>
+ * @return Whether the required personal data is set
+ */
+ boolean isRequiredPersonalDataSet ();
+
+ /**
+ * Checks whether all required personal data is set for changing them
+ * <p>
+ * @return Whether the required personal data is set
+ */
+ boolean isRequiredChangePersonalDataSet ();
+
+ /**
+ * Checks whether same passwords has been entered
+ * <p>
+ * @return Whether same passwords has been entered
+ */
+ boolean isSamePasswordEntered ();
+
+ /**
+ * Checks if the user id is empty
+ * <p>
+ * @return Whether the user id is empty
+ */
+ boolean isUserIdEmpty ();
+
+ /**
+ * Changes logged-in user's personal data if the current password matches
+ * and TAC + privacy statement has been accepted.
+ * <p>
+ * @return New target page
+ */
+ String doChangePersonalData ();
+
+ /**
+ * Checks whether this application requires a user name to be entered.
+ * Otherwise a random name like "userXXXXX" is generated
+ * <p>
+ * @return Whether this application requires a user name
+ */
+ boolean isUserNameRequired ();
+
+ /**
+ * Checks wether public user profiles are enabled. This requires that user
+ * names are also enabled.
+ * <p>
+ * @return Whether public user profiles are enabled
+ */
+ boolean isPublicUserProfileEnabled ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.password;
+
+import java.util.Objects;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jfinancials.beans.BaseFinancialsController;
+import org.mxchange.jcoreee.utils.FacesUtils;
+import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
+import org.mxchange.jusercore.events.user.password_change.UserUpdatedPasswordEvent;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
+import org.mxchange.jusercore.exceptions.UserStatusLockedException;
+import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+import org.mxchange.jusercore.model.user.UserUtils;
+import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
+import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController;
+import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController;
+
+/**
+ * A user password (change) bean (controller)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("userPasswordController")
+@RequestScoped
+public class FinancialsUserPasswordWebRequestBean extends BaseFinancialsController implements FinancialsUserPasswordWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 15_267_867_367_501L;
+
+ /**
+ * Features controller
+ */
+ @Inject
+ private FinancialsFeaturesWebApplicationController featureController;
+
+ /**
+ * Remote user bean
+ */
+ private final UserSessionBeanRemote userBean;
+
+ /**
+ * Current password (for confirmation of password change)
+ */
+ private String userCurrentPassword;
+
+ /**
+ * Login bean (controller)
+ */
+ @Inject
+ private FinancialsUserLoginWebSessionController userLoginController;
+
+ /**
+ * User password (unencrypted from web form)
+ */
+ private String userPassword;
+
+ /**
+ * User password repeated (unencrypted from web form)
+ */
+ private String userPasswordRepeat;
+
+ /**
+ * Event being fired when user's password has been updated
+ */
+ @Any
+ @Inject
+ private Event<UpdatedUserPasswordEvent> userUpdatedPasswordEvent;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsUserPasswordWebRequestBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public String doChangePassword () {
+ // This method shall only be called if the user is logged-in
+ if (!this.userLoginController.isUserLoggedIn()) {
+ // Not logged-in
+ throw new IllegalStateException("User is not logged-in"); //NOI18N
+ } else if (!this.isRequiredChangePasswordSet()) {
+ // Not all required fields are set
+ throw new FaceletException("Not all required fields are set."); //NOI18N
+ } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
+ // Password not matching
+ throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
+ } else if (!this.featureController.isFeatureEnabled("change_user_password")) { //NOI18N
+ // Editing is not allowed
+ throw new IllegalStateException("User tried to change password."); //NOI18N
+ } else if (!UserUtils.ifPasswordMatches(this.getUserCurrentPassword(), this.userLoginController.getLoggedInUser())) {
+ // Password mismatches
+ this.showFacesMessage("form_user_change_password:userCurrentPassword", "Entered current password does not matched stored password."); //NOI18N
+
+ // Clear bean
+ this.clear();
+
+ // No redirect
+ return ""; //NOI18N
+ } else if (!Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())) {
+ // Both entered passwords don't match
+ this.showFacesMessage("form_user_change_password:userPasswordRepeat", "Entered new passwords mismatch."); //NOI18N
+
+ // Clear bean
+ this.clear();
+
+ // No redirect
+ return ""; //NOI18N
+ } else if (Objects.equals(this.getUserCurrentPassword(), this.getUserPassword())) {
+ // New password matches current
+ this.showFacesMessage("form_user_change_password:userPassword", "Entered new password is same as current password."); //NOI18N
+
+ // Clear bean
+ this.clear();
+
+ // No redirect
+ return ""; //NOI18N
+ } else if (this.userLoginController.isPasswordInHistory(this.getUserPassword())) {
+ // Is already in list (to old passwords are ignored)
+ this.showFacesMessage("form_user_change_password:userPassword", "Entered new password is has already been used some time ago."); //NOI18N
+
+ // Clear bean
+ this.clear();
+
+ // No redirect
+ return ""; //NOI18N
+ }
+
+ // Get user instance
+ User user = this.userLoginController.getLoggedInUser();
+
+ // Encrypt password
+ String encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
+
+ // Set it in user
+ user.setUserEncryptedPassword(encryptedPassword);
+
+ try {
+ // Get base URL
+ String baseUrl = FacesUtils.generateBaseUrl();
+
+ // All is set, then update password
+ PasswordHistory passwordHistory = this.userBean.updateUserPassword(user, baseUrl);
+
+ // Fire event
+ this.userUpdatedPasswordEvent.fire(new UserUpdatedPasswordEvent(passwordHistory));
+ } catch (final UserNotFoundException | UserStatusUnconfirmedException | UserStatusLockedException ex) {
+ // Clear bean
+ this.clear();
+
+ // Throw again
+ throw new FaceletException(ex);
+ }
+
+ // Clear bean
+ this.clear();
+
+ // Return outcome
+ return "login_data_saved"; //NOI18N
+ }
+
+ @Override
+ public String getUserCurrentPassword () {
+ return this.userCurrentPassword;
+ }
+
+ @Override
+ public void setUserCurrentPassword (final String userCurrentPassword) {
+ this.userCurrentPassword = userCurrentPassword;
+ }
+
+ @Override
+ public String getUserPassword () {
+ return this.userPassword;
+ }
+
+ @Override
+ public void setUserPassword (final String userPassword) {
+ this.userPassword = userPassword;
+ }
+
+ @Override
+ public String getUserPasswordRepeat () {
+ return this.userPasswordRepeat;
+ }
+
+ @Override
+ public void setUserPasswordRepeat (final String userPasswordRepeat) {
+ this.userPasswordRepeat = userPasswordRepeat;
+ }
+
+ public boolean isRequiredChangePasswordSet () {
+ // Is all data set?
+ return ((this.getUserCurrentPassword() != null) &&
+ (!this.getUserCurrentPassword().isEmpty()) &&
+ (this.getUserPassword() != null) &&
+ (!this.getUserPassword().isEmpty()) &&
+ (this.getUserPasswordRepeat() != null) &&
+ (!this.getUserPasswordRepeat().isEmpty()));
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ this.setUserPassword(null);
+ this.setUserPasswordRepeat(null);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.password;
+
+import java.io.Serializable;
+import javax.ejb.Local;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Local
+public interface FinancialsUserPasswordWebRequestController extends Serializable {
+
+ /**
+ * Getter for unencrypted user password
+ * <p>
+ * @return Unencrypted user password
+ */
+ String getUserPassword ();
+
+ /**
+ * Setter for unencrypted user password
+ * <p>
+ * @param userPassword Unencrypted user password
+ */
+ void setUserPassword (final String userPassword);
+
+ /**
+ * Getter for current unencrypted user password
+ * <p>
+ * @return Current unencrypted user password
+ */
+ String getUserCurrentPassword ();
+
+ /**
+ * Setter for current unencrypted user password
+ * <p>
+ * @param userCurrentPassword Current unencrypted user password
+ */
+ void setUserCurrentPassword (final String userCurrentPassword);
+
+ /**
+ * Getter for unencrypted user password repeated
+ * <p>
+ * @return Unencrypted user password repeated
+ */
+ String getUserPasswordRepeat ();
+
+ /**
+ * Setter for unencrypted user password repeated
+ * <p>
+ * @param userPasswordRepeat Unencrypted user password repeated
+ */
+ void setUserPasswordRepeat (final String userPasswordRepeat);
+
+ /**
+ * Changes logged-in user's password. It must not match with current password and should not appear in password history list for X (configurable) entries.
+ * <p>
+ * @return Redirect outcome
+ */
+ String doChangePassword ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.converter.contact;
+
+import java.text.MessageFormat;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.FacesConverter;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+
+/**
+ * Converter for contact id <-> valid contact instance
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesConverter (value = "ContactConverter")
+public class AddressbookContactConverter implements Converter {
+
+ /**
+ * User EJB
+ */
+ private ContactSessionBeanRemote contactBean;
+
+ /**
+ * Logger instance
+ */
+ @Log
+ private LoggerBeanLocal loggerBeanLocal;
+
+ /**
+ * Initialization of this converter
+ */
+ public AddressbookContactConverter () {
+ // Try to get it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Lookup logger
+ this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
+
+ // ... and user controller
+ this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw it
+ throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+ }
+ }
+
+ @Override
+ public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
+
+ // Is the value null or empty?
+ if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+ // Warning message
+ this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
+
+ // Return null
+ return null;
+ }
+
+ // Init instance
+ Contact contact = null;
+
+ try {
+ // Try to parse the value as long
+ Long contactId = Long.valueOf(submittedValue);
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: contactId{0}", contactId)); //NOI18N
+
+ // Try to get user instance from it
+ contact = this.contactBean.findContactById(contactId);
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: contact={0}", contact)); //NOI18N
+ } catch (final NumberFormatException ex) {
+ // Throw again
+ throw new ConverterException(ex);
+ } catch (final ContactNotFoundException ex) {
+ // Debug message
+ this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
+ }
+
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: contact={0} - EXIT!", contact)); //NOI18N
+
+ // Return it
+ return contact;
+ }
+
+ @Override
+ public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
+ // Is the object null?
+ if ((null == value) || ((String.valueOf(value)).isEmpty())) {
+ // Is null
+ return ""; //NOI18N
+ } else if (!(value instanceof Contact)) {
+ // Not same interface
+ throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement Contact.", value)); //NOI18N
+ }
+
+ // Return category id
+ return String.valueOf(((Contact) value).getContactId());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.converter.country;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Objects;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
+
+/**
+ * Converter for country instance
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesConverter (value = "CountryConverter")
+public class AddressbookCountryConverter implements Converter {
+
+ /**
+ * Country bean
+ */
+ private CountrySingletonBeanRemote countryBean;
+
+ /**
+ * Logger instance
+ */
+ @Log
+ private LoggerBeanLocal loggerBeanLocal;
+
+ /**
+ * Initialization of this converter
+ */
+ public AddressbookCountryConverter () {
+ // Try to get it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Lookup logger
+ this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
+
+ // ... and country bean
+ this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jfinancials-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw it
+ throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+ }
+ }
+
+ @Override
+ public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2},this.countryBean={3} - CALLED!", context, component, submittedValue, this.countryBean)); //NOI18N
+
+ // Is the value null or empty?
+ if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+ // Warning message
+ this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
+
+ // Return null
+ return null;
+ }
+
+ // Get full list
+ List<Country> countryList = this.countryBean.allCountries();
+
+ // Init value
+ Country country = null;
+
+ // Try this better
+ try {
+ // Convert it to long
+ Long countryId = Long.parseLong(submittedValue);
+
+ // Category id should not be below 1
+ assert (countryId > 0) : "countryId is smaller than one: " + countryId; //NOI18N
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: countryId={0}", countryId)); //NOI18N
+
+ // Try to find it
+ for (final Country cntry : countryList) {
+ // Is the id the same? (null-safe)
+ if (Objects.equals(cntry.getCountryId(), countryId)) {
+ // Found it
+ country = cntry;
+ break;
+ }
+ }
+ } catch (final NumberFormatException ex) {
+ // Log exception (maybe to much?)
+ this.loggerBeanLocal.logException(ex);
+ }
+
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: country={0} - EXIT!", country)); //NOI18N
+
+ // Return it
+ return country;
+ }
+
+ @Override
+ public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
+ // Is the object null?
+ if ((null == value) || ((String.valueOf(value)).isEmpty())) {
+ // Is null
+ return ""; //NOI18N
+ } else if (!(value instanceof Country)) {
+ // Not same interface
+ throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement Country.", value)); //NOI18N
+ }
+
+ // Return category id
+ return String.valueOf(((Country) value).getCountryId());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.converter.mobile;
+
+import java.text.MessageFormat;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.FacesConverter;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
+import org.mxchange.jphone.phonenumbers.DialableNumber;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
+
+/**
+ * Converter for mobile id <-> valid mobile instance
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesConverter (value = "MobileConverter")
+public class FinancialsMobileConverter implements Converter {
+
+ /**
+ * Logger instance
+ */
+ @Log
+ private LoggerBeanLocal loggerBeanLocal;
+
+ /**
+ * Phone EJB
+ */
+ private PhoneSessionBeanRemote phoneBean;
+
+ /**
+ * Initialization of this converter
+ */
+ public FinancialsMobileConverter () {
+ // Try to get it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Lookup logger
+ this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
+
+ // ... and user controller
+ this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw it
+ throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+ }
+ }
+
+ @Override
+ public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
+
+ // Is the value null or empty?
+ if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+ // Warning message
+ this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
+
+ // Return null
+ return null;
+ }
+
+ // Init instance
+ DialableMobileNumber mobile = null;
+
+ try {
+ // Try to parse the value as long
+ Long mobileId = Long.valueOf(submittedValue);
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId)); //NOI18N
+
+ // Try to get mobile instance from it
+ mobile = this.phoneBean.findMobileNumberById(mobileId);
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: mobile={0}", mobile)); //NOI18N
+ } catch (final NumberFormatException ex) {
+ // Throw again
+ throw new ConverterException(ex);
+ } catch (final PhoneEntityNotFoundException ex) {
+ // Debug message
+ this.loggerBeanLocal.logDebug(MessageFormat.format("{0}.getAsObject(): Exception: {1} - Returning null ...", this.getClass().getSimpleName(), ex)); //NOI18N
+ }
+
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: mobile={0} - EXIT!", mobile)); //NOI18N
+
+ // Return it
+ return mobile;
+ }
+
+ @Override
+ public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
+ // Is the object null?
+ if ((null == value) || ((String.valueOf(value)).isEmpty())) {
+ // Is null
+ return ""; //NOI18N
+ } else if (!(value instanceof DialableNumber)) {
+ // Not same interface
+ throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N
+ }
+
+ // Return category id
+ return String.valueOf(((DialableNumber) value).getPhoneId());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.converter.mobileprovider;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Objects;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote;
+
+/**
+ * Converter for SMS provider instance
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesConverter (value = "MobileProviderConverter")
+public class FinancialsMobileProviderConverter implements Converter {
+
+ /**
+ * Logger instance
+ */
+ @Log
+ private LoggerBeanLocal loggerBeanLocal;
+
+ /**
+ * Mobile provider bean
+ */
+ private MobileProviderSingletonBeanRemote mobileRemoteBean;
+
+ /**
+ * Initialization of this converter
+ */
+ public FinancialsMobileProviderConverter () {
+ // Try to get it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Lookup logger
+ this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
+
+ /// and mobile provider controller
+ this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/jfinancials-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.MobileProvider.MobileProviderSingletonBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw it
+ throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+ }
+ }
+
+ @Override
+ public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
+
+ // Is the value null or empty?
+ if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+ // Warning message
+ this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
+
+ // Return null
+ return null;
+ }
+
+ // Get full list
+ List<MobileProvider> providerList = this.mobileRemoteBean.allMobileProvider();
+
+ // Init value
+ MobileProvider provider = null;
+
+ // Try this better
+ try {
+ // Convert it to long
+ Long providerId = Long.parseLong(submittedValue);
+
+ // Category id should not be below 1
+ assert (providerId > 0) : "providerId is smaller than one: " + providerId; //NOI18N
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: providerId={0}", providerId)); //NOI18N
+
+ // Try to find it
+ for (final MobileProvider prov : providerList) {
+ // Is the id the same? (null-safe)
+ if (Objects.equals(prov.getProviderId(), providerId)) {
+ // Found it
+ provider = prov;
+ break;
+ }
+ }
+ } catch (final NumberFormatException ex) {
+ // Log exception (maybe to much?)
+ this.loggerBeanLocal.logException(ex);
+ }
+
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: provider={0} - EXIT!", provider)); //NOI18N
+
+ // Return it
+ return provider;
+ }
+
+ @Override
+ public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
+ // Is the object null?
+ if ((null == value) || ((String.valueOf(value)).isEmpty())) {
+ // Is null
+ return ""; //NOI18N
+ } else if (!(value instanceof MobileProvider)) {
+ // Not same interface
+ throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement MobileProvider.", value)); //NOI18N
+ }
+
+ // Return category id
+ return String.valueOf(((MobileProvider) value).getProviderId());
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.converter.user;
+
+import java.text.MessageFormat;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.FacesConverter;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+
+/**
+ * Converter for user id <-> valid user instance
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesConverter (value = "UserConverter")
+public class FinancialsUserConverter implements Converter {
+
+ /**
+ * Logger instance
+ */
+ @Log
+ private LoggerBeanLocal loggerBeanLocal;
+
+ /**
+ * User EJB
+ */
+ private UserSessionBeanRemote userBean;
+
+ /**
+ * Initialization of this converter
+ */
+ public FinancialsUserConverter () {
+ // Try to get it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Lookup logger
+ this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
+
+ // ... and user controller
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw it
+ throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+ }
+ }
+
+ @Override
+ public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: context={0},component={1},submittedValue={2} - CALLED!", context, component, submittedValue)); //NOI18N
+
+ // Is the value null or empty?
+ if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+ // Warning message
+ this.loggerBeanLocal.logWarning(MessageFormat.format("{0}.getAsObject(): submittedValue is null or empty - EXIT!", this.getClass().getSimpleName())); //NOI18N
+
+ // Return null
+ return null;
+ }
+
+ // Init instance
+ User user = null;
+
+ try {
+ // Try to parse the value as long
+ Long userId = Long.valueOf(submittedValue);
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId)); //NOI18N
+
+ // Try to get user instance from it
+ user = this.userBean.findUserById(userId);
+
+ // Debug message
+ // NOISY-DEBUG: this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: user={0}", user)); //NOI18N
+ } catch (final NumberFormatException ex) {
+ // Throw again
+ throw new ConverterException(ex);
+ } catch (final UserNotFoundException ex) {
+ // Debug message
+ this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: Exception: {0} - Returning null ...", ex)); //NOI18N
+ }
+
+ // Trace message
+ // NOISY-DEBUG: this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: user={0} - EXIT!", user)); //NOI18N
+
+ // Return it
+ return user;
+ }
+
+ @Override
+ public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
+ // Is the object null?
+ if ((null == value) || ((String.valueOf(value)).isEmpty())) {
+ // Is null
+ return ""; //NOI18N
+ } else if (!(value instanceof User)) {
+ // Not same interface
+ throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement User.", value)); //NOI18N
+ }
+
+ // Return category id
+ return String.valueOf(((User) value).getUserId());
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.validator.birthday;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.FacesValidator;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcoreee.validator.date.BaseDateValidator;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+
+/**
+ * A birthday validator
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesValidator("BirthdayValidator")
+public class FinancialsBirthdayValidator extends BaseDateValidator implements Validator {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 28_735_756_819_460L;
+
+ /**
+ * Logger bean
+ */
+ @Log
+ private LoggerBeanLocal loggerBeanLocal;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsBirthdayValidator () {
+ // Try to get it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Lookup logger
+ this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw it
+ throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+ }
+ }
+
+ @Override
+ public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
+ // Trace message
+ this.loggerBeanLocal.logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
+
+ // All accepted, required fields
+ String[] requiredFields = {"birthday", "contactBirthday"}; //NOI18N
+
+ // Pre-validation (example: not null, not a string, empty string ...)
+ super.preValidate(context, component, value, requiredFields, false);
+
+ // Cast value
+ Date birthday = (Date) value;
+
+ // @TODO Finish this, e.g. load maximum,minimum birthday from properties file
+
+ // Trace message
+ this.loggerBeanLocal.logTrace("validate: EXIT!"); //NOI18N
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.validator.emailaddress;
+
+import java.text.MessageFormat;
+import java.util.regex.Pattern;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.FacesValidator;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.faces.view.facelets.FaceletException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
+import org.mxchange.jcoreee.validator.string.BaseStringValidator;
+
+/**
+ * A validator for email address validation
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesValidator ("EmailAddressValidator")
+public class FinancialsEmailAddressValidator extends BaseStringValidator implements Validator {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 187_536_745_607_192L;
+
+ /**
+ * Contact session bean
+ */
+ private final ContactSessionBeanRemote contactBean;
+
+ /**
+ * Default constructor
+ */
+ public FinancialsEmailAddressValidator () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
+
+ // The required field
+ String[] requiredFields = {"emailAddress", "emailAddressRepeat", "resendEmailAddress"}; //NOI18N
+
+ // Pre-validation (example: not null, not a string, empty string ...)
+ super.preValidate(context, component, value, requiredFields, false);
+
+ // Get string from object ... ;-)
+ // @TODO Add IDN support (GNU lib?) Search for emailAddressRepeat
+ String emailAddress = String.valueOf(value);
+
+ // Checks if the email address matches a regex ("low-level" check, should also be done by <f:validatorRegex />)
+ boolean matches = Pattern.matches("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$", emailAddress); //NOI18N
+
+ // Is the email address valid?
+ if (!matches) {
+ // Generate message
+ String message = MessageFormat.format("Email address {0} does not match regular expression.", emailAddress); //NOI18N
+
+ // Not matching
+ throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
+ }
+
+ // Get client id (aka form id)
+ String clientId = component.getClientId();
+
+ // Is the email address already registered?
+ if ((!clientId.endsWith("resendEmailAddress")) && (this.contactBean.isEmailAddressRegistered(emailAddress))) { //NOI18N
+ // Generate message
+ String message = MessageFormat.format("Email address {0} is already registered.", emailAddress); //NOI18N
+
+ // No, then abort here
+ throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
+ } else if ((clientId.endsWith("resendEmailAddress")) && (!this.contactBean.isEmailAddressRegistered(emailAddress))) { //NOI18N
+ // Generate message
+ String message = MessageFormat.format("Email address {0} is not registered.", emailAddress); //NOI18N
+
+ // No, then abort here
+ throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
+ }
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("validate: EXIT!"); //NOI18N
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * 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.validator.password;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.FacesValidator;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.inject.Inject;
+import org.mxchange.jcoreee.validator.string.BaseStringValidator;
+import org.mxchange.jusercore.container.login.LoginContainer;
+import org.mxchange.jusercore.container.login.UserLoginContainer;
+import org.mxchange.jusercore.model.user.UserUtils;
+import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController;
+
+/**
+ * A validator for validating passwords (if they match with stored)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesValidator (value = "UserPasswordValidator")
+public class FinancialsUserPasswordValidator extends BaseStringValidator implements Validator {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 48_581_795_687_317L;
+
+ /**
+ * User login controller
+ */
+ @Inject
+ private FinancialsUserLoginWebSessionController loginController;
+
+ @Override
+ public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
+
+ // The required field
+ String[] requiredFields = {"currentPassword"}; //NOI18N
+
+ // Pre-validation (example: not null, not a string, empty string ...)
+ super.preValidate(context, component, value, requiredFields, false);
+
+ // value is known to be an entered password, so instance login container
+ LoginContainer container = new UserLoginContainer(this.loginController.getLoggedInUser(), (String) value);
+
+ // Test it here
+ if (!UserUtils.ifPasswordMatches(container, this.loginController.getLoggedInUser())) {
+ // Password mismatches
+ throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password mismatching.", "The password the user has entered does not match the stored password.")); //NOI18N
+ }
+
+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("validate: EXIT!"); //NOI18N
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.validator.user;
+
+import java.text.MessageFormat;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.enterprise.event.Observes;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.FacesValidator;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcoreee.validator.number.BaseLongValidator;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+
+/**
+ * A validator for user ids
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@FacesValidator (value = "UserIdValidator")
+public class FinancialsUserIdValidator extends BaseLongValidator implements Validator {
+
+ /**
+ * Cached user status
+ */
+ private static final Set<Long> cachedStatus = new TreeSet<>();
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 12_869_569_314_764_690L;
+
+ /**
+ * Logger instance
+ */
+ @Log
+ private LoggerBeanLocal loggerBeanLocal;
+
+ /**
+ * Remote bean
+ */
+ private UserSessionBeanRemote userBean;
+
+ /**
+ * Initialization of this converter
+ */
+ public FinancialsUserIdValidator () {
+ // Try to get it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Lookup logger
+ this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
+
+ // ... and user controller
+ this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+ } catch (final NamingException ex) {
+ // Continue to throw it
+ throw new RuntimeException(MessageFormat.format("context.lookup() failed: {0}", ex.getMessage()), ex); //NOI18N
+ }
+ }
+
+ /**
+ * Event fired when the user registration is complete
+ * <p>
+ * @param event User registration event
+ */
+ public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
+ // Trace message
+ this.loggerBeanLocal.logTrace(MessageFormat.format("UserIdValidator:afterRegistrationEvent: event={0} - CALLED!", event)); //NOI18N
+
+ // event 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.user is null"); //NOI18N
+ } else if (event.getRegisteredUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.user.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
+ }
+
+ // Get user instance
+ User registeredUser = event.getRegisteredUser();
+
+ // Debug message
+ this.loggerBeanLocal.logDebug(MessageFormat.format("UserIdValidator:afterRegistrationEvent: registeredUser={0}", registeredUser)); //NOI18N
+
+ // Update cache
+ FinancialsUserIdValidator.cachedStatus.add(registeredUser.getUserId());
+
+ // Trace message
+ this.loggerBeanLocal.logTrace("UserIdValidator:afterRegistrationEvent: EXIT!"); //NOI18N
+ }
+
+ @Override
+ public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
+ // Trace message
+ this.loggerBeanLocal.logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N
+
+ // All accepted, required fields
+ String[] requiredFields = {"userId"}; //NOI18N
+
+ // Pre-validation (example: not null, not a string, empty string ...)
+ super.preValidate(context, component, value, requiredFields, false);
+
+ // Cast value
+ Long userId = (Long) value;
+
+ // Define variable
+ Boolean ifUserExists;
+
+ // Is a map entry there?
+ if (FinancialsUserIdValidator.cachedStatus.contains(userId)) {
+ // Get from cache
+ ifUserExists = Boolean.TRUE;
+ } else {
+ // Get status
+ ifUserExists = this.userBean.ifUserIdExists(userId);
+ }
+
+ // Is the user id valid?
+ if (!ifUserExists) {
+ // Is not valid
+ throw new ValidatorException(new FacesMessage(MessageFormat.format("No user found with id {0}. Please check your link.", userId))); //NOI18N
+ }
+
+ // Add to cache if valid
+ FinancialsUserIdValidator.cachedStatus.add(userId);
+
+ // Trace message
+ this.loggerBeanLocal.logTrace("validate: EXIT!"); //NOI18N
+ }
+
+}
COUNTRY_GERMANY=Deutschland
COUNTRY_PHILIPPINES=Philippinen
NONE_SELECTED=k.A.
-ADDRESSBOOK_ID=Id-Nummer:
-ADDRESSBOOK_ID_TITLE=Identifizierende, eindeutige Nummer
-ADDRESSBOOK_NAME=Addressbuchname:
-ADDRESSBOOK_NAME_TITLE=Name des Adressbuches
-ADDRESSBOOK_CREATED=Erstellt:
-ADDRESSBOOK_CREATED_TITLE=Wann das Adressbuch erstellt wurde.
-LINK_SHOW_ADDRESSBOOK_TITLE=Adressbuch anzeigen
-PAGE_TITLE_USER_SHOW_ADDRESSBOOK=Adressbuch anzeigen
-CONTENT_TITLE_USER_SHOW_ADDRESSBOOK=Anzeigen des ausgew\u00e4hlten Adressbuchs:
-ADDRESSBOOK_TOTAL_ENTRIES=Eintr\u00e4ge:
-PAGE_TITLE_USER_SHOW_ADDRESSBOOK_ENTRIES=Adressbucheintr\u00e4ge zeigen
-CONTENT_TITLE_USER_SHOW_ADDRESSBOOK_ENTRIES=Alle Adressbuchentr\u00e4ge anzeigen:
-ADDRESSBOOK_TOTAL_ENTRIES_TITLE=Eintr\u00e4ge im Adressbuch
-PARAMETER_ADDRESSBOOK_ID_MISSING=Bitte diese Seite mit Id-Nummer aufrufen.
-PARAMETER_ADDRESSBOOK_ID_INVALID=Id-Nummer f\u00fcr Adressbuch ung\u00fcltig. Bitte links weiter navigieren.
ENTERED_HOUSE_NUMBER_INVALID=Die eingegebene Hausnummer ist ung\u00fcltig.
ENTERED_ZIP_CODE_INVALID=Die eingegebene Postleitzahl ist ung\u00fcltig.
-PARAMETER_ADDRESSBOOK_ID_NOT_FOUND=Der angeklickte Link ist nicht mehr g\u00fcltig: Adressbuch mit der Id-Nummer nicht gefunden.
-LINK_LOGIN_SHARED_ADDRESS_BOOKS=Mit anderen geteilt
-LINK_LOGIN_SHARED_ADDRESS_BOOKS_TITLE=Mit anderen Benutzern geteilte Adressb\u00fccher
-PAGE_TITLE_LOGIN_SHARED_ADDRESSBOOKS=Mit anderen geteilte Adressb\u00fccher
-CONTENT_TITLE_LOGIN_SHARED_ADDRESSBOOKS=Meine mit anderen Benutzern geteilte Adressb\u00fccher:
-LINK_LOGIN_START_SHARING_ADDRESSBOOKS=Jetzt Ihre Adressb\u00fccher mit anderen Mitgliedern teilen!
-LOGIN_TABLE_HEADER_SHARED_ADDRESSBOOKS=Meine mit anderen Benutzern geteilte Adressb\u00fccher
-TABLE_SUMMARY_LOGIN_SHARED_ADDRESSBOOKS=Diese Tabelle listed alle von Ihnen mit anderen Benutzern geteilte Adressb\u00fccher auf.
-LOGIN_USER_HAS_NOT_SHARED_ADDRESSBOOKS=Derzeit teilen Sie keine Adressb\u00fccher mit anderen Benutzern.
TABLE_HEADER_USER_LIST=Alle Benutzer auflisten
TABLE_SUMMARY_USER_LIST=Diese Tabelle listet alle registrierten Benutzer aus, mit denen Sie Ihre Adressb\u00fccher teilen k\u00f6nnen.
USER_PROFILE_LEGEND=\u00d6ffentlich einsehbares Profil:
USER_NAME=Benutzername:
USER_CREATED=Beigetreten:
USER_CREATED_TITLE=Wann der Benutzer dieser Community beigetreten ist.
-USER_LIST_SHARING_ADDRESSBOOKS=Freigegebene Adressb\u00fccher:
-LINK_LOGIN_LIST_SHARING_ADDRESSBOOKS=Auflisten
-LINK_LOGIN_LIST_SHARING_ADDRESSBOOKS_TITLE=Listet alle mit dem Benutzer geteilte Adressb\u00fccher auf.
PAGE_TITLE_INDEX_USER_PROFILE=Benutzerprofil
CONTENT_TITLE_INDEX_USER_PROFILE=\u00d6ffentliches Profil des Benutzers:
-PAGE_TITLE_LOGIN_LIST_SHARING_ADDRESSBOOKS=Mit einem Benutzer geteilte Adressb\u00fccher
-CONTENT_TITLE_LOGIN_LIST_SHARING_ADDRESSBOOKS=Mit einem Benutzer geteilte Adressb\u00fccher auflisten:
PARAMETER_USER_ID_MISSING=Benutzernummer nicht angegeben.
PARAMETER_USER_ID_INVALID=Der angeklickte Link ist nicht mehr g\u00fcltig: Den Benutzer mit der Id-Nummer existiert nicht (mehr).
PARAMETER_USER_ID_NOT_FOUND=Benutzeraccount mit der Id-Nummer nicht gefunden.
TABLE_HEADER_ERROR_HANDLING_USER_ID=Fehler beim Verarbeiten der Benutzernummer:
-TABLE_HEADER_SHOW_ADDRESSBOOK=Adressbuchdaten:
-LINK_LOGIN_START_SHARING_ADDRESSBOOK=Mit jemandem dieses Adressbuch teilen
-LINK_LOGIN_START_SHARING_ADDRESSBOOK_TITLE=Dieses Adresssbuch k\u00f6nnen Sie mit einem anderen Benutzer teilen. Dadurch kann er Ihre Kontakte sehen.
-PAGE_TITLE_LOGIN_START_SHARING_ADDRESSBOOK=Das Adressbuch mit anderen Benutzern teilen
-CONTENT_TITLE_LOGIN_START_SHARING_ADDRESSBOOK=Teilen Sie dieses Adressbuch mit anderen Benutzern:
-LOGIN_START_SHARING_TITLE=Teilen
-LOGIN_START_SHARING_BUTTON=Mit diesem Benutzer teilen
-LOGIN_START_SHARING_BUTTON_TITLE=Teilen Sie Ihr ausgew\u00e4hltes Adressbuch mit diesem Benutzer.
-TABLE_HEADER_CHOOSE_USER_FOR_SHARING=W\u00e4hlen Sie einen Benutzer zum Teilen Ihres Adressbuches aus.
-LOGIN_START_SHARING_NOTICE1=Damit werden Ihr gesamtes Adressbuch fuer den ausgewaehlten Benutzer sichtbar.
-LOGIN_START_SHARING_NOTICE2=Sie k\u00f6nnen dies jederzeit wiederrufen.
LINK_USER_PROFILE=Zum Benutzerprofil
LINK_USER_PROFILE_TITLE=Das Benutzerprofil in einem neuen Fenster aufrufen.
-LINK_LOGIN_START_SHARING_ADDRESSBOOKS_TITLE=Teilen Sie Ihre Adressb\u00fccher mit anderen Benutzern. Sie k\u00f6nnen den Schritt jederzeit zur\u00fccknehmen.
-ADDRESSBOOK_STATUS_UNLOCKED=Freigegeben
-ADDRESSBOOK_STATUS_LOCKED=Gesperrt
-ADDRESSBOOK_STATUS_TITLE=Status des Adressbuches
-SHARED_ADDRESSBOOK=Adressbuch:
-SHAREE_USER_NAME=Geteilt mit:
-SHARE_CREATED=Wann gestartet:
-SHARE_CREATED_TITLE=Wann die Freigabe erfolgte
-SHARED_ADDRESSBOOK_TITLE=Welches Adressbuch freigegeben wurde
-SHAREE_USER_NAME_TITLE=Mit wem Sie Ihr Adressbuch teilen
-ADDRESSBOOK_OWNER=Besitzer:
-ADDRESSBOOK_STATUS=Status:
-PAGE_TITLE_INDEX_SHOW_ADDRESSBOOK=\u00d6ffentlicher Teil des Adressbuchs anzeigen
USER_PROFILE_NOT_PUBLICLY_VISIBLE=Das Benutzerprofil ist privat.
PAGE_TITLE_LOGIN_USER_PROFILE=Benutzerprofil ansehen
PUBLIC_USER_PROFILE=\u00d6ffentliches Benutzerprofil
USER_NOT_LOGGED_IN=Sie sind nicht angemeldet.
LOGIN_OWN_PROFILE_INVISIBLE=Ihr Profil ist auf "durchsichtig" gestellt.
ERROR_USER_INSTANCE_NOT_SET=Fehler: Benutzer-Instanz nicht gesetzt.
-LOGIN_ADDRESSBOOK_NOT_SET=Fehler: Adressbuch-Instanz nicht gesetzt.
LINK_GUEST_LOGIN_LOST_PASSWORD=Passwort vergessen?
LINK_TITLE_GUEST_LOGIN_LOST_PASSWORD=Passwort wiederherstellen
TABLE_HEADER_ERROR_USER_NOT_LOGGED_IN=Sie m\u00fcssen angemeldet sein
LOGIN_CHOOSE_PERSONAL_DATA_EMAIL_PASSWORD_NOTICE=Sie k\u00f6nnen hier Ihre pers\u00f6nlichen Daten, Ihre Email-Adresse und Ihr Passwort zum Einloggen \u00e4ndern.
LINK_LOGIN_CHANGE_PERSONAL_DATA=Pers\u00f6nliche Daten, wie Anschrift usw. \u00e4ndern
LINK_LOGIN_CHANGE_PERSONAL_DATA_TITLE=\u00c4ndern Sie hier Ihre pers\u00f6nlichen Daten, wie Anschrift, Telefonnummer und so weiter.
-LINK_LOGIN_CHANGE_EMAIL_ADDRESS=Ihre Email-Adresse \u00e4ndern
-LINK_LOGIN_CHANGE_EMAIL_ADDRESS_TITLE=\u00c4ndern Sie hier Ihre Email-Adresse. Dies ben\u00f6tigt eine weitere Best\u00e4tigung und kann jederzeit zur\u00fcckgaengig gemacht werden.
LINK_LOGIN_CHANGE_PASSWORD=Ihr Passwort \u00e4ndern
LINK_LOGIN_CHANGE_PASSWORD_TITLE=\u00c4ndern Sie hier Ihr Passwort, falls Sie ein anderes m\u00f6chten.
LOGIN_ENTER_CURRENT_PASSWORD_CONFIRMATION_LEGEND=Bitte derzeitiges Passwort zur Best\u00e4tigung eingeben:
LOGIN_MESSAGE_DATA_SAVED=Daten wurden gespeichert.
PAGE_TITLE_LOGIN_DATA_SAVED=Ihre Daten wurden gespeichert
CONTENT_TITLE_LOGIN_DATA_SAVED=Daten wurden gespeichert:
-LOGIN_CHANGE_EMAIL_ADDRESS_TITLE=\u00c4ndern Sie Ihre Email-Adresse:
LOGIN_CHANGE_EMAIL_LEGEND=Email-Adresse \u00e4ndern:
LOGIN_CHANGE_EMAIL_LEGEND_TITLE=Hier k\u00f6nnen Sie Ihre Email-Adresse \u00e4ndern. Dazu m\u00fcssen Sie diese zweimal eingeben und die neue Adresse best\u00e4tigen.
-LOGIN_CHANGE_EMAIL_OLD_ADDRESS=Ihre derzeitige Email-Adresse:
LOGIN_CHANGE_EMAIL_ENTER_EMAIL=Neue Email-Adresse eingeben:
LOGIN_CHANGE_EMAIL_ENTER_EMAIL_REPEAT=Neue Email-Adresse wiederholen:
BUTTON_CHANGE_EMAIL_ADDRESS=Email-Adresse \u00e4ndern
ADMIN_MENU_CONTACT_TITLE=Kontaktdaten
LINK_ADMIN_LIST_CONTACT=Kontaktdaten auflisten
LINK_ADMIN_LIST_CONTACT_TITLE=Listet alle Kontaktdaten auf, egal wo her sie angelegt wurden.
-ERROR_PARAMETER_CELLPHONE_NUMBER_CONTACT_NOT_SET=Fehler: Parameter 'cellphoneNumber' und 'contact' nicht gesetzt.
+ERROR_PARAMETER_CELLPHONE_NUMBER_CONTACT_NOT_SET=Fehler: Parameter 'mobileNumber' und 'contact' nicht gesetzt.
ADMIN_ADD_CONTACT_MINIMUM_DATA=Bitte geben Sie mindestens Anrede, Vorname und Nachname an.
ERROR_PARAMETER_CONTACT_NOT_SET=Fehler: Parameter 'contact' nicht gesetzt.
ADMIN_HEADER_SHOW_CONTACT=Kontaktdaten f\u00fcr {0}:
COUNTRY_GERMANY=Germany
COUNTRY_PHILIPPINES=Philippines
NONE_SELECTED=Empty
-ADDRESSBOOK_ID=Id number:
-ADDRESSBOOK_ID_TITLE=Identifying unique number
-ADDRESSBOOK_NAME=Address book name:
-ADDRESSBOOK_NAME_TITLE=Name of the address book
-ADDRESSBOOK_CREATED=Created:
-ADDRESSBOOK_CREATED_TITLE=When the address book was created.
-LINK_SHOW_ADDRESSBOOK_TITLE=Show address book
-PAGE_TITLE_USER_SHOW_ADDRESSBOOK=Show address book
-CONTENT_TITLE_USER_SHOW_ADDRESSBOOK=Show selected address book:
-ADDRESSBOOK_TOTAL_ENTRIES=Entries:
-PAGE_TITLE_USER_SHOW_ADDRESSBOOK_ENTRIES=Show address book entries
-CONTENT_TITLE_USER_SHOW_ADDRESSBOOK_ENTRIES=Show all address book entries:
-ADDRESSBOOK_TOTAL_ENTRIES_TITLE=Entries in address book
-PARAMETER_ADDRESSBOOK_ID_MISSING=Please call this web page with id number.
-PARAMETER_ADDRESSBOOK_ID_INVALID=Id number for address book invalid. Please continue navigating on left menu.
ENTERED_HOUSE_NUMBER_INVALID=The entered house number is invalid.
ENTERED_ZIP_CODE_INVALID=The entered ZIP code is invalid.
-PARAMETER_ADDRESSBOOK_ID_NOT_FOUND=The clicked link is no longer valid: Address book with entered id number does not exist (anymore).
-LINK_LOGIN_SHARED_ADDRESS_BOOKS=Shared with others
-LINK_LOGIN_SHARED_ADDRESS_BOOKS_TITLE=With other users shared address books
-PAGE_TITLE_LOGIN_SHARED_ADDRESSBOOKS=With others shared address books
-CONTENT_TITLE_LOGIN_SHARED_ADDRESSBOOKS=Mine with other users shared address books:
-LINK_LOGIN_START_SHARING_ADDRESSBOOKS=Start now sharing your address books with other users!
-LOGIN_TABLE_HEADER_SHARED_ADDRESSBOOKS=My with other users shared address books
-TABLE_SUMMARY_LOGIN_SHARED_ADDRESSBOOKS=This table lists all your with other users shared address books.
-LOGIN_USER_HAS_NOT_SHARED_ADDRESSBOOKS=Currently you don't share any address books with other users.
TABLE_HEADER_USER_LIST=List all users
TABLE_SUMMARY_USER_LIST=This table lists all registered users you can share your address books with.
USER_PROFILE_LEGEND=Publicly visible profile:
USER_NAME=User name:
USER_CREATED=Joined:
USER_CREATED_TITLE=When the user has joined this community.
-USER_LIST_SHARING_ADDRESSBOOKS=Shared address books:
-LINK_LOGIN_LIST_SHARING_ADDRESSBOOKS=List
-LINK_LOGIN_LIST_SHARING_ADDRESSBOOKS_TITLE=Lists all with this user shared address books.
PAGE_TITLE_INDEX_USER_PROFILE=User profile
CONTENT_TITLE_INDEX_USER_PROFILE=Public profile of the user:
-PAGE_TITLE_LOGIN_LIST_SHARING_ADDRESSBOOKS=With a user shared address books
-CONTENT_TITLE_LOGIN_LIST_SHARING_ADDRESSBOOKS=List with a user shared address books:
PARAMETER_USER_ID_MISSING=No user id number provided
PARAMETER_USER_ID_INVALID=The clicked link is no longer valid: The user with provided id number does not exist (anymore).
PARAMETER_USER_ID_NOT_FOUND=User account with given id number not found.
TABLE_HEADER_ERROR_HANDLING_USER_ID=Error while handling user id:
-TABLE_HEADER_SHOW_ADDRESSBOOK=Address book data:
-LINK_LOGIN_START_SHARING_ADDRESSBOOK=Start sharing this address book with another user
-LINK_LOGIN_START_SHARING_ADDRESSBOOK_TITLE=You can start sharing this address book with anther user. Then he cann see your contacts.
-PAGE_TITLE_LOGIN_START_SHARING_ADDRESSBOOK=Share the address book with other users
-CONTENT_TITLE_LOGIN_START_SHARING_ADDRESSBOOK=Start sharing this address book with other users:
-LOGIN_START_SHARING_TITLE=Share
-LOGIN_START_SHARING_BUTTON=Share with this user
-LOGIN_START_SHARING_BUTTON_TITLE=Share your choosen address book with this user.
-TABLE_HEADER_CHOOSE_USER_FOR_SHARING=Choose a user for sharing your address book with.
-LOGIN_START_SHARING_NOTICE1=With this your whole address book becomes visible to the other user.
-LOGIN_START_SHARING_NOTICE2=You can always revoke your choice.
LINK_USER_PROFILE=To user profile
LINK_USER_PROFILE_TITLE=Open the user profile in a new window.
-LINK_LOGIN_START_SHARING_ADDRESSBOOKS_TITLE=Start sharing your address books with other users. You can always revoke your decission.
-ADDRESSBOOK_STATUS_UNLOCKED=Unlocked
-ADDRESSBOOK_STATUS_LOCKED=Locked
-ADDRESSBOOK_STATUS_TITLE=Status of the address book
-SHARED_ADDRESSBOOK=Address book:
-SHAREE_USER_NAME=Shared with:
-SHARE_CREATED=Started:
-SHARE_CREATED_TITLE=When the sharing has started.
-SHARED_ADDRESSBOOK_TITLE=Which address book is being shared
-SHAREE_USER_NAME_TITLE=With who you shared your address book
-ADDRESSBOOK_OWNER=Owner:
-ADDRESSBOOK_STATUS=Status:
-PAGE_TITLE_INDEX_SHOW_ADDRESSBOOK=Show public part of address book
USER_PROFILE_NOT_PUBLICLY_VISIBLE=The user profile is private.
PAGE_TITLE_LOGIN_USER_PROFILE=View user profile
PUBLIC_USER_PROFILE=Public user profile
LOGIN_NO_USER_NAME_MESSAGE=You have entered no user name.
USER_NOT_LOGGED_IN=You are not signed in.
LOGIN_OWN_PROFILE_INVISIBLE=Your profile is set to "invisible".
-LOGIN_ADDRESSBOOK_NOT_SET=Error: Address book instance not set.
LINK_GUEST_LOGIN_LOST_PASSWORD=Forgot your password?
LINK_TITLE_GUEST_LOGIN_LOST_PASSWORD=Restore your password
TABLE_HEADER_ERROR_USER_NOT_LOGGED_IN=You need to be logged-in
ADMIN_LINK_DELETE_SHORT_TITLE=Delete entry.
ADMIN_LINK_UNLINK_SHORT=Unlink
ADMIN_LINK_UNLINK_SHORT_TITLE=Removes link to entry.
-PAGE_TITLE_ADMIN_DELETE_CELLPHONE=Delete contact's cellphone entry
-CONTENT_TITLE_ADMIN_DELETE_CELLPHONE=Delete contact's cellphone entry:
-PAGE_TITLE_ADMIN_EDIT_CELLPHONE=Edit contact's cellphone entry
-CONTENT_TITLE_ADMIN_EDIT_CELLPHONE=Edit contact's cellphone entry:
-PAGE_TITLE_ADMIN_LIST_CONTACT_CELLPHONE=List all cellphone entries
-PAGE_TITLE_ADMIN_SHOW_CELLPHONE=Show contact's cellphone entry
-CONTENT_TITLE_ADMIN_SHOW_CELLPHONE=Show contact's cellphone entry:
-PAGE_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE=Remove link contact-cellphone
-CONTENT_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE=Remove link between contact-cellphone:
+PAGE_TITLE_ADMIN_DELETE_CELLPHONE=Delete contact's mobile entry
+CONTENT_TITLE_ADMIN_DELETE_CELLPHONE=Delete contact's mobile entry:
+PAGE_TITLE_ADMIN_EDIT_CELLPHONE=Edit contact's mobile entry
+CONTENT_TITLE_ADMIN_EDIT_CELLPHONE=Edit contact's mobile entry:
+PAGE_TITLE_ADMIN_LIST_CONTACT_CELLPHONE=List all mobile entries
+PAGE_TITLE_ADMIN_SHOW_CELLPHONE=Show contact's mobile entry
+CONTENT_TITLE_ADMIN_SHOW_CELLPHONE=Show contact's mobile entry:
+PAGE_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE=Remove link contact-mobile
+CONTENT_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE=Remove link between contact-mobile:
ERROR_PARAMETER_PHONE_ID_NOT_SET=Error: Parameter 'phoneId' is not set.
PAGE_TITLE_ADMIN_SHOW_MOBILE_PROVIDER=Show mobile provider
CONTENT_TITLE_ADMIN_SHOW_MOBILE_PROVIDER=Show mobile provider:
-TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE=A single contact's cellphone entry.
-TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE_LINKS=This table shows links of of this cellphone number to all contacts.
-ADMIN_HEADER_SHOW_CELLPHONE_LINKS=All links between contact-cellphone for id {0}:
+TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE=A single contact's mobile entry.
+TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE_LINKS=This table shows links of of this mobile number to all contacts.
+ADMIN_HEADER_SHOW_CELLPHONE_LINKS=All links between contact-mobile for id {0}:
ERROR_PARAMETER_CONTACT_ID_NOT_SET=Error: Parameter 'contactId' is not set.
ADMIN_SHOW_CELLPHONE_UNLINK=Unlink:
ADMIN_CONTACT_ID=Contact id:
ADMIN_MENU_CONTACT_TITLE=Manage contact data
LINK_ADMIN_LIST_CONTACT=List contact data
LINK_ADMIN_LIST_CONTACT_TITLE=Lists all contact data regardless where they was created.
-ERROR_PARAMETER_CELLPHONE_NUMBER_CONTACT_NOT_SET=Error: Parameter 'cellphoneNumber' and 'contact' are not set.
+ERROR_PARAMETER_CELLPHONE_NUMBER_CONTACT_NOT_SET=Error: Parameter 'mobileNumber' and 'contact' are not set.
ADMIN_ADD_CONTACT_MINIMUM_DATA=Please enter at least salutation, first name and family name.
ERROR_PARAMETER_CONTACT_NOT_SET=Error: Parameter 'contact' is not set.
ADMIN_HEADER_SHOW_CONTACT=Contact data for {0}:
<to-view-id>/admin/mobile_provider/admin_mobile_provider_list.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_list_contact_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_list.xhtml</to-view-id>
+ <from-outcome>admin_list_contact_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_list.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<to-view-id>/admin/mobile_provider/admin_mobile_provider_show.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_show_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_cellphone_show.xhtml</to-view-id>
+ <from-outcome>admin_show_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_mobile_show.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_edit_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_cellphone_edit.xhtml</to-view-id>
+ <from-outcome>admin_edit_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_mobile_edit.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_unlink_contact_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_unlink.xhtml</to-view-id>
+ <from-outcome>admin_unlink_contact_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_unlink.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_delete_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_cellphone_delete.xhtml</to-view-id>
+ <from-outcome>admin_delete_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_mobile_delete.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>admin_edit_user</from-outcome>
<to-view-id>/admin/mobile_provider/admin_mobile_provider_show.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_edit_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_edit.xhtml</to-view-id>
+ <from-outcome>admin_edit_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_edit.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_delete_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_delete.xhtml</to-view-id>
+ <from-outcome>admin_delete_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_delete.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_unlink_contact_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_unlink.xhtml</to-view-id>
+ <from-outcome>admin_unlink_contact_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_unlink.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_show_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_show.xhtml</to-view-id>
+ <from-outcome>admin_show_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_show.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
- <from-view-id>/admin/cellphone/admin_contact_cellphone_list.xhtml</from-view-id>
+ <from-view-id>/admin/mobile/admin_contact_mobile_list.xhtml</from-view-id>
<navigation-case>
- <from-outcome>admin_show_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_show.xhtml</to-view-id>
+ <from-outcome>admin_show_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_show.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_edit_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_edit.xhtml</to-view-id>
+ <from-outcome>admin_edit_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_edit.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_delete_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_delete.xhtml</to-view-id>
+ <from-outcome>admin_delete_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_delete.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
- <from-view-id>/admin/cellphone/admin_contact_cellphone_show.xhtml</from-view-id>
+ <from-view-id>/admin/mobile/admin_contact_mobile_show.xhtml</from-view-id>
<navigation-case>
<from-outcome>admin_show_mobile_provider</from-outcome>
<to-view-id>/admin/mobile_provider/admin_mobile_provider_show.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_edit_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_edit.xhtml</to-view-id>
+ <from-outcome>admin_edit_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_edit.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_delete_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_delete.xhtml</to-view-id>
+ <from-outcome>admin_delete_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_delete.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>admin_unlink_contact_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_unlink.xhtml</to-view-id>
+ <from-outcome>admin_unlink_contact_mobile</from-outcome>
+ <to-view-id>/admin/mobile/admin_contact_mobile_unlink.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>admin_show_contact</from-outcome>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
- <h:outputText styleClass="errors" value="#{msg.ERROR_BEAN_HELPER_CONTACT_NOT_SET}" rendered="#{empty beanHelper.contact}" />
-
- <ui:fragment rendered="#{empty beanHelper.contact.contactCellphoneNumber and not empty beanHelper.contact}">
- <ui:include src="/WEB-INF/templates/admin/cellphone/admin_form_contact_cellphone.tpl" />
- </ui:fragment>
-
- <ui:fragment rendered="#{not empty beanHelper.contact.contactCellphoneNumber and not empty beanHelper.contact}">
- <ui:include src="/WEB-INF/templates/admin/cellphone/admin_cellphone_data.tpl" />
- </ui:fragment>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
- <h:outputText styleClass="errors" value="#{msg.ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET}" rendered="#{empty adminPhoneController.cellPhone}" />
-
- <h:panelGrid id="cellphone_data" summary="#{msg.ADMIN_TABLE_SUMMARY_SHOW_CELLPHONE_DATA}" headerClass="table_header_column" styleClass="table_big" columns="2" rendered="#{not empty adminPhoneController.cellPhone}">
- <f:facet name="header">
- <h:outputText value="#{msg.ADMIN_HEADER_SHOW_CELLPHONE_DATA}" />
- </f:facet>
-
- <h:column>
- <h:outputLabel for="cellphoneId" styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_ID}" />
-
- <h:outputText id="cellphoneId" styleClass="data_field" value="#{adminPhoneController.cellPhone.phoneId}" />
- </h:column>
-
- <h:column>
- <h:outputLabel for="cellphoneProvider" styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_PROVIDER_NAME}" />
-
- <h:link outcome="admin_show_mobile_provider">
- <f:param name="providerId" value="#{adminPhoneController.cellPhone.cellphoneProvider.providerId}" />
- <h:outputText id="cellphoneProvider" styleClass="data_field" value="#{adminPhoneController.cellPhone.cellphoneProvider.providerName}" />
- </h:link>
- </h:column>
-
- <h:column>
- <h:outputLabel for="cellphoneNumber" styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_NUMBER_COMPLETE}" />
-
- <h:outputText id="cellphoneNumber" styleClass="data_field" value="#{adminPhoneController.cellPhone.cellphoneProvider.providerCountry.countryExternalDialPrefix}#{adminPhoneController.cellPhone.cellphoneProvider.providerDialPrefix}-#{adminPhoneController.cellPhone.phoneNumber}" />
- </h:column>
-
- <h:column>
- <h:outputLabel styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_LINKS}" />
-
- <div class="data_field">
- <ui:include src="/WEB-INF/templates/admin/cellphone/admin_cellphone_links.tpl">
- <ui:param name="isShowPage" value="#{isShowPage}" />
- </ui:include>
- </div>
- </h:column>
- </h:panelGrid>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
- <h:outputText styleClass="errors" value="#{msg.ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET}" rendered="#{empty adminPhoneController.cellPhone}" />
-
- <ui:fragment rendered="#{not empty adminPhoneController.cellPhone}">
- <ul class="mini_nav">
- <ui:fragment rendered="#{empty isShowPage or not isShowPage}">
- <li class="mini_link">
- <h:link outcome="admin_show_cellphone">
- <h:outputText value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_SHORT_TITLE}" />
- <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
- </h:link>
- </li>
- </ui:fragment>
-
- <li class="mini_link">
- <h:link outcome="admin_edit_cellphone">
- <h:outputText value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_SHORT_TITLE}" />
- <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
- </h:link>
- </li>
-
- <ui:fragment rendered="#{not empty beanHelper.contact}">
- <li class="mini_link">
- <h:link outcome="admin_unlink_contact_cellphone">
- <h:outputText styleClass="unlink_link" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_SHORT_TITLE}" />
- <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
- <f:param name="contactId" value="#{beanHelper.contact.contactId}" />
- </h:link>
- </li>
- </ui:fragment>
-
- <li class="mini_link">
- <h:link outcome="admin_delete_cellphone">
- <h:outputText styleClass="delete_link" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_SHORT_TITLE}" />
- <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
- </h:link>
- </li>
- </ul>
- </ui:fragment>
-</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<ui:composition
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
-
- <h:outputText styleClass="errors" value="#{msg.ERROR_BEAN_HELPER_CONTACT_NOT_SET}" rendered="#{empty beanHelper.contact}" />
-
- <h:form id="form_add_contact_cellphone">
- </h:form>
-</ui:composition>
<div class="table_row">
<div class="table_left_medium">
- <h:outputLabel for="cellphoneNumber" value="#{msg.ADMIN_PERSONAL_DATA_CELLPHONE_NUMBER}" />
+ <h:outputLabel for="mobileNumber" value="#{msg.ADMIN_PERSONAL_DATA_CELLPHONE_NUMBER}" />
</div>
<div class="table_right_medium">
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+
+ <h:outputText styleClass="errors" value="#{msg.ERROR_BEAN_HELPER_CONTACT_NOT_SET}" rendered="#{empty beanHelper.contact}" />
+
+ <h:form id="form_add_contact_mobile">
+ </h:form>
+</ui:composition>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+
+ <h:outputText styleClass="errors" value="#{msg.ERROR_BEAN_HELPER_CONTACT_NOT_SET}" rendered="#{empty beanHelper.contact}" />
+
+ <ui:fragment rendered="#{empty beanHelper.contact.contactCellphoneNumber and not empty beanHelper.contact}">
+ <ui:include src="/WEB-INF/templates/admin/mobile/admin_form_contact_mobile.tpl" />
+ </ui:fragment>
+
+ <ui:fragment rendered="#{not empty beanHelper.contact.contactCellphoneNumber and not empty beanHelper.contact}">
+ <ui:include src="/WEB-INF/templates/admin/mobile/admin_mobile_data.tpl" />
+ </ui:fragment>
+</ui:composition>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+
+ <h:outputText styleClass="errors" value="#{msg.ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET}" rendered="#{empty adminPhoneController.cellPhone}" />
+
+ <h:panelGrid id="mobile_data" summary="#{msg.ADMIN_TABLE_SUMMARY_SHOW_CELLPHONE_DATA}" headerClass="table_header_column" styleClass="table_big" columns="2" rendered="#{not empty adminPhoneController.cellPhone}">
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_HEADER_SHOW_CELLPHONE_DATA}" />
+ </f:facet>
+
+ <h:column>
+ <h:outputLabel for="mobileId" styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_ID}" />
+
+ <h:outputText id="mobileId" styleClass="data_field" value="#{adminPhoneController.cellPhone.phoneId}" />
+ </h:column>
+
+ <h:column>
+ <h:outputLabel for="mobileProvider" styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_PROVIDER_NAME}" />
+
+ <h:link outcome="admin_show_mobile_provider">
+ <f:param name="providerId" value="#{adminPhoneController.cellPhone.mobileProvider.providerId}" />
+ <h:outputText id="mobileProvider" styleClass="data_field" value="#{adminPhoneController.cellPhone.mobileProvider.providerName}" />
+ </h:link>
+ </h:column>
+
+ <h:column>
+ <h:outputLabel for="mobileNumber" styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_NUMBER_COMPLETE}" />
+
+ <h:outputText id="mobileNumber" styleClass="data_field" value="#{adminPhoneController.cellPhone.mobileProvider.providerCountry.countryExternalDialPrefix}#{adminPhoneController.cellPhone.mobileProvider.providerDialPrefix}-#{adminPhoneController.cellPhone.phoneNumber}" />
+ </h:column>
+
+ <h:column>
+ <h:outputLabel styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_LINKS}" />
+
+ <div class="data_field">
+ <ui:include src="/WEB-INF/templates/admin/mobile/admin_mobile_links.tpl">
+ <ui:param name="isShowPage" value="#{isShowPage}" />
+ </ui:include>
+ </div>
+ </h:column>
+ </h:panelGrid>
+</ui:composition>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+
+ <h:outputText styleClass="errors" value="#{msg.ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET}" rendered="#{empty adminPhoneController.cellPhone}" />
+
+ <ui:fragment rendered="#{not empty adminPhoneController.cellPhone}">
+ <ul class="mini_nav">
+ <ui:fragment rendered="#{empty isShowPage or not isShowPage}">
+ <li class="mini_link">
+ <h:link outcome="admin_show_mobile">
+ <h:outputText value="#{msg.ADMIN_LINK_SHOW_SHORT}" title="#{msg.ADMIN_LINK_SHOW_SHORT_TITLE}" />
+ <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
+ </h:link>
+ </li>
+ </ui:fragment>
+
+ <li class="mini_link">
+ <h:link outcome="admin_edit_mobile">
+ <h:outputText value="#{msg.ADMIN_LINK_EDIT_SHORT}" title="#{msg.ADMIN_LINK_EDIT_SHORT_TITLE}" />
+ <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
+ </h:link>
+ </li>
+
+ <ui:fragment rendered="#{not empty beanHelper.contact}">
+ <li class="mini_link">
+ <h:link outcome="admin_unlink_contact_mobile">
+ <h:outputText styleClass="unlink_link" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_SHORT_TITLE}" />
+ <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
+ <f:param name="contactId" value="#{beanHelper.contact.contactId}" />
+ </h:link>
+ </li>
+ </ui:fragment>
+
+ <li class="mini_link">
+ <h:link outcome="admin_delete_mobile">
+ <h:outputText styleClass="delete_link" value="#{msg.ADMIN_LINK_DELETE_SHORT}" title="#{msg.ADMIN_LINK_DELETE_SHORT_TITLE}" />
+ <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
+ </h:link>
+ </li>
+ </ul>
+ </ui:fragment>
+</ui:composition>
<div class="table_row">
<div class="table_left">
- <h:outputLabel for="cellphoneNumber" value="#{msg.PERSONAL_DATA_CELLPHONE_NUMBER}" />
+ <h:outputLabel for="mobileNumber" value="#{msg.PERSONAL_DATA_CELLPHONE_NUMBER}" />
</div>
<div class="table_right">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:fragment rendered="#{not empty targetController}">
- <h:selectOneMenu styleClass="select" id="cellphoneCarrier" value="#{targetController.cellphoneCarrier}">
+ <h:selectOneMenu styleClass="select" id="mobileCarrier" value="#{targetController.mobileCarrier}">
<f:converter converterId="MobileProviderConverter" />
<f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
<f:selectItems value="#{mobileProviderController.allMobileProvider()}" var="mobileProvider" itemValue="#{mobileProvider}" itemLabel="#{mobileProvider.providerCountry.countryExternalDialPrefix}#{mobileProvider.providerDialPrefix} (#{mobileProvider.providerName})" />
</h:selectOneMenu>
- <h:inputText styleClass="input" id="cellphoneNumber" size="10" maxlength="20" value="#{targetController.cellphoneNumber}">
- <f:validator for="cellphoneNumber" validatorId="PhoneNumberValidator" />
+ <h:inputText styleClass="input" id="mobileNumber" size="10" maxlength="20" value="#{targetController.mobileNumber}">
+ <f:validator for="mobileNumber" validatorId="PhoneNumberValidator" />
</h:inputText>
</ui:fragment>
</ul>
</ui:fragment>
- <div class="menu_header">
- <h:outputText value="#{msg.MENU_ADDRESSBOOKS_TITLE}" />
- </div>
-
- <ul>
- <li>
- <h:link title="#{msg.LINK_LOGIN_OWN_ADDRESSBOOKS_TITLE}" outcome="login_own_addressbooks" value="#{msg.LINK_LOGIN_OWN_ADDRESSBOOKS}" />
- </li>
-
- <li>
- <h:link title="#{msg.LINK_LOGIN_OTHER_ADDRESSBOOKS_TITLE}" outcome="login_other_addressbooks" value="#{msg.LINK_LOGIN_OTHER_ADDRESSBOOKS}" />
- </li>
-
- <li>
- <h:link title="#{msg.LINK_LOGIN_SHARED_ADDRESS_BOOKS_TITLE}" outcome="login_shared_addressbooks" value="#{msg.LINK_LOGIN_SHARED_ADDRESS_BOOKS}" />
- </li>
- </ul>
-
<div class="menu_header">
<h:outputText value="#{msg.MENU_LOGOUT_TITLE}" />
</div>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <f:metadata>
- <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
- </f:metadata>
-
- <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
- <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_DELETE_CELLPHONE}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_ADMIN_DELETE_CELLPHONE}
- </ui:define>
-
- <ui:define name="content">
- Here goes your content.
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <f:metadata>
- <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
- </f:metadata>
-
- <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
- <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_EDIT_CELLPHONE}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_ADMIN_EDIT_CELLPHONE}
- </ui:define>
-
- <ui:define name="content">
- Here goes your content.
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <f:metadata>
- <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
- </f:metadata>
-
- <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
- <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_SHOW_CELLPHONE}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_ADMIN_SHOW_CELLPHONE}
- </ui:define>
-
- <ui:define name="content">
- <ui:include src="/WEB-INF/templates/admin/cellphone/admin_cellphone_data.tpl">
- <ui:param name="isShowPage" value="#{true}" />
- </ui:include>
-
- <h:dataTable id="contact_cellphone_link" var="contact" value="#{contactPhoneController.allMobileContacts()}" summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE_LINKS}" headerClass="table_header_column" styleClass="table_medium">
- <f:facet name="header">
- <h:outputFormat value="#{msg.ADMIN_HEADER_SHOW_CELLPHONE_LINKS}">
- <f:param value="#{adminPhoneController.cellPhone.phoneId}" />
- </h:outputFormat>
- </f:facet>
-
- <h:column>
- <h:outputLabel for="contactId" styleClass="data_label" value="#{msg.ADMIN_CONTACT_ID}" />
-
- <h:link id="contactId" styleClass="data_field" outcome="admin_show_contact">
- <h:outputText value="#{contact.contactId}" />
- <f:param name="contactId" value="#{contact.contactId}" />
- </h:link>
- </h:column>
-
- <h:column>
- <h:outputLabel for="contactGender" styleClass="data_label" value="#{msg.ADMIN_CONTACT_GENDER}" />
-
- <h:outputText id="contactGender" styleClass="data_field" value="#{msg[contact.contactGender.messageKey]}" />
- </h:column>
-
- <h:column>
- <h:outputLabel for="contactTitle" styleClass="data_label" value="#{msg.ADMIN_CONTACT_TITLE}" />
-
- <h:outputText id="contactTitle" styleClass="data_field" value="#{contact.contactTitle}" />
- </h:column>
-
- <h:column>
- <h:outputLabel for="contactFirstName" styleClass="data_label" value="#{msg.ADMIN_CONTACT_FIRST_NAME}" />
-
- <h:outputText id="contactFirstName" styleClass="data_field" value="#{contact.contactFirstName}" />
- </h:column>
-
- <h:column>
- <h:outputLabel for="contactFamilyName" styleClass="data_label" value="#{msg.ADMIN_CONTACT_FAMILY_NAME}" />
-
- <h:outputText id="contactFamilyName" styleClass="data_field" value="#{contact.contactFamilyName}" />
- </h:column>
-
- <h:column>
- <h:outputLabel for="contactEmailAddress" styleClass="data_label" value="#{msg.ADMIN_CONTACT_EMAIL_ADDRESS}" />
-
- <h:outputLink id="contactEmailAddress" styleClass="data_field" value="mailto:#{contact.contactEmailAddress}">
- <h:outputText value="#{contact.contactEmailAddress}" />
- </h:outputLink>
- </h:column>
-
- <h:column>
- <h:outputLabel styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_UNLINK}" />
-
- <div class="data_field">
- <ul class="mini_nav">
- <li class="mini_link">
- <h:link outcome="admin_unlink_contact_cellphone">
- <h:outputText styleClass="unlink_link" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_SHORT_TITLE}" />
- <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
- <f:param name="contactId" value="#{contact.contactId}" />
- </h:link>
- </li>
- </ul>
- </div>
- </h:column>
- </h:dataTable>
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
- <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_LIST_CONTACT_CELLPHONE}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_ADMIN_LIST_CONTACT_CELLPHONE}
- </ui:define>
-
- <ui:define name="content">
- <h:dataTable id="table_list_cellphones" var="cellphone" value="#{phoneController.allCellphones()}" styleClass="table_big" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_CELLPHONES}" rendered="#{not phoneController.allCellphones().isEmpty()}">
- <h:column>
- <f:facet name="header">
- <h:outputText value="#{msg.ADMIN_SHOW_CELLPHONE_ID}" />
- </f:facet>
- </h:column>
- </h:dataTable>
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <f:metadata>
- <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
- <f:viewParam name="contactId" value="#{beanHelper.contact}" converter="ContactConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_CONTACT_ID_NOT_SET}" />
- </f:metadata>
-
- <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
- <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE}
- </ui:define>
-
- <ui:define name="content">
- Here goes your content.
- </ui:define>
- </ui:composition>
-</html>
</div>
<div>
- <ui:include src="/WEB-INF/templates/admin/cellphone/admin_cellphone_add_show.tpl" />
+ <ui:include src="/WEB-INF/templates/admin/mobile/admin_mobile_add_show.tpl" />
</div>
</ui:define>
</ui:composition>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
+ lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ >
+
+ <f:metadata>
+ <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
+ </f:metadata>
+
+ <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+ <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_DELETE_CELLPHONE}</ui:define>
+
+ <ui:define name="content_header">
+ #{msg.CONTENT_TITLE_ADMIN_DELETE_CELLPHONE}
+ </ui:define>
+
+ <ui:define name="content">
+ Here goes your content.
+ </ui:define>
+ </ui:composition>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
+ lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ >
+
+ <f:metadata>
+ <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
+ </f:metadata>
+
+ <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+ <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_EDIT_CELLPHONE}</ui:define>
+
+ <ui:define name="content_header">
+ #{msg.CONTENT_TITLE_ADMIN_EDIT_CELLPHONE}
+ </ui:define>
+
+ <ui:define name="content">
+ Here goes your content.
+ </ui:define>
+ </ui:composition>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
+ lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ >
+
+ <f:metadata>
+ <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
+ </f:metadata>
+
+ <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+ <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_SHOW_CELLPHONE}</ui:define>
+
+ <ui:define name="content_header">
+ #{msg.CONTENT_TITLE_ADMIN_SHOW_CELLPHONE}
+ </ui:define>
+
+ <ui:define name="content">
+ <ui:include src="/WEB-INF/templates/admin/mobile/admin_mobile_data.tpl">
+ <ui:param name="isShowPage" value="#{true}" />
+ </ui:include>
+
+ <h:dataTable id="contact_mobile_link" var="contact" value="#{contactPhoneController.allMobileContacts()}" summary="#{msg.TABLE_SUMMARY_ADMIN_SHOW_CELLPHONE_LINKS}" headerClass="table_header_column" styleClass="table_medium">
+ <f:facet name="header">
+ <h:outputFormat value="#{msg.ADMIN_HEADER_SHOW_CELLPHONE_LINKS}">
+ <f:param value="#{adminPhoneController.cellPhone.phoneId}" />
+ </h:outputFormat>
+ </f:facet>
+
+ <h:column>
+ <h:outputLabel for="contactId" styleClass="data_label" value="#{msg.ADMIN_CONTACT_ID}" />
+
+ <h:link id="contactId" styleClass="data_field" outcome="admin_show_contact">
+ <h:outputText value="#{contact.contactId}" />
+ <f:param name="contactId" value="#{contact.contactId}" />
+ </h:link>
+ </h:column>
+
+ <h:column>
+ <h:outputLabel for="contactGender" styleClass="data_label" value="#{msg.ADMIN_CONTACT_GENDER}" />
+
+ <h:outputText id="contactGender" styleClass="data_field" value="#{msg[contact.contactGender.messageKey]}" />
+ </h:column>
+
+ <h:column>
+ <h:outputLabel for="contactTitle" styleClass="data_label" value="#{msg.ADMIN_CONTACT_TITLE}" />
+
+ <h:outputText id="contactTitle" styleClass="data_field" value="#{contact.contactTitle}" />
+ </h:column>
+
+ <h:column>
+ <h:outputLabel for="contactFirstName" styleClass="data_label" value="#{msg.ADMIN_CONTACT_FIRST_NAME}" />
+
+ <h:outputText id="contactFirstName" styleClass="data_field" value="#{contact.contactFirstName}" />
+ </h:column>
+
+ <h:column>
+ <h:outputLabel for="contactFamilyName" styleClass="data_label" value="#{msg.ADMIN_CONTACT_FAMILY_NAME}" />
+
+ <h:outputText id="contactFamilyName" styleClass="data_field" value="#{contact.contactFamilyName}" />
+ </h:column>
+
+ <h:column>
+ <h:outputLabel for="contactEmailAddress" styleClass="data_label" value="#{msg.ADMIN_CONTACT_EMAIL_ADDRESS}" />
+
+ <h:outputLink id="contactEmailAddress" styleClass="data_field" value="mailto:#{contact.contactEmailAddress}">
+ <h:outputText value="#{contact.contactEmailAddress}" />
+ </h:outputLink>
+ </h:column>
+
+ <h:column>
+ <h:outputLabel styleClass="data_label" value="#{msg.ADMIN_SHOW_CELLPHONE_UNLINK}" />
+
+ <div class="data_field">
+ <ul class="mini_nav">
+ <li class="mini_link">
+ <h:link outcome="admin_unlink_contact_mobile">
+ <h:outputText styleClass="unlink_link" value="#{msg.ADMIN_LINK_UNLINK_SHORT}" title="#{msg.ADMIN_LINK_UNLINK_SHORT_TITLE}" />
+ <f:param name="phoneId" value="#{adminPhoneController.cellPhone.phoneId}" />
+ <f:param name="contactId" value="#{contact.contactId}" />
+ </h:link>
+ </li>
+ </ul>
+ </div>
+ </h:column>
+ </h:dataTable>
+ </ui:define>
+ </ui:composition>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
+ lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ >
+
+ <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+ <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_LIST_CONTACT_CELLPHONE}</ui:define>
+
+ <ui:define name="content_header">
+ #{msg.CONTENT_TITLE_ADMIN_LIST_CONTACT_CELLPHONE}
+ </ui:define>
+
+ <ui:define name="content">
+ <h:dataTable id="table_list_mobiles" var="mobile" value="#{phoneController.allCellphones()}" styleClass="table_big" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_CELLPHONES}" rendered="#{not phoneController.allCellphones().isEmpty()}">
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_SHOW_CELLPHONE_ID}" />
+ </f:facet>
+ </h:column>
+ </h:dataTable>
+ </ui:define>
+ </ui:composition>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
+ lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ >
+
+ <f:metadata>
+ <f:viewParam name="phoneId" value="#{adminPhoneController.cellPhone}" converter="CellphoneConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_PHONE_ID_NOT_SET}" />
+ <f:viewParam name="contactId" value="#{beanHelper.contact}" converter="ContactConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_CONTACT_ID_NOT_SET}" />
+ </f:metadata>
+
+ <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+ <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE}</ui:define>
+
+ <ui:define name="content_header">
+ #{msg.CONTENT_TITLE_ADMIN_UNLINK_CONTACT_CELLPHONE}
+ </ui:define>
+
+ <ui:define name="content">
+ Here goes your content.
+ </ui:define>
+ </ui:composition>
+</html>
</div>
<div>
- <ui:include src="/WEB-INF/templates/admin/cellphone/admin_cellphone_add_show.tpl" />
+ <ui:include src="/WEB-INF/templates/admin/mobile/admin_mobile_add_show.tpl" />
</div>
</ui:define>
</ui:composition>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core">
-
- <f:metadata>
- <f:viewParam id="addressbookId" name="addressbookId" value="#{addressbookController.addressbookId}" required="true" requiredMessage="#{msg.PARAMETER_ADDRESSBOOK_ID_MISSING}" converterMessage="#{msg.PARAMETER_ADDRESSBOOK_ID_INVALID}" validatorMessage="#{msg.PARAMETER_ADDRESSBOOK_ID_NOT_FOUND}">
- <f:convertNumber for="addressbookId" type="number" minIntegerDigits="1" maxIntegerDigits="20" />
- <f:validator for="addressbookId" validatorId="AddressbookIdValidator" />
- </f:viewParam>
- </f:metadata>
-
- <ui:composition template="/WEB-INF/templates/#{userLoginController.templateType}/#{userLoginController.templateType}_base.tpl">
- <ui:define name="login_title">#{msg.PAGE_TITLE_USER_SHOW_ADDRESSBOOK}</ui:define>
- <ui:define name="guest_title">#{msg.PAGE_TITLE_INDEX_SHOW_ADDRESSBOOK}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_USER_SHOW_ADDRESSBOOK}
- </ui:define>
-
- <ui:define name="content">
- <h:panelGrid headerClass="table_header" styleClass="table" columns="2" rendered="#{addressbookController.loadAddressbook()}">
- <f:facet name="header">#{msg.TABLE_HEADER_SHOW_ADDRESSBOOK}</f:facet>
-
- <h:outputLabel for="addressbookName" styleClass="table_label">#{msg.ADDRESSBOOK_NAME}</h:outputLabel>
- <h:outputText id="addressbookName" value="#{addressbookController.addressbookName}" />
-
- <h:outputLabel for="userProfileLink" styleClass="table_label">#{msg.ADDRESSBOOK_OWNER}</h:outputLabel>
- <ui:include src="/WEB-INF/templates/user/user_profile_link.tpl">
- <ui:param name="user" value="#{addressbookController.addressbookUser}" />
- </ui:include>
-
- <h:outputLabel for="addressbookCreated" styleClass="table_label">#{msg.ADDRESSBOOK_CREATED}</h:outputLabel>
- <h:outputFormat id="addressbookCreated" value="#{addressbookController.addressbook.addressbookCreated.time}" title="#{msg.ADDRESSBOOK_CREATED_TITLE}">
- <f:convertDateTime for="addressbookCreated" type="both" timeStyle="short" dateStyle="medium" />
- </h:outputFormat>
-
- <h:outputLabel for="addressbookStatus" styleClass="table_label">#{msg.ADDRESSBOOK_STATUS}</h:outputLabel>
- <h:outputText id="addressbookStatus" value="#{msg[addressbookController.addressbook.addressbookStatus.messageKey]}" title="#{msg.ADDRESSBOOK_STATUS_TITLE}" />
-
- <f:facet name="footer">
- <h:outputText id="ownProfileInvible" styleClass="notice" value="#{msg.USER_NOT_LOGGED_IN}" rendered="#{not userLoginController.isUserLoggedIn()}" />
- <h:outputText id="ownProfileInvible" styleClass="notice" value="#{msg.LOGIN_OWN_PROFILE_INVISIBLE}" rendered="#{userLoginController.isUserLoggedIn() and userLoginController.isInvisible()}" />
-
- <ui:fragment rendered="#{userLoginController.isUserLoggedIn() and not userLoginController.isInvisible()}">
- <h:outputText value="Bla bla" rendered="#{addressbookController.isOtherAddressbook()}" />
- </ui:fragment>
- </f:facet>
- </h:panelGrid>
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <ui:composition template="/WEB-INF/templates/login/user/user_base.tpl">
- <ui:define name="login_title">#{msg.PAGE_TITLE_USER_SHOW_ADDRESSBOOK_ENTRIES}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_USER_SHOW_ADDRESSBOOK_ENTRIES}
- </ui:define>
-
- <ui:define name="content">
- Here goes your content.
- </ui:define>
- </ui:composition>
-</html>
<f:facet name="header">#{msg.USER_CREATED}</f:facet>
<h:outputFormat id="userCreated" value="#{user.userCreated.time}" title="#{msg.USER_CREATED_TITLE}" />
</h:column>
-
- <h:column>
- <f:facet name="header">#{msg.USER_LIST_SHARING_ADDRESSBOOKS}</f:facet>
- <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
- <h:link outcome="login_list_sharing_addressbooks" value="#{msg.LINK_LOGIN_LIST_SHARING_ADDRESSBOOKS}" title="#{msg.LINK_LOGIN_LIST_SHARING_ADDRESSBOOKS_TITLE}">
- <f:param name="userId" value="#{user.userId}" />
- </h:link>
- </ui:fragment>
- <ui:fragment rendered="#{not loginController.isUserLoggedIn()}">
- <h:outputText id="userShared" value="#{addressbookController.countAllUserSharedAddressbooks(user)}" />
- </ui:fragment>
- </h:column>
</h:dataTable>
</div>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <ui:composition template="/WEB-INF/templates/login/user/user_base.tpl">
- <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_ADD_ADDRESSBOOK}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_LOGIN_ADD_ADDRESSBOOK}
- </ui:define>
-
- <ui:define name="content">
- <ui:fragment rendered="#{userLoginController.isUserLoggedIn()}">
- <h:form id="add_addressbook" acceptcharset="utf-8">
- <div class="table">
- <div class="table_header">
- #{msg.FORM_LOGIN_ADD_ADDRESSBOOK_TITLE}
- </div>
-
- <div class="table_row">
- <div class="table_left">
- <h:outputLabel for="addressbookName" value="#{msg.LOGIN_ENTER_ADDRESSBOOK_NAME}"/>
- </div>
-
- <div class="table_right">
- <h:inputText styleClass="input" id="addressbookName" value="#{addressbookController.addressbookName}" maxlength="50" size="20" title="#{msg.LOGIN_ENTER_ADDRESSBOOK_NAME_TITLE}" required="true" requiredMessage="#{msg.LOGIN_ADDRESSBOOK_NAME_REQUIRED_MESSAGE}">
- <f:validator for="addressbookName" validatorId="NameValidator" />
- </h:inputText>
- </div>
- </div>
-
- <div class="table_footer">
- <h:commandButton styleClass="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
- <h:commandButton styleClass="submit" type="submit" id="register" value="#{msg.BUTTON_LOGIN_ADD_ADDRESSBOOK}" action="#{addressbookController.addAddressbook()}" />
- </div>
- </div>
- </h:form>
- </ui:fragment>
-
- <ui:fragment rendered="#{not userLoginController.isUserLoggedIn()}">
- <ui:include src="/WEB-INF/templates/user/user_not_logged_in.tpl" />
- </ui:fragment>
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <f:metadata>
- <f:viewParam id="userId" name="userId" value="#{shareController.shareeUserId}" required="true" requiredMessage="#{msg.PARAMETER_USER_ID_MISSING}" converterMessage="#{msg.PARAMETER_USER_ID_INVALID}" validatorMessage="#{msg.PARAMETER_USER_ID_NOT_FOUND}">
- <f:convertNumber for="userId" type="number" minIntegerDigits="1" maxIntegerDigits="20" />
- <f:validator for="userId" validatorId="UserIdValidator" />
- </f:viewParam>
- </f:metadata>
-
- <ui:composition template="/WEB-INF/templates/login/login_base.tpl">
- <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_LIST_SHARING_ADDRESSBOOKS}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_LOGIN_LIST_SHARING_ADDRESSBOOKS}
- </ui:define>
-
- <ui:define name="content">
- <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
- <ui:fragment rendered="#{shareController.isShareeUserIdSet()}">
- Here goes your content.
- </ui:fragment>
-
- <ui:fragment rendered="#{shareController.isShareeUserIdEmpty()}">
- <ui:include src="/WEB-INF/templates/generic/userid_error.tpl" />
- </ui:fragment>
- </ui:fragment>
-
- <ui:fragment rendered="#{not loginController.isUserLoggedIn()}">
- <ui:include src="/WEB-INF/templates/generic/user_not_logged_in.tpl" />
- </ui:fragment>
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <ui:composition template="/WEB-INF/templates/login/login_base.tpl">
- <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_OTHER_ADDRESSBOOKS}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_LOGIN_OTHER_ADDRESSBOOKS}
- </ui:define>
-
- <ui:define name="content">
- <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
- Here goes your content.
- </ui:fragment>
-
- <ui:fragment rendered="#{not loginController.isUserLoggedIn()}">
- <ui:include src="/WEB-INF/templates/generic/user_not_logged_in.tpl" />
- </ui:fragment>
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <ui:composition template="/WEB-INF/templates/login/user/user_base.tpl">
- <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_OWN_ADDRESSBOOKS}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_LOGIN_OWN_ADDRESSBOOKS}
- </ui:define>
-
- <ui:define name="content">
- <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
- <div class="table">
- <div class="table_header">
- #{msg.TABLE_HEADER_LIST_OWN_ADDRESSBOOKS}
- </div>
-
- <div class="para">
- <h:dataTable id="table_own_addressbooks" var="addressbook" value="#{addressbookController.allAddressbooks()}" styleClass="table" headerClass="table_data_column" summary="#{msg.TABLE_SUMMARY_LOGIN_LIST_OWN_ADDRESSBOOKS}" rendered="#{addressbookController.hasCreatedAddressbooks()}">
- <h:column>
- <f:facet name="header">#{msg.ADDRESSBOOK_NAME}</f:facet>
-
- <h:link outcome="user_show_addressbook" title="#{msg.LINK_SHOW_ADDRESSBOOK_TITLE}">
- <f:param name="addressbookId" value="#{addressbook.addressbookId}" />
- <h:outputText id="addressbookName" value="#{addressbook.addressbookName}" title="#{msg.ADDRESSBOOK_NAME_TITLE}" />
- </h:link>
- </h:column>
-
- <h:column>
- <f:facet name="header">#{msg.ADDRESSBOOK_TOTAL_ENTRIES}</f:facet>
-
- <h:link outcome="show_addressbook_entries" title="#{msg.LINK_SHOW_ADDRESSBOOK_ENTRIES_TITLE}">
- <f:param name="addressbookId" value="#{addressbook.addressbookId}" />
- <h:outputText id="addressbookEntries" value="#{addressbookController.allEntriesSize(addressbook)}" title="#{msg.ADDRESSBOOK_TOTAL_ENTRIES_TITLE}" />
- </h:link>
- </h:column>
-
- <h:column>
- <f:facet name="header">#{msg.ADDRESSBOOK_CREATED}</f:facet>
-
- <h:outputFormat id="addressbookCreated" value="#{addressbook.addressbookCreated.time}" title="#{msg.ADDRESSBOOK_CREATED_TITLE}">
- <f:convertDateTime for="addressbookCreated" type="both" timeStyle="short" dateStyle="medium" />
- </h:outputFormat>
- </h:column>
- </h:dataTable>
- </div>
-
- <div class="table_footer">
- <h:link id="add_first_addressbook" outcome="login_add_addressbook" value="#{msg.LINK_LOGIN_ADD_FIRST_ADDRESSBOOK}" title="#{msg.LINK_LOGIN_ADD_FIRST_ADDRESSBOOK_TITLE}" rendered="#{addressbookController.hasCreatedAddressbooks() == false}" />
- <h:link id="add_additional_addressbook" outcome="login_add_addressbook" value="#{msg.LINK_LOGIN_ADD_ADDITIONAL_ADDRESSBOOK}" title="#{msg.LINK_LOGIN_ADD_ADDITIONAL_ADDRESSBOOK_TITLE}" rendered="#{addressbookController.hasCreatedAddressbooks()}" />
- </div>
- </div>
- </ui:fragment>
-
- <h:outputText rendered="#{not userLoginController.isUserLoggedIn()}">
- <ui:include src="/WEB-INF/templates/user/user_not_logged_in.tpl" />
- </h:outputText>
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core">
-
- <ui:composition template="/WEB-INF/templates/login/login_base.tpl">
- <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_SHARED_ADDRESSBOOKS}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_LOGIN_SHARED_ADDRESSBOOKS}
- </ui:define>
-
- <ui:define name="content">
- <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
- <div class="table">
- <div class="table_header">
- #{msg.LOGIN_TABLE_HEADER_SHARED_ADDRESSBOOKS}
- </div>
-
- <div class="para">
- <h:dataTable id="sharedAddressbooks" var="share" value="#{shareController.allShares()}" headerClass="table_data_column" summary="#{msg.TABLE_SUMMARY_LOGIN_SHARED_ADDRESSBOOKS}" rendered="#{shareController.isSharingAddressbooks()}">
- <h:column>
- <f:facet name="header">#{msg.SHARED_ADDRESSBOOK}</f:facet>
-
- <h:link outcome="user_show_addressbook" title="#{msg.LINK_SHOW_ADDRESSBOOK_TITLE}">
- <f:param name="addressbookId" value="#{share.shareAddressbook.addressbookId}" />
- <h:outputText id="addressbookName" value="#{share.shareAddressbook.addressbookName}" title="#{msg.SHARED_ADDRESSBOOK_TITLE}" />
- </h:link>
- </h:column>
-
- <h:column>
- <f:facet name="header">#{msg.SHAREE_USER_NAME}</f:facet>
- <ui:include src="/WEB-INF/templates/generic/user_profile_link.tpl">
- <ui:param name="user" value="#{share.setShareUserSharee(shareUserSharer)}" />
- </ui:include>
- </h:column>
-
- <h:column>
- <f:facet name="header">#{msg.SHARE_CREATED}</f:facet>
- <h:outputText id="shareCreated" value="#{share.shareCreated.time}" title="#{msg.SHARE_CREATED_TITLE}">
- <f:convertDateTime for="shareCreated" type="both" timeStyle="short" dateStyle="medium" />
- </h:outputText>
- </h:column>
- </h:dataTable>
- </div>
-
- <div class="para">
- <h:outputText class="notice" value="#{msg.LOGIN_USER_HAS_NOT_SHARED_ADDRESSBOOKS}" rendered="#{not shareController.isSharingAddressbooks()}" />
- </div>
-
- <div class="table_footer">
- <h:link id="shareAddressbook" outcome="user_list" title="#{msg.LINK_LOGIN_START_SHARING_ADDRESSBOOKS_TITLE}" value="#{msg.LINK_LOGIN_START_SHARING_ADDRESSBOOKS}" />
- </div>
- </div>
- </ui:fragment>
-
- <ui:fragment rendered="#{not loginController.isUserLoggedIn()}">
- <ui:include src="/WEB-INF/templates/generic/user_not_logged_in.tpl" />
- </ui:fragment>
- </ui:define>
- </ui:composition>
-</html>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
-
- <ui:composition template="/WEB-INF/templates/#{loginController.templateType}/#{loginController.templateType}_base.tpl">
- <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_START_SHARING_ADDRESSBOOK}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_LOGIN_START_SHARING_ADDRESSBOOK}
- </ui:define>
-
- <ui:define name="content">
- <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
- <div class="table_big">
-
- <div class="table_header">
- #{msg.TABLE_HEADER_CHOOSE_USER_FOR_SHARING}
- </div>
-
- <div class="para">
- <h:outputText id="userNotLoggedIn" class="notice" value="#{msg.USER_NOT_LOGGED_IN}" rendered="#{not loginController.isUserLoggedIn()}" />
-
- <h:dataTable id="userList" headerClass="table_header_column" var="user" value="#{addressbookController.allUsersNotSharing()}" rendered="#{loginController.isUserLoggedIn() and not empty addressbookController.addressbook and not loginController.isInvisible()}">
-
- <h:column>
- <f:facet name="header">#{msg.USER_ID}</f:facet>
- <h:outputText value="#{user.userId}" />
- </h:column>
-
- <h:column>
- <f:facet name="header">#{msg.USER_NAME}</f:facet>
- <ui:include src="/WEB-INF/templates/generic/user_profile_link.tpl">
- <ui:param name="user" value="#{user}" />
- </ui:include>
- </h:column>
-
- <h:column>
- <f:facet name="header">#{msg.LOGIN_START_SHARING_TITLE}</f:facet>
- <h:form acceptcharset="utf-8" id="startSharing" rendered="#{profileController.isProfileLinkVisibleByUser(user)}">
- <h:commandButton class="submit" id="submit" value="#{msg.LOGIN_START_SHARING_BUTTON}" action="#{shareController.startSharing(user, addressbookController.addressbook)}" title="#{msg.LOGIN_START_SHARING_BUTTON_TITLE}" />
- </h:form>
- </h:column>
- </h:dataTable>
-
- <h:outputText id="addressbokUnset" class="notice" value="#{msg.LOGIN_ADDRESSBOOK_NOT_SET}" rendered="#{empty addressbookController.addressbook}" />
-
- <h:outputText id="ownProfileInvisible" class="notice" value="#{msg.LOGIN_OWN_PROFILE_INVISIBLE}" rendered="#{loginController.isUserLoggedIn() and not empty addressbookController.addressbook and not loginController.isInvisible()}" />
- </div>
-
- <div class="table_footer">
- <ul>
- <li>#{msg.LOGIN_START_SHARING_NOTICE1}</li>
- <li>#{msg.LOGIN_START_SHARING_NOTICE2}</li>
- </ul>
- </div>
- </div>
- </ui:fragment>
-
- <ui:fragment rendered="#{not loginController.isUserLoggedIn()}">
- <ui:include src="/WEB-INF/templates/generic/user_not_logged_in.tpl" />
- </ui:fragment>
- </ui:define>
- </ui:composition>
-</html>