Browse Source

improve screenshot processing, modify error pages, add fess.var.path

Shinsuke Sugaya 9 years ago
parent
commit
6c546159ae

+ 7 - 0
pom.xml

@@ -76,6 +76,7 @@
 		<packaging.fess.app.dir>${packaging.fess.home.dir}/app</packaging.fess.app.dir>
 		<packaging.fess.app.dir>${packaging.fess.home.dir}/app</packaging.fess.app.dir>
 		<packaging.fess.bin.dir>${packaging.fess.home.dir}/bin</packaging.fess.bin.dir>
 		<packaging.fess.bin.dir>${packaging.fess.home.dir}/bin</packaging.fess.bin.dir>
 		<packaging.fess.conf.dir>/etc/fess</packaging.fess.conf.dir>
 		<packaging.fess.conf.dir>/etc/fess</packaging.fess.conf.dir>
+        <packaging.fess.var.dir>/var/lib/fess</packaging.fess.var.dir>
 		<packaging.fess.lib.dir>${packaging.fess.home.dir}/lib</packaging.fess.lib.dir>
 		<packaging.fess.lib.dir>${packaging.fess.home.dir}/lib</packaging.fess.lib.dir>
 		<packaging.fess.log.dir>/var/log/fess</packaging.fess.log.dir>
 		<packaging.fess.log.dir>/var/log/fess</packaging.fess.log.dir>
 		<packaging.fess.temp.dir>/var/tmp/fess</packaging.fess.temp.dir>
 		<packaging.fess.temp.dir>/var/tmp/fess</packaging.fess.temp.dir>
@@ -456,6 +457,12 @@
 								</source>
 								</source>
 							</sources>
 							</sources>
 						</mapping>
 						</mapping>
+						<mapping>
+							<directory>${packaging.fess.var.dir}</directory>
+							<filemode>755</filemode>
+							<username>${packaging.fess.user}</username>
+							<groupname>${packaging.fess.group}</groupname>
+						</mapping>
 						<!-- bin -->
 						<!-- bin -->
 						<mapping>
 						<mapping>
 							<directory>${packaging.fess.bin.dir}</directory>
 							<directory>${packaging.fess.bin.dir}</directory>

+ 3 - 0
src/main/assemblies/files/fess.in.sh

@@ -88,6 +88,9 @@ FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dtomcat.config.path=tomcat_config.properties"
 if [ "x$FESS_CONF_PATH" != "x" ]; then
 if [ "x$FESS_CONF_PATH" != "x" ]; then
   FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.conf.path=$FESS_CONF_PATH"
   FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.conf.path=$FESS_CONF_PATH"
 fi
 fi
+if [ "x$FESS_VAR_PATH" != "x" ]; then
+  FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.var.path=$FESS_VAR_PATH"
+fi
 if [ "x$ES_HTTP_URL" != "x" ]; then
 if [ "x$ES_HTTP_URL" != "x" ]; then
   FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.es.http_address=$ES_HTTP_URL"
   FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.es.http_address=$ES_HTTP_URL"
 fi
 fi

+ 0 - 2
src/main/java/org/codelibs/fess/Constants.java

@@ -129,8 +129,6 @@ public class Constants extends CoreLibConstants {
 
 
     public static final String SEARCH_FILE_PROXY_PROPERTY = "search.file.proxy";
     public static final String SEARCH_FILE_PROXY_PROPERTY = "search.file.proxy";
 
 
-    public static final String SEARCH_DESKTOP_PROPERTY = "search.desktop";
-
     public static final String NOTIFICATION_TO_PROPERTY = "notification.to";
     public static final String NOTIFICATION_TO_PROPERTY = "notification.to";
 
 
     public static final String USE_BROWSER_LOCALE_FOR_SEARCH_PROPERTY = "search.use.browser.locale";
     public static final String USE_BROWSER_LOCALE_FOR_SEARCH_PROPERTY = "search.use.browser.locale";

+ 5 - 6
src/main/java/org/codelibs/fess/app/web/cache/CacheAction.java

@@ -19,6 +19,7 @@ import java.util.Map;
 
 
 import org.codelibs.fess.Constants;
 import org.codelibs.fess.Constants;
 import org.codelibs.fess.app.web.base.FessSearchAction;
 import org.codelibs.fess.app.web.base.FessSearchAction;
+import org.codelibs.fess.app.web.error.ErrorAction;
 import org.codelibs.fess.util.DocumentUtil;
 import org.codelibs.fess.util.DocumentUtil;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.index.query.TermQueryBuilder;
 import org.elasticsearch.index.query.TermQueryBuilder;
@@ -65,16 +66,14 @@ public class CacheAction extends FessSearchAction {
             logger.warn("Failed to request: " + form.docId, e);
             logger.warn("Failed to request: " + form.docId, e);
         }
         }
         if (doc == null) {
         if (doc == null) {
-            throwValidationError(messages -> {
-                messages.addErrorsDocidNotFound(GLOBAL, form.docId);
-            }, () -> asHtml(path_ErrorJsp));
+            saveError(messages -> messages.addErrorsDocidNotFound(GLOBAL, form.docId));
+            return redirect(ErrorAction.class);
         }
         }
 
 
         final String content = viewHelper.createCacheContent(doc, form.hq);
         final String content = viewHelper.createCacheContent(doc, form.hq);
         if (content == null) {
         if (content == null) {
-            throwValidationError(messages -> {
-                messages.addErrorsDocidNotFound(GLOBAL, form.docId);
-            }, () -> asHtml(path_ErrorJsp));
+            saveError(messages -> messages.addErrorsDocidNotFound(GLOBAL, form.docId));
+            return redirect(ErrorAction.class);
         }
         }
 
 
         return asStream(DocumentUtil.getValue(doc, fessConfig.getIndexFieldDocId(), String.class)).contentType("text/html; charset=UTF-8")
         return asStream(DocumentUtil.getValue(doc, fessConfig.getIndexFieldDocId(), String.class)).contentType("text/html; charset=UTF-8")

+ 1 - 17
src/main/java/org/codelibs/fess/app/web/error/ErrorAction.java

@@ -34,22 +34,6 @@ public class ErrorAction extends FessSearchAction {
     //                                                                      ==============
     //                                                                      ==============
     @Execute
     @Execute
     public HtmlResponse index(final ErrorForm form) {
     public HtmlResponse index(final ErrorForm form) {
-        return asHtml(path_Error_NotFoundJsp);
+        return asHtml(path_Error_ErrorJsp);
     }
     }
-
-    @Execute
-    public HtmlResponse systemError(final ErrorForm form) {
-        return asHtml(path_Error_SystemJsp);
-    }
-
-    @Execute
-    public HtmlResponse badRequest(final ErrorForm form) {
-        return asHtml(path_Error_BadRequestJsp);
-    }
-
-    @Execute
-    public HtmlResponse notFound(final ErrorForm form) {
-        return asHtml(path_Error_NotFoundJsp);
-    }
-
 }
 }

+ 40 - 0
src/main/java/org/codelibs/fess/app/web/error/ErrorBadrequrestAction.java

@@ -0,0 +1,40 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed 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.
+ */
+package org.codelibs.fess.app.web.error;
+
+import org.codelibs.fess.app.web.base.FessSearchAction;
+import org.lastaflute.web.Execute;
+import org.lastaflute.web.response.HtmlResponse;
+
+public class ErrorBadrequrestAction extends FessSearchAction {
+
+    // ===================================================================================
+    //                                                                            Constant
+    //
+
+    // ===================================================================================
+    //                                                                           Attribute
+    //
+
+    // ===================================================================================
+    //                                                                      Search Execute
+    //                                                                      ==============
+
+    @Execute
+    public HtmlResponse index(final ErrorForm form) {
+        return asHtml(path_Error_BadRequestJsp);
+    }
+}

+ 40 - 0
src/main/java/org/codelibs/fess/app/web/error/ErrorNotfoundAction.java

@@ -0,0 +1,40 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed 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.
+ */
+package org.codelibs.fess.app.web.error;
+
+import org.codelibs.fess.app.web.base.FessSearchAction;
+import org.lastaflute.web.Execute;
+import org.lastaflute.web.response.HtmlResponse;
+
+public class ErrorNotfoundAction extends FessSearchAction {
+
+    // ===================================================================================
+    //                                                                            Constant
+    //
+
+    // ===================================================================================
+    //                                                                           Attribute
+    //
+
+    // ===================================================================================
+    //                                                                      Search Execute
+    //                                                                      ==============
+
+    @Execute
+    public HtmlResponse index(final ErrorForm form) {
+        return asHtml(path_Error_NotFoundJsp);
+    }
+}

+ 40 - 0
src/main/java/org/codelibs/fess/app/web/error/ErrorSystemerrorAction.java

@@ -0,0 +1,40 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed 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.
+ */
+package org.codelibs.fess.app.web.error;
+
+import org.codelibs.fess.app.web.base.FessSearchAction;
+import org.lastaflute.web.Execute;
+import org.lastaflute.web.response.HtmlResponse;
+
+public class ErrorSystemerrorAction extends FessSearchAction {
+
+    // ===================================================================================
+    //                                                                            Constant
+    //
+
+    // ===================================================================================
+    //                                                                           Attribute
+    //
+
+    // ===================================================================================
+    //                                                                      Search Execute
+    //                                                                      ==============
+
+    @Execute
+    public HtmlResponse index(final ErrorForm form) {
+        return asHtml(path_Error_SystemJsp);
+    }
+}

+ 10 - 36
src/main/java/org/codelibs/fess/app/web/go/GoAction.java

@@ -15,19 +15,16 @@
  */
  */
 package org.codelibs.fess.app.web.go;
 package org.codelibs.fess.app.web.go;
 
 
-import java.awt.Desktop;
-import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.net.URLEncoder;
 import java.util.Map;
 import java.util.Map;
 
 
-import javax.servlet.http.HttpServletResponse;
-
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.core.net.URLUtil;
 import org.codelibs.core.net.URLUtil;
 import org.codelibs.fess.Constants;
 import org.codelibs.fess.Constants;
 import org.codelibs.fess.app.web.base.FessSearchAction;
 import org.codelibs.fess.app.web.base.FessSearchAction;
+import org.codelibs.fess.app.web.error.ErrorAction;
 import org.codelibs.fess.crawler.util.CharUtil;
 import org.codelibs.fess.crawler.util.CharUtil;
 import org.codelibs.fess.es.log.exentity.ClickLog;
 import org.codelibs.fess.es.log.exentity.ClickLog;
 import org.codelibs.fess.helper.SearchLogHelper;
 import org.codelibs.fess.helper.SearchLogHelper;
@@ -66,7 +63,7 @@ public class GoAction extends FessSearchAction {
         if (isLoginRequired()) {
         if (isLoginRequired()) {
             return redirectToLogin();
             return redirectToLogin();
         }
         }
-        validate(form, messages -> {}, () -> asHtml(path_ErrorJsp));
+        validate(form, messages -> {}, () -> asHtml(path_Error_ErrorJsp));
 
 
         Map<String, Object> doc = null;
         Map<String, Object> doc = null;
         try {
         try {
@@ -75,22 +72,20 @@ public class GoAction extends FessSearchAction {
                             queryRequestBuilder -> {
                             queryRequestBuilder -> {
                                 final TermQueryBuilder termQuery = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), form.docId);
                                 final TermQueryBuilder termQuery = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), form.docId);
                                 queryRequestBuilder.setQuery(termQuery);
                                 queryRequestBuilder.setQuery(termQuery);
-                                queryRequestBuilder.addFields(fessConfig.getIndexFieldUrl());
+                                queryRequestBuilder.addFields(fessConfig.getIndexFieldUrl(), fessConfig.getIndexFieldConfigId());
                                 return true;
                                 return true;
                             }).get();
                             }).get();
         } catch (final Exception e) {
         } catch (final Exception e) {
             logger.warn("Failed to request: " + form.docId, e);
             logger.warn("Failed to request: " + form.docId, e);
         }
         }
         if (doc == null) {
         if (doc == null) {
-            throwValidationError(messages -> {
-                messages.addErrorsDocidNotFound(GLOBAL, form.docId);
-            }, () -> asHtml(path_ErrorJsp));
+            saveError(messages -> messages.addErrorsDocidNotFound(GLOBAL, form.docId));
+            return redirect(ErrorAction.class);
         }
         }
         final String url = DocumentUtil.getValue(doc, fessConfig.getIndexFieldUrl(), String.class);
         final String url = DocumentUtil.getValue(doc, fessConfig.getIndexFieldUrl(), String.class);
         if (url == null) {
         if (url == null) {
-            throwValidationError(messages -> {
-                messages.addErrorsDocumentNotFound(GLOBAL, form.docId);
-            }, () -> asHtml(path_ErrorJsp));
+            saveError(messages -> messages.addErrorsDocumentNotFound(GLOBAL, form.docId));
+            return redirect(ErrorAction.class);
         }
         }
 
 
         if (Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SEARCH_LOG_PROPERTY, Constants.TRUE))) {
         if (Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SEARCH_LOG_PROPERTY, Constants.TRUE))) {
@@ -137,31 +132,10 @@ public class GoAction extends FessSearchAction {
                 try {
                 try {
                     return viewHelper.asContentResponse(doc);
                     return viewHelper.asContentResponse(doc);
                 } catch (final Exception e) {
                 } catch (final Exception e) {
-                    logger.error("Failed to load: " + doc, e);
-                    throwValidationError(messages -> {
-                        messages.addErrorsNotLoadFromServer(GLOBAL, url);
-                    }, () -> asHtml(path_ErrorJsp));
-                    return null; // workaround
-                }
-            } else if (Constants.TRUE.equals(crawlerProperties.getProperty(Constants.SEARCH_DESKTOP_PROPERTY, Constants.FALSE))) {
-                final String path = url.replaceFirst("file:/+", "//");
-                final File file = new File(path);
-                if (!file.exists()) {
-                    throwValidationError(messages -> {
-                        messages.addErrorsNotFoundOnFileSystem(GLOBAL, url);
-                    }, () -> asHtml(path_ErrorJsp));
-                }
-                final Desktop desktop = Desktop.getDesktop();
-                try {
-                    desktop.open(file);
-                } catch (final Exception e) {
-                    logger.warn("Could not open " + path, e);
-                    throwValidationError(messages -> {
-                        messages.addErrorsCouldNotOpenOnSystem(GLOBAL, url);
-                    }, () -> asHtml(path_ErrorJsp));
+                    logger.debug("Failed to load: " + doc, e);
+                    saveError(messages -> messages.addErrorsNotLoadFromServer(GLOBAL, url));
+                    return redirect(ErrorAction.class);
                 }
                 }
-
-                return HtmlResponse.asEmptyBody().httpStatus(HttpServletResponse.SC_NO_CONTENT);
             } else {
             } else {
                 return HtmlResponse.fromRedirectPathAsIs(url + hash);
                 return HtmlResponse.fromRedirectPathAsIs(url + hash);
             }
             }

+ 27 - 50
src/main/java/org/codelibs/fess/app/web/screenshot/ScreenshotAction.java

@@ -18,32 +18,21 @@ package org.codelibs.fess.app.web.screenshot;
 import java.io.BufferedInputStream;
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileInputStream;
-import java.io.OutputStream;
 import java.util.Map;
 import java.util.Map;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
 
-import org.apache.commons.io.IOUtils;
-import org.codelibs.core.io.CopyUtil;
-import org.codelibs.core.io.OutputStreamUtil;
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.fess.app.web.base.FessSearchAction;
 import org.codelibs.fess.app.web.base.FessSearchAction;
 import org.codelibs.fess.util.DocumentUtil;
 import org.codelibs.fess.util.DocumentUtil;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.index.query.TermQueryBuilder;
 import org.elasticsearch.index.query.TermQueryBuilder;
 import org.lastaflute.web.Execute;
 import org.lastaflute.web.Execute;
-import org.lastaflute.web.response.HtmlResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.lastaflute.web.response.ActionResponse;
 
 
 public class ScreenshotAction extends FessSearchAction {
 public class ScreenshotAction extends FessSearchAction {
 
 
-    // ===================================================================================
-    //                                                                            Constant
-    //
-    private static final Logger logger = LoggerFactory.getLogger(ScreenshotAction.class);
-
     // ===================================================================================
     // ===================================================================================
     //                                                                           Attribute
     //                                                                           Attribute
     //
     //
@@ -58,51 +47,39 @@ public class ScreenshotAction extends FessSearchAction {
     //                                                                      Search Execute
     //                                                                      Search Execute
     //                                                                      ==============
     //                                                                      ==============
     @Execute
     @Execute
-    public HtmlResponse index(final ScreenshotForm form) {
+    public ActionResponse index(final ScreenshotForm form) {
         if (isLoginRequired()) {
         if (isLoginRequired()) {
             return redirectToLogin();
             return redirectToLogin();
         }
         }
 
 
-        OutputStream out = null;
-        BufferedInputStream in = null;
-        try {
-            final Map<String, Object> doc =
-                    fessEsClient.getDocument(fessConfig.getIndexDocumentSearchIndex(), fessConfig.getIndexDocumentType(),
-                            queryRequestBuilder -> {
-                                final TermQueryBuilder termQuery = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), form.docId);
-                                queryRequestBuilder.setQuery(termQuery);
-                                queryRequestBuilder.addFields(queryHelper.getResponseFields());
-                                return true;
-                            }).get();
-            final String url = DocumentUtil.getValue(doc, fessConfig.getIndexFieldUrl(), String.class);
-            if (StringUtil.isBlank(form.queryId) || StringUtil.isBlank(url) || screenShotManager == null) {
-                // 404
-                response.sendError(HttpServletResponse.SC_NOT_FOUND);
-                return null;
-            }
-
-            final File screenShotFile = screenShotManager.getScreenShotFile(form.queryId, form.docId);
-            if (screenShotFile == null) {
-                // 404
-                response.sendError(HttpServletResponse.SC_NOT_FOUND);
-                screenShotManager.generate(doc);
-                return null;
-            }
-
-            response.setContentType(getImageMimeType(screenShotFile));
+        final Map<String, Object> doc =
+                fessEsClient.getDocument(fessConfig.getIndexDocumentSearchIndex(), fessConfig.getIndexDocumentType(),
+                        queryRequestBuilder -> {
+                            final TermQueryBuilder termQuery = QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), form.docId);
+                            queryRequestBuilder.setQuery(termQuery);
+                            queryRequestBuilder.addFields(queryHelper.getResponseFields());
+                            return true;
+                        }).get();
+        final String url = DocumentUtil.getValue(doc, fessConfig.getIndexFieldUrl(), String.class);
+        if (StringUtil.isBlank(form.queryId) || StringUtil.isBlank(url) || screenShotManager == null) {
+            // 404
+            throw404("Screenshot for " + form.docId + " is not found.");
+            return null;
+        }
 
 
-            out = response.getOutputStream();
-            in = new BufferedInputStream(new FileInputStream(screenShotFile));
-            CopyUtil.copy(in, out);
-            OutputStreamUtil.flush(out);
-        } catch (final Exception e) {
-            logger.error("Failed to response: " + form.docId, e);
-        } finally {
-            IOUtils.closeQuietly(in);
-            IOUtils.closeQuietly(out);
+        final File screenShotFile = screenShotManager.getScreenShotFile(form.queryId, form.docId);
+        if (screenShotFile == null) {
+            // 404
+            throw404("Screenshot for " + form.docId + " is under generating.");
+            screenShotManager.generate(doc);
+            return null;
         }
         }
 
 
-        return null;
+        return asStream(form.docId).contentType(getImageMimeType(screenShotFile)).stream(out -> {
+            try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(screenShotFile))) {
+                out.write(in);
+            }
+        });
     }
     }
 
 
     protected String getImageMimeType(final File imageFile) {
     protected String getImageMimeType(final File imageFile) {

+ 7 - 8
src/main/java/org/codelibs/fess/helper/ViewHelper.java

@@ -489,13 +489,12 @@ public class ViewHelper implements Serializable {
         }
         }
         final FessConfig fessConfig = ComponentUtil.getFessConfig();
         final FessConfig fessConfig = ComponentUtil.getFessConfig();
         final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil.getCrawlingConfigHelper();
         final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil.getCrawlingConfigHelper();
-        final Object configIdObj = doc.get(fessConfig.getIndexFieldConfigId());
-        if (configIdObj == null) {
+        final String configId = DocumentUtil.getValue(doc, fessConfig.getIndexFieldConfigId(), String.class);
+        if (configId == null) {
             throw new FessSystemException("configId is null.");
             throw new FessSystemException("configId is null.");
         }
         }
-        final String configId = configIdObj.toString();
         if (configId.length() < 2) {
         if (configId.length() < 2) {
-            throw new FessSystemException("Invalid configId: " + configIdObj);
+            throw new FessSystemException("Invalid configId: " + configId);
         }
         }
         final ConfigType configType = crawlingConfigHelper.getConfigType(configId);
         final ConfigType configType = crawlingConfigHelper.getConfigType(configId);
         CrawlingConfig config = null;
         CrawlingConfig config = null;
@@ -513,14 +512,14 @@ public class ViewHelper implements Serializable {
             config = dataConfigService.getDataConfig(crawlingConfigHelper.getId(configId)).get();
             config = dataConfigService.getDataConfig(crawlingConfigHelper.getId(configId)).get();
         }
         }
         if (config == null) {
         if (config == null) {
-            throw new FessSystemException("No crawlingConfig: " + configIdObj);
+            throw new FessSystemException("No crawlingConfig: " + configId);
         }
         }
-        final String url = (String) doc.get(fessConfig.getIndexFieldUrl());
+        final String url = DocumentUtil.getValue(doc, fessConfig.getIndexFieldUrl(), String.class);
         final CrawlerClientFactory crawlerClientFactory = SingletonLaContainer.getComponent(CrawlerClientFactory.class);
         final CrawlerClientFactory crawlerClientFactory = SingletonLaContainer.getComponent(CrawlerClientFactory.class);
         config.initializeClientFactory(crawlerClientFactory);
         config.initializeClientFactory(crawlerClientFactory);
         final CrawlerClient client = crawlerClientFactory.getClient(url);
         final CrawlerClient client = crawlerClientFactory.getClient(url);
         if (client == null) {
         if (client == null) {
-            throw new FessSystemException("No CrawlerClient: " + configIdObj + ", url: " + url);
+            throw new FessSystemException("No CrawlerClient: " + configId + ", url: " + url);
         }
         }
         final ResponseData responseData = client.execute(RequestDataBuilder.newRequestData().get().url(url).build());
         final ResponseData responseData = client.execute(RequestDataBuilder.newRequestData().get().url(url).build());
         final StreamResponse response = new StreamResponse(StringUtil.EMPTY);
         final StreamResponse response = new StreamResponse(StringUtil.EMPTY);
@@ -532,7 +531,7 @@ public class ViewHelper implements Serializable {
                 out.write(is);
                 out.write(is);
             } catch (final IOException e) {
             } catch (final IOException e) {
                 if (!"ClientAbortException".equals(e.getClass().getSimpleName())) {
                 if (!"ClientAbortException".equals(e.getClass().getSimpleName())) {
-                    throw new FessSystemException("Failed to write a content. configId: " + configIdObj + ", url: " + url, e);
+                    throw new FessSystemException("Failed to write a content. configId: " + configId + ", url: " + url, e);
                 }
                 }
             }
             }
             if (logger.isDebugEnabled()) {
             if (logger.isDebugEnabled()) {

+ 3 - 3
src/main/java/org/codelibs/fess/mylasta/action/FessHtmlPath.java

@@ -284,6 +284,9 @@ public interface FessHtmlPath {
     /** The path of the HTML: /error/badRequest.jsp */
     /** The path of the HTML: /error/badRequest.jsp */
     HtmlNext path_Error_BadRequestJsp = new HtmlNext("/error/badRequest.jsp");
     HtmlNext path_Error_BadRequestJsp = new HtmlNext("/error/badRequest.jsp");
 
 
+    /** The path of the HTML: /error/error.jsp */
+    HtmlNext path_Error_ErrorJsp = new HtmlNext("/error/error.jsp");
+
     /** The path of the HTML: /error/footer.jsp */
     /** The path of the HTML: /error/footer.jsp */
     HtmlNext path_Error_FooterJsp = new HtmlNext("/error/footer.jsp");
     HtmlNext path_Error_FooterJsp = new HtmlNext("/error/footer.jsp");
 
 
@@ -299,9 +302,6 @@ public interface FessHtmlPath {
     /** The path of the HTML: /error/system.jsp */
     /** The path of the HTML: /error/system.jsp */
     HtmlNext path_Error_SystemJsp = new HtmlNext("/error/system.jsp");
     HtmlNext path_Error_SystemJsp = new HtmlNext("/error/system.jsp");
 
 
-    /** The path of the HTML: /error.jsp */
-    HtmlNext path_ErrorJsp = new HtmlNext("/error.jsp");
-
     /** The path of the HTML: /footer.jsp */
     /** The path of the HTML: /footer.jsp */
     HtmlNext path_FooterJsp = new HtmlNext("/footer.jsp");
     HtmlNext path_FooterJsp = new HtmlNext("/footer.jsp");
 
 

+ 8 - 5
src/main/java/org/codelibs/fess/screenshot/ScreenShotManager.java

@@ -48,7 +48,7 @@ public class ScreenShotManager {
     @Resource
     @Resource
     protected ServletContext application;
     protected ServletContext application;
 
 
-    public File baseDir;
+    protected File baseDir;
 
 
     public long shutdownTimeout = 5 * 60 * 1000; // 5min
     public long shutdownTimeout = 5 * 60 * 1000; // 5min
 
 
@@ -68,16 +68,19 @@ public class ScreenShotManager {
 
 
     @PostConstruct
     @PostConstruct
     public void init() {
     public void init() {
-        if (baseDir == null) {
+        final String varPath = System.getProperty("fess.var.path");
+        if (varPath != null) {
+            baseDir = new File(varPath, "screenshots");
+        } else {
             final String path = application.getRealPath(DEFAULT_SCREENSHOT_DIR);
             final String path = application.getRealPath(DEFAULT_SCREENSHOT_DIR);
             if (StringUtil.isNotBlank(path)) {
             if (StringUtil.isNotBlank(path)) {
                 baseDir = new File(path);
                 baseDir = new File(path);
             } else {
             } else {
                 baseDir = new File("." + DEFAULT_SCREENSHOT_DIR);
                 baseDir = new File("." + DEFAULT_SCREENSHOT_DIR);
             }
             }
-            if (baseDir.mkdirs()) {
-                logger.info("Created: " + baseDir.getAbsolutePath());
-            }
+        }
+        if (baseDir.mkdirs()) {
+            logger.info("Created: " + baseDir.getAbsolutePath());
         }
         }
         if (!baseDir.isDirectory()) {
         if (!baseDir.isDirectory()) {
             throw new FessSystemException("Not found: " + baseDir.getAbsolutePath());
             throw new FessSystemException("Not found: " + baseDir.getAbsolutePath());

+ 12 - 7
src/main/webapp/WEB-INF/view/error.jsp → src/main/webapp/WEB-INF/view/error/error.jsp

@@ -1,12 +1,11 @@
 <%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
 <%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
 <!DOCTYPE html>
 <!DOCTYPE html>
 <html>
 <html>
-<head>
+<head profile="http://a9.com/-/spec/opensearch/1.1/">
 <meta charset="utf-8">
 <meta charset="utf-8">
-<meta http-equiv="content-style-type" content="text/css" />
-<meta http-equiv="content-script-type" content="text/javascript" />
-<meta name="viewport" content="width=device-width, initial-scale=1.0">
-<title><la:message key="labels.error_title" /></title>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<meta http-equiv="x-ua-compatible" content="ie=edge">
+<title><la:message key="labels.system_error_title" /></title>
 <link href="${f:url('/css/style-base.css')}" rel="stylesheet"
 <link href="${f:url('/css/style-base.css')}" rel="stylesheet"
 	type="text/css" />
 	type="text/css" />
 <link href="${f:url('/css/style.css')}" rel="stylesheet"
 <link href="${f:url('/css/style.css')}" rel="stylesheet"
@@ -17,16 +16,22 @@
 	<div class="container">
 	<div class="container">
 		<div class="content">
 		<div class="content">
 			<div class="center row">
 			<div class="center row">
-				<div class="span10">
+				<div class="col-md-12">
 					<h2>
 					<h2>
 						<la:message key="labels.error_title" />
 						<la:message key="labels.error_title" />
 					</h2>
 					</h2>
-					<div class="errormessage">${errorMessage}</div>
+					<div>
+						<la:info id="msg" message="true">
+							<div class="alert alert-info">${msg}</div>
+						</la:info>
+						<la:errors styleClass="list-unstyled"/>
+					</div>
 				</div>
 				</div>
 			</div>
 			</div>
 		</div>
 		</div>
 		<jsp:include page="footer.jsp" />
 		<jsp:include page="footer.jsp" />
 	</div>
 	</div>
+	<input type="hidden" id="contextPath" value="<%=request.getContextPath()%>" />
 	<script type="text/javascript"
 	<script type="text/javascript"
 		src="${f:url('/js/jquery-2.1.4.min.js')}"></script>
 		src="${f:url('/js/jquery-2.1.4.min.js')}"></script>
 	<script type="text/javascript" src="${f:url('/js/bootstrap.js')}"></script>
 	<script type="text/javascript" src="${f:url('/js/bootstrap.js')}"></script>

+ 3 - 3
src/main/webapp/WEB-INF/view/error/redirect.jsp

@@ -7,7 +7,7 @@ StringBuilder redirectPage = new StringBuilder();
 redirectPage.append(((javax.servlet.http.HttpServletRequest)request).getContextPath());
 redirectPage.append(((javax.servlet.http.HttpServletRequest)request).getContextPath());
 if("systemError".equals(type)) {
 if("systemError".equals(type)) {
 	if(requestUri != null && !requestUri.endsWith("systemError")) {
 	if(requestUri != null && !requestUri.endsWith("systemError")) {
-		redirectPage.append("/error/systemError");
+		redirectPage.append("/error/systemerror");
 		response.sendRedirect(redirectPage.toString());
 		response.sendRedirect(redirectPage.toString());
 	} else {
 	} else {
 		response.sendError(statusCode);
 		response.sendError(statusCode);
@@ -16,10 +16,10 @@ if("systemError".equals(type)) {
 	redirectPage.append("/login/index?type=logout");
 	redirectPage.append("/login/index?type=logout");
 	response.sendRedirect(redirectPage.toString());
 	response.sendRedirect(redirectPage.toString());
 } else if("badRequest".equals(type)) {
 } else if("badRequest".equals(type)) {
-	redirectPage.append("/error/badRequest");
+	redirectPage.append("/error/badrequest");
 	response.sendRedirect(redirectPage.toString());
 	response.sendRedirect(redirectPage.toString());
 } else {
 } else {
-	redirectPage.append("/error/notFound?url=");
+	redirectPage.append("/error/notfound?url=");
 	redirectPage.append(java.net.URLEncoder.encode(requestUri , "UTF-8"));
 	redirectPage.append(java.net.URLEncoder.encode(requestUri , "UTF-8"));
 	response.sendRedirect(redirectPage.toString());
 	response.sendRedirect(redirectPage.toString());
 }
 }

+ 0 - 25
src/main/webapp/WEB-INF/web.xml

@@ -72,25 +72,6 @@
     <filter-class>org.lastaflute.web.servlet.filter.LastaToActionFilter</filter-class>
     <filter-class>org.lastaflute.web.servlet.filter.LastaToActionFilter</filter-class>
   </filter>
   </filter>
 
 
-  <!--
-  <filter>
-    <filter-name>adLoginInfoFilter</filter-name>
-    <filter-class>org.codelibs.fess.filter.AdLoginInfoFilter</filter-class>
-    <init-param>
-      <param-name>redirectLoginError</param-name>
-      <param-value>true</param-value>
-    </init-param>
-    <init-param>
-      <param-name>useTestUser</param-name>
-      <param-value>false</param-value>
-    </init-param>
-    <init-param>
-      <param-name>testUserName</param-name>
-      <param-value>testUser</param-value>
-    </init-param>
-  </filter>
-  -->
-
   <!-- SPNEGO    -->
   <!-- SPNEGO    -->
   <!--
   <!--
   <filter>
   <filter>
@@ -202,12 +183,6 @@
       <filter-name>SpnegoHttpFilter</filter-name>
       <filter-name>SpnegoHttpFilter</filter-name>
       <url-pattern>/*</url-pattern>
       <url-pattern>/*</url-pattern>
   </filter-mapping>
   </filter-mapping>
-  <filter-mapping>
-    <filter-name>adLoginInfoFilter</filter-name>
-    <url-pattern>*.do</url-pattern>
-    <dispatcher>REQUEST</dispatcher>
-    <dispatcher>FORWARD</dispatcher>
-  </filter-mapping>
 -->
 -->
 
 
   <!-- ================================================================================= -->
   <!-- ================================================================================= -->

+ 13 - 32
src/main/webapp/js/search.js

@@ -2,7 +2,6 @@ $(function() {
 	var $result = $('#result');
 	var $result = $('#result');
 	var $queryId = $('#queryId');
 	var $queryId = $('#queryId');
 	var $favorites = $('.favorite', $result);
 	var $favorites = $('.favorite', $result);
-	var $screenshot = $('#screenshot', $result);
 	var $searchButton = $('#searchButton');
 	var $searchButton = $('#searchButton');
 	var contextPath = $('#contextPath').val();
 	var contextPath = $('#contextPath').val();
 
 
@@ -56,38 +55,20 @@ $(function() {
 	});
 	});
 
 
 	$result.on('mouseover', 'a.link', function(e) {
 	$result.on('mouseover', 'a.link', function(e) {
-		if ($screenshot.size() > 0) {
-			var docId = $(this).attr('data-id'), rt = $('#rt').val(), url = $(
-					this).attr('href'), queryId = $queryId.val(), buf = [];
-			buf.push(contextPath);
-			buf.push('/go/?rt=');
-			buf.push(rt);
-			buf.push('&docId=');
-			buf.push(docId);
-
-			var hashIndex = url.indexOf('#');
-			if (hashIndex >= 0) {
-				var hashStr = url.substring(hashIndex);
-				buf.push('&hash=');
-				buf.push(encodeURIComponent(hashStr));
-				buf.push(hashStr);
-			}
-
-			$screenshot.children().remove();
-
-			var content = '<a href="' + buf.join('')
-					+ '"><img src="screenshot?queryId=' + queryId + '&docId='
-					+ docId + '"></a>';
-			$screenshot.append(content);
-			$('img', $screenshot).error(function() {
-				$screenshot.children().remove();
-			});
-		}
-	});
+		var docId = $(this).attr('data-id'), rt = $('#rt').val(), url = $(
+				this).attr('href'), queryId = $queryId.val(), buf = [];
+		buf.push(contextPath);
+		buf.push('/go/?rt=');
+		buf.push(rt);
+		buf.push('&docId=');
+		buf.push(docId);
 
 
-	$result.on('mouseout', 'a.link', function(e) {
-		if ($screenshot.size() > 0) {
-			$screenshot.children().remove();
+		var hashIndex = url.indexOf('#');
+		if (hashIndex >= 0) {
+			var hashStr = url.substring(hashIndex);
+			buf.push('&hash=');
+			buf.push(encodeURIComponent(hashStr));
+			buf.push(hashStr);
 		}
 		}
 	});
 	});
 
 

+ 1 - 0
src/packaging/common/env/fess

@@ -6,6 +6,7 @@
 FESS_TEMP_PATH=${packaging.fess.temp.dir}
 FESS_TEMP_PATH=${packaging.fess.temp.dir}
 FESS_LOG_PATH=${packaging.fess.log.dir}
 FESS_LOG_PATH=${packaging.fess.log.dir}
 FESS_CONF_PATH=${packaging.fess.conf.dir}
 FESS_CONF_PATH=${packaging.fess.conf.dir}
+FESS_VAR_PATH=${packaging.fess.var.dir}
 
 
 FESS_DICTIONARY_PATH=/var/lib/elasticsearch/config/
 FESS_DICTIONARY_PATH=/var/lib/elasticsearch/config/
 
 

+ 1 - 0
src/packaging/rpm/init.d/fess

@@ -51,6 +51,7 @@ pidfile="$PID_DIR/${prog}.pid"
 export FESS_TEMP_PATH
 export FESS_TEMP_PATH
 export FESS_LOG_PATH
 export FESS_LOG_PATH
 export FESS_CONF_PATH
 export FESS_CONF_PATH
+export FESS_VAR_PATH
 export FESS_DICTIONARY_PATH
 export FESS_DICTIONARY_PATH
 export FESS_HEAP_SIZE
 export FESS_HEAP_SIZE
 export ES_HOME
 export ES_HOME