From 31f23bc5fbcbe9e94d9f468e70ecf42179458b22 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sat, 12 Mar 2016 19:50:27 +0100 Subject: [PATCH] make sure the email address is/not persisted ("enqueued") --- .../model/email_address/EmailChangeSessionBean.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 fa060d1..68d4e12 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. -- 2.39.5