]> git.mxchange.org Git - jjobs-war.git/commitdiff
removed double //NOI18N (please cherry-pick)
authorRoland Häder <roland@mxchange.org>
Mon, 15 Aug 2016 14:32:40 +0000 (16:32 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 19 Aug 2016 21:33:05 +0000 (23:33 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java
src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java
src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java
src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java
src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java [new file with mode: 0644]
src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationController.java [new file with mode: 0644]
src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java

index 189f9cea1c16fac602f2a01abf1d9451be743942..e0b78c39a6d8ba03769f7bad1ef1d59abc328878 100644 (file)
@@ -350,7 +350,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                        throw new NullPointerException("contact is null"); //NOI18N
                } else if (contact.getContactId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
                } else if (contact.getContactId() < 1) {
                        // Not valid
                        throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
@@ -443,7 +443,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement
                        throw new NullPointerException("beanHelper.contact is null"); //NOI18N
                } else if (contact.getContactId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N //NOI18N
+                       throw new NullPointerException("beanHelper.contact.contactId is null"); //NOI18N
                } else if (contact.getContactId() < 1) {
                        // Invalid id
                        throw new IllegalStateException(MessageFormat.format("beanHelper.contact.contactId={0} is invalid", contact.getContactId())); //NOI18N
index c3807eda577036c37d2435b10e6d1a932f2eaf8a..1fb75c849f023a15272b66671ce07992b9d2de07 100644 (file)
@@ -264,7 +264,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
                        throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
                } else if (event.getAddedContact().getContactId() < 1) {
                        // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
                }
 
                // Clear this bean
index a251d6c7f514b2822e3b92c2b1e27b27d2225764..32c6829ad12a36477b04fbaf97e7df635fd20ffa 100644 (file)
@@ -101,7 +101,7 @@ public class JobsAdminContactPhoneWebRequestBean extends BaseJobsController impl
                        throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
                } else if (event.getAddedContact().getContactId() < 1) {
                        // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
                }
 
                // Clear this bean
index 970c1fd625a11248cb6fb0cda6eacd49654d4278..4cd5abce5748661c9f8a796279b42269fd7ec00f 100644 (file)
@@ -92,7 +92,7 @@ public class JobsContactPhoneWebSessionBean extends BaseLandingController implem
                        throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
                } else if (event.getAddedContact().getContactId() < 1) {
                        // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
                }
 
                // Clear this bean
index 1249feabab9a98594eb4d7fca6a0f829475b1ca1..9eb104552cdfba02f57903dc0424a24a22a775d7 100644 (file)
@@ -29,10 +29,6 @@ import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jjobs.beans.BaseJobsController;
 import org.mxchange.jjobs.beans.helper.JobsWebRequestController;
-import org.mxchange.jphone.events.cellphone.deleted.AdminCellphoneNumberDeletedEvent;
-import org.mxchange.jphone.events.cellphone.deleted.AdminDeletedCellphoneNumberEvent;
-import org.mxchange.jphone.events.updated.AdminCellphoneNumberUpdatedEvent;
-import org.mxchange.jphone.events.updated.AdminUpdatedCellphoneNumberEvent;
 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
 import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote;
diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationBean.java
new file mode 100644 (file)
index 0000000..2209e11
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * 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.jjobs.beans.phone;
+
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jjobs.beans.BaseJobsController;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+
+/**
+ * Regular controller (bean) for phone numbers
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("phoneController")
+@ApplicationScoped
+public class JobsPhoneWebApplicationBean extends BaseJobsController implements JobsPhoneWebApplicationController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 491_058_674_675_690_105L;
+
+       /**
+        * All cell phone numbers
+        */
+       private final List<DialableCellphoneNumber> cellphoneNumbers;
+
+       /**
+        * All fax numbers
+        */
+       private final List<DialableFaxNumber> faxNumbers;
+
+       /**
+        * All land-line numbers
+        */
+       private final List<DialableLandLineNumber> landLineNumbers;
+
+       /**
+        * General EJB for phone numbers
+        */
+       private PhoneSessionBeanRemote phoneBean;
+
+       /**
+        * Default constructor
+        */
+       public JobsPhoneWebApplicationBean () {
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup the beans
+                       this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw it again
+                       throw new FaceletException(e);
+               }
+
+               // Init all lists
+               this.cellphoneNumbers = new LinkedList<>();
+               this.faxNumbers = new LinkedList<>();
+               this.landLineNumbers = new LinkedList<>();
+       }
+
+       @Override
+       public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
+               // The event must be valid
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getAddedContact() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("event.addedContact is null"); //NOI18N
+               } else if (event.getAddedContact().getContactId() == null) {
+                       // ... and again
+                       throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+               } else if (event.getAddedContact().getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N
+               }
+
+               // Update contact's cellphone, land-line and fax number
+               this.updateContactPhoneNumbers(event.getAddedContact());
+
+               // Clear this bean
+               this.clear();
+       }
+
+       @Override
+       public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getAddedUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.addedUser is null"); //NOI18N
+               } else if (event.getAddedUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+               } else if (event.getAddedUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+               }
+
+               // Update contact's cellphone, land-line and fax number
+               this.updateContactPhoneNumbers(event.getAddedUser().getUserContact());
+
+               // Clear all data
+               this.clear();
+       }
+
+       @Override
+       public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUpdatedContact() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.updatedContact is null"); //NOI18N
+               } else if (event.getUpdatedContact().getContactId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
+               } else if (event.getUpdatedContact().getContactId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+               }
+
+               // Update contact's cellphone, land-line and fax number
+               this.updateContactPhoneNumbers(event.getUpdatedContact());
+
+               // Clear all data
+               this.clear();
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<DialableCellphoneNumber> allCellphoneNumbers () {
+               return this.cellphoneNumbers;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<DialableFaxNumber> allFaxNumbers () {
+               return this.faxNumbers;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<DialableLandLineNumber> allLandLineNumbers () {
+               return this.landLineNumbers;
+       }
+
+       /**
+        * Post-construction method
+        */
+       @PostConstruct
+       public void init () {
+               // All phone numbers
+               this.cellphoneNumbers.addAll(this.phoneBean.allCellphoneNumbers());
+               this.faxNumbers.addAll(this.phoneBean.allFaxNumbers());
+               this.landLineNumbers.addAll(this.phoneBean.allLandLineNumbers());
+       }
+
+       /**
+        * Clears this bean
+        */
+       private void clear () {
+               // Clear all data
+       }
+
+       /**
+        * Uniquely add given cellphone number to this bean's list. First remove the
+        * old instance (by id number), then re-add it again.
+        * <p>
+        * @param cellphoneNumber Cellphone number to add
+        */
+       private void uniqueAddCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) {
+               // Make sure the parameter is valid
+               if (null == cellphoneNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("cellphoneNumber is null");
+               } else if (cellphoneNumber.getPhoneId() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("cellphoneNumber.phoneId is null");
+               } else if (cellphoneNumber.getPhoneId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("cellphoneNumber.phoneId={0} is not valid.", cellphoneNumber.getPhoneId()));
+               }
+
+               // First remove it by object
+               if (!this.cellphoneNumbers.remove(cellphoneNumber)) {
+                       // Did not work, try by id number
+                       for (final DialableCellphoneNumber cell : this.cellphoneNumbers) {
+                               // Is id number the same?
+                               if (Objects.equals(cell.getPhoneId(), cellphoneNumber.getPhoneId())) {
+                                       // Found it
+                                       this.cellphoneNumbers.remove(cell);
+                                       break;
+                               }
+                       }
+               }
+
+               // ... then add it
+               this.cellphoneNumbers.add(cellphoneNumber);
+       }
+
+       /**
+        * Uniquely add given fax number to this bean's list. First remove the old
+        * instance (by id number), then re-add it again.
+        * <p>
+        * @param faxNumber number to add
+        */
+       private void uniqueAddFaxNumber (final DialableFaxNumber faxNumber) {
+               // Make sure the parameter is valid
+               if (null == faxNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("faxNumber is null");
+               } else if (faxNumber.getPhoneId() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("faxNumber.phoneId is null");
+               } else if (faxNumber.getPhoneId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid.", faxNumber.getPhoneId()));
+               }
+
+               // First remove it
+               if (!this.faxNumbers.remove(faxNumber)) {
+                       // Did not work, try by id number
+                       for (final DialableFaxNumber fax : this.faxNumbers) {
+                               // Is id number the same?
+                               if (Objects.equals(fax.getPhoneId(), faxNumber.getPhoneId())) {
+                                       // Found it
+                                       this.faxNumbers.remove(fax);
+                                       break;
+                               }
+                       }
+               }
+
+               // ... then add it
+               this.faxNumbers.add(faxNumber);
+       }
+
+       /**
+        * Uniquely add given land-line number to this bean's list. First remove the
+        * old instance (by id number), then re-add it again.
+        * <p>
+        * @param landLineNumber Land-line number to add
+        */
+       private void uniqueAddLandLineNumber (final DialableLandLineNumber landLineNumber) {
+               // Make sure the parameter is valid
+               if (null == landLineNumber) {
+                       // Throw NPE
+                       throw new NullPointerException("landLineNumber is null");
+               } else if (landLineNumber.getPhoneId() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("landLineNumber.phoneId is null");
+               } else if (landLineNumber.getPhoneId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid.", landLineNumber.getPhoneId()));
+               }
+
+               // First remove it
+               if (!this.landLineNumbers.remove(landLineNumber)) {
+                       // Did not work, try by id number
+                       for (final DialableLandLineNumber landLine : this.landLineNumbers) {
+                               // Is id number the same?
+                               if (Objects.equals(landLine.getPhoneId(), landLineNumber.getPhoneId())) {
+                                       // Found it
+                                       this.landLineNumbers.remove(landLine);
+                                       break;
+                               }
+                       }
+               }
+
+               // ... then add it
+               this.landLineNumbers.add(landLineNumber);
+       }
+
+       /**
+        * Updates given contact's cellphone, land-line and fax number
+        * <p>
+        * @param contact Contact instance
+        */
+       private void updateContactPhoneNumbers (final Contact contact) {
+               // Parameter must be valid
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null");
+               } else if (contact.getContactId() == null) {
+                       // Throw again
+                       throw new NullPointerException("contact.contactId is null");
+               } else if (contact.getContactId() < 1) {
+                       // Id number is not valid
+               }
+
+               // Is cellphone set?
+               if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
+                       // Unique-add it
+                       this.uniqueAddCellphoneNumber(contact.getContactCellphoneNumber());
+               }
+
+               // Is land-line set?
+               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       // Unique-add it
+                       this.uniqueAddLandLineNumber(contact.getContactLandLineNumber());
+               }
+
+               // Is fax set?
+               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       // Unique-add it
+                       this.uniqueAddFaxNumber(contact.getContactFaxNumber());
+               }
+       }
+
+}
diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationController.java b/src/java/org/mxchange/jjobs/beans/phone/JobsPhoneWebApplicationController.java
new file mode 100644 (file)
index 0000000..004a698
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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.jjobs.beans.phone;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.ejb.Local;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+
+/**
+ * An interface for a request web controller (bean) for administrative phone
+ * number purposes.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Local
+public interface JobsPhoneWebApplicationController extends Serializable {
+
+       /**
+        * Event observer for newly added users by adminstrator
+        * <p>
+        * @param event Event being fired
+        */
+       void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
+
+       /**
+        * Observes events being fired when an administrator has added a new
+        * contact.
+        * <p>
+        * @param event Event being fired
+        */
+       void afterAdminAddedContact (final AdminAddedContactEvent event);
+
+       /**
+        * Event observer for updated contact data by administrators
+        * <p>
+        * @param event Updated contact data event
+        */
+       void afterAdminUpdatedContactDataEvent (final AdminUpdatedContactEvent event);
+
+       /**
+        * Returns a list of all cellphone numbers. For performance reasons, the
+        * controller (bean) should be application-scoped as from user to user
+        * nothing changes. And the controller's post-construct method should load
+        * all numbers and cache it in the controller.
+        * <p>
+        * @return List of all cell phone numbers
+        */
+       List<DialableCellphoneNumber> allCellphoneNumbers ();
+
+       /**
+        * Returns a list of all fax numbers. For performance reasons, the
+        * controller (bean) should be application-scoped as from user to user
+        * nothing changes. And the controller's post-construct method should load
+        * all numbers and cache it in the controller.
+        * <p>
+        * @return List of all fax numbers
+        */
+       List<DialableFaxNumber> allFaxNumbers ();
+
+       /**
+        * Returns a list of all land-line numbers. For performance reasons, the
+        * controller (bean) should be application-scoped as from user to user
+        * nothing changes. And the controller's post-construct method should load
+        * all numbers and cache it in the controller.
+        * <p>
+        * @return List of all land-line numbers
+        */
+       List<DialableLandLineNumber> allLandLineNumbers ();
+
+}
index 09d3c631bb6302a8fa653ce3738b387d8c430bd6..53c412f6a01528b27680e82b941c128ab079ce23 100644 (file)
@@ -205,8 +205,8 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
                                throw new NullPointerException("contactController.gender is null"); //NOI18N
                        } else if (this.contactController.getFirstName() == null) {
                                // ... and again
-                               throw new NullPointerException("contactController.firstName is null"); //NOI18N //NOI18N
-                       } else if (this.contactController.getFirstName().isEmpty()) {
+                               throw new NullPointerException("contactController.firstName is null"); //NOI18N
+                       } else if (this.adminContactController.getFirstName().isEmpty()) {
                                // ... and again
                                throw new IllegalArgumentException("contactController.firstName is empty"); //NOI18N
                        } else if (this.adminContactController.getFamilyName() == null) {
@@ -214,22 +214,13 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
                                throw new NullPointerException("contactController.familyName is null"); //NOI18N
                        } else if (this.contactController.getFamilyName().isEmpty()) {
                                // ... and again
-                               throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N //NOI18N
-                       } else if (this.contactController.getEmailAddress() == null) {
+                               throw new IllegalArgumentException("contactController.familyName is empty"); //NOI18N
+                       } else if (this.adminContactController.getEmailAddress() == null) {
                                // ... and again
                                throw new NullPointerException("contactController.emailAddress is null"); //NOI18N
                        } else if (this.adminContactController.getEmailAddress().isEmpty()) {
                                // ... and again
-                               throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N //NOI18N
-                       } else if (this.contactController.getEmailAddressRepeat() == null) {
-                               // ... and again
-                               throw new NullPointerException("contactController.emailAddressRepeat is null");
-                       } else if (this.contactController.getEmailAddressRepeat().isEmpty()) {
-                               // ... and again
-                               throw new IllegalArgumentException("contactController.emailAddressRepeat is empty"); //NOI18N //NOI18N
-                       } else if (!Objects.equals(this.contactController.getEmailAddress(), this.contactController.getEmailAddressRepeat())) {
-                               // Is not same email address
-                               throw new IllegalArgumentException("Both entered email addresses don't match.");
+                               throw new IllegalArgumentException("contactController.emailAddress is empty"); //NOI18N
                        }
                }
 
@@ -364,7 +355,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J
                        throw new NullPointerException("beanHelper.user is null"); //NOI18N
                } else if (user.getUserId() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("beanHelper.user.userId is null"); //NOI18N //NOI18N
+                       throw new NullPointerException("beanHelper.user.userId is null"); //NOI18N
                } else if (user.getUserId() < 1) {
                        // Invalid id
                        throw new IllegalStateException(MessageFormat.format("beanHelper.user.userId={0} is invalid", user.getUserId())); //NOI18N
index addfdd7e4fd0217343da834f94a8c6a7948cff56..b7897b2d09856e8e90dc46868a7c8e967fa6ca8a 100644 (file)
@@ -161,7 +161,7 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                        Context context = new InitialContext();
 
                        // Try to lookup
-                       this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+                       this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
                } catch (final NamingException e) {
                        // Throw again
                        throw new FaceletException(e);
@@ -170,9 +170,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
 
        @Override
        public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminAddedUserEvent: event={0} - CALLED!", event)); //NOI18N
-
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -221,8 +218,8 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                // Clear all data
                this.clear();
 
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminAddedUserEvent: EXIT!"); //NOI18N
+               // Set user id again
+               this.setUserId(event.getLinkedUser().getUserId());
        }
 
        @Override
@@ -269,9 +266,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
 
        @Override
        public void afterAdminUpdatedUserDataEvent (@Observes final AdminUpdatedUserDataEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminUpdatedUserEvent: event={0} - CALLED!", event)); //NOI18N
-
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -292,16 +286,10 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
 
                // Clear all data
                this.clear();
-
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminUpdatedUserEvent: EXIT!"); //NOI18N
        }
 
        @Override
        public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
-
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -320,9 +308,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                // Get user instance
                User registeredUser = event.getRegisteredUser();
 
-               // Debug message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
-
                // Copy all data from registered->user
                this.copyUser(registeredUser);
 
@@ -343,16 +328,10 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
 
                // Set user id again
                this.setUserId(registeredUser.getUserId());
-
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterRegistration: EXIT!"); //NOI18N
        }
 
        @Override
        public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
-
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -374,9 +353,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
 
        @Override
        public void afterUserLogin (@Observes final UserLoggedInEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
-
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -463,9 +439,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
 
        @Override
        public User createUserInstance (final boolean createContactData) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: CALLED!", this.getClass().getSimpleName()));
-
                // Required personal data must be set
                assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
 
@@ -499,25 +472,16 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                        // Create contact instance
                        Contact contact = this.contactController.createContactInstance();
 
-                       // Debug message
-                       //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: contact={1}", this.getClass().getSimpleName(), contact));
-
                        // Set contact in user
                        user.setUserContact(contact);
                }
 
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: user={1} - EXIT!", this.getClass().getSimpleName(), user));
-
                // Return it
                return user;
        }
 
        @Override
        public User createUserLogin () {
-               // Trace message
-               //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: CALLED!", this.getClass().getSimpleName()));
-
                // Is all data set?
                if (this.getUserName() == null) {
                        // Throw NPE
@@ -533,9 +497,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                // Update all data ...
                recruiter.setUserName(this.getUserName());
 
-               // Trace message
-               //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: recruiter={1} - EXIT!", this.getClass().getSimpleName(), recruiter));
-
                // Return the new instance
                return recruiter;
        }
@@ -765,14 +726,14 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
        }
 
        @Override
-       public User lookupUserById (final Long userId) throws UserNotFoundException {
+       public User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException {
                // Parameter must be valid
-               if (null == userId) {
+               if (null == emailAddress) {
                        // Throw NPE
-                       throw new NullPointerException("userId is null"); //NOI18N
-               } else if (userId < 1) {
+                       throw new NullPointerException("emailAddress is null"); //NOI18N
+               } else if (emailAddress.isEmpty()) {
                        // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
+                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
                }
 
                // Init variable
@@ -783,8 +744,17 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                        // Get next user
                        User next = iterator.next();
 
-                       // Is the user id found?
-                       if (Objects.equals(next.getUserId(), userId)) {
+                       // Contact should be set
+                       if (next.getUserContact() == null) {
+                               // Contact is null
+                               throw new NullPointerException(MessageFormat.format("next.userContact is null for user id {0}", next.getUserId())); //NOI18N
+                       } else if (next.getUserContact().getContactEmailAddress() == null) {
+                               // Email address should be set
+                               throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getUserId())); //NOI18N
+                       }
+
+                       // Is the email address found?
+                       if (Objects.equals(next.getUserContact().getContactEmailAddress(), emailAddress)) {
                                // Copy to other variable
                                user = next;
                                break;
@@ -794,7 +764,7 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                // Is it still null?
                if (null == user) {
                        // Not visible for the current user
-                       throw new UserNotFoundException(userId);
+                       throw new UserEmailAddressNotFoundException(emailAddress);
                }
 
                // Return it
@@ -802,14 +772,14 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
        }
 
        @Override
-       public User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException {
+       public User lookupUserById (final Long userId) throws UserNotFoundException {
                // Parameter must be valid
-               if (null == emailAddress) {
+               if (null == userId) {
                        // Throw NPE
-                       throw new NullPointerException("emailAddress is null"); //NOI18N
-               } else if (emailAddress.isEmpty()) {
+                       throw new NullPointerException("userId is null"); //NOI18N
+               } else if (userId < 1) {
                        // Not valid
-                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
                }
 
                // Init variable
@@ -820,17 +790,8 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                        // Get next user
                        User next = iterator.next();
 
-                       // Contact should be set
-                       if (next.getUserContact() == null) {
-                               // Contact is null
-                               throw new NullPointerException(MessageFormat.format("next.userContact is null for user id {0}", next.getUserId())); //NOI18N
-                       } else if (next.getUserContact().getContactEmailAddress() == null) {
-                               // Email address should be set
-                               throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getUserId())); //NOI18N //NOI18N
-                       }
-
-                       // Is the email address found?
-                       if (Objects.equals(next.getUserContact().getContactEmailAddress(), emailAddress)) {
+                       // Is the user id found?
+                       if (Objects.equals(next.getUserId(), userId)) {
                                // Copy to other variable
                                user = next;
                                break;
@@ -840,7 +801,7 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                // Is it still null?
                if (null == user) {
                        // Not visible for the current user
-                       throw new UserEmailAddressNotFoundException(emailAddress);
+                       throw new UserNotFoundException(userId);
                }
 
                // Return it
@@ -858,9 +819,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                if (this.userNameList.contains(user.getUserName())) {
                        // Abort here
                        throw new IllegalArgumentException(MessageFormat.format("User name {0} already added.", user.getUserName())); //NOI18N
-               } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
-                       // Already added
-                       throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", user.getUserContact().getContactEmailAddress())); //NOI18N
                }
 
                // Add user name