Bläddra i källkod

fix #2547 pass values to jobs

Shinsuke Sugaya 4 år sedan
förälder
incheckning
9a90d5617f

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

@@ -448,6 +448,8 @@ public class Constants extends CoreLibConstants {
 
     public static final String SYSTEM_PROP_PREFIX = "fess.system.";
 
+    public static final String FESS_CONFIG_PREFIX = "fess.config.";
+
     public static final String XERCES_FEATURE_PREFIX = "http://apache.org/xml/features/";
 
     public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd";

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

@@ -264,6 +264,8 @@ public class CrawlJob extends ExecJob {
             cmdList.add("-Dlasta.env=" + getExecuteType());
         }
 
+        addFessConfigProperties(cmdList);
+        addFessSystemProperties(cmdList);
         addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null);
         cmdList.add("-Dfess." + getExecuteType() + ".process=true");
         cmdList.add("-Dfess.log.path=" + (logFilePath != null ? logFilePath : systemHelper.getLogFilePath()));

+ 10 - 0
src/main/java/org/codelibs/fess/job/ExecJob.java

@@ -138,6 +138,16 @@ public abstract class ExecJob {
         }
     }
 
+    protected void addFessConfigProperties(final List<String> cmdList) {
+        System.getProperties().keySet().stream().filter(k -> k != null && k.toString().startsWith(Constants.FESS_CONFIG_PREFIX))
+                .forEach(k -> addSystemProperty(cmdList, k.toString(), null, null));
+    }
+
+    protected void addFessSystemProperties(final List<String> cmdList) {
+        System.getProperties().keySet().stream().filter(k -> k != null && k.toString().startsWith(Constants.SYSTEM_PROP_PREFIX))
+                .forEach(k -> addSystemProperty(cmdList, k.toString(), null, null));
+    }
+
     protected void deleteTempDir(final File ownTmpDir) {
         if (ownTmpDir == null) {
             return;

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

@@ -161,6 +161,8 @@ public class GenerateThumbnailJob extends ExecJob {
             cmdList.add("-Dlasta.env=" + getExecuteType());
         }
 
+        addFessConfigProperties(cmdList);
+        addFessSystemProperties(cmdList);
         addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null);
         cmdList.add("-Dfess." + getExecuteType() + ".process=true");
         if (logFilePath == null) {

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

@@ -148,6 +148,8 @@ public class SuggestJob extends ExecJob {
             cmdList.add("-Dlasta.env=" + getExecuteType());
         }
 
+        addFessConfigProperties(cmdList);
+        addFessSystemProperties(cmdList);
         addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null);
         cmdList.add("-Dfess." + getExecuteType() + ".process=true");
         if (logFilePath == null) {

+ 3 - 3
src/main/java/org/codelibs/fess/mylasta/direction/FessConfigImpl.java

@@ -17,6 +17,7 @@ package org.codelibs.fess.mylasta.direction;
 
 import java.util.concurrent.ExecutionException;
 
+import org.codelibs.fess.Constants;
 import org.dbflute.helper.jprop.ObjectiveProperties;
 import org.lastaflute.core.direction.PropertyFilter;
 
@@ -27,8 +28,6 @@ public class FessConfigImpl extends FessConfig.SimpleImpl {
 
     private static final long serialVersionUID = 1L;
 
-    private static final String FESS_CONFIG = "fess.config.";
-
     @Override
     protected ObjectiveProperties newObjectiveProperties(final String resourcePath, final PropertyFilter propertyFilter) {
         return new ObjectiveProperties(resourcePath) { // for e.g. checking existence and filtering value
@@ -44,7 +43,8 @@ public class FessConfigImpl extends FessConfig.SimpleImpl {
 
             private String getFromCache(final String propertyKey) {
                 try {
-                    return cache.get(propertyKey, () -> System.getProperty(FESS_CONFIG + propertyKey, super.get(propertyKey)));
+                    return cache.get(propertyKey,
+                            () -> System.getProperty(Constants.FESS_CONFIG_PREFIX + propertyKey, super.get(propertyKey)));
                 } catch (final ExecutionException e) {
                     return super.get(propertyKey);
                 }