This commit is contained in:
Shinsuke Sugaya 2015-03-29 20:26:33 +09:00
parent e657d94b12
commit 5683bdff56
7 changed files with 63 additions and 82 deletions

14
pom.xml
View file

@ -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>

View file

@ -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();

View file

@ -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;
}

View file

@ -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");

View file

@ -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[] {

View file

@ -45,6 +45,7 @@
-->
<root>
<priority value="info"/>
<appender-ref ref="rollingFile"/>
<!-- TODO replace for production -->
<appender-ref ref="stdout"/>
</root>
</log4j:configuration>

View file

@ -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>