From 4df058c7af042c6d536d0d995aa2f9957b14cc33 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 6 Oct 2015 15:39:07 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20new=20exception=20caught=20and?= =?utf8?q?=20renamed=20one=20-=20updated=20jars=20Signed-off-by:Roland=20H?= =?utf8?q?=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcontacts-core.jar | Bin 18203 -> 18203 bytes lib/juser-core.jar | Bin 13411 -> 15206 bytes lib/juser-lib.jar | Bin 3425 -> 3782 bytes .../beans/register/UserRegisterWebBean.java | 14 ++++++-- .../addressbook/beans/user/UserWebBean.java | 34 ++++++++++++++++-- .../beans/user/UserWebController.java | 16 +++++++++ 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar index 5fd68dc8f80098600ff320c77eef156f7e79d9d2..ceeaa29af8efe058726733354565e73674c2bba6 100644 GIT binary patch delta 199 zcmbQ;$2hx>kte{LnT3mifrEizdc{N@O{QrT6V0bH0ofN6K;$P)AURo<(HKMpFytA5Vg>)3IL)l BMe+au delta 199 zcmbQ;$2hx>kte{LnT3mifrEiTG;bo0CX-0sMDyuPK=uU%5cx?HNKTezGzL*YjMgBk zpV0|KU1qccQk#XDSlK|d6o;iEhz`|M;|9^SCZ{<;w3pou79c&D#n}>Q_+)!$2N18( z*#Jas1_}bHch1fr%GkvlL^Zesfv77kejrN4H3CG{xyFE~JFamc%Em1jL@jiy0svUn BH@W}- diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 30c2eb8281ea781cce326a635f5476b122507439..bacd4604eea1d39d40cef3cc12fc6e84825e17ef 100644 GIT binary patch delta 1839 zcmZuxYfPJE6h2?Cqm(l0D6W+DElAgn+3V&4I>W7Og|2KZ3nL2Vv;A~9z}eC{gbmph zbuig+;N6X3_RAPkmq_B}hks1WjMJz;+;m3cOcqUC%o2Z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vdWiKByF{#ySbr*m0fNf}R|sMRg9J!0L@=y{t6CUQX<;<} z(Dq)NW`O;0zyJr~kQT<`1G&g+BA|w&SR}2*a(g7_1eo9?o7n<(I0YNwGz8!bR6;9M zLmST8LtIqx<~w9f7igdx8^m?k=fS2k?9VnfTC>8vjWdf z#(~(x4%e0-|3)W%Lw2a?mL9t&m0ODx-cO-Gh`v&mDXjNZkhA4h;;`zmI`&a;J zR6_EZh+1^$4azuW%*NKBK{3A_>-yEmj5I>s!8U2Wzzfx6SkEp9~3JSc)zsLU3BY>HPsw%RsH=} a@dtB!a3(ghV^z7)XaNgMYXF7{Y4tyv$`4im diff --git a/lib/juser-lib.jar b/lib/juser-lib.jar index 83cf0feae10030f1352a1c89e12ac9e5838a4d95..bc0d93d984b186468f94b648e07df11bb22b1189 100644 GIT binary patch delta 730 zcma))&ubGw6vw|a+3X~{o8M8}l-63X8Y*m{h?Ux^RTIThWs3(vgvG33C5gDZ^%6?x zAK)R(!K*^AUi7A*=)r@B;>F%P6g-F*#fvxbO=?S8FD~qS_Pv=m@9p=!t-yE0 zW&jCbv(vN6{8OiQ>M^J9kK=0nS*BHvvS|f}omP0n&MIuM1%*7HC%ka@8c%O_st^YU?1JpYwkMN_ik{T&|`2F%VMNDHv z;Gn=Efg!mn?shW`FS-$Wfhu9q4PO7H7W`VMt^8ljSI?pXIxQ8nb#C;P)*fY1>0R>utuOPrQ*AyXk za!;a)kvWZ#nwd30fC9<+G#wxnu;|VM_-$58=eyzNs083|5hvvo7HtzRoCqs{g&pO% zg9<_glo#Qn+BWoV6R+$Abeu5}W8z%@q!v=c6ktLQfM`)Z)23aJ0WCzAY{-G82LIbB zU?(AmjDBDE?v|-AEO}LK;>as9&b_aeUc43F3VM}spf?ydy1^Ls*BLv0_P?@Me{Y;y U{PSGO@1L_)i2Fg^I%ZM$1U~UsP5=M^ diff --git a/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebBean.java b/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebBean.java index 77cfa372..24dddcb4 100644 --- a/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/register/UserRegisterWebBean.java @@ -24,7 +24,8 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.addressbook.beans.user.UserWebController; -import org.mxchange.jusercore.exceptions.UserAlreadyRegisteredException; +import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; +import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException; import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.status.UserAccountStatus; @@ -75,6 +76,15 @@ public class UserRegisterWebBean implements UserRegisterWebController { // Get user instance User user = this.userController.createUserInstance(); + // Is the user already used? + if (this.userController.isUserNameRegistered(user.getUserName())) { + // User name is already used + throw new FaceletException(new UserNameAlreadyRegisteredException(user)); + } else if (this.userController.isEmailAddressRegistered(user.getUserContact().getEmailAddress())) { + // Email address has already been taken + throw new FaceletException(new EmailAddressAlreadyRegisteredException(user)); + } + // For debugging/programming only: user.setUserAccountStatus(UserAccountStatus.CONFIRMED); @@ -87,7 +97,7 @@ public class UserRegisterWebBean implements UserRegisterWebController { // All fine, redirect to proper page return "register_done"; //NOI18N - } catch (final UserAlreadyRegisteredException ex) { + } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) { // Continue to throw throw new FaceletException(ex); } diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java index 5b0bdc27..de5c6e05 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java @@ -17,6 +17,8 @@ package org.mxchange.addressbook.beans.user; import java.util.Date; +import java.util.List; +import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Named; @@ -45,7 +47,6 @@ public class UserWebBean implements UserWebController { private static final long serialVersionUID = 542_145_347_916L; /////////////////////// Properties ///////////////////// - /** * Birth day */ @@ -136,6 +137,16 @@ public class UserWebBean implements UserWebController { */ private Integer zipCode; + /** + * Email address list + */ + private List emailAddressList; + + /** + * User name list + */ + private List userNameList; + /** * Default constructor */ @@ -156,6 +167,25 @@ public class UserWebBean implements UserWebController { } } + @Override + public boolean isEmailAddressRegistered (String emailAddress) { + return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(emailAddress))); + } + + @Override + public boolean isUserNameRegistered (final String userName) { + return ((this.userNameList instanceof List) && (this.userNameList.contains(userName))); + } + + @PostConstruct + public void init () { + // Get full user name list for reducing EJB calls + this.userNameList = this.userBean.getUserNameList(); + + // Get full email address list for reducing EJB calls + this.emailAddressList = this.userBean.getEmailAddressList(); + } + @Override public void copyUser (final User user) { // Copy all fields: @@ -216,7 +246,7 @@ public class UserWebBean implements UserWebController { @Override public Date getBirthday () { - return birthday; + return this.birthday; } @Override diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java index 7bef48a4..cc7c9d16 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java @@ -42,6 +42,22 @@ public interface UserWebController extends Serializable { */ public User createUserInstance (); + /** + * Checks whether given user name is used + *

+ * @param userName User name to check + * @return Whether it is already used + */ + public boolean isUserNameRegistered (final String userName); + + /** + * Checks whether given email address is used + *

+ * @param emailAddress Email address to check + * @return Whether it is already used + */ + public boolean isEmailAddressRegistered (final String emailAddress); + /** * Getter for birth day *

-- 2.39.5