import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
import org.mxchange.jcontacts.contact.UserContact;
import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
import org.mxchange.jcountry.data.Country;
import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController;
this.emailAddressList.add(contactEmailAddress);
}
+ @Override
+ public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
+ // Trace message
+ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: 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.getUpdatedContact()== null) {
+ // Throw NPE again
+ throw new NullPointerException("event.user is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() == null) {
+ // userId is null
+ throw new NullPointerException("event.user.userId is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+ }
+
+ // Get iterator from list
+ Iterator<Contact> iterator = this.contactList.iterator();
+
+ // "Walk" through all entries
+ while (iterator.hasNext()) {
+ // Get next element
+ Contact next = iterator.next();
+
+ // Is id number the same?
+ if (Objects.equals(event.getUpdatedContact().getContactId(), next.getContactId())) {
+ // Found entry, so remove it and abort
+ this.contactList.remove(next);
+
+ // Remove also email from list
+ this.emailAddressList.remove(next.getContactEmailAddress());
+ break;
+ }
+ }
+
+ // Add contact to list
+ this.contactList.add(event.getUpdatedContact());
+
+ // Add email address to list
+ this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress());
+ }
+
@Override
public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) {
// Trace message
// Trace message
//this.getLogger().logTrace(MessageFormat.format("createContactInstance: localContact={0} - EXIT!", localContact));
+
// Return it
return localContact;
}
import java.util.Date;
import org.mxchange.jcontacts.contact.Contact;
import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
import org.mxchange.jcountry.data.Country;
import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
*/
void afterRegistrationEvent (final UserRegisteredEvent event);
+ /**
+ * Event observer for updated contact data by admins
+ * <p>
+ * @param event Updated contact data event
+ */
+ void afterAdminUpdatedContactDataEvent (final AdminUpdatedContactEvent event);
+
/**
* Event observer for logged-in user
* <p>