From: Roland Häder Date: Wed, 27 Apr 2016 15:51:06 +0000 (+0200) Subject: Continued with contact: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eba7333678e67766e8409892c868db71bdf38d3b;p=jjobs-war.git Continued with contact: - added observers for events being fired when admin added new contact - cleared admin contact bean after adding contact Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index 936b6fba..48d8e53f 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -285,6 +285,9 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques // Fire event this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact)); + // Clear this bean + this.clear(); + // Return outcome return "admin_list_contact"; //NOI18N } diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java index c5b011c8..9770590c 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java @@ -36,6 +36,7 @@ import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; import org.mxchange.jcontacts.contact.UserContact; import org.mxchange.jcontacts.contact.gender.Gender; import org.mxchange.jcontacts.contact.utils.ContactUtils; +import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcountry.data.Country; diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java index 811e4db8..dd508b54 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java @@ -21,6 +21,7 @@ import java.util.Date; import java.util.List; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.gender.Gender; +import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactNotFoundException; import org.mxchange.jcountry.data.Country; @@ -69,13 +70,6 @@ public interface JobsContactWebSessionController extends Serializable { */ void updateContactDataFromController (final Contact userContact); - /** - * Adds given email address to list - *

- * @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. @@ -95,6 +89,14 @@ public interface JobsContactWebSessionController extends Serializable { */ void afterRegistrationEvent (final UserRegisteredEvent event); + /** + * Observes events being fired when an administrator has added a new + * contact. + *

+ * @param event Event being fired + */ + void afterAdminAddedContact (final AdminAddedContactEvent event); + /** * Event observer for updated contact data by admins *

diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java index 64bc0049..485fbe25 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java @@ -33,12 +33,9 @@ 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.jjobs.beans.contact.JobsContactWebSessionController; import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; @@ -152,6 +149,27 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController { } } + @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.customerId is null"); //NOI18N + } else if (event.getAddedContact().getContactId() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("event.addedContact.customerId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N + } + + // Call other method + this.selectableContacts.add(event.getAddedContact()); + } + @Override public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) { // Trace message diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java index e7869ec9..ddb7d4e9 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java @@ -19,6 +19,7 @@ package org.mxchange.jjobs.beans.user; import java.io.Serializable; import java.util.List; import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; @@ -105,6 +106,14 @@ public interface JobsUserWebSessionController extends Serializable { */ boolean isContactFound (final Contact contact); + /** + * Observes events being fired when an administrator has added a new + * contact. + *

+ * @param event Event being fired + */ + void afterAdminAddedContact (final AdminAddedContactEvent event); + /** * Checks whether a public user account is registered. This means that at * least one user profile has its flag "public user profile" enabled.