1 25 26 package net.killingar.forum.tags; 27 28 import net.killingar.forum.internal.AccessLevel; 29 import net.killingar.forum.internal.managers.AreaManager; 30 import net.killingar.forum.internal.managers.ForumManager; 31 32 import javax.servlet.jsp.JspException ; 33 import javax.servlet.jsp.JspTagException ; 34 35 public class AreaAccessTag extends webwork.view.taglib.WebWorkBodyTagSupport 36 { 37 private long access = 0, areaGroup = -1; 38 39 public int doStartTag() throws JspException 40 { 41 try 42 { 43 ForumManager manager = (ForumManager)pageContext.getSession().getAttribute("manager"); 44 AreaManager amgr = (AreaManager)manager.getManager(AreaManager.class.getName()); 45 if (amgr.hasAccess(manager.getUserID(), areaGroup, access)) 46 return EVAL_BODY_TAG; 47 else 48 return SKIP_BODY; 49 } 50 catch (Exception ex) 51 { 52 throw new JspTagException ("AreaAccessTag: " + ex); 54 } 56 } 57 58 public void setAccess(String a) 59 { 60 try 61 { 62 access = Long.parseLong(a); 63 } 64 catch(NumberFormatException e) 65 { 66 access = AccessLevel.parseAccessLevel(a); 67 } 68 } 69 70 public void setAreagroup(String a) 71 { 72 try 73 { 74 areaGroup = Long.parseLong(a); 75 } 76 catch(NumberFormatException e) 77 { 78 try 79 { 80 areaGroup = ((Long )findValue(a)).longValue(); 81 } 82 catch(ClassCastException e2) 83 { 84 areaGroup = -1; } 86 } 87 } 88 89 public int doEndTag() throws JspTagException 90 { 91 try 92 { 93 if(bodyContent != null) 94 bodyContent.writeOut(bodyContent.getEnclosingWriter()); 95 96 bodyContent = null; 97 } 98 catch(java.io.IOException e) 99 { 100 throw new JspTagException ("IO Error: " + e.getMessage()); 101 } 102 return EVAL_PAGE; 103 } 104 105 public int doAfterBody() throws JspTagException 106 { 107 return SKIP_BODY; 108 } 109 } 110 | Popular Tags |