]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Mon, 29 Aug 2016 15:51:00 +0000 (17:51 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 29 Aug 2016 17:28:36 +0000 (19:28 +0200)
- added base URL parameter + email delivery

src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java

index d042455682aced3176f1a4f0b8837f4f9c73ac3e..bc46b1dda6dd59558f949b469379a53e9b23a0db 100644 (file)
@@ -158,6 +158,12 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes
                } 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
@@ -592,9 +598,9 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes
        }
 
        @Override
-       public PasswordHistory updateUserPassword (final User user) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
+       public PasswordHistory updateUserPassword (final User user, final String baseUrl) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
 
                // user should not be null
                if (null == user) {
@@ -612,6 +618,12 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes
                } else if (!this.ifUserExists(user)) {
                        // User does not exist
                        throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //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
                }
 
                // Call other method
@@ -629,6 +641,20 @@ public class JobsUserSessionBean extends BaseJobsDatabaseBean implements UserSes
                // 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