diff --git a/pom.xml b/pom.xml index aca63c6730f888f0ff34688765f434f9c1a23225..e07e23b92ba1ca7f0fe0f2d73e892829bcc032c2 100644 --- a/pom.xml +++ b/pom.xml @@ -66,6 +66,11 @@ <poi.version>3.11-beta2</poi.version> <pdfbox.version>1.8.7</pdfbox.version> <saflute.version>1.0.0-SNAPSHOT</saflute.version> + <!-- Tomcat --> + <tomcat.delegate>true</tomcat.delegate> + <tomcat.useSeparateTomcatClassLoader>true</tomcat.useSeparateTomcatClassLoader> + <maven.tomcat.uriEncoding>UTF-8</maven.tomcat.uriEncoding> + <maven.tomcat.tomcatUsers.file>${basedir}/src/test/resources/tomcat-users.xml</maven.tomcat.tomcatUsers.file> </properties> <build> <finalName>fess</finalName> @@ -77,6 +82,15 @@ <directory>src/main/resources</directory> </resource> </resources> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.codelibs</groupId> + <artifactId>tomcat8-maven-plugin</artifactId> + <version>3.0-SNAPSHOT</version> + </plugin> + </plugins> + </pluginManagement> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> diff --git a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java index 41220856cb1a5d9b963a58e34a09d5a7c2131fca..c9903d5cd587d86a3fbd1423fa9ce9c7b2ae9f19 100644 --- a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java +++ b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java @@ -61,6 +61,8 @@ public class SuggestHelper { final Thread th = new Thread(new Runnable() { @Override public void run() { + // TODO replace with Elasticsearch + /* while (true) { final PingResponse response = searchService.ping(); final int status = response.getStatus(); @@ -77,6 +79,7 @@ public class SuggestHelper { //ignore } } + */ } }); th.start(); diff --git a/src/main/java/org/codelibs/fess/helper/SystemHelper.java b/src/main/java/org/codelibs/fess/helper/SystemHelper.java index a275426af92df08a332b2607f5f585c8239fa783..4340f1b51f8ab7e6a0c3194ece76ce56178c3d88 100644 --- a/src/main/java/org/codelibs/fess/helper/SystemHelper.java +++ b/src/main/java/org/codelibs/fess/helper/SystemHelper.java @@ -16,8 +16,6 @@ package org.codelibs.fess.helper; -import java.io.File; -import java.io.FilenameFilter; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -39,20 +37,16 @@ import org.apache.commons.lang.LocaleUtils; import org.apache.commons.lang.StringUtils; import org.codelibs.core.util.StringUtil; import org.codelibs.fess.Constants; -import org.codelibs.fess.FessSystemException; import org.codelibs.fess.db.exentity.RoleType; import org.codelibs.fess.service.RoleTypeService; -import org.codelibs.fess.util.ResourceUtil; import org.codelibs.robot.util.CharUtil; import org.codelibs.solr.lib.SolrGroup; import org.codelibs.solr.lib.policy.QueryType; import org.codelibs.solr.lib.policy.StatusPolicy; import org.seasar.framework.container.SingletonS2Container; import org.seasar.framework.container.annotation.tiger.InitMethod; -import org.seasar.framework.util.FileUtil; import org.seasar.struts.util.MessageResourcesUtil; import org.seasar.struts.util.RequestUtil; -import org.seasar.struts.util.ServletContextUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,18 +90,8 @@ public class SystemHelper implements Serializable { private String[] supportedUploadedMediaExtentions = new String[] { "jpg", "jpeg", "gif", "png", "swf" }; - private String jarDir = "/jar/"; - - private String launcherFileNamePrefix = "fess-launcher-"; - private int maxTextLength = 4000; - // readonly - private String launcherJarPath; - - // readonly - private String launcherJnlpPath; - private final AtomicBoolean forceStop = new AtomicBoolean(false); protected String[] supportedLanguages = new String[] { "ar", "bg", "ca", "da", "de", "el", "en", "es", "eu", "fa", "fi", "fr", "ga", @@ -117,45 +101,6 @@ public class SystemHelper implements Serializable { @InitMethod public void init() { - final File[] files = ResourceUtil.getJarFiles(launcherFileNamePrefix); - if (files.length > 0) { - final String fileName = files[0].getName(); - final String jarPath = ServletContextUtil.getServletContext().getRealPath(jarDir); - final File[] jarFiles = new File(jarPath).listFiles(new FilenameFilter() { - @Override - public boolean accept(final File dir, final String name) { - return name.startsWith(launcherFileNamePrefix); - } - }); - if (jarFiles != null) { - for (final File jarFile : jarFiles) { - if (jarFile.exists() && !jarFile.delete()) { - logger.warn("Could not delete " + jarFile.getAbsolutePath()); - } - } - } - final File launcherJarFile = new File(jarPath, fileName); - final File parentLauncherJarFile = launcherJarFile.getParentFile(); - if (!parentLauncherJarFile.exists() && !parentLauncherJarFile.mkdirs()) { - logger.warn("Could not create " + parentLauncherJarFile.getAbsolutePath()); - } - FileUtil.copy(files[0], launcherJarFile); - launcherJarPath = jarDir + fileName; - launcherJnlpPath = launcherJarPath.replace(".jar", ".jnlp"); - final File launcherJnlpFile = new File(launcherJarFile.getAbsolutePath().replace(".jar", ".jnlp")); - final File jnlpTemplateFile = new File(ResourceUtil.getOrigPath("jnlp/fess-launcher.jnlp")); - if (!jnlpTemplateFile.isFile()) { - throw new FessSystemException(jnlpTemplateFile.getAbsolutePath() + " is not found."); - } - try { - String content = new String(FileUtil.getBytes(jnlpTemplateFile), Constants.UTF_8); - content = content.replace("${launcherJarFile}", fileName); - FileUtil.write(launcherJnlpFile.getAbsolutePath(), content.getBytes(Constants.UTF_8)); - } catch (final UnsupportedEncodingException e) { - throw new FessSystemException("Could not write " + jnlpTemplateFile.getAbsolutePath(), e); - } - } - langItemsCache = CacheBuilder.newBuilder().maximumSize(20).expireAfterAccess(1, TimeUnit.HOURS) .build(new CacheLoader<String, List<Map<String, String>>>() { @@ -373,30 +318,6 @@ public class SystemHelper implements Serializable { this.supportedUploadedMediaExtentions = supportedUploadedMediaExtentions; } - public String getJarDir() { - return jarDir; - } - - public void setJarDir(final String jarDir) { - this.jarDir = jarDir; - } - - public String getLauncherFileNamePrefix() { - return launcherFileNamePrefix; - } - - public void setLauncherFileNamePrefix(final String launcherFileNamePrefix) { - this.launcherFileNamePrefix = launcherFileNamePrefix; - } - - public String getLauncherJarPath() { - return launcherJarPath; - } - - public String getLauncherJnlpPath() { - return launcherJnlpPath; - } - public int getMaxTextLength() { return maxTextLength; } diff --git a/src/main/java/org/codelibs/fess/servlet/H2ConfigServlet.java b/src/main/java/org/codelibs/fess/servlet/H2ConfigServlet.java index bf73b0909d7a65f675e548f41a397f0ab6690933..9b06aa0449924c3d4dc72b9cd38d71e4dd05499a 100644 --- a/src/main/java/org/codelibs/fess/servlet/H2ConfigServlet.java +++ b/src/main/java/org/codelibs/fess/servlet/H2ConfigServlet.java @@ -16,6 +16,8 @@ package org.codelibs.fess.servlet; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -46,7 +48,11 @@ public class H2ConfigServlet extends HttpServlet { if (value != null) { argList.add(value); } else { - argList.add(getServletContext().getRealPath("/WEB-INF/db/")); + String baseDir = getServletContext().getRealPath("/WEB-INF/db/"); + if (Files.notExists(Paths.get(baseDir))) { + baseDir = getServletContext().getRealPath("/WEB-INF/") + "/../../h2/webapp/WEB-INF/db/"; + } + argList.add(baseDir); } argList.add("-tcp"); diff --git a/src/main/resources/fess.dicon b/src/main/resources/fess.dicon index b420a245bcc9cddb96d4756246c76cd870764a6f..236ca2e8294ed1c02e02d035764d2c8936166632 100644 --- a/src/main/resources/fess.dicon +++ b/src/main/resources/fess.dicon @@ -37,7 +37,11 @@ "hi", "hu", "hy", "id", "it", "ja", "lv", "ko", "nl", "no", "pt", "ro", "ru", "sv", "th", "tr", "zh_CN", "zh_TW", "zh" }</property> --> - <property name="logFilePath">@System@getProperty("fess.log.file").replaceAll(".out", "_crawler.out")</property> + <property name="logFilePath"> + @System@getProperty("fess.log.file") == null ? + @System@getProperty("java.io.tmpdir") + "/fess_crawler.out" : + @System@getProperty("fess.log.file").replaceAll(".out", "_crawler.out") + </property> <property name="crawlerJavaOptions"> @System@getProperty("java.version").startsWith("1.7") ? new String[] { diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index 55d153c965ef1862c85b2be712094445dc10ddb0..f3beb7024c80bc3211440229ffb92507b64e323d 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -45,6 +45,7 @@ --> <root> <priority value="info"/> - <appender-ref ref="rollingFile"/> + <!-- TODO replace for production --> + <appender-ref ref="stdout"/> </root> </log4j:configuration> diff --git a/src/test/resources/tomcat-users.xml b/src/test/resources/tomcat-users.xml new file mode 100644 index 0000000000000000000000000000000000000000..5b908722b064606186fa4705706ddd67188fcc4b --- /dev/null +++ b/src/test/resources/tomcat-users.xml @@ -0,0 +1,32 @@ +<?xml version='1.0' encoding='utf-8'?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<tomcat-users> + <role rolename="fess"/> + <role rolename="solr"/> + <role rolename="manager-script"/> + <user username="admin" password="admin" roles="fess"/> + <user username="solradmin" password="solradmin" roles="solr"/> + <user username="manager" password="manager" roles="manager-script"/> +<!-- + <role rolename="tomcat"/> + <role rolename="role1"/> + <user username="tomcat" password="tomcat" roles="tomcat"/> + <user username="both" password="tomcat" roles="tomcat,role1"/> + <user username="role1" password="tomcat" roles="role1"/> +--> +</tomcat-users>