]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
Continued a bit:
authorRoland Häder <roland@mxchange.org>
Wed, 18 May 2016 07:50:46 +0000 (09:50 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 26 May 2016 13:15:15 +0000 (15:15 +0200)
- added sending out registration email
- added internal TODO

src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkSessionBean.java
src/java/org/mxchange/jusercore/model/register/JobsUserRegistrationSessionBean.java

index 290362c8bb526379647cb1f3d6e17e6534c932b7..4a2ebd8a9eb1a4c41cbd0de3621a75c8caf87725 100644 (file)
@@ -80,6 +80,7 @@ public class JobsResendLinkSessionBean extends BaseJobsDatabaseBean implements R
                }
 
                // Send email
+               // TODO: Internationlize the subject line somehow
                this.sendEmail("Resend confirmation link", "resend_confirmation_link", emailAddress, user); //NOI18N
 
                // Log trace message
index 13d180ac240c125964238391e6d9439dfc533eac..dc056a9ba4fa78b593a313d2a8140e092badc591 100644 (file)
@@ -18,7 +18,11 @@ package org.mxchange.jusercore.model.register;
 
 import java.text.MessageFormat;
 import javax.ejb.EJB;
+import javax.ejb.EJBException;
 import javax.ejb.Stateless;
+import javax.mail.Address;
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
 import org.mxchange.jcontacts.contact.Contact;
@@ -140,6 +144,15 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem
                if (null == user) {
                        // Abort here
                        throw new NullPointerException("user is null"); //NOI18N
+               } else if (user.getUserContact() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("user.userContact is null"); //NOI18N
+               } else if (user.getUserContact().getContactEmailAddress() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("user.userContact.contactEmailAddress is null"); //NOI18N
+               } else if (user.getUserContact().getContactEmailAddress().isEmpty()) {
+                       // Is empty
+                       throw new IllegalArgumentException("user.userContact.contactEmailAddress is empty"); //NOI18N
                }
 
                // Check if user is registered
@@ -154,7 +167,20 @@ public class JobsUserRegistrationSessionBean extends BaseJobsDatabaseBean implem
                // Call other EJB
                User addedUser = this.userBean.addUser(user);
 
-               // Create email
+               // Init variable
+               Address emailAddress;
+
+               try {
+                       // Create email address and set
+                       emailAddress = new InternetAddress(user.getUserContact().getContactEmailAddress());
+               } catch (final AddressException ex) {
+                       // Throw again
+                       throw new EJBException(ex);
+               }
+
+               // Send email
+               // TODO: Internationlize the subject line somehow
+               this.sendEmail("Registration", "registration", emailAddress, user); //NOI18N
 
                // Trace message
                this.getLoggerBeanLocal().logTrace(MessageFormat.format("registerUser: addedUser={0},addedUser.userId={1} - EXIT!", addedUser, addedUser.getUserId())); //NOI18N