KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > jsp > taglib > security > MayCreateTag


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.bridge.jsp.taglib.security;
11 import org.mmbase.bridge.jsp.taglib.util.Attribute;
12 import org.mmbase.bridge.jsp.taglib.Condition;
13 import org.mmbase.bridge.jsp.taglib.CloudReferrerTag;
14
15 import javax.servlet.jsp.JspTagException JavaDoc;
16
17
18 /**
19  * A very simple tag to check if node may be created
20  *
21  * @author Michiel Meeuwissen
22  * @version $Id: MayCreateTag.java,v 1.9 2004/07/26 20:18:01 nico Exp $
23  */

24
25 public class MayCreateTag extends CloudReferrerTag implements Condition {
26
27     protected Attribute type = Attribute.NULL;
28     protected Attribute inverse = Attribute.NULL;
29
30     public void setInverse(String JavaDoc b) throws JspTagException JavaDoc {
31         inverse = getAttribute(b);
32     }
33     protected boolean getInverse() throws JspTagException JavaDoc {
34         return inverse.getBoolean(this, false);
35     }
36
37     public void setType(String JavaDoc t) throws JspTagException JavaDoc {
38         type = getAttribute(t);
39     }
40
41     public int doStartTag() throws JspTagException JavaDoc {
42         if ((getCloudVar().getNodeManager(type.getString(this)).mayCreateNode()) != getInverse()) {
43             return EVAL_BODY;
44         } else {
45             return SKIP_BODY;
46         }
47     }
48
49     public int doAfterBody() throws JspTagException JavaDoc {
50         if (EVAL_BODY == EVAL_BODY_BUFFERED) { // not needed if EVAL_BODY_INCLUDE
51
try{
52                 if(bodyContent != null) {
53                     bodyContent.writeOut(bodyContent.getEnclosingWriter());
54                 }
55             } catch(java.io.IOException JavaDoc e){
56                 throw new JspTagException JavaDoc("IO Error: " + e.getMessage());
57             }
58         }
59         return SKIP_BODY;
60     }
61
62 }
63
Popular Tags