diff --git a/pom.xml b/pom.xml index aca63c673..e07e23b92 100644 --- a/pom.xml +++ b/pom.xml @@ -66,6 +66,11 @@ 3.11-beta2 1.8.7 1.0.0-SNAPSHOT + + true + true + UTF-8 + ${basedir}/src/test/resources/tomcat-users.xml fess @@ -77,6 +82,15 @@ src/main/resources + + + + org.codelibs + tomcat8-maven-plugin + 3.0-SNAPSHOT + + + maven-compiler-plugin diff --git a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java index 41220856c..c9903d5cd 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 a275426af..4340f1b51 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>>() { @@ -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 bf73b0909..9b06aa044 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 b420a245b..236ca2e82 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" } --> - @System@getProperty("fess.log.file").replaceAll(".out", "_crawler.out") + + @System@getProperty("fess.log.file") == null ? + @System@getProperty("java.io.tmpdir") + "/fess_crawler.out" : + @System@getProperty("fess.log.file").replaceAll(".out", "_crawler.out") + @System@getProperty("java.version").startsWith("1.7") ? new String[] { diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index 55d153c96..f3beb7024 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -45,6 +45,7 @@ --> - + + diff --git a/src/test/resources/tomcat-users.xml b/src/test/resources/tomcat-users.xml new file mode 100644 index 000000000..5b908722b --- /dev/null +++ b/src/test/resources/tomcat-users.xml @@ -0,0 +1,32 @@ + + + + + + + + + + +