]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Continued with refacturing:
authorRoland Häder <roland@mxchange.org>
Wed, 20 Apr 2016 14:15:51 +0000 (16:15 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 20 Apr 2016 18:21:27 +0000 (20:21 +0200)
- added new controller for contact (general + admin)
- removed all contact-related stuff from user controller (as there are specific ones)
- login_data_saved splitted into login_user_data_saved and login_contact_data_saved
- fixed relevant temnplates (contact controller)

Signed-off-by: Roland Häder <roland@mxchange.org>
18 files changed:
nbproject/faces-config.NavData
src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/helper/AddressbookAdminWebRequestController.java
src/java/org/mxchange/addressbook/beans/helper/AddressbookAdminWebRequestHelper.java
src/java/org/mxchange/addressbook/beans/register/AddressbookUserRegisterWebSessionBean.java
src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionBean.java
src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionController.java
src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java
src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/admin/user/admin_form_user_personal_data.tpl
web/WEB-INF/templates/generic/form_personal_data.tpl
web/admin/user/admin_user_edit.xhtml
web/login/login_contact_data_saved.xhtml [new file with mode: 0644]
web/login/login_user_data_saved.xhtml [new file with mode: 0644]

index 70c4286ad890fdf1854c5df52a378966aa8787ee..0fa75d5023618925e65e9c08d8c25ef1e6fcfb48 100644 (file)
@@ -2,59 +2,61 @@
 <Scene Scope="Project" version="2">
     <Scope Scope="Faces Configuration Only"/>
     <Scope Scope="Project">
-        <Node id="admin/cellphone/admin_contact_cellphone_list.xhtml" x="400" y="900" zoom="true"/>
-        <Node id="admin/contact/admin_contact_show.xhtml" x="400" y="1050" zoom="true"/>
-        <Node id="login/login_change_password.xhtml" x="1400" y="750" zoom="true"/>
-        <Node id="privacy.xhtml" x="650" y="1200" zoom="true"/>
-        <Node id="admin/mobile_provider/admin_mobile_provider_show.xhtml" x="900" y="600" zoom="true"/>
-        <Node id="admin/user/admin_user_show.xhtml" x="400" y="150" zoom="true"/>
-        <Node id="admin/index.xhtml" x="900" y="300" zoom="true"/>
-        <Node id="login/login_start_sharing_addressbook.xhtml" x="1150" y="900" zoom="true"/>
-        <Node id="user/resend_link.xhtml" x="650" y="150" zoom="true"/>
-        <Node id="admin/admin_logout.xhtml" x="900" y="150" zoom="true"/>
-        <Node id="admin/user/admin_user_unlock.xhtml" x="650" y="1050" zoom="true"/>
-        <Node id="index.xhtml" x="1400" y="600" zoom="true"/>
-        <Node id="user/register_done.xhtml" x="150" y="450" zoom="true"/>
-        <Node id="admin/admin_category_delete.xhtml" x="1400" y="300" zoom="true"/>
-        <Node id="*" x="1400" y="450" zoom="true"/>
-        <Node id="user/login_error.xhtml" x="1400" y="150" zoom="true"/>
-        <Node id="admin/cellphone/admin_contact_cellphone_edit.xhtml" x="650" y="300" zoom="true"/>
-        <Node id="user/show_addressbook_entries.xhtml" x="400" y="750" zoom="true"/>
-        <Node id="user/lost_passwd.xhtml" x="650" y="750" zoom="true"/>
-        <Node id="login/login_list_sharing_addressbooks.xhtml" x="2150" y="150" zoom="true"/>
-        <Node id="user/login.xhtml" x="2400" y="150" zoom="true"/>
-        <Node id="admin/cellphone/admin_contact_cellphone_unlink.xhtml" x="150" y="900" zoom="true"/>
-        <Node id="admin/country/admin_country_list.xhtml" x="150" y="1050" zoom="true"/>
-        <Node id="login/login_edit_user_data.xhtml" x="900" y="1050" zoom="true"/>
-        <Node id="login/login_shared_addressbooks.xhtml" x="400" y="300" zoom="true"/>
-        <Node id="admin/mobile_provider/admin_mobile_provider_delete.xhtml" x="900" y="900" zoom="true"/>
-        <Node id="admin/mobile_provider/admin_mobile_provider_list.xhtml" x="900" y="750" zoom="true"/>
-        <Node id="basket.xhtml" x="400" y="600" zoom="true"/>
-        <Node id="admin/cellphone/admin_contact_cellphone_delete.xhtml" x="150" y="300" zoom="true"/>
-        <Node id="exception.xhtml" x="150" y="750" zoom="true"/>
-        <Node id="admin/user/admin_user_delete.xhtml" x="150" y="1200" zoom="true"/>
-        <Node id="login/login_data_saved.xhtml" x="1150" y="750" zoom="true"/>
-        <Node id="user/register.xhtml" x="650" y="600" zoom="true"/>
-        <Node id="login/login_index.xhtml" x="150" y="600" zoom="true"/>
-        <Node id="login/login_add_addressbook.xhtml" x="650" y="450" zoom="true"/>
-        <Node id="login/login_own_addressbooks.xhtml" x="1150" y="300" zoom="true"/>
-        <Node id="admin/user/admin_user_edit.xhtml" x="150" y="1350" zoom="true"/>
-        <Node id="terms.xhtml" x="150" y="150" zoom="true"/>
-        <Node id="admin/contact/admin_contact_edit.xhtml" x="1650" y="150" zoom="true"/>
-        <Node id="admin/user/admin_user_list.xhtml" x="1900" y="300" zoom="true"/>
-        <Node id="admin/country/admin_country_delete.xhtml" x="2150" y="300" zoom="true"/>
-        <Node id="user/user_list.xhtml" x="900" y="450" zoom="true"/>
-        <Node id="admin/country/admin_country_edit.xhtml" x="650" y="900" zoom="true"/>
-        <Node id="logout.xhtml" x="1650" y="450" zoom="true"/>
-        <Node id="login/login_change_personal_data.xhtml" x="1150" y="150" zoom="true"/>
-        <Node id="user/user_profile.xhtml" x="1900" y="450" zoom="true"/>
-        <Node id="user/show_addressbook.xhtml" x="1150" y="600" zoom="true"/>
-        <Node id="imprint.xhtml" x="400" y="1200" zoom="true"/>
-        <Node id="admin/mobile_provider/admin_mobile_provider_edit.xhtml" x="400" y="450" zoom="true"/>
-        <Node id="login/login_other_addressbooks.xhtml" x="1150" y="450" zoom="true"/>
-        <Node id="admin/cellphone/admin_contact_cellphone_show.xhtml" x="1900" y="150" zoom="true"/>
-        <Node id="admin/admin_product_delete.xhtml" x="1650" y="600" zoom="true"/>
-        <Node id="login/login_change_email_address.xhtml" x="1650" y="300" zoom="true"/>
+        <Node id="admin/cellphone/admin_contact_cellphone_list.xhtml" x="650" y="750" zoom="true"/>
+        <Node id="admin/contact/admin_contact_show.xhtml" x="650" y="900" zoom="true"/>
+        <Node id="privacy.xhtml" x="400" y="450" zoom="true"/>
+        <Node id="login/login_change_password.xhtml" x="900" y="300" zoom="true"/>
+        <Node id="admin/mobile_provider/admin_mobile_provider_show.xhtml" x="1400" y="600" zoom="true"/>
+        <Node id="admin/user/admin_user_show.xhtml" x="1400" y="300" zoom="true"/>
+        <Node id="admin/index.xhtml" x="400" y="1350" zoom="true"/>
+        <Node id="login/login_start_sharing_addressbook.xhtml" x="400" y="600" zoom="true"/>
+        <Node id="user/resend_link.xhtml" x="650" y="1050" zoom="true"/>
+        <Node id="admin/admin_logout.xhtml" x="900" y="750" zoom="true"/>
+        <Node id="admin/user/admin_user_unlock.xhtml" x="400" y="300" zoom="true"/>
+        <Node id="index.xhtml" x="900" y="1050" zoom="true"/>
+        <Node id="user/register_done.xhtml" x="1400" y="450" zoom="true"/>
+        <Node id="*" x="1400" y="150" zoom="true"/>
+        <Node id="admin/admin_category_delete.xhtml" x="1650" y="300" zoom="true"/>
+        <Node id="user/login_error.xhtml" x="150" y="1050" zoom="true"/>
+        <Node id="admin/cellphone/admin_contact_cellphone_edit.xhtml" x="1150" y="150" zoom="true"/>
+        <Node id="user/show_addressbook_entries.xhtml" x="150" y="150" zoom="true"/>
+        <Node id="user/lost_passwd.xhtml" x="2150" y="150" zoom="true"/>
+        <Node id="login/login_list_sharing_addressbooks.xhtml" x="650" y="300" zoom="true"/>
+        <Node id="user/login.xhtml" x="650" y="600" zoom="true"/>
+        <Node id="login/login_edit_user_data.xhtml" x="150" y="300" zoom="true"/>
+        <Node id="login/login_contact_data_saved.xhtml" x="400" y="750" zoom="true"/>
+        <Node id="admin/cellphone/admin_contact_cellphone_unlink.xhtml" x="900" y="900" zoom="true"/>
+        <Node id="admin/country/admin_country_list.xhtml" x="650" y="1200" zoom="true"/>
+        <Node id="login/login_shared_addressbooks.xhtml" x="650" y="450" zoom="true"/>
+        <Node id="admin/mobile_provider/admin_mobile_provider_delete.xhtml" x="400" y="1050" zoom="true"/>
+        <Node id="admin/mobile_provider/admin_mobile_provider_list.xhtml" x="150" y="1200" zoom="true"/>
+        <Node id="basket.xhtml" x="150" y="450" zoom="true"/>
+        <Node id="login/login_data_saved.xhtml" x="1900" y="150" zoom="true"/>
+        <Node id="admin/user/admin_user_delete.xhtml" x="1150" y="600" zoom="true"/>
+        <Node id="admin/cellphone/admin_contact_cellphone_delete.xhtml" x="1900" y="450" zoom="true"/>
+        <Node id="exception.xhtml" x="1150" y="900" zoom="true"/>
+        <Node id="user/register.xhtml" x="150" y="750" zoom="true"/>
+        <Node id="login/login_add_addressbook.xhtml" x="150" y="1350" zoom="true"/>
+        <Node id="login/login_index.xhtml" x="150" y="1500" zoom="true"/>
+        <Node id="login/login_own_addressbooks.xhtml" x="1150" y="750" zoom="true"/>
+        <Node id="admin/user/admin_user_edit.xhtml" x="400" y="150" zoom="true"/>
+        <Node id="terms.xhtml" x="1400" y="750" zoom="true"/>
+        <Node id="admin/contact/admin_contact_edit.xhtml" x="900" y="150" zoom="true"/>
+        <Node id="admin/user/admin_user_list.xhtml" x="1150" y="450" zoom="true"/>
+        <Node id="admin/country/admin_country_delete.xhtml" x="900" y="450" zoom="true"/>
+        <Node id="user/user_list.xhtml" x="1150" y="300" zoom="true"/>
+        <Node id="login/login_user_data_saved.xhtml" x="1900" y="300" zoom="true"/>
+        <Node id="logout.xhtml" x="1650" y="150" zoom="true"/>
+        <Node id="admin/country/admin_country_edit.xhtml" x="900" y="600" zoom="true"/>
+        <Node id="user/user_profile.xhtml" x="150" y="600" zoom="true"/>
+        <Node id="login/login_change_personal_data.xhtml" x="2400" y="150" zoom="true"/>
+        <Node id="user/show_addressbook.xhtml" x="650" y="150" zoom="true"/>
+        <Node id="imprint.xhtml" x="2150" y="300" zoom="true"/>
+        <Node id="admin/mobile_provider/admin_mobile_provider_edit.xhtml" x="1650" y="450" zoom="true"/>
+        <Node id="login/login_other_addressbooks.xhtml" x="1650" y="600" zoom="true"/>
+        <Node id="admin/cellphone/admin_contact_cellphone_show.xhtml" x="150" y="900" zoom="true"/>
+        <Node id="admin/admin_product_delete.xhtml" x="400" y="1200" zoom="true"/>
+        <Node id="login/login_change_email_address.xhtml" x="400" y="900" zoom="true"/>
     </Scope>
     <Scope Scope="All Faces Configurations"/>
 </Scene>
diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java
new file mode 100644 (file)
index 0000000..46f154b
--- /dev/null
@@ -0,0 +1,506 @@
+/*
+ * 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.addressbook.beans.contact;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jusercore.events.user.AdminAddedUserEvent;
+
+/**
+ * A user bean (controller)
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("adminContactController")
+@RequestScoped
+public class AddressbookAdminContactWebRequestBean implements AddressbookAdminContactWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_916L;
+
+       /**
+        * An event fired when the administrator has added a new user
+        */
+       @Inject
+       @Any
+       private Event<AdminAddedUserEvent> addedUserEvent;
+
+       /**
+        * Birth day
+        */
+       private Date birthday;
+
+       /**
+        * Cellphone number's carrier
+        */
+       private MobileProvider cellphoneCarrier;
+
+       /**
+        * Cellphone id number
+        */
+       private Long cellphoneId;
+
+       /**
+        * Cellphone number
+        */
+       private Long cellphoneNumber;
+
+       /**
+        * City
+        */
+       private String city;
+
+       /**
+        * Optional comments
+        */
+       private String comment;
+
+       /**
+        * Remote contact bean
+        */
+       private final ContactSessionBeanRemote contactBean;
+
+       /**
+        * Contact id
+        */
+       private Long contactId;
+
+       /**
+        * Country instance
+        */
+       private Country country;
+
+       /**
+        * Email address
+        */
+       private String emailAddress;
+
+       /**
+        * Family name
+        */
+       private String familyName;
+
+       /**
+        * Fax number's area code
+        */
+       private Integer faxAreaCode;
+
+       /**
+        * Country instance for fax number
+        */
+       private Country faxCountry;
+
+       /**
+        * Fax id number
+        */
+       private Long faxId;
+
+       /**
+        * Fax number
+        */
+       private Long faxNumber;
+
+       /**
+        * First name
+        */
+       private String firstName;
+
+       /**
+        * Gender instance
+        */
+       private Gender gender;
+
+       /**
+        * House number
+        */
+       private Short houseNumber;
+
+       /**
+        * Land-line id number
+        */
+       private Long landLineId;
+
+       /**
+        * Phone number area code
+        */
+       private Integer phoneAreaCode;
+
+       /**
+        * Country instance for phone number
+        */
+       private Country phoneCountry;
+
+       /**
+        * Phone number
+        */
+       private Long phoneNumber;
+
+       /**
+        * Street
+        */
+       private String street;
+
+       /**
+        * ZIP code
+        */
+       private Integer zipCode;
+
+       /**
+        * Default constructor
+        */
+       public AddressbookAdminContactWebRequestBean () {
+               // Set gender to UNKNOWN
+               this.gender = Gender.UNKNOWN;
+
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jratecalc-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw again
+                       throw new FaceletException(e);
+               }
+       }
+
+       @Override
+       public void copyContactToController (final Contact contact) {
+               // The contact instance must be valid
+               if (null == contact) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.user.userContact is null");
+               } else if (contact.getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("this.user.userContact.contactId={0} is not valid.", contact.getContactId()));
+               }
+
+               // Set all fields: contact
+               this.setContactId(contact.getContactId());
+               this.setBirthday(contact.getContactBirthday());
+               this.setCity(contact.getContactCity());
+               this.setComment(contact.getContactComment());
+               this.setCountry(contact.getContactCountry());
+               this.setEmailAddress(contact.getContactEmailAddress());
+               this.setFamilyName(contact.getContactFamilyName());
+               this.setFirstName(contact.getContactFirstName());
+               this.setGender(contact.getContactGender());
+               this.setHouseNumber(contact.getContactHouseNumber());
+               this.setStreet(contact.getContactStreet());
+               this.setZipCode(contact.getContactZipCode());
+
+               // ... cellphone data
+               this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId());
+               this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider());
+               this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber());
+
+               // ... fax data
+               this.setFaxId(contact.getContactFaxNumber().getPhoneId());
+               this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
+               this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
+               this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
+
+               // .. land-line data
+               this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
+               this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
+               this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
+               this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
+       }
+
+       @Override
+       public Date getBirthday () {
+               return this.birthday;
+       }
+
+       @Override
+       public void setBirthday (final Date birthday) {
+               this.birthday = birthday;
+       }
+
+       @Override
+       public MobileProvider getCellphoneCarrier () {
+               return this.cellphoneCarrier;
+       }
+
+       @Override
+       public void setCellphoneCarrier (final MobileProvider cellphoneCarrier) {
+               this.cellphoneCarrier = cellphoneCarrier;
+       }
+
+       @Override
+       public Long getCellphoneId () {
+               return this.cellphoneId;
+       }
+
+       @Override
+       public void setCellphoneId (final Long cellphoneId) {
+               this.cellphoneId = cellphoneId;
+       }
+
+       @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 Long getContactId () {
+               return this.contactId;
+       }
+
+       @Override
+       public void setContactId (final Long contactId) {
+               this.contactId = contactId;
+       }
+
+       @Override
+       public Country getCountry () {
+               return this.country;
+       }
+
+       @Override
+       public void setCountry (final Country country) {
+               this.country = country;
+       }
+
+       @Override
+       public String getEmailAddress () {
+               return this.emailAddress;
+       }
+
+       @Override
+       public void setEmailAddress (final String emailAddress) {
+               this.emailAddress = emailAddress;
+       }
+
+       @Override
+       public String getFamilyName () {
+               return this.familyName;
+       }
+
+       @Override
+       public void setFamilyName (final String familyName) {
+               this.familyName = familyName;
+       }
+
+       @Override
+       public Integer getFaxAreaCode () {
+               return this.faxAreaCode;
+       }
+
+       @Override
+       public void setFaxAreaCode (final Integer faxAreaCode) {
+               this.faxAreaCode = faxAreaCode;
+       }
+
+       @Override
+       public Country getFaxCountry () {
+               return this.faxCountry;
+       }
+
+       @Override
+       public void setFaxCountry (final Country faxCountry) {
+               this.faxCountry = faxCountry;
+       }
+
+       @Override
+       public Long getFaxId () {
+               return this.faxId;
+       }
+
+       @Override
+       public void setFaxId (final Long faxId) {
+               this.faxId = faxId;
+       }
+
+       @Override
+       public Long getFaxNumber () {
+               return this.faxNumber;
+       }
+
+       @Override
+       public void setFaxNumber (final Long faxNumber) {
+               this.faxNumber = faxNumber;
+       }
+
+       @Override
+       public String getFirstName () {
+               return this.firstName;
+       }
+
+       @Override
+       public void setFirstName (final String firstName) {
+               this.firstName = firstName;
+       }
+
+       @Override
+       public Gender getGender () {
+               return this.gender;
+       }
+
+       @Override
+       public void setGender (final Gender gender) {
+               this.gender = gender;
+       }
+
+       @Override
+       public Short getHouseNumber () {
+               return this.houseNumber;
+       }
+
+       @Override
+       public void setHouseNumber (final Short houseNumber) {
+               this.houseNumber = houseNumber;
+       }
+
+       @Override
+       public Long getLandLineId () {
+               return this.landLineId;
+       }
+
+       @Override
+       public void setLandLineId (final Long landLineId) {
+               this.landLineId = landLineId;
+       }
+
+       @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 Integer getZipCode () {
+               return this.zipCode;
+       }
+
+       @Override
+       public void setZipCode (final Integer zipCode) {
+               this.zipCode = zipCode;
+       }
+
+       /**
+        * Post-initialization of this class
+        */
+       @PostConstruct
+       public void init () {
+       }
+
+       /**
+        * Clears this bean
+        */
+       private void clear () {
+               // Clear all
+               this.setContactId(null);
+               this.setBirthday(null);
+               this.setCellphoneCarrier(null);
+               this.setCellphoneNumber(null);
+               this.setCity(null);
+               this.setComment(null);
+               this.setCountry(null);
+               this.setEmailAddress(null);
+               this.setFamilyName(null);
+               this.setFaxAreaCode(null);
+               this.setFaxCountry(null);
+               this.setFaxNumber(null);
+               this.setFirstName(null);
+               this.setGender(null);
+               this.setHouseNumber(null);
+               this.setPhoneAreaCode(null);
+               this.setPhoneCountry(null);
+               this.setPhoneNumber(null);
+               this.setStreet(null);
+               this.setZipCode(null);
+       }
+
+}
diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestController.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestController.java
new file mode 100644 (file)
index 0000000..6de461b
--- /dev/null
@@ -0,0 +1,362 @@
+/*
+ * 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.addressbook.beans.contact;
+
+import java.io.Serializable;
+import java.util.Date;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+
+/**
+ * An administrative interface for user beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AddressbookAdminContactWebRequestController extends Serializable {
+
+       /**
+        * Copies given contact's data to this controller
+        * <p>
+        * @param contact Contact instance
+        */
+       void copyContactToController (final Contact contact);
+
+       /**
+        * Getter for cellphone id
+        * <p>
+        * @return Cellphone id
+        */
+       Long getCellphoneId ();
+
+       /**
+        * Setter for cellphone id
+        * <p>
+        * @param cellphoneId Cellphone id
+        */
+       void setCellphoneId (final Long cellphoneId);
+
+       /**
+        * Getter for fax id
+        * <p>
+        * @return Fax id
+        */
+       Long getFaxId ();
+
+       /**
+        * Setter for fax id
+        * <p>
+        * @param faxId Fax id
+        */
+       void setFaxId (final Long faxId);
+
+       /**
+        * Getter for land-line id
+        * <p>
+        * @return Land-line id
+        */
+       Long getLandLineId ();
+
+       /**
+        * Setter for land-line id
+        * <p>
+        * @param landLineId Land-line id
+        */
+       void setLandLineId (final Long landLineId);
+
+       /**
+        * Getter for birth day
+        * <p>
+        * @return Birth day
+        */
+       Date getBirthday ();
+
+       /**
+        * Setter for birth day
+        * <p>
+        * @param birthday Birth day
+        */
+       void setBirthday (final Date birthday);
+
+       /**
+        * Getter for ellphone number's carrier
+        * <p>
+        * @return Cellphone number's carrier
+        */
+       MobileProvider getCellphoneCarrier ();
+
+       /**
+        * Setter for cellphone number's carrier prefix
+        * <p>
+        * @param cellphoneCarrier Cellphone number's carrier prefix
+        */
+       void setCellphoneCarrier (final MobileProvider 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 contact id
+        * <p>
+        * @return Contact id
+        */
+       Long getContactId ();
+
+       /**
+        * Setter for contact id
+        * <p>
+        * @param contactId Contact id
+        */
+       void setContactId (final Long contactId);
+
+       /**
+        * Getter for country instance
+        * <p>
+        * @return Country instance
+        */
+       Country getCountry ();
+
+       /**
+        * Setter for country instance
+        * <p>
+        * @param country Country instance
+        */
+       void setCountry (final Country country);
+
+       /**
+        * Getter for email address
+        * <p>
+        * @return Email address
+        */
+       String getEmailAddress ();
+
+       /**
+        * Setter for email address
+        * <p>
+        * @param emailAddress Email address
+        */
+       void setEmailAddress (final String emailAddress);
+
+       /**
+        * Family name
+        * <p>
+        * @return the familyName
+        */
+       String getFamilyName ();
+
+       /**
+        * Family name
+        * <p>
+        * @param familyName the familyName to set
+        */
+       void setFamilyName (final String familyName);
+
+       /**
+        * Getter for fax number's area code
+        * <p>
+        * @return Fax number's area code
+        */
+       Integer getFaxAreaCode ();
+
+       /**
+        * Setter for fax number's area code
+        * <p>
+        * @param faxAreaCode Fax number's area code
+        */
+       void setFaxAreaCode (final Integer faxAreaCode);
+
+       /**
+        * Getter for fax's country instance
+        * <p>
+        * @return Fax' country instance
+        */
+       Country getFaxCountry ();
+
+       /**
+        * Setter for fax's country instance
+        * <p>
+        * @param faxCountry Fax' country instance
+        */
+       void setFaxCountry (final Country faxCountry);
+
+       /**
+        * Getter for fax number
+        * <p>
+        * @return Fax number
+        */
+       Long getFaxNumber ();
+
+       /**
+        * Setter for fax number
+        * <p>
+        * @param faxNumber Fax number
+        */
+       void setFaxNumber (final Long faxNumber);
+
+       /**
+        * First name
+        * <p>
+        * @return the first name
+        */
+       String getFirstName ();
+
+       /**
+        * First name
+        * <p>
+        * @param firstName the first name to set
+        */
+       void setFirstName (final String firstName);
+
+       /**
+        * Gender of the contact
+        * <p>
+        * @return the gender
+        */
+       Gender getGender ();
+
+       /**
+        * Gender of the contact
+        * <p>
+        * @param gender the gender to set
+        */
+       void setGender (final Gender gender);
+
+       /**
+        * House number
+        * <p>
+        * @return the houseNumber
+        */
+       Short getHouseNumber ();
+
+       /**
+        * House number
+        * <p>
+        * @param houseNumber the houseNumber to set
+        */
+       void setHouseNumber (final Short houseNumber);
+
+       /**
+        * Getter for 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);
+
+       /**
+        * ZIP code
+        * <p>
+        * @return the zipCode
+        */
+       Integer getZipCode ();
+
+       /**
+        * ZIP code
+        * <p>
+        * @param zipCode the zipCode to set
+        */
+       void setZipCode (final Integer zipCode);
+
+}
diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java
new file mode 100644 (file)
index 0000000..7e2c94d
--- /dev/null
@@ -0,0 +1,827 @@
+/*
+ * 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.addressbook.beans.contact;
+
+import java.text.MessageFormat;
+import java.util.Date;
+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.addressbook.beans.login.AddressbookUserLoginWebSessionController;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
+import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+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.mobileprovider.MobileProvider;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
+
+/**
+ * A general contact bean (controller)
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("contactController")
+@SessionScoped
+public class AddressbookContactWebSessionBean implements AddressbookContactWebSessionController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 542_145_347_916L;
+
+       /**
+        * Birth day
+        */
+       private Date birthday;
+
+       /**
+        * Cellphone number's carrier
+        */
+       private MobileProvider cellphoneCarrier;
+
+       /**
+        * Cellphone number
+        */
+       private Long cellphoneNumber;
+
+       /**
+        * City
+        */
+       private String city;
+
+       /**
+        * Optional comments
+        */
+       private String comment;
+
+       /**
+        * Remote contact bean
+        */
+       private final ContactSessionBeanRemote contactBean;
+
+       /**
+        * Contact list
+        */
+       private List<Contact> contactList;
+
+       /**
+        * Country instance
+        */
+       private Country country;
+
+       /**
+        * Email address
+        */
+       private String emailAddress;
+
+       /**
+        * 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 AddressbookUserLoginWebSessionController 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;
+
+       /**
+        * ZIP code
+        */
+       private Integer zipCode;
+
+       /**
+        * Default constructor
+        */
+       public AddressbookContactWebSessionBean () {
+               // Set gender to UNKNOWN
+               this.gender = Gender.UNKNOWN;
+
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jratecalc-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw again
+                       throw new FaceletException(e);
+               }
+       }
+
+       @Override
+       public void addEmailAddress (final String contactEmailAddress) {
+               // Add it
+               this.emailAddressList.add(contactEmailAddress);
+       }
+
+       @Override
+       public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) {
+               // Trace message
+               System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
+
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getRegisteredUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.user is null"); //NOI18N
+               } else if (event.getRegisteredUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.user.userId is null"); //NOI18N
+               } else if (event.getRegisteredUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+               }
+
+               // Get user instance
+               Contact registeredContact = event.getRegisteredUser().getUserContact();
+
+               // Debug message
+               System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: registeredContact={0}", registeredContact)); //NOI18N
+
+               // Copy all data from registered->user
+               this.copyContact(registeredContact);
+
+               // Add user name and email address
+               this.addUserNameEmailAddress(registeredContact);
+
+               // Clear all data
+               this.clear();
+
+               // Trace message
+               System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N
+       }
+
+       @Override
+       public void afterUserLogin (final @Observes UserLoggedInEvent event) {
+               // Trace message
+               System.out.println(MessageFormat.format("ContactWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
+
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getLoggedInUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.user is null"); //NOI18N
+               } else if (event.getLoggedInUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.user.userId is null"); //NOI18N
+               } else if (event.getLoggedInUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
+               }
+
+               // Copy all data to this bean
+               this.copyContact(event.getLoggedInUser().getUserContact());
+
+               // Trace message
+               System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N
+       }
+
+       /**
+        * Clears this bean
+        */
+       @Override
+       public void clear () {
+               // Clear all data
+               // - personal data
+               this.setGender(Gender.UNKNOWN);
+               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);
+       }
+
+       @Override
+       public Contact createContactInstance () {
+               // User message
+               //this.getLogger().logTrace("createContactInstance: CALLED!");
+
+               // Required personal data must be set
+               assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
+
+               // Create new contact instance
+               Contact localContact = new UserContact();
+
+               // Generate phone number
+               DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+               DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
+               DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+
+               // Create new contact
+               Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
+               contact.setContactStreet(this.getStreet());
+               contact.setContactHouseNumber(this.getHouseNumber());
+               contact.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 MobileProvider) && (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.setContactOwnContact(Boolean.TRUE);
+
+               // Trace message
+               //this.getLogger().logTrace(MessageFormat.format("createContactInstance: localContact={0} - EXIT!", localContact));
+               // Return it
+               return localContact;
+       }
+
+       @Override
+       public String doChangePersonalContactData () {
+               // This method shall only be called if the user is logged-in
+               if (!this.loginController.isUserLoggedIn()) {
+                       // Not logged-in
+                       throw new IllegalStateException("User is not logged-in"); //NOI18N
+               } else if (!this.isRequiredChangePersonalDataSet()) {
+                       // Not all required fields are set
+                       throw new FaceletException("Not all required fields are set."); //NOI18N
+               } else if (!this.loginController.ifCurrentPasswordMatches()) {
+                       // Password not matching
+                       throw new FaceletException(new UserPasswordMismatchException(this.loginController.getLoggedInUser()));
+               }
+
+               // Get contact instance
+               Contact contact = this.loginController.getLoggedInUser().getUserContact();
+
+               // It should be there, so run some tests on it
+               assert (contact instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
+               assert (contact.getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
+               assert (contact.getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N
+
+               // Update all fields
+               contact.setContactGender(this.getGender());
+               contact.setContactFirstName(this.getFirstName());
+               contact.setContactFamilyName(this.getFamilyName());
+               contact.setContactStreet(this.getStreet());
+               contact.setContactHouseNumber(this.getHouseNumber());
+               contact.setContactZipCode(this.getZipCode());
+               contact.setContactCity(this.getCity());
+               contact.setContactCountry(this.getCountry());
+
+               // Is there a phone number?
+               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       // Debug message
+                       System.out.println(MessageFormat.format("ContactWebBean:doChangePersonalData: phoneId={0}", contact.getContactLandLineNumber().getPhoneId())); //NOI18N
+
+                       // Yes, then update as well
+                       contact.getContactLandLineNumber().setPhoneAreaCode(this.getPhoneAreaCode());
+                       contact.getContactLandLineNumber().setPhoneNumber(this.getPhoneNumber());
+               }
+
+               // Is there a fax number?
+               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       // Debug message
+                       System.out.println(MessageFormat.format("ContactWebBean:doChangePersonalData: faxId={0}", contact.getContactFaxNumber().getPhoneId())); //NOI18N
+
+                       // Yes, then update as well
+                       contact.getContactFaxNumber().setPhoneAreaCode(this.getFaxAreaCode());
+                       contact.getContactFaxNumber().setPhoneNumber(this.getFaxNumber());
+               }
+
+               // Is there a cellphone number?
+               if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
+                       // Debug message
+                       System.out.println(MessageFormat.format("ContactWebBean:doChangePersonalData: cellPhoneId={0}", contact.getContactCellphoneNumber().getPhoneId())); //NOI18N
+
+                       // Yes, then update as well
+                       contact.getContactCellphoneNumber().setCellphoneProvider(this.getCellphoneCarrier());
+                       contact.getContactCellphoneNumber().setPhoneNumber(this.getCellphoneNumber());
+               }
+
+               // Send it to the EJB
+               this.contactBean.updateContactPersonalData(contact);
+
+               // All fine
+               return "contact_data_saved"; //NOI18N
+       }
+
+       @Override
+       public Date getBirthday () {
+               return this.birthday;
+       }
+
+       @Override
+       public void setBirthday (final Date birthday) {
+               this.birthday = birthday;
+       }
+
+       @Override
+       public MobileProvider getCellphoneCarrier () {
+               return this.cellphoneCarrier;
+       }
+
+       @Override
+       public void setCellphoneCarrier (final MobileProvider 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 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 Integer getZipCode () {
+               return this.zipCode;
+       }
+
+       @Override
+       public void setZipCode (final Integer zipCode) {
+               this.zipCode = zipCode;
+       }
+
+       /**
+        * Post-initialization of this class
+        */
+       @PostConstruct
+       public void init () {
+               // Get full email address list for reducing EJB calls
+               this.emailAddressList = this.contactBean.getEmailAddressList();
+
+               // Get full contact list
+               this.contactList = this.contactBean.getAllContacts();
+       }
+
+       @Override
+       public boolean isEmailAddressRegistered (final Contact contact) {
+               return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress())));
+       }
+
+       @Override
+       public boolean isRequiredChangePersonalDataSet () {
+               return ((this.getGender() != null) &&
+                               (this.getFirstName() != null) &&
+                               (this.getFamilyName() != null) &&
+                               (this.getStreet() != null) &&
+                               (this.getHouseNumber() != null) &&
+                               (this.getZipCode() != null) &&
+                               (this.getCity() != null));
+       }
+
+       @Override
+       public boolean isRequiredPersonalDataSet () {
+               return ((this.getGender() != null) &&
+                               (this.getFirstName() != null) &&
+                               (this.getFamilyName() != null) &&
+                               (this.getStreet() != null) &&
+                               (this.getHouseNumber() != null) &&
+                               (this.getZipCode() != null) &&
+                               (this.getCity() != null) &&
+                               (this.getEmailAddress() != null) &&
+                               (this.getEmailAddressRepeat() != null));
+       }
+
+       @Override
+       public boolean isSameEmailAddressEntered () {
+               return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
+       }
+
+       @Override
+       public Contact lookupContactById (final Long contactId) throws ContactNotFoundException {
+               // Init variable
+               Contact localContact = null;
+
+               // Clear this bean
+               this.clear();
+
+               // Try to lookup it in visible user list
+               for (final Iterator<Contact> iterator = this.contactList.iterator(); iterator.hasNext();) {
+                       // Get next user
+                       Contact next = iterator.next();
+
+                       // Is the user id found?
+                       if (Objects.equals(next.getContactId(), contactId)) {
+                               // Copy to other variable
+                               localContact = next;
+                               break;
+                       }
+               }
+
+               // Is it still null?
+               if (null == localContact) {
+                       // Not visible for the current user
+                       throw new ContactNotFoundException(contactId);
+               }
+
+               // Copy all data to this bean
+               this.copyContact(localContact);
+
+               // Return it
+               return localContact;
+       }
+
+       @Override
+       public void updateContactDataFromController (final Contact userContact) {
+               // Is the instance valid?
+               if (null == userContact) {
+                       // Throw NPE
+                       throw new NullPointerException("userContact is null"); //NOI18N
+               } else if (userContact.getContactId() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("userContact.contactId is null"); //NOI18N
+               } else if (userContact.getContactId() < 1) {
+                       // Not valid id number
+                       throw new IllegalArgumentException(MessageFormat.format("userContact.contactId={0} is not valid.", userContact.getContactId())); //NOI18N
+               }
+
+               // Set all
+               this.copyContact(userContact);
+       }
+
+       /**
+        * Adds email address to bean's internal list.
+        * <p>
+        * @param contact Contact instance
+        */
+       private void addUserNameEmailAddress (final Contact contact) {
+               // Make sure the entry is not added yet
+               if (this.emailAddressList.contains(contact.getContactEmailAddress())) {
+                       // Already added
+                       throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N
+               }
+
+               // Add email addres
+               this.emailAddressList.add(contact.getContactEmailAddress());
+       }
+
+       /**
+        * Copies given contact into the controller
+        * <p>
+        * @param contact Contact instance
+        */
+       private void copyContact (final Contact contact) {
+               // Copy all fields:
+               // - base data
+               this.setGender(contact.getContactGender());
+               this.setFirstName(contact.getContactFirstName());
+               this.setFamilyName(contact.getContactFamilyName());
+               this.setStreet(contact.getContactStreet());
+               this.setHouseNumber(contact.getContactHouseNumber());
+               this.setZipCode(contact.getContactZipCode());
+               this.setCity(contact.getContactCity());
+               this.setCountry(contact.getContactCountry());
+
+               // Get cellphone, phone and fax instance
+               DialableCellphoneNumber cellphone = contact.getContactCellphoneNumber();
+               DialableFaxNumber fax = contact.getContactFaxNumber();
+               DialableLandLineNumber phone = contact.getContactLandLineNumber();
+
+               // - contact data
+               if ((phone instanceof DialableLandLineNumber) && (phone.getPhoneAreaCode() > 0)) {
+                       this.setPhoneCountry(phone.getPhoneCountry());
+                       this.setPhoneAreaCode(phone.getPhoneAreaCode());
+                       this.setPhoneNumber(phone.getPhoneNumber());
+               }
+               if ((cellphone instanceof DialableCellphoneNumber) && (cellphone.getCellphoneProvider() instanceof MobileProvider)) {
+                       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(contact.getContactEmailAddress());
+
+               // -- other data
+               this.setBirthday(contact.getContactBirthday());
+               this.setComment(contact.getContactComment());
+       }
+
+}
diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionController.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionController.java
new file mode 100644 (file)
index 0000000..757b827
--- /dev/null
@@ -0,0 +1,411 @@
+/*
+ * 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.addressbook.beans.contact;
+
+import java.io.Serializable;
+import java.util.Date;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
+import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface AddressbookContactWebSessionController extends Serializable {
+
+       /**
+        * Minimum password length
+        */
+       public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
+
+       /**
+        * Updates all data from bean in given contact instance
+        * <p>
+        * @param userContact Contact instance to update
+        */
+       void updateContactDataFromController (final Contact userContact);
+
+       /**
+        * Adds given email address to list
+        * <p>
+        * @param contactEmailAddress Email address to add
+        */
+       void addEmailAddress (final String contactEmailAddress);
+
+       /**
+        * Tries to lookup contact by given id number. If the user is not found a
+        * proper exceptions are thrown.
+        * <p>
+        * @param contactId Contact id
+        * <p>
+        * @return Contact instance
+        * <p>
+        * @throws ContactNotFoundException If the user is not found
+        */
+       Contact lookupContactById (final Long contactId) throws ContactNotFoundException;
+
+       /**
+        * Clears this controller
+        */
+       void clear ();
+
+       /**
+        * 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);
+
+       /**
+        * Creates an instance from all properties
+        * <p>
+        * @return A contact instance
+        */
+       Contact createContactInstance ();
+
+       /**
+        * Getter for birth day
+        * <p>
+        * @return Birth day
+        */
+       Date getBirthday ();
+
+       /**
+        * Setter for birth day
+        * <p>
+        * @param birthday Birth day
+        */
+       void setBirthday (final Date birthday);
+
+       /**
+        * Getter for ellphone number's carrier
+        * <p>
+        * @return Cellphone number's carrier
+        */
+       MobileProvider getCellphoneCarrier ();
+
+       /**
+        * Setter for cellphone number's carrier prefix
+        * <p>
+        * @param cellphoneCarrier Cellphone number's carrier prefix
+        */
+       void setCellphoneCarrier (final MobileProvider 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, 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);
+
+       /**
+        * ZIP code
+        * <p>
+        * @return the zipCode
+        */
+       Integer getZipCode ();
+
+       /**
+        * ZIP code
+        * <p>
+        * @param zipCode the zipCode to set
+        */
+       void setZipCode (final Integer zipCode);
+
+       /**
+        * Checks whether contact instance's email address is used
+        * <p>
+        * @param contact Contact instance's email address to check
+        * <p>
+        * @return Whether it is already used
+        */
+       boolean isEmailAddressRegistered (final Contact contact);
+
+       /**
+        * Checks whether all required personal data is set
+        * <p>
+        * @return Whether the required personal data is set
+        */
+       boolean isRequiredPersonalDataSet ();
+
+       /**
+        * Checks whether all required personal data is set for changing them
+        * <p>
+        * @return Whether the required personal data is set
+        */
+       boolean isRequiredChangePersonalDataSet ();
+
+       /**
+        * Checks whether same email addresses have been entered
+        * <p>
+        * @return Whether same email addresses have been entered
+        */
+       boolean isSameEmailAddressEntered ();
+
+       /**
+        * Changes logged-in user's personal data if the current password matches
+        * and TAC + privacy statement has been accepted.
+        * <p>
+        * @return New target page
+        */
+       String doChangePersonalContactData ();
+
+}
index 9ddac3e92c089cd2c1543bf17906a73fc7cba21c..24f2a10c19935f4ab4cfdae9725ade3f8f70f1f3 100644 (file)
@@ -40,4 +40,9 @@ public interface AddressbookAdminWebRequestController extends Serializable {
         */
        void setUser (final User user);
 
+       /**
+        * Copies currently set user instance's data to adminUserController
+        */
+       void copyUserToController ();
+
 }
index 29ee85e5b724aa8f3ad3b373f8f43e1c0bc6db4b..0f45c1751766282d8818e6b6264b5401c4f0baa6 100644 (file)
  */
 package org.mxchange.addressbook.beans.helper;
 
+import java.text.MessageFormat;
 import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
 import javax.inject.Named;
+import org.mxchange.addressbook.beans.contact.AddressbookAdminContactWebRequestController;
+import org.mxchange.addressbook.beans.user.AddressbookAdminUserWebSessionController;
+import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jusercore.model.user.User;
 
 /**
@@ -34,6 +39,18 @@ public class AddressbookAdminWebRequestHelper implements AddressbookAdminWebRequ
         */
        private static final long serialVersionUID = 17_258_793_567_145_701L;
 
+       /**
+        * Admin contact controller
+        */
+       @Inject
+       private AddressbookAdminContactWebRequestController adminContactController;
+
+       /**
+        * Admin user controller
+        */
+       @Inject
+       private AddressbookAdminUserWebSessionController adminUserController;
+
        /**
         * User instance
         */
@@ -45,6 +62,30 @@ public class AddressbookAdminWebRequestHelper implements AddressbookAdminWebRequ
        public AddressbookAdminWebRequestHelper () {
        }
 
+       @Override
+       public void copyUserToController () {
+               // Validate user instance
+               if (this.getUser() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.user is null");
+               } else if (this.getUser().getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.user.userId is null");
+               } else if (this.getUser().getUserId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId()));
+               }
+
+               // Set all fields: user
+               this.adminUserController.setUserName(this.getUser().getUserName());
+
+               // Get contact instance (shortens stuff)
+               Contact contact = this.getUser().getUserContact();
+
+               // Call contact controller
+               this.adminContactController.copyContactToController(contact);
+       }
+
        @Override
        public User getUser () {
                return this.user;
index 97bc416832c1037d9e9d16e5625c55dbfa92ff1b..bad5cac17bf85b67d332b5331e00cf2ac37db575 100644 (file)
@@ -134,4 +134,5 @@ public class AddressbookUserRegisterWebSessionBean implements AddressbookUserReg
                        throw new FaceletException(ex);
                }
        }
+
 }
index f5e5685e474319980878ef71c033c8b7e5b23cb9..4173c5242f53d03a624747b19c6d42e584b7311d 100644 (file)
@@ -18,7 +18,6 @@ package org.mxchange.addressbook.beans.user;
 
 import java.text.MessageFormat;
 import java.util.Collections;
-import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
@@ -33,16 +32,6 @@ 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.mobileprovider.MobileProvider;
 import org.mxchange.jusercore.events.user.AdminAddedUserEvent;
 import org.mxchange.jusercore.events.user.AdminUserAddedEvent;
 import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
@@ -55,6 +44,7 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
 import org.mxchange.jusercore.model.user.UserUtils;
 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
 
 /**
  * A user bean (controller)
@@ -78,94 +68,10 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
        private Event<AdminAddedUserEvent> addedUserEvent;
 
        /**
-        * Birth day
+        * Regular contact controller
         */
-       private Date birthday;
-
-       /**
-        * Cellphone number's carrier
-        */
-       private MobileProvider 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;
-
-       /**
-        * 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;
-
-       /**
-        * Phone number area code
-        */
-       private Integer phoneAreaCode;
-
-       /**
-        * Country instance for phone number
-        */
-       private Country phoneCountry;
-
-       /**
-        * Phone number
-        */
-       private Long phoneNumber;
-
-       /**
-        * Street
-        */
-       private String street;
+       @Inject
+       private AddressbookContactWebSessionController contactController;
 
        /**
         * Remote user bean
@@ -193,6 +99,7 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
        private String userPasswordRepeat;
 
        /**
+<<<<<<< HEAD:src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionBean.java
         * ZIP code
         */
        private Integer zipCode;
@@ -207,9 +114,6 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
         * Default constructor
         */
        public AddressbookAdminUserWebSessionBean () {
-               // Set gender to UNKNOWN
-               this.gender = Gender.UNKNOWN;
-
                // Try it
                try {
                        // Get initial context
@@ -233,79 +137,8 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
                localUser.setUserAccountStatus(UserAccountStatus.CONFIRMED);
                localUser.setUserProfileMode(ProfileMode.INVISIBLE);
 
-               // Generate phone number
-               DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
-               DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
-               DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
-
-               // Create new contact
-               Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
-               contact.setContactStreet(this.getStreet());
-               contact.setContactHouseNumber(this.getHouseNumber());
-               contact.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 MobileProvider) && (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());
+               // Create contact instance
+               Contact contact = this.contactController.createContactInstance();
 
                // Set contact in user
                localUser.setUserContact(contact);
@@ -318,7 +151,7 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
                if (this.userController.isUserNameRegistered(localUser)) {
                        // User name is already used
                        throw new FaceletException(new UserNameAlreadyRegisteredException(localUser));
-               } else if (this.userController.isEmailAddressRegistered(localUser)) {
+               } else if (this.contactController.isEmailAddressRegistered(localUser.getUserContact())) {
                        // Email address is already used
                        throw new FaceletException(new EmailAddressAlreadyRegisteredException(localUser));
                } else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) {
@@ -358,6 +191,9 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
 
                // Clear all
                this.clear();
+
+               // Clear contact instance
+               this.contactController.clear();
        }
 
        @Override
@@ -366,186 +202,6 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
                return Collections.unmodifiableList(this.userList);
        }
 
-       @Override
-       public Date getBirthday () {
-               return this.birthday;
-       }
-
-       @Override
-       public void setBirthday (final Date birthday) {
-               this.birthday = birthday;
-       }
-
-       @Override
-       public MobileProvider getCellphoneCarrier () {
-               return this.cellphoneCarrier;
-       }
-
-       @Override
-       public void setCellphoneCarrier (final MobileProvider 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 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 String getUserName () {
                return this.userName;
@@ -576,16 +232,6 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
                this.userPasswordRepeat = userPasswordRepeat;
        }
 
-       @Override
-       public Integer getZipCode () {
-               return this.zipCode;
-       }
-
-       @Override
-       public void setZipCode (final Integer zipCode) {
-               this.zipCode = zipCode;
-       }
-
        @Override
        public boolean hasUsers () {
                return (!this.allUsers().isEmpty());
@@ -602,6 +248,7 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
 
        @Override
        public User lookupUserById (final Long userId) throws UserNotFoundException {
+               // Parameter must be valid
                if (null == userId) {
                        // Throw NPE
                        throw new NullPointerException("userId is null"); //NOI18N
@@ -641,28 +288,9 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW
         */
        private void clear () {
                // Clear all
-               this.setBirthday(null);
-               this.setCellphoneCarrier(null);
-               this.setCellphoneNumber(null);
-               this.setCity(null);
-               this.setComment(null);
-               this.setCountry(null);
-               this.setEmailAddress(null);
-               this.setFamilyName(null);
-               this.setFaxAreaCode(null);
-               this.setFaxCountry(null);
-               this.setFaxNumber(null);
-               this.setFirstName(null);
-               this.setGender(null);
-               this.setHouseNumber(null);
-               this.setPhoneAreaCode(null);
-               this.setPhoneCountry(null);
-               this.setPhoneNumber(null);
-               this.setStreet(null);
                this.setUserName(null);
                this.setUserPassword(null);
                this.setUserPasswordRepeat(null);
-               this.setZipCode(null);
        }
 
        /**
index 26f734ca20d1037f7584773ddd8a609574684fe7..979276d2d3ddced9f325b162224ab3f5c0f3c7a5 100644 (file)
 package org.mxchange.addressbook.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.mobileprovider.MobileProvider;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.User;
 
@@ -65,258 +61,6 @@ public interface AddressbookAdminUserWebSessionController extends Serializable {
         */
        void addUser ();
 
-       /**
-        * 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
-        */
-       MobileProvider getCellphoneCarrier ();
-
-       /**
-        * Setter for cellphone number's carrier prefix
-        * <p>
-        * @param cellphoneCarrier Cellphone number's carrier prefix
-        */
-       void setCellphoneCarrier (final MobileProvider 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);
-
-       /**
-        * 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 name
         * <p>
@@ -359,18 +103,4 @@ public interface AddressbookAdminUserWebSessionController extends Serializable {
         */
        void setUserPasswordRepeat (final String userPasswordRepeat);
 
-       /**
-        * ZIP code
-        * <p>
-        * @return the zipCode
-        */
-       Integer getZipCode ();
-
-       /**
-        * ZIP code
-        * <p>
-        * @param zipCode the zipCode to set
-        */
-       void setZipCode (final Integer zipCode);
-
 }
index 12d19b022d438bb6e8d22ca83192b77cbe590e79..6282bdd5abf02d548e5855daae908e2f5a2f8e51 100644 (file)
@@ -18,7 +18,6 @@ package org.mxchange.addressbook.beans.user;
 
 import java.text.MessageFormat;
 import java.util.Collections;
-import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Objects;
@@ -31,18 +30,10 @@ import javax.inject.Named;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
 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.mobileprovider.MobileProvider;
 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
@@ -50,6 +41,9 @@ 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.addressbook.beans.login.AddressbookUserLoginWebSessionController;
+import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
+import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
 
 /**
  * A user bean (controller)
@@ -65,96 +59,11 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
         */
        private static final long serialVersionUID = 542_145_347_916L;
 
-       /////////////////////// Properties /////////////////////
-       /**
-        * Birth day
-        */
-       private Date birthday;
-
-       /**
-        * Cellphone number's carrier
-        */
-       private MobileProvider 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
+        * General contact controller
         */
-       private Short houseNumber;
+       @Inject
+       private AddressbookContactWebSessionController contactController;
 
        /**
         * Login bean (controller)
@@ -162,26 +71,6 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
        @Inject
        private AddressbookUserLoginWebSessionController 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
         */
@@ -222,18 +111,10 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
         */
        private List<User> visibleUserList;
 
-       /**
-        * ZIP code
-        */
-       private Integer zipCode;
-
        /**
         * Default constructor
         */
        public AddressbookUserWebSessionBean () {
-               // Set gender to UNKNOWN
-               this.gender = Gender.UNKNOWN;
-
                // Try it
                try {
                        // Get initial context
@@ -346,301 +227,54 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
                localUser.setUserName(this.getUserName());
                localUser.setUserProfileMode(this.getUserProfileMode());
 
-               // Generate phone number
-               DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
-               DialableCellphoneNumber cellphone = new CellphoneNumber(this.getCellphoneCarrier(), this.getCellphoneNumber());
-               DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
-
-               // Create new contact
-               Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName());
-               contact.setContactStreet(this.getStreet());
-               contact.setContactHouseNumber(this.getHouseNumber());
-               contact.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 MobileProvider) && (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.setContactOwnContact(Boolean.TRUE);
+               // Create contact instance
+               Contact contact = this.contactController.createContactInstance();
 
                // Set contact in user
                localUser.setUserContact(contact);
 
                // Trace message
                //this.getLogger().logTrace(MessageFormat.format("createUserInstance: user={0} - EXIT!", user));
-
                // Return it
                return localUser;
        }
 
        @Override
-       public Date getBirthday () {
-               return this.birthday;
-       }
-
-       @Override
-       public void setBirthday (final Date birthday) {
-               this.birthday = birthday;
-       }
-
-       @Override
-       public MobileProvider getCellphoneCarrier () {
-               return this.cellphoneCarrier;
-       }
-
-       @Override
-       public void setCellphoneCarrier (final MobileProvider 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;
-       }
+       public String doChangePersonalData () {
+               // This method shall only be called if the user is logged-in
+               if (!this.loginController.isUserLoggedIn()) {
+                       // Not logged-in
+                       throw new IllegalStateException("User is not logged-in"); //NOI18N
+               } else if (!this.isRequiredChangePersonalDataSet()) {
+                       // Not all required fields are set
+                       throw new FaceletException("Not all required fields are set."); //NOI18N
+               } else if (!this.loginController.ifCurrentPasswordMatches()) {
+                       // Password not matching
+                       throw new FaceletException(new UserPasswordMismatchException(this.loginController.getLoggedInUser()));
+               }
 
-       @Override
-       public void setHouseNumber (final Short houseNumber) {
-               this.houseNumber = houseNumber;
-       }
+               // Get user instance
+               User user = this.loginController.getLoggedInUser();
 
-       @Override
-       public Integer getPhoneAreaCode () {
-               return this.phoneAreaCode;
-       }
+               // Copy contact data to contact instance
+               this.contactController.updateContactDataFromController(user.getUserContact());
 
-       @Override
-       public void setPhoneAreaCode (final Integer phoneAreaCode) {
-               this.phoneAreaCode = phoneAreaCode;
-       }
+               // It should be there, so run some tests on it
+               assert (user instanceof User) : "Instance loginController.loggedInUser is null";
+               assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null";
+               assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId());
+               assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null";
+               assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null";
+               assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId());
 
-       @Override
-       public Country getPhoneCountry () {
-               return this.phoneCountry;
-       }
+               // Update all fields
+               user.setUserProfileMode(this.getUserProfileMode());
 
-       @Override
-       public void setPhoneCountry (final Country phoneCountry) {
-               this.phoneCountry = phoneCountry;
-       }
+               // Send it to the EJB
+               this.userBean.updateUserPersonalData(user);
 
-       @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;
+               // All fine
+               return "user_data_saved"; //NOI18N
        }
 
        @Override
@@ -693,16 +327,6 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
                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
         */
@@ -711,9 +335,6 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
                // 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
@@ -724,45 +345,21 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
                }
        }
 
-       @Override
-       public boolean isEmailAddressRegistered (final User user) {
-               return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(user.getUserContact().getContactEmailAddress())));
-       }
-
        @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));
+                               (this.contactController.isRequiredChangePersonalDataSet()));
        }
 
        @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.contactController.isRequiredPersonalDataSet()) &&
                                (this.getUserPassword() != null) &&
                                (this.getUserPasswordRepeat() != null));
        }
 
-       @Override
-       public boolean isSameEmailAddressEntered () {
-               return (Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat()));
-       }
-
        @Override
        public boolean isSamePasswordEntered () {
                return ((!this.getUserPassword().isEmpty()) && (Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())));
@@ -828,7 +425,7 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
                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())) {
+               } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
                        // Already added
                        throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", user.getUserContact().getContactEmailAddress())); //NOI18N
                }
@@ -837,7 +434,7 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
                this.userNameList.add(user.getUserName());
 
                // Add email addres
-               this.emailAddressList.add(user.getUserContact().getContactEmailAddress());
+               this.contactController.addEmailAddress(user.getUserContact().getContactEmailAddress());
        }
 
        /**
@@ -847,26 +444,9 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
                // 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);
@@ -882,39 +462,10 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
                // - 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 MobileProvider)) {
-                       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());
        }
 }
index 769c879551eb3fcbcd47b06840b9931cd47a8cd7..414e8ceea4a28933edfc0640dfac23795633a5bc 100644 (file)
 package org.mxchange.addressbook.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.mobileprovider.MobileProvider;
 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
@@ -80,300 +76,6 @@ public interface AddressbookUserWebSessionController extends Serializable {
         */
        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
-        */
-       MobileProvider getCellphoneCarrier ();
-
-       /**
-        * Setter for cellphone number's carrier prefix
-        * <p>
-        * @param cellphoneCarrier Cellphone number's carrier prefix
-        */
-       void setCellphoneCarrier (final MobileProvider 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>
@@ -444,29 +146,6 @@ public interface AddressbookUserWebSessionController extends Serializable {
         */
        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>
@@ -481,13 +160,6 @@ public interface AddressbookUserWebSessionController extends Serializable {
         */
        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>
@@ -519,4 +191,12 @@ public interface AddressbookUserWebSessionController extends Serializable {
         */
        boolean isUserIdEmpty ();
 
+       /**
+        * Changes logged-in user's personal data if the current password matches
+        * and TAC + privacy statement has been accepted.
+        * <p>
+        * @return New target page
+        */
+       String doChangePersonalData ();
+
 }
index c0b8019492aba09c983047ced82d592d0f1761dc..58fd41d9f634c4664df539dddbfd183caba037e7 100644 (file)
        <navigation-rule>
                <from-view-id>/login/login_change_email_address.xhtml</from-view-id>
                <navigation-case>
-                       <from-outcome>login_data_saved</from-outcome>
-                       <to-view-id>/login/login_data_saved.xhtml</to-view-id>
+                       <from-outcome>contact_data_saved</from-outcome>
+                       <to-view-id>/login/login_contact_data_saved.xhtml</to-view-id>
                </navigation-case>
                <navigation-case>
                        <from-outcome>admin_delete_product</from-outcome>
index 3881afff8f2d3d6dafda33710e92e8f60a509c3f..d27c6c1d6f0163aa4748269c926cdb703aef7660 100644 (file)
@@ -20,7 +20,7 @@
 
                                <div class="table_right">
                                        <ui:include src="/WEB-INF/templates/generic/gender_selection_box.tpl">
-                                               <ui:param name="targetController" value="#{adminUserController}" />
+                                               <ui:param name="targetController" value="#{adminContactController}" />
                                        </ui:include>
                                </div>
 
@@ -33,7 +33,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="firstName" size="10" maxlength="255" value="#{adminUserController.firstName}" required="true">
+                                       <h:inputText class="input" id="firstName" size="10" maxlength="255" value="#{adminContactController.firstName}" required="true">
                                                <f:validator for="firstName" validatorId="NameValidator" />
                                        </h:inputText>
                                </div>
@@ -47,7 +47,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="familyName" size="10" maxlength="255" value="#{adminUserController.familyName}" required="true">
+                                       <h:inputText class="input" id="familyName" size="10" maxlength="255" value="#{adminContactController.familyName}" required="true">
                                                <f:validator for="familyName" validatorId="NameValidator" />
                                        </h:inputText>
                                </div>
@@ -61,7 +61,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="street" size="20" maxlength="255" value="#{adminUserController.street}" />
+                                       <h:inputText class="input" id="street" size="20" maxlength="255" value="#{adminContactController.street}" />
                                </div>
 
                                <div class="clear"></div>
@@ -73,7 +73,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="houseNumber" size="3" maxlength="5" value="#{adminUserController.houseNumber}" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}">
+                                       <h:inputText class="input" id="houseNumber" size="3" maxlength="5" value="#{adminContactController.houseNumber}" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}">
                                                <f:validateLongRange for="houseNumber" minimum="1" maximum="500" />
                                        </h:inputText>
                                </div>
@@ -87,7 +87,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="zipCode" size="5" maxlength="6" value="#{adminUserController.zipCode}" validatorMessage="#{msg.ENTERED_ZIP_CODE_INVALID}">
+                                       <h:inputText class="input" id="zipCode" size="5" maxlength="6" value="#{adminContactController.zipCode}" validatorMessage="#{msg.ENTERED_ZIP_CODE_INVALID}">
                                                <f:validateLongRange for="zipCode" minimum="1" maximum="99999" />
                                        </h:inputText>
                                </div>
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="city" size="10" maxlength="255" value="#{adminUserController.city}" />
+                                       <h:inputText class="input" id="city" size="10" maxlength="255" value="#{adminContactController.city}" />
                                </div>
 
                                <div class="clear"></div>
                                </div>
 
                                <div class="table_right">
-                                       <h:selectOneMenu class="select" id="country" value="#{adminUserController.country}" converter="country">
+                                       <h:selectOneMenu class="select" id="country" value="#{adminContactController.country}" converter="country">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
                                                <f:selectItems value="#{countryController.allCountries()}" var="c" itemValue="#{c}" itemLabel="#{c.countryCode} (#{msg[c.countryI18nkey]})" />
                                        </h:selectOneMenu>
                                </div>
 
                                <div class="table_right">
-                                       <h:selectOneMenu class="select" id="countryPhoneCode" value="#{adminUserController.phoneCountry}" converter="country">
+                                       <h:selectOneMenu class="select" id="countryPhoneCode" value="#{adminContactController.phoneCountry}" converter="country">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
                                                <f:selectItems value="#{countryController.allCountries()}" var="c" itemValue="#{c}" itemLabel="#{c.countryAbroadDialPrefix}#{c.countryPhoneCode}" />
                                        </h:selectOneMenu>
 
-                                       <h:inputText class="input" id="phoneAreaCode" size="5" maxlength="10" value="#{adminUserController.phoneAreaCode}">
+                                       <h:inputText class="input" id="phoneAreaCode" size="5" maxlength="10" value="#{adminContactController.phoneAreaCode}">
                                                <f:validator for="phoneAreaCode" validatorId="PhoneNumberValidator" />
                                        </h:inputText>
 
-                                       <h:inputText class="input" id="phoneNumber" size="10" maxlength="20" value="#{adminUserController.phoneNumber}">
+                                       <h:inputText class="input" id="phoneNumber" size="10" maxlength="20" value="#{adminContactController.phoneNumber}">
                                                <f:validator for="phoneNumber" validatorId="PhoneNumberValidator" />
                                        </h:inputText>
                                </div>
                                </div>
 
                                <div class="table_right">
-                                       <h:selectOneMenu class="select" id="faxCountryCode" value="#{adminUserController.faxCountry}" converter="country">
+                                       <h:selectOneMenu class="select" id="faxCountryCode" value="#{adminContactController.faxCountry}" converter="country">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
                                                <f:selectItems value="#{countryController.allCountries()}" var="c" itemValue="#{c}" itemLabel="#{c.countryAbroadDialPrefix}#{c.countryPhoneCode}" />
                                        </h:selectOneMenu>
 
-                                       <h:inputText class="input" id="faxAreaCode" size="5" maxlength="10" value="#{adminUserController.faxAreaCode}">
+                                       <h:inputText class="input" id="faxAreaCode" size="5" maxlength="10" value="#{adminContactController.faxAreaCode}">
                                                <f:validator for="faxAreaCode" validatorId="PhoneNumberValidator" />
                                        </h:inputText>
 
-                                       <h:inputText class="input" id="faxNumber" size="10" maxlength="20" value="#{adminUserController.faxNumber}">
+                                       <h:inputText class="input" id="faxNumber" size="10" maxlength="20" value="#{adminContactController.faxNumber}">
                                                <f:validator for="faxNumber" validatorId="PhoneNumberValidator" />
                                        </h:inputText>
                                </div>
 
                                <div class="table_right">
                                        <ui:include src="/WEB-INF/templates/generic/mobile_selection_box.tpl">
-                                               <ui:param name="targetController" value="#{adminUserController}" />
+                                               <ui:param name="targetController" value="#{adminContactController}" />
                                        </ui:include>
                                </div>
 
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="emailAddress" size="20" maxlength="255" value="#{adminUserController.emailAddress}" required="true" />
+                                       <h:inputText class="input" id="emailAddress" size="20" maxlength="255" value="#{adminContactController.emailAddress}" required="true" />
                                </div>
 
                                <div class="clear"></div>
index dd1413655a9c4453b09ff21d11ddb84164b31fc3..3ee392292412f54f74e2ab9914eb19786be95a52 100644 (file)
@@ -20,7 +20,7 @@
 
                                <div class="table_right">
                                        <ui:include src="/WEB-INF/templates/generic/gender_selection_box.tpl">
-                                               <ui:param  name="targetController" value="#{userController}" />
+                                               <ui:param  name="targetController" value="#{contactController}" />
                                        </ui:include>
                                </div>
 
@@ -33,7 +33,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="firstName" size="10" maxlength="255" value="#{userController.firstName}" required="true">
+                                       <h:inputText class="input" id="firstName" size="10" maxlength="255" value="#{contactController.firstName}" required="true">
                                                <f:validator for="firstName" validatorId="NameValidator" />
                                        </h:inputText>
                                </div>
@@ -47,7 +47,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="familyName" size="10" maxlength="255" value="#{userController.familyName}" required="true">
+                                       <h:inputText class="input" id="familyName" size="10" maxlength="255" value="#{contactController.familyName}" required="true">
                                                <f:validator for="familyName" validatorId="NameValidator" />
                                        </h:inputText>
                                </div>
@@ -61,7 +61,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="street" size="20" maxlength="255" value="#{userController.street}" required="true">
+                                       <h:inputText class="input" id="street" size="20" maxlength="255" value="#{contactController.street}" required="true">
                                                <f:validator for="street" validatorId="NameValidator" />
                                        </h:inputText>
                                </div>
@@ -75,7 +75,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="houseNumber" size="3" maxlength="5" value="#{userController.houseNumber}" required="true" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}">
+                                       <h:inputText class="input" id="houseNumber" size="3" maxlength="5" value="#{contactController.houseNumber}" required="true" validatorMessage="#{msg.ENTERED_HOUSE_NUMBER_INVALID}">
                                                <f:validateLongRange for="houseNumber" minimum="1" maximum="500" />
                                        </h:inputText>
                                </div>
@@ -89,7 +89,7 @@
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="zipCode" size="5" maxlength="6" value="#{userController.zipCode}" required="true" validatorMessage="#{msg.ENTERED_ZIP_CODE_INVALID}">
+                                       <h:inputText class="input" id="zipCode" size="5" maxlength="6" value="#{contactController.zipCode}" required="true" validatorMessage="#{msg.ENTERED_ZIP_CODE_INVALID}">
                                                <f:validateLongRange for="zipCode" minimum="1" maximum="99999" />
                                        </h:inputText>
                                </div>
                                </div>
 
                                <div class="table_right">
-                                       <h:inputText class="input" id="city" size="10" maxlength="255" value="#{userController.city}" required="true">
+                                       <h:inputText class="input" id="city" size="10" maxlength="255" value="#{contactController.city}" required="true">
                                                <f:validator for="city" validatorId="NameValidator" />
                                        </h:inputText>
                                </div>
                                </div>
 
                                <div class="table_right">
-                                       <h:selectOneMenu class="select" id="country" value="#{userController.country}" converter="country">
+                                       <h:selectOneMenu class="select" id="country" value="#{contactController.country}" converter="country">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
                                                <f:selectItems value="#{country.allCountries()}" var="c" itemValue="#{c}" itemLabel="#{c.countryCode} (#{msg[c.countryI18nkey]})" />
                                        </h:selectOneMenu>
                                </div>
 
                                <div class="table_right">
-                                       <h:selectOneMenu class="select" id="countryPhoneCode" value="#{userController.phoneCountry}" converter="country">
+                                       <h:selectOneMenu class="select" id="countryPhoneCode" value="#{contactController.phoneCountry}" converter="country">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
                                                <f:selectItems value="#{country.allCountries()}" var="c" itemValue="#{c}" itemLabel="#{c.countryAbroadDialPrefix}#{c.countryPhoneCode}" />
                                        </h:selectOneMenu>
 
-                                       <h:inputText class="input" id="phoneAreaCode" size="5" maxlength="10" value="#{userController.phoneAreaCode}">
+                                       <h:inputText class="input" id="phoneAreaCode" size="5" maxlength="10" value="#{contactController.phoneAreaCode}">
                                                <f:validator for="phoneAreaCode" validatorId="PhoneNumberValidator" />
                                        </h:inputText>
 
-                                       <h:inputText class="input" id="phoneNumber" size="10" maxlength="20" value="#{userController.phoneNumber}">
+                                       <h:inputText class="input" id="phoneNumber" size="10" maxlength="20" value="#{contactController.phoneNumber}">
                                                <f:validator for="phoneNumber" validatorId="PhoneNumberValidator" />
                                        </h:inputText>
                                </div>
                                </div>
 
                                <div class="table_right">
-                                       <h:selectOneMenu class="select" id="faxCountryCode" value="#{userController.faxCountry}" converter="country">
+                                       <h:selectOneMenu class="select" id="faxCountryCode" value="#{contactController.faxCountry}" converter="country">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
                                                <f:selectItems value="#{country.allCountries()}" var="c" itemValue="#{c}" itemLabel="#{c.countryAbroadDialPrefix}#{c.countryPhoneCode}" />
                                        </h:selectOneMenu>
 
-                                       <h:inputText class="input" id="faxAreaCode" size="5" maxlength="10" value="#{userController.faxAreaCode}">
+                                       <h:inputText class="input" id="faxAreaCode" size="5" maxlength="10" value="#{contactController.faxAreaCode}">
                                                <f:validator for="faxAreaCode" validatorId="PhoneNumberValidator" />
                                        </h:inputText>
 
-                                       <h:inputText class="input" id="faxNumber" size="10" maxlength="20" value="#{userController.faxNumber}">
+                                       <h:inputText class="input" id="faxNumber" size="10" maxlength="20" value="#{contactController.faxNumber}">
                                                <f:validator for="faxNumber" validatorId="PhoneNumberValidator" />
                                        </h:inputText>
                                </div>
 
                                <div class="table_right">
                                        <ui:include src="/WEB-INF/templates/generic/mobile_selection_box.tpl">
-                                               <ui:param name="targetController" value="#{userController}" />
+                                               <ui:param name="targetController" value="#{contactController}" />
                                        </ui:include>
                                </div>
 
index 4d3c97fe8aace47a02efc8a6a31bef75e91718f6..123924a444a672beebe75ccd023ef541010b6ff0 100644 (file)
                <ui:define name="content">
                        <h:outputText styleClass="errors" value="#{msg.ERROR_USER_ID_NOT_FOUND}" rendered="#{empty adminHelper.user}" />
 
-                       Here goes your content.
+                       <h:form id="admin_edit_user" rendered="#{not empty adminHelper.user}">
+                               <f:metadata>
+                                       <f:viewAction action="#{adminHelper.copyUserToController()}" />
+                               </f:metadata>
+                       </h:form>
                </ui:define>
        </ui:composition>
 </html>
diff --git a/web/login/login_contact_data_saved.xhtml b/web/login/login_contact_data_saved.xhtml
new file mode 100644 (file)
index 0000000..25b6967
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
+       lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
+       xmlns="http://www.w3.org/1999/xhtml"
+         xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+         xmlns:h="http://xmlns.jcp.org/jsf/html"
+         xmlns:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <ui:composition template="/WEB-INF/templates/login/login_base.tpl">
+               <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_CONTACT_DATA_SAVED}</ui:define>
+
+               <ui:define name="content_header">
+                       #{msg.CONTENT_TITLE_LOGIN_CONTACT_DATA_SAVED}
+               </ui:define>
+
+               <ui:define name="content">
+                       <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
+                               <ui:include id="message_box" src="/WEB-INF/templates/generic/message_box.tpl">
+                                       <ui:param name="message" value="#{msg.LOGIN_MESSAGE_DATA_SAVED}" />
+                               </ui:include>
+                       </ui:fragment>
+
+                       <ui:fragment rendered="#{not loginController.isUserLoggedIn()}">
+                               <ui:include id="login_only" src="/WEB-INF/templates/generic/user_not_logged_in.tpl" />
+                       </ui:fragment>
+               </ui:define>
+       </ui:composition>
+</html>
diff --git a/web/login/login_user_data_saved.xhtml b/web/login/login_user_data_saved.xhtml
new file mode 100644 (file)
index 0000000..e42c555
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
+       lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
+       xmlns="http://www.w3.org/1999/xhtml"
+         xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+         xmlns:h="http://xmlns.jcp.org/jsf/html"
+         xmlns:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <ui:composition template="/WEB-INF/templates/login/login_base.tpl">
+               <ui:define name="login_title">#{msg.PAGE_TITLE_LOGIN_USER_DATA_SAVED}</ui:define>
+
+               <ui:define name="content_header">
+                       #{msg.CONTENT_TITLE_LOGIN_USER_DATA_SAVED}
+               </ui:define>
+
+               <ui:define name="content">
+                       <ui:fragment rendered="#{loginController.isUserLoggedIn()}">
+                               <ui:include id="message_box" src="/WEB-INF/templates/generic/message_box.tpl">
+                                       <ui:param name="message" value="#{msg.LOGIN_MESSAGE_DATA_SAVED}" />
+                               </ui:include>
+                       </ui:fragment>
+
+                       <ui:fragment rendered="#{not loginController.isUserLoggedIn()}">
+                               <ui:include id="login_only" src="/WEB-INF/templates/generic/user_not_logged_in.tpl" />
+                       </ui:fragment>
+               </ui:define>
+       </ui:composition>
+</html>