浏览代码

improve session id handling

Shinsuke Sugaya 9 年之前
父节点
当前提交
d4ec792963

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

@@ -364,8 +364,4 @@ public class Constants extends CoreLibConstants {
     public static final String LDAP_INITIAL_CONTEXT_FACTORY = "ldap.initial.context.factory";
 
     public static final String LDAP_ACCOUNT_FILTER = "ldap.account.filter";
-
-    public static final String CRAWLER_SESSION_ID_PREFIX = "C";
-
-    public static final String SUGGEST_SESSION_ID_PREFIX = "S";
 }

+ 22 - 27
src/main/java/org/codelibs/fess/app/web/admin/scheduler/AdminSchedulerAction.java

@@ -15,6 +15,8 @@
  */
 package org.codelibs.fess.app.web.admin.scheduler;
 
+import java.text.MessageFormat;
+
 import javax.annotation.Resource;
 
 import org.codelibs.fess.Constants;
@@ -26,7 +28,6 @@ import org.codelibs.fess.es.config.exentity.ScheduledJob;
 import org.codelibs.fess.helper.JobHelper;
 import org.codelibs.fess.helper.SystemHelper;
 import org.codelibs.fess.job.JobExecutor;
-import org.codelibs.fess.util.ComponentUtil;
 import org.codelibs.fess.util.RenderDataUtil;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalThing;
@@ -116,32 +117,26 @@ public class AdminSchedulerAction extends FessAdminAction {
     @Execute
     public HtmlResponse createnewjob(final String type, final String id, final String name) {
         saveToken();
-        return asHtml(path_AdminScheduler_AdminSchedulerEditJsp).useForm(
-                CreateForm.class,
-                op -> {
-                    op.setup(scheduledJobForm -> {
-                        scheduledJobForm.initialize();
-                        scheduledJobForm.crudMode = CrudMode.CREATE;
-                        scheduledJobForm.jobLogging = Constants.ON;
-                        scheduledJobForm.crawler = Constants.ON;
-                        scheduledJobForm.available = Constants.ON;
-                        scheduledJobForm.cronExpression = null;
-                        scheduledJobForm.name =
-                                ComponentUtil.getMessageManager().getMessage(LaRequestUtil.getRequest().getLocale(),
-                                        "labels." + type + "_job_title", name);
-                        final String[] ids = new String[] { "", "", "" };
-                        if (Constants.WEB_CRAWLER_TYPE.equals(type)) {
-                            ids[0] = "\"" + id + "\"";
-                        } else if (Constants.FILE_CRAWLER_TYPE.equals(type)) {
-                            ids[1] = "\"" + id + "\"";
-                        } else if (Constants.DATA_CRAWLER_TYPE.equals(type)) {
-                            ids[2] = "\"" + id + "\"";
-                        }
-                        scheduledJobForm.scriptData =
-                                ComponentUtil.getMessageManager().getMessage(LaRequestUtil.getRequest().getLocale(),
-                                        "labels.scheduledjob_script_template", ids[0], ids[1], ids[2]);
-                    });
-                });
+        return asHtml(path_AdminScheduler_AdminSchedulerEditJsp).useForm(CreateForm.class, op -> {
+            op.setup(scheduledJobForm -> {
+                scheduledJobForm.initialize();
+                scheduledJobForm.crudMode = CrudMode.CREATE;
+                scheduledJobForm.jobLogging = Constants.ON;
+                scheduledJobForm.crawler = Constants.ON;
+                scheduledJobForm.available = Constants.ON;
+                scheduledJobForm.cronExpression = null;
+                scheduledJobForm.name = MessageFormat.format(fessConfig.getJobTemplateTitle(type), name);
+                final String[] ids = new String[] { "", "", "" };
+                if (Constants.WEB_CRAWLER_TYPE.equals(type)) {
+                    ids[0] = "\"" + id + "\"";
+                } else if (Constants.FILE_CRAWLER_TYPE.equals(type)) {
+                    ids[1] = "\"" + id + "\"";
+                } else if (Constants.DATA_CRAWLER_TYPE.equals(type)) {
+                    ids[2] = "\"" + id + "\"";
+                }
+                scheduledJobForm.scriptData = MessageFormat.format(fessConfig.getJobTemplateScript(), ids[0], ids[1], ids[2], id);
+            });
+        });
     }
 
     @Execute

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

@@ -166,7 +166,7 @@ public class CrawlJob {
 
         if (sessionId == null) { // create session id
             final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
-            sessionId = Constants.CRAWLER_SESSION_ID_PREFIX + sdf.format(new Date());
+            sessionId = sdf.format(new Date());
         }
         resultBuf.append("Session Id: ").append(sessionId).append("\n");
         resultBuf.append("Web  Config Id:");

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

@@ -99,7 +99,7 @@ public class SuggestJob {
 
         if (sessionId == null) { // create session id
             final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
-            sessionId = Constants.SUGGEST_SESSION_ID_PREFIX + sdf.format(new Date());
+            sessionId = sdf.format(new Date());
         }
         resultBuf.append("Session Id: ").append(sessionId).append("\n");
         if (jobExecutor != null) {

+ 0 - 12
src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java

@@ -851,9 +851,6 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Create new job */
     public static final String LABELS_file_crawling_button_create_job = "{labels.file_crawling_button_create_job}";
 
-    /** The key of the message: File Crawler - {0} */
-    public static final String LABELS_file_crawling_job_title = "{labels.file_crawling_job_title}";
-
     /** The key of the message: Web Crawling */
     public static final String LABELS_web_crawling_configuration = "{labels.web_crawling_configuration}";
 
@@ -881,9 +878,6 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Create new job */
     public static final String LABELS_web_crawling_button_create_job = "{labels.web_crawling_button_create_job}";
 
-    /** The key of the message: Web Crawler - {0} */
-    public static final String LABELS_web_crawling_job_title = "{labels.web_crawling_job_title}";
-
     /** The key of the message: General Configuration */
     public static final String LABELS_crawler_configuration = "{labels.crawler_configuration}";
 
@@ -1355,9 +1349,6 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Quick Setup */
     public static final String LABELS_wizard_start_title = "{labels.wizard_start_title}";
 
-    /** The key of the message: Data Crawler - {0} */
-    public static final String LABELS_data_crawling_job_title = "{labels.data_crawling_job_title}";
-
     /** The key of the message: Using Configuration Wizard, you can create crawling settings easily. */
     public static final String LABELS_wizard_start_desc = "{labels.wizard_start_desc}";
 
@@ -1590,9 +1581,6 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Stop */
     public static final String LABELS_scheduledjob_button_stop = "{labels.scheduledjob_button_stop}";
 
-    /** The key of the message: return container.getComponent("crawlJob").logLevel("info").execute(executor, [{0}] as String[],[{1}] as String[],[{2}] as String[], ""); */
-    public static final String LABELS_scheduledjob_script_template = "{labels.scheduledjob_script_template}";
-
     /** The key of the message: Back */
     public static final String LABELS_joblog_button_back = "{labels.joblog_button_back}";
 

+ 56 - 0
src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java

@@ -69,6 +69,18 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
     /** The key of the configuration. e.g. default_crawler */
     String JOB_SYSTEM_JOB_IDS = "job.system.job.ids";
 
+    /** The key of the configuration. e.g. Web Crawler - {0} */
+    String JOB_TEMPLATE_TITLE_WEB = "job.template.title.web";
+
+    /** The key of the configuration. e.g. File Crawler - {0} */
+    String JOB_TEMPLATE_TITLE_FILE = "job.template.title.file";
+
+    /** The key of the configuration. e.g. Data Crawler - {0} */
+    String JOB_TEMPLATE_TITLE_DATA = "job.template.title.data";
+
+    /** The key of the configuration. e.g. return container.getComponent("crawlJob").logLevel("info").sessionId("{3}").execute(executor, [{0}] as String[],[{1}] as String[],[{2}] as String[], ""); */
+    String JOB_TEMPLATE_SCRIPT = "job.template.script";
+
     /** The key of the configuration. e.g. java */
     String JAVA_COMMAND_PATH = "java.command.path";
 
@@ -617,6 +629,34 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
      */
     String getJobSystemJobIds();
 
+    /**
+     * Get the value for the key 'job.template.title.web'. <br>
+     * The value is, e.g. Web Crawler - {0} <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getJobTemplateTitleWeb();
+
+    /**
+     * Get the value for the key 'job.template.title.file'. <br>
+     * The value is, e.g. File Crawler - {0} <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getJobTemplateTitleFile();
+
+    /**
+     * Get the value for the key 'job.template.title.data'. <br>
+     * The value is, e.g. Data Crawler - {0} <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getJobTemplateTitleData();
+
+    /**
+     * Get the value for the key 'job.template.script'. <br>
+     * The value is, e.g. return container.getComponent("crawlJob").logLevel("info").sessionId("{3}").execute(executor, [{0}] as String[],[{1}] as String[],[{2}] as String[], ""); <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getJobTemplateScript();
+
     /**
      * Get the value for the key 'java.command.path'. <br>
      * The value is, e.g. java <br>
@@ -2182,6 +2222,22 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             return get(FessConfig.JOB_SYSTEM_JOB_IDS);
         }
 
+        public String getJobTemplateTitleWeb() {
+            return get(FessConfig.JOB_TEMPLATE_TITLE_WEB);
+        }
+
+        public String getJobTemplateTitleFile() {
+            return get(FessConfig.JOB_TEMPLATE_TITLE_FILE);
+        }
+
+        public String getJobTemplateTitleData() {
+            return get(FessConfig.JOB_TEMPLATE_TITLE_DATA);
+        }
+
+        public String getJobTemplateScript() {
+            return get(FessConfig.JOB_TEMPLATE_SCRIPT);
+        }
+
         public String getJavaCommandPath() {
             return get(FessConfig.JAVA_COMMAND_PATH);
         }

+ 18 - 0
src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java

@@ -186,4 +186,22 @@ public interface FessProp {
         return StreamUtil.of(getSupportedUploadedMediaExtentions().split(",")).filter(s -> StringUtil.isNotBlank(s))
                 .toArray(n -> new String[n]);
     }
+
+    String getJobTemplateTitleWeb();
+
+    String getJobTemplateTitleFile();
+
+    String getJobTemplateTitleData();
+
+    public default String getJobTemplateTitle(String type) {
+        if (Constants.WEB_CRAWLER_TYPE.equals(type)) {
+            return getJobTemplateTitleWeb();
+        } else if (Constants.FILE_CRAWLER_TYPE.equals(type)) {
+            return getJobTemplateTitleFile();
+        } else if (Constants.DATA_CRAWLER_TYPE.equals(type)) {
+            return getJobTemplateTitleData();
+        }
+        return "None";
+    }
+
 }

+ 4 - 1
src/main/resources/fess_config.properties

@@ -48,7 +48,10 @@ jvm.suggest.options=\
 
 # job
 job.system.job.ids=default_crawler
-
+job.template.title.web=Web Crawler - {0}
+job.template.title.file=File Crawler - {0}
+job.template.title.data=Data Crawler - {0}
+job.template.script=return container.getComponent("crawlJob").logLevel("info").sessionId("{3}").execute(executor, [{0}] as String[],[{1}] as String[],[{2}] as String[], "");
 
 java.command.path=java
 path.encoding=UTF-8

+ 1 - 1
src/main/resources/fess_indices/.fess_config/scheduled_job.bulk

@@ -1,7 +1,7 @@
 {"index":{"_index":".fess_config","_type":"scheduled_job","_id":"default_crawler"}}
 {"name":"Default Crawler","target":"all","cronExpression":"0 0 0 * * ?","scriptType":"groovy","scriptData":"return container.getComponent(\"crawlJob\").logLevel(\"info\").execute(executor);","jobLogging":true,"crawler":true,"available":true,"sortOrder":1,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0}
 {"index":{"_index":".fess_config","_type":"scheduled_job","_id":"suggest_indexer"}}
-{"name":"Suggest Indexer","target":"all","cronExpression":"0 0 0 * * ?","scriptType":"groovy","scriptData":"return container.getComponent(\"suggestJob\").logLevel(\"info\").execute(executor);","jobLogging":true,"crawler":false,"available":true,"sortOrder":2,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0}
+{"name":"Suggest Indexer","target":"all","cronExpression":"0 0 0 * * ?","scriptType":"groovy","scriptData":"return container.getComponent(\"suggestJob\").logLevel(\"info\").sessionId(\"SUGGEST\").execute(executor);","jobLogging":true,"crawler":false,"available":true,"sortOrder":2,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0}
 {"index":{"_index":".fess_config","_type":"scheduled_job","_id":"log_aggregator"}}
 {"name":"Log Aggregator","target":"all","cronExpression":"0 * * * * ?","scriptType":"groovy","scriptData":"return container.getComponent(\"aggregateLogJob\").execute();","jobLogging":false,"crawler":false,"available":true,"sortOrder":3,"createdBy":"system","createdTime":0,"updatedBy":"system","updatedTime":0}
 {"index":{"_index":".fess_config","_type":"scheduled_job","_id":"log_purger"}}

+ 0 - 4
src/main/resources/fess_label.properties

@@ -280,7 +280,6 @@ labels.role_type=Role
 labels.label_type=Label
 labels.file_crawling_button_create=Create
 labels.file_crawling_button_create_job=Create new job
-labels.file_crawling_job_title=File Crawler - {0}
 labels.web_crawling_configuration=Web Crawling
 labels.web_crawling_title_details=Web Crawling Configuration
 labels.included_urls=Included URLs For Crawling
@@ -290,7 +289,6 @@ labels.excluded_doc_urls=Excluded URLs For Indexing
 labels.user_agent=User Agent
 labels.web_crawling_button_create=Create
 labels.web_crawling_button_create_job=Create new job
-labels.web_crawling_job_title=Web Crawler - {0}
 labels.crawler_configuration=General Configuration
 labels.crawler_title_edit=General Configuration
 labels.schedule=Schedule
@@ -448,7 +446,6 @@ labels.data_crawling_button_create=Create
 labels.data_crawling_button_create_job=Create new job
 labels.wizard_title_configuration=Configuration Wizard
 labels.wizard_start_title=Quick Setup
-labels.data_crawling_job_title=Data Crawler - {0}
 labels.wizard_start_desc=Using Configuration Wizard, you can create crawling settings easily.
 labels.wizard_start_button=Start Configuration
 labels.wizard_button_cancel=Cancel
@@ -527,7 +524,6 @@ labels.scheduledjob_active=Active
 labels.scheduledjob_nojob=Inactive
 labels.scheduledjob_button_start=Start now
 labels.scheduledjob_button_stop=Stop
-labels.scheduledjob_script_template=return container.getComponent("crawlJob").logLevel("info").execute(executor, [{0}] as String[],[{1}] as String[],[{2}] as String[], "");
 labels.joblog_button_back=Back
 labels.joblog_button_delete=Delete
 labels.joblog_configuration=Job Log

+ 0 - 4
src/main/resources/fess_label_en.properties

@@ -280,7 +280,6 @@ labels.role_type=Role
 labels.label_type=Label
 labels.file_crawling_button_create=Create
 labels.file_crawling_button_create_job=Create new job
-labels.file_crawling_job_title=File Crawler - {0}
 labels.web_crawling_configuration=Web Crawling
 labels.web_crawling_title_details=Web Crawling Configuration
 labels.included_urls=Included URLs For Crawling
@@ -290,7 +289,6 @@ labels.excluded_doc_urls=Excluded URLs For Indexing
 labels.user_agent=User Agent
 labels.web_crawling_button_create=Create
 labels.web_crawling_button_create_job=Create new job
-labels.web_crawling_job_title=Web Crawler - {0}
 labels.crawler_configuration=General Configuration
 labels.crawler_title_edit=General Configuration
 labels.schedule=Schedule
@@ -448,7 +446,6 @@ labels.data_crawling_button_create=Create
 labels.data_crawling_button_create_job=Create new job
 labels.wizard_title_configuration=Configuration Wizard
 labels.wizard_start_title=Quick Setup
-labels.data_crawling_job_title=Data Crawler - {0}
 labels.wizard_start_desc=Using Configuration Wizard, you can create crawling settings easily.
 labels.wizard_start_button=Start Configuration
 labels.wizard_button_cancel=Cancel
@@ -527,7 +524,6 @@ labels.scheduledjob_active=Active
 labels.scheduledjob_nojob=Inactive
 labels.scheduledjob_button_start=Start now
 labels.scheduledjob_button_stop=Stop
-labels.scheduledjob_script_template=return container.getComponent("crawlJob").logLevel("info").execute(executor, [{0}] as String[],[{1}] as String[],[{2}] as String[], "");
 labels.joblog_button_back=Back
 labels.joblog_button_delete=Delete
 labels.joblog_configuration=Job Log

+ 0 - 1
src/main/resources/fess_label_ja.properties

@@ -515,7 +515,6 @@ labels.scheduledjob_active = \u6709\u52b9
 labels.scheduledjob_nojob = \u7121\u52b9
 labels.scheduledjob_button_start = \u4eca\u3059\u3050\u958b\u59cb
 labels.scheduledjob_button_stop = \u505c\u6b62
-labels.scheduledjob_script_template = return container.getComponent("crawlJob").logLevel("info").execute(executor, [{0}] as String[],[{1}] as String[],[{2}] as String[], "");
 labels.joblog_button_back = \u623b\u308b
 labels.joblog_button_delete = \u524a\u9664
 labels.joblog_configuration = \u30b8\u30e7\u30d6\u30ed\u30b0