]> git.mxchange.org Git - jfinancials-ejb.git/commitdiff
make sure the email address is/not persisted ("enqueued")
authorRoland Haeder <roland@mxchange.org>
Sat, 12 Mar 2016 18:50:30 +0000 (19:50 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 12 Mar 2016 18:50:30 +0000 (19:50 +0100)
src/java/org/mxchange/jusercore/model/email_address/EmailChangeSessionBean.java

index 97d96b12648c250e02254b1b4e76acd3d106b1c1..9626d73f7ac3036826a36193910a7418cf949501 100644 (file)
@@ -19,9 +19,9 @@ package org.mxchange.jusercore.model.email_address;
 import java.text.MessageFormat;
 import java.util.List;
 import javax.ejb.EJB;
+import javax.ejb.EJBException;
 import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
-import javax.persistence.PersistenceException;
 import javax.persistence.Query;
 import org.mxchange.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
@@ -81,7 +81,10 @@ public class EmailChangeSessionBean extends BaseDatabaseBean implements EmailCha
                        throw new NullPointerException("emailAddress is null"); //NOI18N
                } else if (!this.userBean.ifUserExists(emailAddress.getEmailChangeUser())) {
                        // User does not exist
-                       throw new PersistenceException(MessageFormat.format("Email change with id {0} does not exist.", emailAddress.getEmailChangeId())); //NOI18N
+                       throw new EJBException(MessageFormat.format("Email change with id {0} does not exist.", emailAddress.getEmailChangeId())); //NOI18N
+               } else if (this.isEmailAddressEnqueued(emailAddress.getEmailAddress())) {
+                       // Email address is already enqueued
+                       throw new EJBException(MessageFormat.format("Email address {0} is already enqueued.", emailAddress.getEmailAddress()));
                }
 
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
@@ -137,7 +140,10 @@ public class EmailChangeSessionBean extends BaseDatabaseBean implements EmailCha
                        throw new IllegalArgumentException(MessageFormat.format("emailAddress.emailChangeId={0} is not valid.", emailAddress.getEmailChangeId())); //NOI18N
                } else if (!this.userBean.ifUserExists(emailAddress.getEmailChangeUser())) {
                        // User does not exist
-                       throw new PersistenceException(MessageFormat.format("Email change with id {0} does not exist.", emailAddress.getEmailChangeId())); //NOI18N
+                       throw new EJBException(MessageFormat.format("Email change with id {0} does not exist.", emailAddress.getEmailChangeId())); //NOI18N
+               } else if (!this.isEmailAddressEnqueued(emailAddress.getEmailAddress())) {
+                       // Email address is not enqueued
+                       throw new EJBException(MessageFormat.format("Email address {0} is not enqueued.", emailAddress.getEmailAddress()));
                }
 
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.