isblogpublishertag.java

### File Source: isblogpublishertag.java

             /*
        P/P   *  Method: net.sourceforge.pebble.web.tagext.IsBlogPublisherTag__static_init
              */
         1  package net.sourceforge.pebble.web.tagext;
         2
         3  import net.sourceforge.pebble.domain.AbstractBlog;
         4  import net.sourceforge.pebble.domain.Blog;
         5  import net.sourceforge.pebble.Constants;
         6  import net.sourceforge.pebble.util.SecurityUtils;
         7
             /*
        P/P   *  Method: void net.sourceforge.pebble.web.tagext.IsBlogPublisherTag()
              */
         8  import javax.servlet.jsp.tagext.TagSupport;
         9  import javax.servlet.jsp.JspException;
        10  import javax.servlet.http.HttpServletRequest;
        11
        12  /**
        13   * A custom tag that includes its body content if the current user belongs to
        14   * the "blog publisher" role for the blog.
        15   *
        16   * @author    Simon Brown
        17   */
        18  public class IsBlogPublisherTag extends TagSupport {
        19
        20    /**
        21     * Implementation from the Tag interface - this is called when the opening tag
        22     * is encountered.
        23     *
        24     * @return  an integer specifying what to do afterwards
        25     * @throws  javax.servlet.jsp.JspException    if something goes wrong
        26     */
               /*
        P/P     *  Method: int doStartTag()
                *
                *  Preconditions:
                *    this.pageContext != null
                *
                *  Presumptions:
                *    javax.servlet.jsp.PageContext:getRequest(...)@28 != null
                *
                *  Postconditions:
                *    return_value in 0..1
                */
        27    public int doStartTag() throws JspException {
        28      HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
        29      AbstractBlog abstractBlog = (AbstractBlog)request.getAttribute(Constants.BLOG_KEY);
        30
        31      if (abstractBlog instanceof Blog) {
        32        Blog blog = (Blog)abstractBlog;
        33        if (SecurityUtils.isUserAuthorisedForBlogAsBlogPublisher(blog)) {
        34          return EVAL_BODY_INCLUDE;
        35        }
        36      }
        37
        38      return SKIP_BODY;
        39    }
        40
        41  }

SofCheck Inspector Build Version : 2.22510

isblogpublishertag.java | 2010-Jun-25 19:40:32
isblogpublishertag.class | 2010-Jul-19 20:23:38