clearmessagesaction.java

### File Source: clearmessagesaction.java

             /*
        P/P   *  Method: net.sourceforge.pebble.web.action.ClearMessagesAction__static_init
              */
         1  package net.sourceforge.pebble.web.action;
         2
         3  import net.sourceforge.pebble.web.security.RequireSecurityToken;
         4  import net.sourceforge.pebble.web.view.View;
         5  import net.sourceforge.pebble.web.view.impl.MessagesView;
         6  import net.sourceforge.pebble.Constants;
         7  import net.sourceforge.pebble.domain.Blog;
         8
             /*
        P/P   *  Method: void net.sourceforge.pebble.web.action.ClearMessagesAction()
              */
         9  import javax.servlet.http.HttpServletRequest;
        10  import javax.servlet.http.HttpServletResponse;
        11  import javax.servlet.ServletException;
        12
        13  /**
        14   * Allows the user to clear all messages for the current blog.
        15   *
        16   * @author    Simon Brown
        17   */
        18  @RequireSecurityToken
        19  public class ClearMessagesAction extends SecureAction {
        20
        21    /**
        22     * Peforms the processing associated with this action.
        23     *
        24     * @param request  the HttpServletRequest instance
        25     * @param response the HttpServletResponse instance
        26     * @return the name of the next view
        27     */
        28    public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
                 /*
        P/P       *  Method: View process(HttpServletRequest, HttpServletResponse)
                  *
                  *  Preconditions:
                  *    this.model != null
                  *    this.model.data != null
                  *
                  *  Presumptions:
                  *    java.util.HashMap:get(...)@63 != null
                  *
                  *  Postconditions:
                  *    return_value == &new MessagesView(process#1)
                  *    new MessagesView(process#1) num objects == 1
                  */
        29      Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
        30      blog.clearMessages();
        31      getModel().put("messages", blog.getMessages());
        32
        33      return new MessagesView();
        34    }
        35
        36    /**
        37     * Gets a list of all roles that are allowed to access this action.
        38     *
        39     * @return  an array of Strings representing role names
        40     * @param request
        41     */
        42    public String[] getRoles(HttpServletRequest request) {
                 /*
        P/P       *  Method: String[] getRoles(HttpServletRequest)
                  *
                  *  Presumptions:
                  *    init'ed(net.sourceforge.pebble.Constants.BLOG_ADMIN_ROLE)
                  *    init'ed(net.sourceforge.pebble.Constants.BLOG_OWNER_ROLE)
                  *
                  *  Postconditions:
                  *    return_value == &new String[](getRoles#1)
                  *    new String[](getRoles#1) num objects == 1
                  *    return_value.length == 2
                  *    return_value[0] == net.sourceforge.pebble.Constants.BLOG_ADMIN_ROLE
                  *    (soft) init'ed(return_value[0])
                  *    return_value[1] == net.sourceforge.pebble.Constants.BLOG_OWNER_ROLE
                  *    (soft) init'ed(return_value[1])
                  */
        43      return new String[]{Constants.BLOG_ADMIN_ROLE, Constants.BLOG_OWNER_ROLE};
        44    }
        45
        46  }

SofCheck Inspector Build Version : 2.22510

clearmessagesaction.java | 2010-Jun-25 19:40:34
clearmessagesaction.class | 2010-Jul-19 20:23:38