]> git.mxchange.org Git - addressbook-war.git/commitdiff
Continued with contact:
authorRoland Häder <roland@mxchange.org>
Wed, 27 Apr 2016 15:51:06 +0000 (17:51 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 10 May 2016 18:44:26 +0000 (20:44 +0200)
- added observers for events being fired when admin added new contact
- cleared admin contact bean after adding contact

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionController.java
src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java
src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java

index bb46862f09f055ba0677852c59b6acbae4ceec90..917234ba491af8a1ea1722e17f37665b7b7d9587 100644 (file)
@@ -285,6 +285,9 @@ public class AddressbookAdminContactWebRequestBean implements AddressbookAdminCo
                // Fire event
                this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact));
 
+               // Clear this bean
+               this.clear();
+
                // Return outcome
                return "admin_list_contact"; //NOI18N
        }
index 725b928f256934253f9b79ee070131d176cd1a83..ed9c740f2d8644751f58f155129291b6b2f32089 100644 (file)
@@ -37,6 +37,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;
index 1f402a8632ad300c88b742eb018022e8678ec080..a7ab2756b9fc37333bba899088cba17a6368f780 100644 (file)
@@ -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;
@@ -46,7 +47,7 @@ public interface AddressbookContactWebSessionController extends Serializable {
         * <p>
         * @return A list of all contacts.
         */
-       List<Contact> allContacts();
+       List<Contact> allContacts ();
 
        /**
         * Checks whether there are contacts.
@@ -69,13 +70,6 @@ public interface AddressbookContactWebSessionController extends Serializable {
         */
        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.
@@ -96,7 +90,15 @@ public interface AddressbookContactWebSessionController extends Serializable {
        void afterRegistrationEvent (final UserRegisteredEvent event);
 
        /**
-        * Event observer for updated contact data by admins
+        * 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
         */
index 2d13c89d9cdf9e6c80c70a1f493f839f1dca2821..405d133a3ab02f459cb6cf7415d70a1300de6dfc 100644 (file)
@@ -35,10 +35,7 @@ import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.contact.AddressbookContactWebSessionController;
 import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController;
 import org.mxchange.jcontacts.contact.Contact;
-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.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;
@@ -158,6 +155,27 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC
                }
        }
 
+       @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
index edac6ccec741d45deef280f0dadfee21cee89ace..c5eb1ade23deb4268b92ec834cfafbc71ba32e75 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.addressbook.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 AddressbookUserWebSessionController extends Serializable {
         */
        boolean isContactFound (final Contact contact);
 
+       /**
+        * Observes events being fired when an administrator has added a new
+        * contact.
+        * <p>
+        * @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.