Subversion Repositories general

Rev

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

package ak.photoalbum.webapp;

import java.io.FileNotFoundException;
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.logic.Logic;

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

  public ActionForward executeAction(ActionMapping mapping, ActionForm form,
     HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    PathForm theForm = (PathForm)form;
    String   branch  = theForm.getBranch();
    String   path    = theForm.getPath();
    Logic    logic   = Logic.getLogic();

    logger.info("get image " + mapping.getParameter() + " for " + path);

    if("dir".equals(mapping.getParameter())) {
      response.setContentType(logic.getThumbnailMime(branch));
      logic.writeDir(branch, path, response.getOutputStream());
    }
    else if("small".equals(mapping.getParameter())) {
      response.setContentType(logic.getThumbnailMime(branch));
      logic.writeSmall(branch, path, response.getOutputStream());
    }
    else if("medium".equals(mapping.getParameter())) {
      response.setContentType(logic.getThumbnailMime(branch));
      logic.writeMedium(branch, path, response.getOutputStream());
    }
    else if("origin".equals(mapping.getParameter())) {
      response.setContentType(logic.getOriginMime(branch, path));
      logic.writeOrigin(branch, path, response.getOutputStream());
    }

    return null;
  }
}