confirmtrackbackaction.java

### File Source: confirmtrackbackaction.java

             /*
        P/P   *  Method: net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init
              *
              *  Postconditions:
              *    init'ed(log)
              */
         1  package net.sourceforge.pebble.web.action;
         2
         3  import net.sourceforge.pebble.Constants;
         4  import net.sourceforge.pebble.api.confirmation.TrackBackConfirmationStrategy;
         5  import net.sourceforge.pebble.domain.*;
         6  import net.sourceforge.pebble.web.view.NotFoundView;
         7  import net.sourceforge.pebble.web.view.View;
         8  import net.sourceforge.pebble.web.view.impl.ConfirmTrackBackView;
         9  import net.sourceforge.pebble.web.view.impl.TrackBackLinkView;
        10  import org.apache.commons.logging.Log;
        11  import org.apache.commons.logging.LogFactory;
        12
             /*
        P/P   *  Method: void net.sourceforge.pebble.web.action.ConfirmTrackBackAction()
              */
        13  import javax.servlet.ServletException;
        14  import javax.servlet.http.HttpServletRequest;
        15  import javax.servlet.http.HttpServletResponse;
        16
        17  /**
        18   * Confirms a TrackBack.
        19   *
        20   * @author    Simon Brown
        21   */
        22  public class ConfirmTrackBackAction extends AbstractTrackBackAction {
        23
        24    /** the log used by this class */
        25    private static Log log = LogFactory.getLog(ConfirmTrackBackAction.class);
        26
        27    /**
        28     * Peforms the processing associated with this action.
        29     *
        30     * @param request  the HttpServletRequest instance
        31     * @param response the HttpServletResponse instance
        32     * @return the name of the next view
        33     */
        34    public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        35      Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
        36      BlogEntry blogEntry;
        37
        38      String entry = (String)request.getSession().getAttribute(BLOG_ENTRY_ID);
        39      if (entry == null) {
        40        return new NotFoundView();
        41      }
        42
        43      BlogService service = new BlogService();
        44      try {
        45        blogEntry = service.getBlogEntry(blog, entry);
        46      } catch (BlogServiceException e) {
        47        throw new ServletException(e);
        48      }
        49      if (blogEntry == null) {
        50        // just send back a 404 - this is probably somebody looking for a way
        51        // to send comment spam ;-)
        52        return new NotFoundView();
        53      } else if (!blogEntry.isTrackBacksEnabled()) {
        54        return new NotFoundView();
        55      }
        56      getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry);
        57
        58      TrackBackConfirmationStrategy strategy = blog.getTrackBackConfirmationStrategy();
        59
        60      if (strategy.isConfirmed(request)) {
        61        generateTrackBackLink(blogEntry);
        62        request.getSession().removeAttribute(BLOG_ENTRY_ID);
        63        return new TrackBackLinkView();
        64      } else {
        65        // try again!
        66        strategy.setupConfirmation(request);
        67        return new ConfirmTrackBackView();
        68      }
        69    }
        70
        71  }

SofCheck Inspector Build Version : 2.22510

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