]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Tue, 10 May 2016 10:44:35 +0000 (12:44 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 10 May 2016 17:15:59 +0000 (19:15 +0200)
- merged some generic stuff from jrecruiter-war project
- sorted members

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java

index 0b5ad4e504d1cfdec21ae59b9530e445b754f711..e794aaacbbed6787022f6ce5f3393787cb90c741 100644 (file)
@@ -220,12 +220,6 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl
                }
        }
 
-       @Override
-       public void addEmailAddress (final String contactEmailAddress) {
-               // Add it
-               this.emailAddressList.add(contactEmailAddress);
-       }
-
        @Override
        public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
                // The event must be valid
@@ -507,6 +501,9 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl
                        contact.setContactCellphoneNumber(cellphone);
                }
 
+               // Trace message
+               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createContactInstance: contact={1} - EXIT!", this.getClass().getSimpleName(), contact));
+
                // Return it
                return contact;
        }
@@ -847,21 +844,21 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl
        }
 
        @Override
-       public void updateContactDataFromController (final Contact userContact) {
+       public void updateContactDataFromController (final Contact contact) {
                // Is the instance valid?
-               if (null == userContact) {
+               if (null == contact) {
                        // Throw NPE
-                       throw new NullPointerException("userContact is null"); //NOI18N
-               } else if (userContact.getContactId() == null) {
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
                        // Throw NPE
-                       throw new NullPointerException("userContact.contactId is null"); //NOI18N
-               } else if (userContact.getContactId() < 1) {
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
                        // Not valid id number
-                       throw new IllegalArgumentException(MessageFormat.format("userContact.contactId={0} is not valid.", userContact.getContactId())); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
                }
 
                // Set all
-               this.copyContact(userContact);
+               this.copyContact(contact);
        }
 
        /**
@@ -918,6 +915,18 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl
         * @param contact Contact instance
         */
        private void copyContact (final Contact contact) {
+               // Is the instance valid?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Not valid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               }
+
                // Copy all fields:
                // - base data
                this.setGender(contact.getContactGender());
@@ -956,4 +965,32 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl
                this.setComment(contact.getContactComment());
        }
 
+       /**
+        * Removes given contact from all lists
+        * <p>
+        * @param contact Contact instance to remove
+        */
+       private void removeContact (final Contact contact) {
+               // Is the instance valid?
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Not valid id number
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
+               }
+
+               // Remove from general list
+               if (!this.contactList.remove(contact)) {
+                       // Did not remove contact
+                       throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N
+               }
+
+               // Remove from other lists
+               this.emailAddressList.remove(contact.getContactEmailAddress());
+       }
+
 }