updates to make it run in jetty

This commit is contained in:
erik 2008-12-08 00:58:53 +00:00
parent f2f7bd91bb
commit c90294003e

View file

@ -31,6 +31,7 @@ import com.drew.metadata.MetadataException;
public class AlbumServlet
extends HttpServlet
{
String basePath = "/home/erik/Photos/Wedding";
EntryDao dao;
@Override
@ -45,24 +46,14 @@ public class AlbumServlet
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
String path = req.getPathTranslated();
String pathInfo = req.getPathInfo();
String page = null;
if (path.endsWith(".photo")) {
path = path.substring(0, path.length() - ".photo".length());
if (pathInfo.endsWith(".photo")) {
pathInfo = pathInfo.substring(0, pathInfo.length() - ".photo".length());
page = "photo";
}
File file = new File(path);
if (file == null) {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
if (!file.exists()) {
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
File file = new File(basePath + pathInfo);
System.out.println("path=" + file);
if (!file.canRead()) {
res.setStatus(HttpServletResponse.SC_FORBIDDEN);
return;
@ -90,7 +81,6 @@ public class AlbumServlet
throw new RuntimeException("sadness", e);
}
} else if ("photo".equals(page)) {
try {
Entry e = dao.readFile(file);
req.setAttribute("entry", e);
@ -150,7 +140,7 @@ public class AlbumServlet
}
BufferedImage img = reader.read(0, param);
// Recalculate scale after subsampling was applied
// Recalculate scale after sub-sampling was applied
double scale;
AffineTransform xform;
if (entry.getOrientation() == 6) {