📄 isblogpublishertag.java
字号:
package net.sourceforge.pebble.web.tagext;
import net.sourceforge.pebble.domain.AbstractBlog;
import net.sourceforge.pebble.domain.Blog;
import net.sourceforge.pebble.Constants;
import net.sourceforge.pebble.util.SecurityUtils;
import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.http.HttpServletRequest;
/**
* A custom tag that includes its body content if the current user belongs to
* the "blog publisher" role for the blog.
*
* @author Simon Brown
*/
public class IsBlogPublisherTag extends TagSupport {
/**
* Implementation from the Tag interface - this is called when the opening tag
* is encountered.
*
* @return an integer specifying what to do afterwards
* @throws javax.servlet.jsp.JspException if something goes wrong
*/
public int doStartTag() throws JspException {
HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
AbstractBlog abstractBlog = (AbstractBlog)request.getAttribute(Constants.BLOG_KEY);
if (abstractBlog instanceof Blog) {
Blog blog = (Blog)abstractBlog;
if (SecurityUtils.isUserAuthorisedForBlogAsBlogPublisher(blog)) {
return EVAL_BODY_INCLUDE;
}
}
return SKIP_BODY;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -