git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@886 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 19 years ago
parent d666b61b83
commit 16a49c1c9d

@ -417,6 +417,11 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
e.getTargetException().getMessage(),e); e.getTargetException().getMessage(),e);
targetClass = null; targetClass = null;
} }
if (bi == null) {
// error with image generation; send file-not-found
httpd.sendRespondError(this.connectionProperties,out,3,404,"File not Found",null,null);
} else {
// send an image to client
targetDate = new Date(System.currentTimeMillis()); targetDate = new Date(System.currentTimeMillis());
String mimeType = mimeTable.getProperty(targetExt,"text/html"); String mimeType = mimeTable.getProperty(targetExt,"text/html");
@ -429,7 +434,7 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
httpd.sendRespondHeader(this.connectionProperties, out, "HTTP/1.1", 200, null, mimeType, result.length, targetDate, null, null, null, null); httpd.sendRespondHeader(this.connectionProperties, out, "HTTP/1.1", 200, null, mimeType, result.length, targetDate, null, null, null, null);
Thread.currentThread().sleep(200); // see below Thread.currentThread().sleep(200); // see below
serverFileUtils.write(result, out); serverFileUtils.write(result, out);
}
} else if ((targetFile.exists()) && (targetFile.canRead())) { } else if ((targetFile.exists()) && (targetFile.canRead())) {
// we have found a file that can be written to the client // we have found a file that can be written to the client
// if this file uses templates, then we use the template // if this file uses templates, then we use the template

@ -350,6 +350,7 @@ public class ImagePainter {
GraphicsConfiguration gc = gs.getDefaultConfiguration(); GraphicsConfiguration gc = gs.getDefaultConfiguration();
BufferedImage bi = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT); BufferedImage bi = gc.createCompatibleImage(width, height, Transparency.TRANSLUCENT);
*/ */
try {
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D gr = bi.createGraphics(); Graphics2D gr = bi.createGraphics();
gr.setBackground(Color.white); gr.setBackground(Color.white);
@ -382,6 +383,25 @@ public class ImagePainter {
} }
} }
return bi; return bi;
} catch (Exception e) {
// strange case where environment disallowes generation of graphics
/*
java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$000(X11GraphicsEnvironment.java:53)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:142)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1141)
at de.anomic.tools.ImagePainter.toImage(ImagePainter.java:354)
*/
System.out.println("Error with Graphics environment:");
e.printStackTrace();
return new BufferedImage(0, 0, BufferedImage.TYPE_INT_RGB);
}
} }
} }

Loading…
Cancel
Save