diff --git a/src/main/java/org/codelibs/fess/job/CrawlJob.java b/src/main/java/org/codelibs/fess/job/CrawlJob.java index cf98642d6..896e8e57d 100644 --- a/src/main/java/org/codelibs/fess/job/CrawlJob.java +++ b/src/main/java/org/codelibs/fess/job/CrawlJob.java @@ -274,6 +274,7 @@ protected void executeCrawler() { addFessConfigProperties(cmdList); addFessSystemProperties(cmdList); + addFessCustomSystemProperties(cmdList, fessConfig.getJobSystemPropertyFilterPattern()); addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null); cmdList.add("-Dfess." + getExecuteType() + ".process=true"); cmdList.add("-Dfess.log.path=" + (logFilePath != null ? logFilePath : systemHelper.getLogFilePath())); diff --git a/src/main/java/org/codelibs/fess/job/ExecJob.java b/src/main/java/org/codelibs/fess/job/ExecJob.java index 1229ad713..173033480 100644 --- a/src/main/java/org/codelibs/fess/job/ExecJob.java +++ b/src/main/java/org/codelibs/fess/job/ExecJob.java @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.List; import java.util.Properties; +import java.util.regex.Pattern; import org.apache.commons.io.FileUtils; import org.apache.logging.log4j.LogManager; @@ -156,6 +157,14 @@ protected void addFessSystemProperties(final List cmdList) { .forEach(k -> addSystemProperty(cmdList, k.toString(), null, null)); } + protected void addFessCustomSystemProperties(final List cmdList, final String regex) { + if (StringUtil.isNotBlank(regex)) { + final Pattern pattern = Pattern.compile(regex); + System.getProperties().keySet().stream().filter(k -> k != null && pattern.matcher(k.toString()).matches()) + .forEach(k -> addSystemProperty(cmdList, k.toString(), null, null)); + } + } + protected void deleteTempDir(final File ownTmpDir) { if (ownTmpDir == null) { return; diff --git a/src/main/java/org/codelibs/fess/job/GenerateThumbnailJob.java b/src/main/java/org/codelibs/fess/job/GenerateThumbnailJob.java index 9b2ce407e..ed08e37c4 100644 --- a/src/main/java/org/codelibs/fess/job/GenerateThumbnailJob.java +++ b/src/main/java/org/codelibs/fess/job/GenerateThumbnailJob.java @@ -164,6 +164,7 @@ protected void executeThumbnailGenerator() { addFessConfigProperties(cmdList); addFessSystemProperties(cmdList); + addFessCustomSystemProperties(cmdList, fessConfig.getJobSystemPropertyFilterPattern()); addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null); cmdList.add("-Dfess." + getExecuteType() + ".process=true"); if (logFilePath == null) { diff --git a/src/main/java/org/codelibs/fess/job/SuggestJob.java b/src/main/java/org/codelibs/fess/job/SuggestJob.java index 3be21b094..d96be183a 100644 --- a/src/main/java/org/codelibs/fess/job/SuggestJob.java +++ b/src/main/java/org/codelibs/fess/job/SuggestJob.java @@ -151,6 +151,7 @@ protected void executeSuggestCreator() { addFessConfigProperties(cmdList); addFessSystemProperties(cmdList); + addFessCustomSystemProperties(cmdList, fessConfig.getJobSystemPropertyFilterPattern()); addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null); cmdList.add("-Dfess." + getExecuteType() + ".process=true"); if (logFilePath == null) { diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index e26e3d90d..a5dd4be3f 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -196,6 +196,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction /** The key of the configuration. e.g. groovy */ String JOB_DEFAULT_SCRIPT = "job.default.script"; + /** The key of the configuration. e.g. */ + String JOB_SYSTEM_PROPERTY_FILTER_PATTERN = "job.system.property.filter.pattern"; + /** The key of the configuration. e.g. 0 */ String PROCESSORS = "processors"; @@ -2161,6 +2164,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction */ String getJobDefaultScript(); + /** + * Get the value for the key 'job.system.property.filter.pattern'.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getJobSystemPropertyFilterPattern(); + + /** + * Get the value for the key 'job.system.property.filter.pattern' as {@link Integer}.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getJobSystemPropertyFilterPatternAsInteger(); + /** * Get the value for the key 'processors'.
* The value is, e.g. 0
@@ -7833,6 +7851,14 @@ public String getJobDefaultScript() { return get(FessConfig.JOB_DEFAULT_SCRIPT); } + public String getJobSystemPropertyFilterPattern() { + return get(FessConfig.JOB_SYSTEM_PROPERTY_FILTER_PATTERN); + } + + public Integer getJobSystemPropertyFilterPatternAsInteger() { + return getAsInteger(FessConfig.JOB_SYSTEM_PROPERTY_FILTER_PATTERN); + } + public String getProcessors() { return get(FessConfig.PROCESSORS); } @@ -10831,6 +10857,7 @@ protected java.util.Map prepareGeneratedDefaultMap() { "return container.getComponent(\"crawlJob\").logLevel(\"info\").webConfigIds([{0}] as String[]).fileConfigIds([{1}] as String[]).dataConfigIds([{2}] as String[]).jobExecutor(executor).execute();"); defaultMap.put(FessConfig.JOB_MAX_CRAWLER_PROCESSES, "0"); defaultMap.put(FessConfig.JOB_DEFAULT_SCRIPT, "groovy"); + defaultMap.put(FessConfig.JOB_SYSTEM_PROPERTY_FILTER_PATTERN, ""); defaultMap.put(FessConfig.PROCESSORS, "0"); defaultMap.put(FessConfig.JAVA_COMMAND_PATH, "java"); defaultMap.put(FessConfig.PYTHON_COMMAND_PATH, "python"); diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java index 3fe8a010c..70ff5c94f 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java @@ -982,7 +982,7 @@ default void addCrawlerMetadataNameMapping(final String name, final String field } @SuppressWarnings("unchecked") - final Map> params = + final Map> params = (Map>) propMap.get(CRAWLER_METADATA_NAME_MAPPING); params.put(name, new Tuple3<>(fieldName, mappingType, dateFormat)); } diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties index 6fecccc38..b1b65b8a9 100644 --- a/src/main/resources/fess_config.properties +++ b/src/main/resources/fess_config.properties @@ -152,6 +152,7 @@ job.template.title.data=Data Crawler - {0} job.template.script=return container.getComponent("crawlJob").logLevel("info").webConfigIds([{0}] as String[]).fileConfigIds([{1}] as String[]).dataConfigIds([{2}] as String[]).jobExecutor(executor).execute(); job.max.crawler.processes=0 job.default.script=groovy +job.system.property.filter.pattern= processors=0 java.command.path=java