1 10 package org.mmbase.bridge.jsp.taglib.security; 11 12 import javax.servlet.jsp.JspTagException ; 13 import org.mmbase.bridge.Node; 14 import org.mmbase.bridge.RelationManager; 15 import org.mmbase.bridge.jsp.taglib.Condition; 16 import org.mmbase.bridge.jsp.taglib.util.Attribute; 17 18 import org.mmbase.util.logging.Logger; 19 import org.mmbase.util.logging.Logging; 20 21 22 29 30 public class MayCreateRelationTag extends MayWriteTag implements Condition { 31 32 private static final Logger log = Logging.getLoggerInstance(MayCreateRelationTag.class); 33 34 private Attribute role = Attribute.NULL; 35 private Attribute source = Attribute.NULL; 36 private Attribute destination = Attribute.NULL; 37 38 public void setRole(String r) throws JspTagException { 39 role = getAttribute(r); 40 } 41 42 public void setSource(String s) throws JspTagException { 43 source = getAttribute(s); 44 } 45 46 public void setDestination(String d) throws JspTagException { 47 destination = getAttribute(d); 48 } 49 50 public int doStartTag() throws JspTagException { 51 String roleStr = role.getString(this); 52 RelationManager rm = getCloudVar().getRelationManager(roleStr); 53 Node sourceNode = getNode(source.getString(this)); 54 Node destinationNode = getNode(destination.getString(this)); 55 56 boolean hasRelationManager = getCloudVar().hasRelationManager(sourceNode.getNodeManager(), 57 destinationNode.getNodeManager(), roleStr); 58 if ((hasRelationManager && rm.mayCreateRelation(sourceNode, destinationNode)) != getInverse()) { 59 return EVAL_BODY; 60 } else { 61 return SKIP_BODY; 62 } 63 64 } 65 } 66 | Popular Tags |