File Source: viewmessagesaction.java

         /* 
    P/P   *  Method: net.sourceforge.pebble.web.action.ViewMessagesAction__static_init
          */
     1  package net.sourceforge.pebble.web.action;
     2  
     3  import net.sourceforge.pebble.Constants;
     4  import net.sourceforge.pebble.domain.Blog;
     5  import net.sourceforge.pebble.domain.Message;
     6  import net.sourceforge.pebble.web.view.View;
     7  import net.sourceforge.pebble.web.view.impl.MessagesView;
     8  
         /* 
    P/P   *  Method: void net.sourceforge.pebble.web.action.ViewMessagesAction()
          */
     9  import javax.servlet.ServletException;
    10  import javax.servlet.http.HttpServletRequest;
    11  import javax.servlet.http.HttpServletResponse;
    12  import java.util.Collections;
    13  import java.util.List;
    14  
    15  /**
    16   * Allows the user to see all messages for the current blog.
    17   *
    18   * @author    Simon Brown
    19   */
    20  public class ViewMessagesAction extends SecureAction {
    21  
    22    /**
    23     * Peforms the processing associated with this action.
    24     *
    25     * @param request  the HttpServletRequest instance
    26     * @param response the HttpServletResponse instance
    27     * @return the name of the next view
    28     */
    29    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
              */
    30      Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    31      List<Message> messages = blog.getMessages();
    32      Collections.reverse(messages);
    33      getModel().put("messages", messages);
    34  
    35      return new MessagesView();
    36    }
    37  
    38    /**
    39     * Gets a list of all roles that are allowed to access this action.
    40     *
    41     * @return  an array of Strings representing role names
    42     * @param request
    43     */
    44    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_CONTRIBUTOR_ROLE)
              *    init'ed(net.sourceforge.pebble.Constants.BLOG_OWNER_ROLE)
              *    init'ed(net.sourceforge.pebble.Constants.BLOG_PUBLISHER_ROLE)
              * 
              *  Postconditions:
              *    return_value == &new String[](getRoles#1)
              *    new String[](getRoles#1) num objects == 1
              *    return_value.length == 4
              *    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])
              *    return_value[2] == net.sourceforge.pebble.Constants.BLOG_PUBLISHER_ROLE
              *    (soft) init'ed(return_value[2])
              *    return_value[3] == net.sourceforge.pebble.Constants.BLOG_CONTRIBUTOR_ROLE
              *    ...
              */
    45      return new String[]{
    46        Constants.BLOG_ADMIN_ROLE,
    47        Constants.BLOG_OWNER_ROLE,
    48        Constants.BLOG_PUBLISHER_ROLE,
    49        Constants.BLOG_CONTRIBUTOR_ROLE
    50      };
    51    }
    52  
    53  }








SofCheck Inspector Build Version : 2.22510
viewmessagesaction.java 2010-Jun-25 19:40:34
viewmessagesaction.class 2010-Jul-19 20:23:38