From 332c058bd407c4b6fb30e6bf32b634a72bc68e05 Mon Sep 17 00:00:00 2001 From: ulrich <undisclosed> Date: Fri, 17 Jan 2020 16:31:42 +0000 Subject: [PATCH] Thumbnails werden nun im jeweiligen Bildordner mit abgelegt und nicht jedesmal 'on the fly' erzeugt. --- src/java/de/uhilger/filecms/pub/Catalog.java | 2 src/java/logging.properties | 138 +++++++++++++++++----------------- web/test.jsp | 25 ++++++ src/java/de/uhilger/filecms/api/FileMgr.java | 5 + src/java/de/uhilger/filecms/pub/ImgFileFilter.java | 29 +++++++ 5 files changed, 129 insertions(+), 70 deletions(-) diff --git a/src/java/de/uhilger/filecms/api/FileMgr.java b/src/java/de/uhilger/filecms/api/FileMgr.java index f96d2f0..d62cbb9 100644 --- a/src/java/de/uhilger/filecms/api/FileMgr.java +++ b/src/java/de/uhilger/filecms/api/FileMgr.java @@ -21,12 +21,15 @@ import de.uhilger.filecms.data.FileRef; import de.uhilger.filecms.pub.AbstractComparator; import de.uhilger.filecms.pub.FileNameComparator; +import de.uhilger.filecms.pub.ImgFileFilter; import de.uhilger.wbx.Bild; import de.uhilger.wbx.WbxUtils; import static de.uhilger.wbx.WbxUtils.EMPTY_STRING; import static de.uhilger.wbx.WbxUtils.WBX_FILE_BASE; import de.uhilger.wbx.data.Inhalt; +import de.uhilger.wbx.web.TNServlet; import java.io.File; +import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -124,7 +127,7 @@ logger.fine("listing path: " + path); File dir = new File(path); if (dir.exists()) { - File[] fileArray = dir.listFiles(); + File[] fileArray = dir.listFiles(new ImgFileFilter()); if (orderBy != null && orderBy.equalsIgnoreCase("name")) { Arrays.sort(fileArray, new FileNameComparator(order)); } else { diff --git a/src/java/de/uhilger/filecms/pub/Catalog.java b/src/java/de/uhilger/filecms/pub/Catalog.java index 453049c..5381c92 100644 --- a/src/java/de/uhilger/filecms/pub/Catalog.java +++ b/src/java/de/uhilger/filecms/pub/Catalog.java @@ -71,7 +71,7 @@ path.append(relPath); File dir = new File(getBase().getAbsolutePath(), path.toString()); if(dir.exists()) { - File[] fileArray = dir.listFiles(); + File[] fileArray = dir.listFiles(new ImgFileFilter()); if(orderBy != null && orderBy.equalsIgnoreCase("date")) { Arrays.sort(fileArray, new FileDateComparator(order)); } diff --git a/src/java/de/uhilger/filecms/pub/ImgFileFilter.java b/src/java/de/uhilger/filecms/pub/ImgFileFilter.java new file mode 100644 index 0000000..c8abcd2 --- /dev/null +++ b/src/java/de/uhilger/filecms/pub/ImgFileFilter.java @@ -0,0 +1,29 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package de.uhilger.filecms.pub; + +import de.uhilger.wbx.web.TNServlet; +import java.io.File; +import java.io.FileFilter; + +/** + * + * @author ulrich + */ +public class ImgFileFilter implements FileFilter { + @Override + public boolean accept(File pathname) { + boolean pass = true; + String fname = pathname.getName().toLowerCase(); + if(fname.endsWith(TNServlet.JPEG) || fname.endsWith(TNServlet.JPG) || fname.endsWith(TNServlet.PNG)) { + if(fname.contains(TNServlet.GR) || fname.contains(TNServlet.KL) || fname.contains(TNServlet.MT) || + fname.contains(TNServlet.SM) || fname.contains(TNServlet.TN)) { + pass = false; + } + } + return pass; + } +} diff --git a/src/java/logging.properties b/src/java/logging.properties index 511b5a4..465c5ec 100644 --- a/src/java/logging.properties +++ b/src/java/logging.properties @@ -1,68 +1,70 @@ -############################################################ -# 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.filecms.handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler -de.uhilger.filecms.level = INFO +############################################################ +# 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 = NONE + +############################################################ +# 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.filecms.handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler +de.uhilger.filecms.level = FINEST +de.uhilger.wbx.handlers = java.util.logging.ConsoleHandler +de.uhilger.wbx.level = FINEST \ No newline at end of file diff --git a/web/test.jsp b/web/test.jsp new file mode 100644 index 0000000..83de0a3 --- /dev/null +++ b/web/test.jsp @@ -0,0 +1,25 @@ +<%-- + Document : test + Created on : 17.01.2020, 07:46:52 + Author : ulrich +--%> + +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@ page import = "java.io.*,java.util.*"%> +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title>Test</title> + </head> + <body> + <p>Testseite</p> + <p> + Catalina Home: <%= System.getProperty("catalina.home")%><br/> + Catalina Base: <%= System.getProperty("catalina.base")%> + </p> + <p> + <img src="/home/test/bilder/278103-14-r_tn.jpg" /> + </p> + </body> +</html> -- Gitblit v1.9.3