Rev 1310 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
45 | fvelez | 1 | package pt.estgp.estgweb.web.tags; |
2 | |||
3 | import org.apache.log4j.Logger; |
||
4 | |||
5 | import javax.servlet.jsp.tagext.BodyTagSupport; |
||
6 | import javax.servlet.jsp.JspException; |
||
7 | import javax.servlet.jsp.JspWriter; |
||
8 | |||
9 | import pt.estgp.estgweb.domain.UserSessionImpl; |
||
10 | import pt.estgp.estgweb.domain.UserImpl; |
||
1814 | jmachado | 11 | import pt.estgp.estgweb.utils.Globals; |
45 | fvelez | 12 | |
146 | jmachado | 13 | public class IsNotAdminTag extends BodyTagSupport |
14 | { |
||
45 | fvelez | 15 | |
16 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(IsNotAdminTag.class); |
||
17 | |||
18 | |||
146 | jmachado | 19 | public int doStartTag() throws JspException |
20 | { |
||
152 | jmachado | 21 | if(go()) |
22 | return EVAL_BODY_TAG; |
||
23 | else |
||
24 | return SKIP_BODY; |
||
45 | fvelez | 25 | } |
26 | |||
152 | jmachado | 27 | public boolean go() |
146 | jmachado | 28 | { |
45 | fvelez | 29 | UserSessionImpl userSession = (UserSessionImpl) pageContext.getRequest().getAttribute(Globals.USER_SESSION_KEY); |
214 | jmachado | 30 | return !(userSession != null && userSession.getUser() != null && ((userSession.getUser()).isSuperuserOrAdmin())); |
152 | jmachado | 31 | } |
140 | fvelez | 32 | |
152 | jmachado | 33 | public int doEndTag() throws JspException |
34 | { |
||
35 | if(go()) |
||
45 | fvelez | 36 | { |
37 | 1.5.0/docs/api/java/lang/String.html">String toPage = bodyContent.getString().trim(); |
||
38 | JspWriter writer = pageContext.getOut(); |
||
39 | try |
||
40 | { |
||
41 | writer.write(toPage); |
||
42 | } |
||
146 | jmachado | 43 | catch (1.5.0/docs/api/java/lang/Exception.html">Exception e) |
45 | fvelez | 44 | { |
146 | jmachado | 45 | logger.error(e, e); |
45 | fvelez | 46 | throw new JspException(e); |
47 | } |
||
48 | } |
||
49 | // Continue processing this page |
||
50 | return EVAL_PAGE; |
||
51 | } |
||
52 | |||
53 | |||
54 | } |