From: Roland Häder Date: Wed, 31 Aug 2016 10:21:02 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=76ade9336b3f4f83a7c0c6a4da97cce917a506bd;p=jjobs-war.git Please cherry-pick: - used more uniqueAddContact() - added debug lines (may become noisy) - logged also unset fax, land-line or mobile number Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java index 141fe14e..4fe7dc4e 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java @@ -451,39 +451,6 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job this.emailAddresses.add(event.getUpdatedContact().getContactEmailAddress()); } - @Override - public void afterUserRegistrationEvent (@Observes final UserRegisteredEvent event) { - // event should not be null - if (null == event) { - // Throw NPE - throw new NullPointerException("event is null"); //NOI18N - } else if (event.getRegisteredUser() == null) { - // Throw NPE again - throw new NullPointerException("event.registeredUser is null"); //NOI18N - } else if (event.getRegisteredUser().getUserId() == null) { - // userId is null - throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N - } else if (event.getRegisteredUser().getUserId() < 1) { - // Not avalid id - throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N - } - - // Get user instance - Contact registeredContact = event.getRegisteredUser().getUserContact(); - - // Copy all data from registered->user - this.copyContact(registeredContact); - - // Add contact instance only once - this.uniqueAddContact(registeredContact); - - // Add user name and email address - this.addUserNameEmailAddress(registeredContact); - - // Clear all data - this.clear(); - } - @Override public void afterUserConfirmedAccountEventEvent (@Observes final UserConfirmedAccountEvent event) { // event should not be null @@ -526,6 +493,36 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job this.copyContact(event.getLoggedInUser().getUserContact()); } + @Override + public void afterUserRegistrationEvent (@Observes final UserRegisteredEvent event) { + // event should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getRegisteredUser() == null) { + // Throw NPE again + throw new NullPointerException("event.registeredUser is null"); //NOI18N + } else if (event.getRegisteredUser().getUserId() == null) { + // userId is null + throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N + } else if (event.getRegisteredUser().getUserId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N + } + + // Get user instance + Contact registeredContact = event.getRegisteredUser().getUserContact(); + + // Copy all data from registered->user + this.copyContact(registeredContact); + + // Add user name and email address + this.addUserNameEmailAddress(registeredContact); + + // Clear all data + this.clear(); + } + @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allContacts () { @@ -1228,6 +1225,9 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job * @param faxNumber Fax number to remove */ private void removeFromContacts (final DialableFaxNumber faxNumber) { + // Log message + System.out.println(MessageFormat.format("{0}.removeFromContacts: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber)); //NOI18N + // Is it valid? if (null == faxNumber) { // Throw NPE @@ -1242,8 +1242,14 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job // Loop through all contacts for (final Contact contact : this.contacts) { + // Log message + System.out.println(MessageFormat.format("{0}.removeFromContacts: contact={1},contact.contactFaxNumber={2}", this.getClass().getSimpleName(), contact, contact.getContactFaxNumber())); //NOI18N + // Is the number set? if (Objects.equals(contact.getContactFaxNumber(), faxNumber)) { + // Log message + System.out.println(MessageFormat.format("{0}.removeFromContacts: Unsetting faxNumber={1} ...", this.getClass().getSimpleName(), faxNumber)); //NOI18N + // Found it contact.setContactFaxNumber(null); } @@ -1256,6 +1262,9 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job * @param landLineNumber Land-line number to remove */ private void removeFromContacts (final DialableLandLineNumber landLineNumber) { + // Log message + System.out.println(MessageFormat.format("{0}.removeFromContacts: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber)); //NOI18N + // Is it valid? if (null == landLineNumber) { // Throw NPE @@ -1270,8 +1279,14 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job // Loop through all contacts for (final Contact contact : this.contacts) { + // Log message + System.out.println(MessageFormat.format("{0}.removeFromContacts: contact={1},contact.contactLandLineNumber={2}", this.getClass().getSimpleName(), contact, contact.getContactLandLineNumber())); //NOI18N + // Is the number set? if (Objects.equals(contact.getContactLandLineNumber(), landLineNumber)) { + // Log message + System.out.println(MessageFormat.format("{0}.removeFromContacts: Unsetting landLineNumber={1} ...", this.getClass().getSimpleName(), landLineNumber)); //NOI18N + // Found it contact.setContactLandLineNumber(null); } @@ -1285,7 +1300,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job */ private void removeFromContacts (final DialableMobileNumber mobileNumber) { // Log message - System.out.println(MessageFormat.format("{0}.removeFromContacts: CALLED!", this.getClass().getSimpleName())); //NOI18N + System.out.println(MessageFormat.format("{0}.removeFromContacts: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); //NOI18N // Is it valid? if (null == mobileNumber) { @@ -1302,12 +1317,12 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job // Loop through all contacts for (final Contact contact : this.contacts) { // Log message - System.out.println(MessageFormat.format("{0}.removeFromContacts: contact={1}", this.getClass().getSimpleName(), contact)); //NOI18N + System.out.println(MessageFormat.format("{0}.removeFromContacts: contact={1},contact.contactMobileNumber={2}", this.getClass().getSimpleName(), contact, contact.getContactMobileNumber())); //NOI18N // Is the number set? if (Objects.equals(contact.getContactMobileNumber(), mobileNumber)) { // Log message - System.out.println(MessageFormat.format("{0}.removeFromContacts: Unsetting ...", this.getClass().getSimpleName())); //NOI18N + System.out.println(MessageFormat.format("{0}.removeFromContacts: Unsetting mobileNumber={1} ...", this.getClass().getSimpleName(), mobileNumber)); //NOI18N // Unset it contact.setContactMobileNumber(null);