From: Roland Haeder Date: Sat, 12 Mar 2016 18:50:30 +0000 (+0100) Subject: make sure the email address is/not persisted ("enqueued") X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=94244705918a1cf9404e99ca56e2d6f3f3e57d6c;p=pizzaservice-mailer-ejb.git make sure the email address is/not persisted ("enqueued") --- diff --git a/src/java/org/mxchange/jusercore/model/email_address/EmailChangeSessionBean.java b/src/java/org/mxchange/jusercore/model/email_address/EmailChangeSessionBean.java index 97d96b1..9626d73 100644 --- a/src/java/org/mxchange/jusercore/model/email_address/EmailChangeSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/email_address/EmailChangeSessionBean.java @@ -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.