updates to make it run in jetty
This commit is contained in:
parent
f2f7bd91bb
commit
c90294003e
1 changed files with 7 additions and 17 deletions
|
|
@ -31,6 +31,7 @@ import com.drew.metadata.MetadataException;
|
||||||
public class AlbumServlet
|
public class AlbumServlet
|
||||||
extends HttpServlet
|
extends HttpServlet
|
||||||
{
|
{
|
||||||
|
String basePath = "/home/erik/Photos/Wedding";
|
||||||
EntryDao dao;
|
EntryDao dao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -45,24 +46,14 @@ public class AlbumServlet
|
||||||
public void doGet(HttpServletRequest req, HttpServletResponse res)
|
public void doGet(HttpServletRequest req, HttpServletResponse res)
|
||||||
throws ServletException, IOException
|
throws ServletException, IOException
|
||||||
{
|
{
|
||||||
String path = req.getPathTranslated();
|
String pathInfo = req.getPathInfo();
|
||||||
|
|
||||||
String page = null;
|
String page = null;
|
||||||
if (path.endsWith(".photo")) {
|
if (pathInfo.endsWith(".photo")) {
|
||||||
path = path.substring(0, path.length() - ".photo".length());
|
pathInfo = pathInfo.substring(0, pathInfo.length() - ".photo".length());
|
||||||
page = "photo";
|
page = "photo";
|
||||||
}
|
}
|
||||||
File file = new File(path);
|
File file = new File(basePath + pathInfo);
|
||||||
if (file == null) {
|
System.out.println("path=" + file);
|
||||||
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file.exists()) {
|
|
||||||
res.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file.canRead()) {
|
if (!file.canRead()) {
|
||||||
res.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
res.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
||||||
return;
|
return;
|
||||||
|
|
@ -90,7 +81,6 @@ public class AlbumServlet
|
||||||
throw new RuntimeException("sadness", e);
|
throw new RuntimeException("sadness", e);
|
||||||
}
|
}
|
||||||
} else if ("photo".equals(page)) {
|
} else if ("photo".equals(page)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Entry e = dao.readFile(file);
|
Entry e = dao.readFile(file);
|
||||||
req.setAttribute("entry", e);
|
req.setAttribute("entry", e);
|
||||||
|
|
@ -150,7 +140,7 @@ public class AlbumServlet
|
||||||
}
|
}
|
||||||
BufferedImage img = reader.read(0, param);
|
BufferedImage img = reader.read(0, param);
|
||||||
|
|
||||||
// Recalculate scale after subsampling was applied
|
// Recalculate scale after sub-sampling was applied
|
||||||
double scale;
|
double scale;
|
||||||
AffineTransform xform;
|
AffineTransform xform;
|
||||||
if (entry.getOrientation() == 6) {
|
if (entry.getOrientation() == 6) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue