From: Roland Häder Date: Mon, 29 Aug 2016 15:51:00 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=455cbd4d502f514f561981e9f458af10a7fb53ae;p=jfinancials-mailer-ejb.git Please cherry-pick: - added base URL parameter + email delivery Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java index c360927..ff8b1e3 100644 --- a/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java @@ -158,6 +158,12 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl } else if (user.getUserConfirmKey() == null) { // Throw NPE throw new NullPointerException("user.userConfirmKey is null"); //NOI18N + } else if (null == baseUrl) { + // Throw it again + throw new NullPointerException("baseUrl is null"); //NOI18N + } else if (baseUrl.isEmpty()) { + // Invalid parameter + throw new IllegalArgumentException("baseUrl is empty"); //NOI18N } // Update user status and remove confirmation key @@ -613,11 +619,11 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl // User does not exist throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N } else if (null == baseUrl) { - // Abort here - throw new NullPointerException("password is null"); //NOI18N + // Throw it again + throw new NullPointerException("baseUrl is null"); //NOI18N } else if (baseUrl.isEmpty()) { - // Abort here - throw new IllegalArgumentException("password is empty"); //NOI18N + // Invalid parameter + throw new IllegalArgumentException("baseUrl is empty"); //NOI18N } // Call other method @@ -635,6 +641,20 @@ public class AddressbookUserSessionBean extends BaseAddressbookDatabaseBean impl // Flush it to get id number back this.getEntityManager().flush(); + // Init variable + Address emailAddress; + + try { + // Create email address and set + emailAddress = new InternetAddress(updatedUser.getUserContact().getContactEmailAddress()); + } catch (final AddressException ex) { + // Throw again + throw new EJBException(ex); + } + + // Send email to user + this.sendEmail("User password change", "user_password_change", emailAddress, user, baseUrl); //NOI18N + // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N