Subversion Repositories general

Rev

Rev 936 | Rev 1242 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package ak.photoalbum.webapp;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.log4j.Logger;
import ak.photoalbum.util.FileUtils;

public final class IndexAction
  extends BaseAction
{
  private static final Logger logger = Logger.getLogger(IndexAction.class);

  public ActionForward executeAction(ActionMapping mapping, ActionForm form,
     HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    PathForm   theForm = (PathForm)form;
    String     dir     = theForm.getPath();
    IndexEntry entry   = new IndexEntry();
    IndexEntry top     = new IndexEntry();
    IndexEntry prev    = new IndexEntry();
    IndexEntry current = new IndexEntry();
    IndexEntry next    = new IndexEntry();
    List       index;

    if(dir == null) dir = "";  // the images root

    logger.info("get index for " + dir);
    Logic.getLogic().getEntry(dir, entry, top, prev, current, next);
    index = Logic.getLogic().listDirectory(dir);

    request.setAttribute("dir", FileUtils.replaceFileSeparator(dir, " - "));
    request.setAttribute("index",     index);
    request.setAttribute("top",       top);
    request.setAttribute("prevEntry", prev);
    request.setAttribute("current",   current);
    request.setAttribute("nextEntry", next);

    return mapping.findForward("success");
  }
}