From 789b704c600d2e74a1f831c3be91a8ac98b2837e Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 15 Oct 2015 08:44:48 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20added=20validator=20for=20user?= =?utf8?q?=20id=20-=20added=20juser-lib.jar=20-=20updated=20jar(s)=20Signe?= =?utf8?q?d-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/juser-core.jar | Bin 22937 -> 23003 bytes lib/juser-lib.jar | Bin 0 -> 3978 bytes nbproject/project.properties | 3 + .../jusercore/model/user/UserIdValidator.java | 68 ++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 lib/juser-lib.jar create mode 100644 src/org/mxchange/jusercore/model/user/UserIdValidator.java diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 0a5cdf28792248f870844e1f1099ad02f151c28e..52192afb650a52b7b7b6199a0479a2083a849665 100644 GIT binary patch delta 1579 zcmZ9Me@s(X6vxkf?W6RUEwso=1sZK#9TqXcFKVa25C%#*##cNJe_7xp0gQHqF2E$rd3deQSe69y8Zxl>-6*>7}gyT^z zJ)?m!J~*L+voOwkUy%U2T#gLBeu6jW`P`%izSY15^kun~Q?6Yy8&e|QR@rQ5>S*iU zxM^)qM|WL2gFJl3?@Fy}cT_rpo7}g-;1Ztk*QmaO@3Ak} zld6Gf19ZU;SX$^;UuNLN<4&*gap68m`#z}QL(s!V_*C&**?YkR`@seWXyczk9t=PL z4nh?SLIe)s^bHAFbt33>m}{%3p58aaJIxPp8^?9 zW2h_>R|b4+Oz^D%xBNBnbAo?Kd_r(m>Xt7OpAtM=>SNP_?<9Ve_%*>NiO&dbDRav= zh~Fe$%YGMZFR@u-w}f`4%*SpMuaxJA{U_MwppV@b+M_|YtOA*-1^=6Ps^Ecgw`?T7 zNbqgtPaD%gViqtlD=c9dc%j_O2Jvor9ZSL5ipY`>WlMsB9!kSN4;)FV17%;ub#dUf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-lib.jar b/lib/juser-lib.jar new file mode 100644 index 0000000000000000000000000000000000000000..cf6b0ff7ab8718301ea8e9f7e5d24f2baf2f520a GIT binary patch literal 3978 zcmcIn&u<%55T11$FLCWAO&r=HA)+EhiK=*0KtzxhaFe)1u^lUJbKufGuU|GVtaroi zI;7n4cND~>XSj3VKoN)jA>241?iDlp@UC~0-F2h#r2X|g^UZtn=9?L}cP8>hfVTj? z-`srwBV!8k(A;`hTiI^awO20z+JWdZ6n#-KelSp+t_og(XtUPZu5Wc7R-5%Ev%~>+ zy_J3LxWcwRUAR+SEf;In$V}~+>4$s)=kUi*svnh$8xCh4@2%W_O7d&f)yE&Nt#nuK zEG+FhOgH($hV2~N4)YLkxm+w4!-d87kjI7Dj-e$>l>d|HpX!IqGI)yU^|-F02Z?V9Bv5L<4y|3tt<@kK}>()@BGQnIRLsgvh?L9 z9wADDw$tG*Maq57tUcbhJzmvK=DIIm{qid!eF$%>Fs;Ij3fC04dBRN5!&o8hny%Xe z%j9*xDVd1K!Y2WO|aB_V)NlzY^zg@Dou0V0?ROiPOhOP>; zD$J=+QDGi`=-2~C=XGIn1>Q^9+YviqxQ{(txajkJ;fk)wYnEl>E(lhE*#^m+YW%3H zNr#}}dkI^UOU&}90yBiEnHcZdZuf}mo&ptrO4wS5I|AMM9mACPLf~ue1ghUm&J^ENehfb1xiB{0#RTukqq&mzHIbU=wlEG*N+C)=W^xT;XMUz zk8l1f1#Sp;tIvd4>-8K=2BSa`UM*%j=#un$@P-cPb%?f^U^7lMbZyPV0@-^SIwlBN z1-{IN8Fg+lR3!Q*BGF&KXvgTsIf{S4=M{ST9H4ud7~nHuI?jZB=TSXd|=OmTP5 z3EUmG1bl{2r2}D_WNVXon9Khcs!bc*BNHt=ecFKnix(_9OzIua5tgw|%bP>h(G!>I zSH%J0ZDYzsIP}uol5~<^6B;%uFC!HreE!C772W`!L!bzs-=P(qKk7?zIH_>O65cs` z<8wB`5H-RO4YKZ=WwXKMga!{55(ak7oV*oZnqjU705~DY?o- za=(rmIA-9l8a;!STz2oF>P7uKDbRR+b{p@3>PR=AW}F&rImr0$_)3W=O@peX9Hj9l zzD814nkqHoa*!%Ef>G75)k_1R#ykY6Cxgg{NrR$BJ%l>Tf|C7N8Xz_9A>eOWfWu;+ z>hD`aNIyIZn1Cbx4xKi_koX$ojr|bv`B^;+FRLk)ZGPNfymJZ-?oVcHAaDw$643-c&Q3aKfyoC*}l6toB4lc+B=ifMPec-!5`RN{zM%l{0p. + */ +package org.mxchange.jusercore.model.user; + +import java.text.MessageFormat; +import javax.ejb.EJB; +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; +import javax.faces.validator.Validator; +import javax.faces.validator.ValidatorException; +import org.mxchange.jcoreee.validator.number.BaseLongValidator; + +/** + * A validator for user ids + *

+ * @author Roland Haeder + */ +@FacesValidator (value = "UserIdValidator") +public class UserIdValidator extends BaseLongValidator implements Validator { + + /** + * Serial number + */ + private static final long serialVersionUID = 12_869_569_314_764_690L; + + /** + * Remote bean + */ + @EJB (mappedName = "ejb/stateless-user") + private UserSessionBeanRemote userBean; + + @Override + public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { + // Trace message + //this.getLogger().logTrace(MessageFormat.format("validate: context={0},component={1},value={2} - CALLED!", context, component, value)); //NOI18N + + // All accepted, required fields + String[] requiredFileds = {"userId"}; //NOI18N + + // Pre-validation (example: not null, not a string, empty string ...) + super.preValidate(context, component, value, requiredFileds, false); + + // Is the address book id valid? + if (!this.userBean.ifUserIdExists((Long) value)) { + // Is not valid + throw new ValidatorException(new FacesMessage(MessageFormat.format("No user found with id {0}. Please check your link.", value))); //NOI18N + } + + // Trace message + //this.getLogger().logTrace("validate: EXIT!"); //NOI18N + } +} -- 2.39.5