diff --git a/pom.xml b/pom.xml index 9302acb926e3c3073b950db808eef875a8fdf13d..ff05c850bb65ccaea2a1a51826a6df876031a37a 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ 1.7.0.1-SNAPSHOT - 0.3.7 + 0.3.8-RC6 https://oss.sonatype.org/content/repositories/snapshots diff --git a/src/main/java/org/codelibs/fess/FessBoot.java b/src/main/java/org/codelibs/fess/FessBoot.java index 593bc2784b38bd832681eb8bb7a06f3d877475d4..11ea2e26bc25bda4af94c81bd28e305ae5c6a34f 100644 --- a/src/main/java/org/codelibs/fess/FessBoot.java +++ b/src/main/java/org/codelibs/fess/FessBoot.java @@ -1,23 +1,14 @@ package org.codelibs.fess; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.Logger; -import java.util.regex.Pattern; import org.dbflute.tomcat.TomcatBoot; public class FessBoot extends TomcatBoot { - private static final Logger logger = Logger.getLogger(FessBoot.class.getPackage().getName()); + private static final String FESS_ENV_PROPERTIES = "fess_env.properties"; - private static final String LOGGING_PROPERTIES = "/logging.properties"; + private static final String LOGGING_PROPERTIES = "logging.properties"; private static final String FESS_CONTEXT_PATH = "fess.context.path"; @@ -31,10 +22,6 @@ public class FessBoot extends TomcatBoot { private static final String JAVA_IO_TMPDIR = "java.io.tmpdir"; - private static final int DEFAULT_BUF_SIZE = 4096; - - private static final String UTF_8 = "UTF-8"; - public FessBoot(final int port, final String contextPath) { super(port, contextPath); } @@ -63,8 +50,12 @@ public class FessBoot extends TomcatBoot { } @Override - protected void info(final String msg) { - logger.info(msg); + protected void loadServerLoggingIfNeeds() { + try { + super.loadServerLoggingIfNeeds(); + } catch (Exception e) { + // ignore + } } // =================================================================================== @@ -72,38 +63,22 @@ public class FessBoot extends TomcatBoot { // ============ public static void main(final String[] args) { - // load logging.properties - try (InputStream is = FessBoot.class.getResourceAsStream(LOGGING_PROPERTIES)) { - if (is != null) { - try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { - final ByteBuffer buffer = ByteBuffer.allocate(DEFAULT_BUF_SIZE); - final byte[] buf = buffer.array(); - int len; - while ((len = is.read(buf)) != -1) { - out.write(buf, 0, len); - } - - String configContent = out.toString(UTF_8); - final String fessHomeDir = System.getProperty("fess.home"); - if (fessHomeDir != null) { - configContent = configContent.replaceAll(Pattern.quote("${fess.home}"), fessHomeDir); - } - - LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(configContent.getBytes(UTF_8))); - logger.info(LOGGING_PROPERTIES + " is loaded."); - } - } - } catch (final IOException e) { - logger.log(Level.WARNING, "Failed to load " + LOGGING_PROPERTIES, e); - } - // update java.io.tmpdir final String value = System.getProperty(FESS_TEMP_PATH); if (value != null) { System.setProperty(JAVA_IO_TMPDIR, value); } - new FessBoot(getPort(), getContextPath()).useTldDetect().asDevelopment(isNoneEnv()).bootAwait(); + new FessBoot(getPort(), getContextPath()) // + .useTldDetect() // for JSP + .configure(FESS_ENV_PROPERTIES) // e.g. URIEncoding + .logging(LOGGING_PROPERTIES, op -> { + final String fessHomeDir = System.getProperty("fess.home"); + if (fessHomeDir != null) { + op.replace("fess.home", fessHomeDir); + } + }) // uses jdk14logger + .asDevelopment(isNoneEnv()).bootAwait(); } private static boolean isNoneEnv() { diff --git a/src/main/resources/fess_env.properties b/src/main/resources/fess_env.properties index 7b68f7850c8decd5da464be0118c690bef91065e..7aa7f842553fb8c5b43d4d7feba8c3037fd68860 100644 --- a/src/main/resources/fess_env.properties +++ b/src/main/resources/fess_env.properties @@ -45,3 +45,8 @@ mail.return.path = root@localhost # ======================================================================================== # Web # ===== +# ---------------------------------------------------------- +# Tomcat +# ------ +tomcat.URIEncoding = UTF-8 +tomcat.useBodyEncodingForURI = true diff --git a/src/main/resources/fess_env_production.properties b/src/main/resources/fess_env_production.properties index 2c2c3c788609fa0f724dc7d2f67f4939025db8df..00561aebb8c2816004c031cc65c42f11024a7413 100644 --- a/src/main/resources/fess_env_production.properties +++ b/src/main/resources/fess_env_production.properties @@ -45,3 +45,8 @@ mail.return.path = root@localhost # ======================================================================================== # Web # ===== +# ---------------------------------------------------------- +# Tomcat +# ------ +tomcat.URIEncoding = UTF-8 +tomcat.useBodyEncodingForURI = true