]> git.mxchange.org Git - pizzaservice-mailer-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>
Sat, 21 May 2016 11:51:12 +0000 (13:51 +0200)
- added sending out registration email
- added internal TODO

src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkSessionBean.java
src/java/org/mxchange/jusercore/model/register/AddressbookUserRegistrationSessionBean.java

index 825f4efde2962f3ef79b8df29523a8bbb0cd52b8..036e5d0ef6791a0e336f5a77eeb82974726e64d6 100644 (file)
@@ -81,6 +81,7 @@ public class AddressbookResendLinkSessionBean extends BaseAddressbookDatabaseBea
                }
 
                // Send email
+               // TODO: Internationlize the subject line somehow
                this.sendEmail("Resend confirmation link", "resend_confirmation_link", emailAddress, user); //NOI18N
 
                // Log trace message
index 98ce50304cc1ff93c0b2ba8b06cdfc4e190892b0..30aeb2b98e26b41c4491c8ab8b90af141193a5df 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 AddressbookUserRegistrationSessionBean extends BaseDatabaseBean imp
                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 AddressbookUserRegistrationSessionBean extends BaseDatabaseBean imp
                // 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