//# 0 errors, 27 messages
//#
package net.sourceforge.pebble.web.action;
    //#confirmtrackbackaction.java:1:1: class: net.sourceforge.pebble.web.action.ConfirmTrackBackAction

import net.sourceforge.pebble.Constants;
import net.sourceforge.pebble.api.confirmation.TrackBackConfirmationStrategy;
import net.sourceforge.pebble.domain.*;
import net.sourceforge.pebble.web.view.NotFoundView;
import net.sourceforge.pebble.web.view.View;
import net.sourceforge.pebble.web.view.impl.ConfirmTrackBackView;
import net.sourceforge.pebble.web.view.impl.TrackBackLinkView;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Confirms a TrackBack.
 *
 * @author    Simon Brown
 */
public class ConfirmTrackBackAction extends AbstractTrackBackAction {
    //#confirmtrackbackaction.java:22: method: void net.sourceforge.pebble.web.action.ConfirmTrackBackAction.net.sourceforge.pebble.web.action.ConfirmTrackBackAction()
    //#input(void net.sourceforge.pebble.web.action.ConfirmTrackBackAction()): this
    //#unanalyzed(void net.sourceforge.pebble.web.action.ConfirmTrackBackAction()): Effects-of-calling:net.sourceforge.pebble.web.action.Action
    //#confirmtrackbackaction.java:22: end of method: void net.sourceforge.pebble.web.action.ConfirmTrackBackAction.net.sourceforge.pebble.web.action.ConfirmTrackBackAction()

  /** the log used by this class */
  private static Log log = LogFactory.getLog(ConfirmTrackBackAction.class);
    //#confirmtrackbackaction.java:25: method: net.sourceforge.pebble.web.action.ConfirmTrackBackAction.net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init
    //#confirmtrackbackaction.java:25: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.web.action.ConfirmTrackBackAction
    //#    method: net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Descendant_Table[net/sourceforge/pebble/web/action/ConfirmTrackBackAction]
    //#output(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.generateTrackBackLink(Lnet/sourceforge/pebble/domain/BlogEntry;)V
    //#output(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.getLocalizedString(Ljava/lang/String;)Ljava/lang/String;
    //#output(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.getModel()Lnet/sourceforge/pebble/web/model/Model;
    //#output(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.process(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Lnet/sourceforge/pebble/web/view/View;
    //#output(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.setModel(Lnet/sourceforge/pebble/web/model/Model;)V
    //#output(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): log
    //#output(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): net/sourceforge/pebble/web/action/AbstractTrackBackAction.__Descendant_Table[net/sourceforge/pebble/web/action/ConfirmTrackBackAction]
    //#output(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): net/sourceforge/pebble/web/action/Action.__Descendant_Table[net/sourceforge/pebble/web/action/ConfirmTrackBackAction]
    //#post(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Descendant_Table[net/sourceforge/pebble/web/action/ConfirmTrackBackAction] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): net/sourceforge/pebble/web/action/AbstractTrackBackAction.__Descendant_Table[net/sourceforge/pebble/web/action/ConfirmTrackBackAction] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): net/sourceforge/pebble/web/action/Action.__Descendant_Table[net/sourceforge/pebble/web/action/ConfirmTrackBackAction] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.generateTrackBackLink(Lnet/sourceforge/pebble/domain/BlogEntry;)V == &net/sourceforge/pebble/web/action/AbstractTrackBackAction.generateTrackBackLink
    //#post(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.getLocalizedString(Ljava/lang/String;)Ljava/lang/String; == &net/sourceforge/pebble/web/action/Action.getLocalizedString
    //#post(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.getModel()Lnet/sourceforge/pebble/web/model/Model; == &net/sourceforge/pebble/web/action/Action.getModel
    //#post(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.process(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)Lnet/sourceforge/pebble/web/view/View; == &process
    //#post(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): __Dispatch_Table.setModel(Lnet/sourceforge/pebble/web/model/Model;)V == &net/sourceforge/pebble/web/action/Action.setModel
    //#post(net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init): init'ed(log)
    //#confirmtrackbackaction.java:25: end of method: net.sourceforge.pebble.web.action.ConfirmTrackBackAction.net.sourceforge.pebble.web.action.ConfirmTrackBackAction__static_init

  /**
   * Peforms the processing associated with this action.
   *
   * @param request  the HttpServletRequest instance
   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    BlogEntry blogEntry;

    String entry = (String)request.getSession().getAttribute(BLOG_ENTRY_ID);
    if (entry == null) {
      return new NotFoundView();
    }

    BlogService service = new BlogService();
    try {
      blogEntry = service.getBlogEntry(blog, entry);
    } catch (BlogServiceException e) {
      throw new ServletException(e);
    }
    if (blogEntry == null) {
      // just send back a 404 - this is probably somebody looking for a way
      // to send comment spam ;-)
      return new NotFoundView();
    } else if (!blogEntry.isTrackBacksEnabled()) {
      return new NotFoundView();
    }
    getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry);

    TrackBackConfirmationStrategy strategy = blog.getTrackBackConfirmationStrategy();

    if (strategy.isConfirmed(request)) {
      generateTrackBackLink(blogEntry);
      request.getSession().removeAttribute(BLOG_ENTRY_ID);
      return new TrackBackLinkView();
    } else {
      // try again!
      strategy.setupConfirmation(request);
      return new ConfirmTrackBackView();
    }
  }

}
    //#confirmtrackbackaction.java:: end of class: net.sourceforge.pebble.web.action.ConfirmTrackBackAction
