src/de/uhilger/wbx/Bild.java | ●●●●● patch | view | raw | blame | history | |
src/de/uhilger/wbx/web/TNServlet.java | ●●●●● patch | view | raw | blame | history | |
src/logging.properties | ●●●●● patch | view | raw | blame | history |
src/de/uhilger/wbx/Bild.java
@@ -27,6 +27,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.OutputStream; import java.net.FileNameMap; import java.net.URLConnection; import javax.imageio.ImageIO; @@ -44,27 +45,33 @@ public static final String[] GRNAME = {"-w", "-k", "-m", "-g"}; public static final int[] GR = {120, 240, 700, 1200}; public void writeImageStream(Image image, int gr, String mimeType, OutputStream out) throws InterruptedException, IOException { ImageIO.write(getReducedImage(image, gr, mimeType), imgType(mimeType), out); } /** * * @param image * @param gr * @param mimeType * @param oName Name der Originaldatei * @param vName Name der verkleinerten Datei * @throws InterruptedException * @throws IOException */ public void writeImageFile(Image image, int gr, String mimeType, String oName, String vName) throws InterruptedException, IOException { public void writeImageFile(Image image, int gr, String mimeType, String vName) throws InterruptedException, IOException { ImageIO.write(getReducedImage(image, gr, mimeType), imgType(mimeType), new File(vName)); } private BufferedImage getReducedImage(Image image, int gr, String mimeType) throws InterruptedException, IOException { BufferedImage img; int q = 90; float sh = 0.f; //String mimeType = photo.getMimetype(); BufferedImage img; if(mimeType.contains("jpeg")) { img = getReducedImage(image, gr, gr, q, sh, false); } else { img = getReducedImage(image, gr, gr, q, sh, true); } ImageIO.write(img, imgType(mimeType), new File(vName)); return img; } /** src/de/uhilger/wbx/web/TNServlet.java
@@ -17,7 +17,11 @@ */ package de.uhilger.wbx.web; import java.awt.Image; import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -30,6 +34,8 @@ * */ public class TNServlet extends DefaultServlet { private static final Logger logger = Logger.getLogger(TNServlet.class.getName()); /** * Diese String-Konstanten noetigenfalls in eine @@ -52,12 +58,19 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String urlStr = request.getRequestURI(); if(urlStr.contains(TN) && (urlStr.endsWith(JPG) || urlStr.endsWith(JPEG) || urlStr.endsWith(PNG))) { String uriStr = request.getRequestURI(); File imgfile = new File(uriStr); logger.fine("realpath of /: " + request.getServletContext().getRealPath("/")); logger.fine("imgfile: " + imgfile.getAbsolutePath()); if(uriStr.contains(TN) && (uriStr.endsWith(JPG) || uriStr.endsWith(JPEG) || uriStr.endsWith(PNG))) { /* TODO: hier mit Hilfe der Klasse Bild eine Miniaturansicht erzeugen und in die Antwort schreiben */ //writeImageStream(Image image, int gr, String mimeType, response.getOutputStream()); } else { super.doGet(request, response); } src/logging.properties
New file @@ -0,0 +1,68 @@ ############################################################ # Default Logging Configuration File # # You can use a different file by specifying a filename # with the java.util.logging.config.file system property. # For example java -Djava.util.logging.config.file=myfile ############################################################ ############################################################ # Global properties ############################################################ # "handlers" specifies a comma separated list of log Handler # classes. These handlers will be installed during VM startup. # Note that these classes must be on the system classpath. # By default we only configure a ConsoleHandler, which will only # show messages at the INFO and above levels. # handlers= java.util.logging.ConsoleHandler # To also add the FileHandler, use the following line instead. handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler # Default global logging level. # This specifies which kinds of events are logged across # all loggers. For any given facility this global level # can be overriden by a facility specific level # Note that the ConsoleHandler also has a separate level # setting to limit messages printed to the console. # .level= FINE .level = OFF ############################################################ # Handler specific properties. # Describes specific configuration info for Handlers. ############################################################ # default file output is in user's home directory. # java.util.logging.FileHandler.pattern = %h/java%u.log # java.util.logging.FileHandler.pattern = /media/extmirror/tomcat747/logs/tv_%u.log # java.util.logging.FileHandler.pattern = ${catalina.base}/logs/file-cms_%u.log java.util.logging.FileHandler.limit = 50000 # java.util.logging.FileHandler.count = 1 java.util.logging.FileHandler.count = 2 # java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter java.util.logging.FileHandler.level = FINER # Limit the message that are printed on the console to INFO and above. # java.util.logging.ConsoleHandler.level = INFO java.util.logging.ConsoleHandler.level = FINER java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter # Example to customize the SimpleFormatter output format # to print one-line log message like this: # <level>: <log message> [<date/time>] # # java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n ############################################################ # Facility specific properties. # Provides extra control for each logger. ############################################################ # For example, set the com.xyz.foo logger to only log SEVERE # messages: # com.xyz.foo.level = SEVERE de.uhilger.wbx.handlers = java.util.logging.ConsoleHandler de.uhilger.wbx.level = FINER