]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
This "Pizza-Service" application was build on an outdated core, as it was not require...
authorRoland Haeder <roland@mxchange.org>
Sat, 9 Apr 2016 17:54:37 +0000 (19:54 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 9 Apr 2016 18:02:19 +0000 (20:02 +0200)
This rewrites the application towards an updated "core".

17 files changed:
lib/juser-core.jar [new file with mode: 0644]
lib/juser-lib.jar [new file with mode: 0644]
nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/project.properties
nbproject/project.xml
src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java
src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/converter/country/PizzaCountryConverter.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/converter/smsprovider/PizzaSmsProviderConverter.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/converter/user/PizzaUserConverter.java [new file with mode: 0644]
src/java/org/mxchange/pizzaservice/converter/country/PizzaCountryConverter.java [deleted file]
src/java/org/mxchange/pizzaservice/converter/smsprovider/PizzaSmsProviderConverter.java [deleted file]
src/java/org/mxchange/pizzaservice/converter/user/PizzaUserConverter.java [deleted file]

diff --git a/lib/juser-core.jar b/lib/juser-core.jar
new file mode 100644 (file)
index 0000000..5d51db1
Binary files /dev/null and b/lib/juser-core.jar differ
diff --git a/lib/juser-lib.jar b/lib/juser-lib.jar
new file mode 100644 (file)
index 0000000..fdf6c73
Binary files /dev/null and b/lib/juser-lib.jar differ
index 1b0a0d3997544e3b8ab29b2bb99cbf90ed7d3a9b..e18a9a08e76136a033725d43293f91a96b16b077 100644 (file)
@@ -1038,6 +1038,8 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.jphone-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jphone-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcontacts-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.juser-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.juser-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcustomer-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcustomer-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jshop-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
@@ -1057,6 +1059,8 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.jphone-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jphone-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jcontacts-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.juser-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.juser-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jcustomer-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jcustomer-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.jshop-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
index 9d44227bd1ca6c27d5f6e0008e6ae3bcf437e7b6..e395beb37b4ec3783ffaa7cfd689eb594752c4ce 100644 (file)
@@ -3,6 +3,6 @@ build.xml.script.CRC32=82213886
 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=10a373e0
-nbproject/build-impl.xml.script.CRC32=f7d4e4e8
+nbproject/build-impl.xml.data.CRC32=0accf525
+nbproject/build-impl.xml.script.CRC32=2d3389c2
 nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.75.1.1
index 9ed25a58dec3a9ee74b792aaa77872f9fb114d08..371d9295863fb4e32bd30472ca8cd76db1ab37e6 100644 (file)
@@ -49,6 +49,8 @@ file.reference.jphone-core.jar=lib/jphone-core.jar
 file.reference.jphone-lib.jar=lib/jphone-lib.jar
 file.reference.jshop-core.jar=lib/jshop-core.jar
 file.reference.jshop-ee-lib.jar=lib/jshop-ee-lib.jar
+file.reference.juser-core.jar=lib/juser-core.jar
+file.reference.juser-lib.jar=lib/juser-lib.jar
 includes=**
 j2ee.compile.on.save=true
 j2ee.copy.static.files.on.save=true
@@ -71,6 +73,8 @@ javac.classpath=\
     ${file.reference.jphone-core.jar}:\
     ${file.reference.jphone-lib.jar}:\
     ${file.reference.jcontacts-core.jar}:\
+    ${file.reference.juser-core.jar}:\
+    ${file.reference.juser-lib.jar}:\
     ${file.reference.jcustomer-core.jar}:\
     ${file.reference.jcustomer-lib.jar}:\
     ${file.reference.jshop-core.jar}:\
@@ -129,6 +133,8 @@ source.reference.jphone-core.jar=../jphone-core/src/
 source.reference.jphone-lib.jar=../jphone-lib/src/
 source.reference.jshop-core.jar=../jshop-core/src/
 source.reference.jshop-ee-lib.jar=../jshop-ee-lib/src/
+source.reference.juser-core.jar=../juser-core/src/
+source.reference.juser-lib.jar=../juser-lib/src/
 source.root=src
 src.dir=${source.root}/java
 test.src.dir=test
index 73eb585ecc2b091f3db768445c0043b0b94b15a6..732fba55c358456cdacf6414ccc44df0cfce11f9 100644 (file)
                     <file>${file.reference.jcontacts-core.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
+                <library dirs="200">
+                    <file>${file.reference.juser-core.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.juser-lib.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
                 <library dirs="200">
                     <file>${file.reference.jcustomer-core.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
index 3a761dc9c243f9d6ed52c2e4f526e845fabf7caa..c63c393d24c13f13eed9feb4915c36ccfedbab12 100644 (file)
@@ -62,7 +62,7 @@ public class PizzaCountryWebApplicationBean implements PizzaCountryWebApplicatio
                        Context context = new InitialContext();
 
                        // Try to lookup the bean
-                       this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.AddressbookCountrySingletonBeanLocal"); //NOI18N
+                       this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/PizzaService-ejb/country!org.mxchange.jcountry.data.AddressbookCountrySingletonBeanLocal"); //NOI18N
                } catch (final NamingException ex) {
                        // Continue to throw
                        throw new FaceletException(ex);
diff --git a/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionBean.java
new file mode 100644 (file)
index 0000000..79c3f00
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.pizzaapplication.beans.login;
+
+import java.util.Objects;
+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.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.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.profilemodes.ProfileMode;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController;
+
+/**
+ * A web bean for user registration
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("loginController")
+@SessionScoped
+public class PizzaUserLoginWebSessionBean implements PizzaUserLoginWebSessionController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 47_828_986_719_691_592L;
+
+       /**
+        * Current password
+        */
+       private String currentPassword;
+
+       /**
+        * Logged-in user instance
+        */
+       private User loggedInUser;
+
+       /**
+        * Remote register session bean
+        */
+       private UserLoginSessionBeanRemote loginBean;
+
+       /**
+        * Event fired when user has logged in
+        */
+       @Inject
+       @Any
+       private Event<UserLoggedInEvent> loginEvent;
+
+       /**
+        * Template type for pages that might be displayed in guest area and login
+        * area. Default is guest area.
+        */
+       private String templateType = "guest"; //NOI18N
+
+       /**
+        * User controller
+        */
+       @Inject
+       private PizzaUserWebSessionController userController;
+
+       /**
+        * Flag whether the user has logged-in, set only from inside
+        */
+       private boolean userLoggedIn;
+
+       /**
+        * Default constructor
+        */
+       public PizzaUserLoginWebSessionBean () {
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.loginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/PizzaService-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public String doLogin () {
+               // Get user instance
+               User user = this.userController.createUserInstance();
+
+               // Create login container
+               LoginContainer container = new UserLoginContainer(user, this.userController.getUserPassword());
+
+               try {
+                       // Call bean
+                       User confirmedUser = this.loginBean.validateUserAccountStatus(container);
+
+                       // All fine here so set it here
+                       this.setLoggedInUser(confirmedUser);
+
+                       // Set template to "login"
+                       this.setTemplateType("login"); //NOI18N
+
+                       // Fire event away. Keep this last before return statement.
+                       this.loginEvent.fire(new UserLoginEvent(confirmedUser));
+
+                       // All fine
+                       return "login"; //NOI18N
+               } catch (final UserNotFoundException | UserStatusLockedException | UserStatusUnconfirmedException | UserPasswordMismatchException ex) {
+                       // Throw again
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @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 String getTemplateType () {
+               return this.templateType;
+       }
+
+       @Override
+       public void setTemplateType (final String templateType) {
+               this.templateType = templateType;
+       }
+
+       @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 isGuest () {
+               return (!this.isUserLoggedIn());
+       }
+
+       @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 isUserLoggedIn () {
+               // Trace message
+               // NOISY: System.out.println(MessageFormat.format("PizzaUserLoginWebSessionBean:isUserLoggedIn: this.loggedInUser={0},this.templateType={1} - CALLED!", this.getLoggedInUser(), this.getTemplateType()));
+
+               // Compare instance
+               this.userLoggedIn = ((this.getLoggedInUser() instanceof User) && (Objects.equals(this.getLoggedInUser().getUserAccountStatus(), UserAccountStatus.CONFIRMED)));
+
+               // Trace message
+               // NOISY: System.out.println(MessageFormat.format("PizzaUserLoginWebSessionBean:isUserLoggedIn: this.userLoggedIn={0} - EXIT!", this.userLoggedIn));
+
+               // Return it
+               return this.userLoggedIn;
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/login/PizzaUserLoginWebSessionController.java
new file mode 100644 (file)
index 0000000..c8ec08a
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.pizzaapplication.beans.login;
+
+import java.io.Serializable;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An interface for registration web controllers
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface PizzaUserLoginWebSessionController extends Serializable {
+
+       /**
+        * Getter for template type
+        * <p>
+        * @return Template type
+        */
+       String getTemplateType ();
+
+       /**
+        * Setter for template type
+        * <p>
+        * @param templateType Template type
+        */
+       void setTemplateType (final String templateType);
+
+       /**
+        * Logins the user, if the account is found, confirmed and unlocked.
+        * <p>
+        * @return Redirect target
+        */
+       String doLogin ();
+
+       /**
+        * 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 ();
+
+       /**
+        * Is this truly a guest?
+        * <p>
+        * @return Whether the user is truly a guest
+        */
+       boolean isGuest ();
+
+       /**
+        * 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 ();
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java
new file mode 100644 (file)
index 0000000..a71bd4c
--- /dev/null
@@ -0,0 +1,914 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.pizzaapplication.beans.user;
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.Date;
+import java.util.GregorianCalendar;
+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.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.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+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.smsprovider.SmsProvider;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.model.user.LoginUser;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.pizzaapplication.beans.login.PizzaUserLoginWebSessionController;
+
+/**
+ * A user bean (controller)
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("userController")
+@SessionScoped
+public class PizzaUserWebSessionBean implements PizzaUserWebSessionController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_916L;
+
+       /////////////////////// Properties /////////////////////
+       /**
+        * Birth day
+        */
+       private Date birthday;
+
+       /**
+        * Cellphone number's carrier
+        */
+       private SmsProvider cellphoneCarrier;
+
+       /**
+        * Cellphone number
+        */
+       private Long cellphoneNumber;
+
+       /**
+        * City
+        */
+       private String city;
+
+       /**
+        * Optional comments
+        */
+       private String comment;
+
+       /**
+        * Country instance
+        */
+       private Country country;
+
+       /**
+        * Email address
+        */
+       private String emailAddress;
+
+       /**
+        * Email address 1 (changing)
+        */
+       private String emailAddress1;
+
+       /**
+        * Email address 2 (repeat in changing)
+        */
+       private String emailAddress2;
+
+       /**
+        * Email address list
+        */
+       private 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;
+
+       /**
+        * Login bean (controller)
+        */
+       @Inject
+       private PizzaUserLoginWebSessionController loginController;
+
+       /**
+        * Phone number area code
+        */
+       private Integer phoneAreaCode;
+
+       /**
+        * Country instance for phone number
+        */
+       private Country phoneCountry;
+
+       /**
+        * Phone number
+        */
+       private Long phoneNumber;
+
+       /**
+        * Street
+        */
+       private String street;
+
+       /**
+        * Remote user bean
+        */
+       private final UserSessionBeanRemote userBean;
+
+       /**
+        * User id
+        */
+       private Long userId;
+
+       /**
+        * 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
+        */
+       private List<User> visibleUserList;
+
+       /**
+        * ZIP code
+        */
+       private Integer zipCode;
+
+       /**
+        * Default constructor
+        */
+       public PizzaUserWebSessionBean () {
+               // Set gender to UNKNOWN
+               this.gender = Gender.UNKNOWN;
+
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.userBean = (UserSessionBeanRemote) context.lookup("java:global/PizzaService-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw again
+                       throw new FaceletException(e);
+               }
+       }
+
+       @Override
+       public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) {
+               // Trace message
+               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.getUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.user is null"); //NOI18N
+               } else if (event.getUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.user.userId is null"); //NOI18N
+               } else if (event.getUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUser(), event.getUser().getUserId())); //NOI18N
+               }
+
+               // Get user instance
+               User registeredUser = event.getUser();
+
+               // Debug message
+               System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
+
+               // Copy all data from registered->user
+               this.copyUser(registeredUser);
+
+               // Add user name and email address
+               this.addUserNameEmailAddress(registeredUser);
+
+               // Clear all data
+               this.clearData();
+
+               // Set user id again
+               this.setUserId(registeredUser.getUserId());
+
+               // Is the account public?
+               if (registeredUser.getUserProfileMode().equals(ProfileMode.PUBLIC)) {
+                       // Also add it to this list
+                       this.visibleUserList.add(registeredUser);
+               }
+
+               // Trace message
+               System.out.println("UserWebBean:afterRegistration: EXIT!"); //NOI18N
+       }
+
+       @Override
+       public void afterUserLogin (final @Observes UserLoggedInEvent event) {
+               // Trace message
+               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.getUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.user is null"); //NOI18N
+               } else if (event.getUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.user.userId is null"); //NOI18N
+               } else if (event.getUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUser(), event.getUser().getUserId())); //NOI18N
+               }
+
+               // Re-initialize list
+               this.visibleUserList = this.userBean.allMemberPublicVisibleUsers();
+
+               // Copy all data to this bean
+               this.copyUser(event.getUser());
+
+               // Trace message
+               System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: this.visibleUserList.size()={0} - EXIT!", this.visibleUserList.size())); //NOI18N
+       }
+
+       @Override
+       public List<User> allVisibleUsers () {
+               // Return it
+               return Collections.unmodifiableList(this.visibleUserList);
+       }
+
+       @Override
+       public User createUserInstance () {
+               // User message
+               //this.getLogger().logTrace("createUserInstance: CALLED!");
+
+               // Required personal data must be set
+               assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
+
+               // Create new user instance
+               User user = new LoginUser();
+               user.setUserName(this.getUserName());
+               user.setUserProfileMode(this.getUserProfileMode());
+               user.setUserCreated(new GregorianCalendar());
+
+               // Generate phone number
+               DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber(), new GregorianCalendar());
+               DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber(), new GregorianCalendar());
+               DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber(), new GregorianCalendar());
+
+               // Create new contact
+               Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
+               contact.setContactStreet(this.getStreet());
+               contact.setContactHouseNumber(this.getHouseNumber());
+               contact.setContactZipCode(this.getZipCode());
+               contact.setContactCity(this.getCity());
+               contact.setContactCountry(this.getCountry());
+               contact.setContactEmailAddress(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 ((cellphone instanceof DialableCellphoneNumber) && (this.getCellphoneCarrier() instanceof SmsProvider) && (this.getCellphoneNumber() != null) && (this.getCellphoneNumber() > 0)) {
+                       // Is the number set?
+                       if (cellphone.getPhoneNumber() == null) {
+                               // Is null
+                               throw new NullPointerException("cellphone.phoneNumber is null"); //NOI18N
+                       } else if (cellphone.getPhoneNumber() < 1) {
+                               // Abort here
+                               throw new IllegalArgumentException("cellphone.phoneNumber is zero or below."); //NOI18N
+                       }
+
+                       // Set cellphone number
+                       contact.setContactCellphoneNumber(cellphone);
+               }
+
+               contact.setContactBirthday(this.getBirthday());
+               contact.setContactComment(this.getComment());
+
+               // Created timestamp and ownContact
+               contact.setContactCreated(new GregorianCalendar());
+               contact.setContactOwnContact(Boolean.TRUE);
+
+               // Set contact in user
+               user.setUserContact(contact);
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("createUserInstance: user={0} - EXIT!", user));
+               // Return it
+               return user;
+       }
+
+       @Override
+       public Date getBirthday () {
+               return this.birthday;
+       }
+
+       @Override
+       public void setBirthday (final Date birthday) {
+               this.birthday = birthday;
+       }
+
+       @Override
+       public SmsProvider getCellphoneCarrier () {
+               return this.cellphoneCarrier;
+       }
+
+       @Override
+       public void setCellphoneCarrier (final SmsProvider cellphoneCarrier) {
+               this.cellphoneCarrier = cellphoneCarrier;
+       }
+
+       @Override
+       public Long getCellphoneNumber () {
+               return this.cellphoneNumber;
+       }
+
+       @Override
+       public void setCellphoneNumber (Long cellphoneNumber) {
+               this.cellphoneNumber = cellphoneNumber;
+       }
+
+       @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 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 getEmailAddress1 () {
+               return this.emailAddress1;
+       }
+
+       @Override
+       public void setEmailAddress1 (final String emailAddress1) {
+               this.emailAddress1 = emailAddress1;
+       }
+
+       @Override
+       public String getEmailAddress2 () {
+               return this.emailAddress2;
+       }
+
+       @Override
+       public void setEmailAddress2 (final String emailAddress2) {
+               this.emailAddress2 = emailAddress2;
+       }
+
+       @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 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 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;
+       }
+
+       @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 user name list for reducing EJB calls
+               this.userNameList = this.userBean.getUserNameList();
+
+               // Get full email address list for reducing EJB calls
+               this.emailAddressList = this.userBean.getEmailAddressList();
+
+               // Is the user logged-in?
+               if (this.loginController.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 isEmailAddressRegistered (final User user) {
+               return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(user.getUserContact().getContactEmailAddress())));
+       }
+
+       @Override
+       public boolean isRequiredPersonalDataSet () {
+               return ((this.getUserName() != null) &&
+                               (this.getUserProfileMode() != null) &&
+                               (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) &&
+                               (this.getUserPassword() != null) &&
+                               (this.getUserPasswordRepeat() != null));
+       }
+
+       @Override
+       public boolean isRequiredChangePersonalDataSet () {
+               return ((this.getUserProfileMode() != null) &&
+                               (this.getGender() != null) &&
+                               (this.getFirstName() != null) &&
+                               (this.getFamilyName() != null) &&
+                               (this.getStreet() != null) &&
+                               (this.getHouseNumber() != null) &&
+                               (this.getZipCode() != null) &&
+                               (this.getCity() != null));
+       }
+
+       @Override
+       public boolean isSameEmailAddressEntered () {
+               return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
+       }
+
+       @Override
+       public boolean isSamePasswordEntered () {
+               return (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 isVisibleUserFound () {
+               return ((this.visibleUserList instanceof List) && (this.visibleUserList.size() > 0));
+       }
+
+       @Override
+       public User lookupUserById (final Long userId) throws UserNotFoundException {
+               // Init variable
+               User user = null;
+
+               // Try to lookup it in visible user list
+               for (final Iterator<User> iterator = this.visibleUserList.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 and email address to bean's internal list. It also
+        * updates the public user list if the user has decided to ha   }
+        * <p>
+        * @param user User instance
+        */
+       private void addUserNameEmailAddress (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.emailAddressList.contains(user.getUserContact().getContactEmailAddress())) {
+                       // Already added
+                       throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", user.getUserContact().getContactEmailAddress())); //NOI18N
+               }
+
+               // Add user name
+               this.userNameList.add(user.getUserName());
+
+               // Add email addres
+               this.emailAddressList.add(user.getUserContact().getContactEmailAddress());
+       }
+
+       /**
+        * Clears all data in this bean
+        */
+       private void clearData () {
+               // Clear all data
+               // - personal data
+               this.setUserId(null);
+               this.setGender(Gender.UNKNOWN);
+               this.setUserProfileMode(null);
+               this.setFirstName(null);
+               this.setFamilyName(null);
+               this.setStreet(null);
+               this.setHouseNumber(null);
+               this.setZipCode(null);
+               this.setCity(null);
+               this.setCountry(null);
+
+               // - contact data
+               this.setEmailAddress(null);
+               this.setEmailAddressRepeat(null);
+               this.setPhoneAreaCode(null);
+               this.setCellphoneCarrier(null);
+               this.setFaxAreaCode(null);
+
+               // - other data
+               this.setBirthday(null);
+               this.setComment(null);
+               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) {
+               // Copy all fields:
+               // - base data
+               this.setUserId(user.getUserId());
+               this.setUserProfileMode(user.getUserProfileMode());
+               this.setGender(user.getUserContact().getContactGender());
+               this.setFirstName(user.getUserContact().getContactFirstName());
+               this.setFamilyName(user.getUserContact().getContactFamilyName());
+               this.setStreet(user.getUserContact().getContactStreet());
+               this.setHouseNumber(user.getUserContact().getContactHouseNumber());
+               this.setZipCode(user.getUserContact().getContactZipCode());
+               this.setCity(user.getUserContact().getContactCity());
+               this.setCountry(user.getUserContact().getContactCountry());
+
+               // Get cellphone, phone and fax instance
+               DialableCellphoneNumber cellphone = user.getUserContact().getContactCellphoneNumber();
+               DialableFaxNumber fax = user.getUserContact().getContactFaxNumber();
+               DialableLandLineNumber phone = user.getUserContact().getContactLandLineNumber();
+
+               // - contact data
+               if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
+                       this.setPhoneCountry(phone.getPhoneCountry());
+                       this.setPhoneAreaCode(phone.getPhoneAreaCode());
+                       this.setPhoneNumber(phone.getPhoneNumber());
+               }
+               if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof SmsProvider)) {
+                       this.setCellphoneCarrier(cellphone.getCellphoneProvider());
+                       this.setCellphoneNumber(cellphone.getPhoneNumber());
+               }
+               if ((fax instanceof DialableFaxNumber) && (fax.getPhoneAreaCode() > 0)) {
+                       this.setFaxCountry(fax.getPhoneCountry());
+                       this.setFaxAreaCode(fax.getPhoneAreaCode());
+                       this.setFaxNumber(fax.getPhoneNumber());
+               }
+               this.setEmailAddress(user.getUserContact().getContactEmailAddress());
+
+               // -- other data
+               this.setBirthday(user.getUserContact().getContactBirthday());
+               this.setComment(user.getUserContact().getContactComment());
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java
new file mode 100644 (file)
index 0000000..74b7d5b
--- /dev/null
@@ -0,0 +1,516 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.pizzaapplication.beans.user;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.exceptions.UserNotFoundException;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface PizzaUserWebSessionController extends Serializable {
+
+       /**
+        * 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;
+
+       /**
+        * 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 public user profiles
+        * <p>
+        * @return A list of all public user profiles
+        */
+       List<User> allVisibleUsers ();
+
+       /**
+        * Creates an instance from all properties
+        * <p>
+        * @return A user instance
+        */
+       User createUserInstance ();
+
+       /**
+        * 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 ellphone number's carrier
+        * <p>
+        * @return Cellphone number's carrier
+        */
+       SmsProvider getCellphoneCarrier ();
+
+       /**
+        * Setter for cellphone number's carrier prefix
+        * <p>
+        * @param cellphoneCarrier Cellphone number's carrier prefix
+        */
+       void setCellphoneCarrier (final SmsProvider cellphoneCarrier);
+
+       /**
+        * Getter for ellphone number
+        * <p>
+        * @return Cellphone number
+        */
+       Long getCellphoneNumber ();
+
+       /**
+        * Setter for ellphone number
+        * <p>
+        * @param cellphoneNumber Cellphone number
+        */
+       void setCellphoneNumber (final Long cellphoneNumber);
+
+       /**
+        * 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 1 (changing)
+        * <p>
+        * @return Email address
+        */
+       String getEmailAddress1 ();
+
+       /**
+        * Setter for email address 1 (changing)
+        * <p>
+        * @param emailAddress1 Email address 1
+        */
+       void setEmailAddress1 (final String emailAddress1);
+
+       /**
+        * Getter for email address 2 (repeat changing)
+        * <p>
+        * @return Email address 2
+        */
+       String getEmailAddress2 ();
+
+       /**
+        * Setter for email address 2 (repeat changing)
+        * <p>
+        * @param emailAddress2 Email address 2
+        */
+       void setEmailAddress2 (final String emailAddress2);
+
+       /**
+        * 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 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 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);
+
+       /**
+        * ZIP code
+        * <p>
+        * @return the zipCode
+        */
+       Integer getZipCode ();
+
+       /**
+        * ZIP code
+        * <p>
+        * @param zipCode the zipCode to set
+        */
+       void setZipCode (final Integer zipCode);
+
+       /**
+        * Checks whether user instance's email address is used
+        * <p>
+        * @param user User instance's email address to check
+        * <p>
+        * @return Whether it is already used
+        */
+       boolean isEmailAddressRegistered (final User user);
+
+       /**
+        * 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 ();
+
+       /**
+        * Checks whether same passwords has been entered
+        * <p>
+        * @return Whether same passwords has been entered
+        */
+       boolean isSamePasswordEntered ();
+
+       /**
+        * 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);
+
+       /**
+        * 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 if the user id is empty
+        * <p>
+        * @return Whether the user id is empty
+        */
+       boolean isUserIdEmpty ();
+}
diff --git a/src/java/org/mxchange/pizzaapplication/converter/country/PizzaCountryConverter.java b/src/java/org/mxchange/pizzaapplication/converter/country/PizzaCountryConverter.java
new file mode 100644 (file)
index 0000000..e913d87
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.pizzaapplication.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 Haeder<roland@mxchange.org>
+ */
+@FacesConverter (value = "country")
+public class PizzaCountryConverter implements Converter {
+
+       /**
+        * Country bean
+        */
+       private CountrySingletonBeanRemote countryBean;
+
+       /**
+        * Logger instance
+        */
+       @Log
+       private LoggerBeanLocal loggerBeanLocal;
+
+       /**
+        * Initialization of this converter
+        */
+       public PizzaCountryConverter () {
+               // 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/PizzaService-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw it
+                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
+               }
+       }
+
+       @Override
+       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Trace message
+               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())) {
+                       // Trace message
+                       this.loggerBeanLocal.logTrace("getAsObject: submittedValue is null or empty - EXIT!"); //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
+                       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
+               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());
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/converter/smsprovider/PizzaSmsProviderConverter.java b/src/java/org/mxchange/pizzaapplication/converter/smsprovider/PizzaSmsProviderConverter.java
new file mode 100644 (file)
index 0000000..b2e3e45
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.pizzaapplication.converter.smsprovider;
+
+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.smsprovider.SmsProvider;
+import org.mxchange.jphone.phonenumbers.smsprovider.SmsProviderSingletonBeanRemote;
+
+/**
+ * Converter for SMS provider instance
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@FacesConverter (value = "cellphoneCarrier")
+public class PizzaSmsProviderConverter implements Converter {
+
+       /**
+        * Logger instance
+        */
+       @Log
+       private LoggerBeanLocal loggerBeanLocal;
+
+       /**
+        * SMS provider bean
+        */
+       private SmsProviderSingletonBeanRemote providerController;
+
+       /**
+        * Initialization of this converter
+        */
+       public PizzaSmsProviderConverter () {
+               // 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 SMS provider controller
+                       this.providerController = (SmsProviderSingletonBeanRemote) context.lookup("java:global/PizzaService-ejb/smsprovider!org.mxchange.jphone.phonenumbers.smsprovider.SmsProviderSingletonBeanRemote"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw it
+                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
+               }
+       }
+
+       @Override
+       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Trace message
+               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())) {
+                       // Trace message
+                       this.loggerBeanLocal.logTrace("getAsObject: submittedValue is null or empty - EXIT!"); //NOI18N
+
+                       // Return null
+                       return null;
+               }
+
+               // Get full list
+               List<SmsProvider> providerList = this.providerController.allSmsProvider();
+
+               // Init value
+               SmsProvider 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
+                       this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: providerId={0}", providerId)); //NOI18N
+
+                       // Try to find it
+                       for (final SmsProvider 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
+               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 SmsProvider)) {
+                       // Not same interface
+                       throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement SmsProvider.", value)); //NOI18N
+               }
+
+               // Return category id
+               return String.valueOf(((SmsProvider) value).getProviderId());
+       }
+}
diff --git a/src/java/org/mxchange/pizzaapplication/converter/user/PizzaUserConverter.java b/src/java/org/mxchange/pizzaapplication/converter/user/PizzaUserConverter.java
new file mode 100644 (file)
index 0000000..6abdb3a
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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.pizzaapplication.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.pizzaapplication.beans.user.PizzaUserWebSessionController;
+
+/**
+ * Converter for user id <-> valid user instance
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@FacesConverter (value = "UserConverter")
+public class PizzaUserConverter implements Converter {
+
+       /**
+        * Logger instance
+        */
+       @Log
+       private LoggerBeanLocal loggerBeanLocal;
+
+       /**
+        * User bean
+        */
+       private PizzaUserWebSessionController userController;
+
+       /**
+        * Initialization of this converter
+        */
+       public PizzaUserConverter () {
+               // 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.userController = (PizzaUserWebSessionController) context.lookup("java:global/PizzaService-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw it
+                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
+               }
+       }
+
+       @Override
+       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
+               // Trace message
+               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())) {
+                       // Trace message
+                       this.loggerBeanLocal.logTrace("getAsObject: submittedValue is null or empty - EXIT!"); //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
+                       this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId));
+
+                       // Try to get user instance from it
+                       user = this.userController.lookupUserById(userId);
+
+                       // Debug message
+                       this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: user={0}", user));
+               } 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));
+
+                       // Return null
+                       return null;
+               }
+
+               // Trace message
+               this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: user={0} - EXIT!", user));
+
+               // 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());
+       }
+
+}
diff --git a/src/java/org/mxchange/pizzaservice/converter/country/PizzaCountryConverter.java b/src/java/org/mxchange/pizzaservice/converter/country/PizzaCountryConverter.java
deleted file mode 100644 (file)
index f9eec18..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * 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.pizzaservice.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 Haeder<roland@mxchange.org>
- */
-@FacesConverter (value = "country")
-public class PizzaCountryConverter implements Converter {
-
-       /**
-        * Country bean
-        */
-       private CountrySingletonBeanRemote countryBean;
-
-       /**
-        * Logger instance
-        */
-       @Log
-       private LoggerBeanLocal loggerBeanLocal;
-
-       /**
-        * Initialization of this converter
-        */
-       public PizzaCountryConverter () {
-               // 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/pizza-ejb/country!org.mxchange.jcountry.data.AddressbookCountrySingletonBeanRemote"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw it
-                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
-               }
-       }
-
-       @Override
-       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
-               // Trace message
-               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())) {
-                       // Trace message
-                       this.loggerBeanLocal.logTrace("getAsObject: submittedValue is null or empty - EXIT!"); //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
-                       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
-               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());
-       }
-}
diff --git a/src/java/org/mxchange/pizzaservice/converter/smsprovider/PizzaSmsProviderConverter.java b/src/java/org/mxchange/pizzaservice/converter/smsprovider/PizzaSmsProviderConverter.java
deleted file mode 100644 (file)
index bc1c94b..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * 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.pizzaservice.converter.smsprovider;
-
-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.smsprovider.SmsProvider;
-import org.mxchange.jphone.phonenumbers.smsprovider.SmsProviderSingletonBeanRemote;
-
-/**
- * Converter for SMS provider instance
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@FacesConverter (value = "cellphoneCarrier")
-public class PizzaSmsProviderConverter implements Converter {
-
-       /**
-        * Logger instance
-        */
-       @Log
-       private LoggerBeanLocal loggerBeanLocal;
-
-       /**
-        * SMS provider bean
-        */
-       private SmsProviderSingletonBeanRemote providerController;
-
-       /**
-        * Initialization of this converter
-        */
-       public PizzaSmsProviderConverter () {
-               // 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 SMS provider controller
-                       this.providerController = (SmsProviderSingletonBeanRemote) context.lookup("java:global/addressbook-ejb/smsprovider!org.mxchange.jphone.phonenumbers.smsprovider.PizzaSmsProviderSingletonBeanRemote"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw it
-                       throw new RuntimeException("context.lookup() failed.", ex); //NOI18N
-               }
-       }
-
-       @Override
-       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
-               // Trace message
-               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())) {
-                       // Trace message
-                       this.loggerBeanLocal.logTrace("getAsObject: submittedValue is null or empty - EXIT!"); //NOI18N
-
-                       // Return null
-                       return null;
-               }
-
-               // Get full list
-               List<SmsProvider> providerList = this.providerController.allSmsProvider();
-
-               // Init value
-               SmsProvider 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
-                       this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: providerId={0}", providerId)); //NOI18N
-
-                       // Try to find it
-                       for (final SmsProvider 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
-               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 SmsProvider)) {
-                       // Not same interface
-                       throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement SmsProvider.", value)); //NOI18N
-               }
-
-               // Return category id
-               return String.valueOf(((SmsProvider) value).getProviderId());
-       }
-}
diff --git a/src/java/org/mxchange/pizzaservice/converter/user/PizzaUserConverter.java b/src/java/org/mxchange/pizzaservice/converter/user/PizzaUserConverter.java
deleted file mode 100644 (file)
index 5eb2706..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * 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.pizzaservice.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.addressbook.beans.user.AddressbookUserWebSessionController;
-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;
-
-/**
- * Converter for user id <-> valid user instance
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@FacesConverter (value = "UserConverter")
-public class PizzaUserConverter implements Converter {
-
-       /**
-        * Logger instance
-        */
-       @Log
-       private LoggerBeanLocal loggerBeanLocal;
-
-       /**
-        * User bean
-        */
-       private AddressbookUserWebSessionController userController;
-
-       /**
-        * Initialization of this converter
-        */
-       public PizzaUserConverter () {
-               // 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.userController = (AddressbookUserWebSessionController) 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("context.lookup() failed.", ex); //NOI18N
-               }
-       }
-
-       @Override
-       public Object getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
-               // Trace message
-               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())) {
-                       // Trace message
-                       this.loggerBeanLocal.logTrace("getAsObject: submittedValue is null or empty - EXIT!"); //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
-                       this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: userId{0}", userId));
-
-                       // Try to get user instance from it
-                       user = this.userController.lookupUserById(userId);
-
-                       // Debug message
-                       this.loggerBeanLocal.logDebug(MessageFormat.format("getAsObject: user={0}", user));
-               } 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));
-
-                       // Return null
-                       return null;
-               }
-
-               // Trace message
-               this.loggerBeanLocal.logTrace(MessageFormat.format("getAsObject: user={0} - EXIT!", user));
-
-               // 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());
-       }
-
-}