Selaa lähdekoodia

mark defautl_crawler as system job, add backup online help

Shinsuke Sugaya 9 vuotta sitten
vanhempi
commit
582de1010a

+ 1 - 1
src/main/java/org/codelibs/fess/app/web/admin/backup/AdminBackupAction.java

@@ -46,7 +46,7 @@ public class AdminBackupAction extends FessAdminAction {
     @Override
     @Override
     protected void setupHtmlData(final ActionRuntime runtime) {
     protected void setupHtmlData(final ActionRuntime runtime) {
         super.setupHtmlData(runtime);
         super.setupHtmlData(runtime);
-        runtime.registerData("helpLink", systemHelper.getHelpLink(fessConfig.getOnlineHelpNameLog()));
+        runtime.registerData("helpLink", systemHelper.getHelpLink(fessConfig.getOnlineHelpNameBackup()));
     }
     }
 
 
     @Execute
     @Execute

+ 19 - 15
src/main/java/org/codelibs/fess/app/web/admin/scheduler/AdminSchedulerAction.java

@@ -168,7 +168,7 @@ public class AdminSchedulerAction extends FessAdminAction {
         if (form.crudMode.intValue() == CrudMode.EDIT) {
         if (form.crudMode.intValue() == CrudMode.EDIT) {
             // back
             // back
             form.crudMode = CrudMode.DETAILS;
             form.crudMode = CrudMode.DETAILS;
-            return asDetailsHtml();
+            return asDetailsHtml(id);
         } else {
         } else {
             form.crudMode = CrudMode.EDIT;
             form.crudMode = CrudMode.EDIT;
             return asEditHtml();
             return asEditHtml();
@@ -182,7 +182,9 @@ public class AdminSchedulerAction extends FessAdminAction {
     public HtmlResponse details(final int crudMode, final String id) {
     public HtmlResponse details(final int crudMode, final String id) {
         verifyCrudMode(crudMode, CrudMode.DETAILS);
         verifyCrudMode(crudMode, CrudMode.DETAILS);
         saveToken();
         saveToken();
-        return asHtml(path_AdminScheduler_AdminSchedulerDetailsJsp).useForm(EditForm.class, op -> {
+        return asHtml(path_AdminScheduler_AdminSchedulerDetailsJsp).renderWith(data -> {
+            data.register("systemJobId", fessConfig.isSystemJobId(id));
+        }).useForm(EditForm.class, op -> {
             op.setup(form -> {
             op.setup(form -> {
                 scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
                 scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
                     loadScheduledJob(form, entity);
                     loadScheduledJob(form, entity);
@@ -231,14 +233,14 @@ public class AdminSchedulerAction extends FessAdminAction {
     @Execute
     @Execute
     public HtmlResponse delete(final EditForm form) {
     public HtmlResponse delete(final EditForm form) {
         verifyCrudMode(form.crudMode, CrudMode.DETAILS);
         verifyCrudMode(form.crudMode, CrudMode.DETAILS);
-        validate(form, messages -> {}, () -> asDetailsHtml());
-        verifyToken(() -> asDetailsHtml());
         final String id = form.id;
         final String id = form.id;
+        validate(form, messages -> {}, () -> asDetailsHtml(id));
+        verifyToken(() -> asDetailsHtml(id));
         scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
         scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
             scheduledJobService.delete(entity);
             scheduledJobService.delete(entity);
             saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
             saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
         }).orElse(() -> {
         }).orElse(() -> {
-            throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml());
+            throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), () -> asDetailsHtml(id));
         });
         });
         return redirect(getClass());
         return redirect(getClass());
     }
     }
@@ -246,9 +248,9 @@ public class AdminSchedulerAction extends FessAdminAction {
     @Execute
     @Execute
     public HtmlResponse start(final EditForm form) {
     public HtmlResponse start(final EditForm form) {
         verifyCrudMode(form.crudMode, CrudMode.DETAILS);
         verifyCrudMode(form.crudMode, CrudMode.DETAILS);
-        validate(form, messages -> {}, () -> asDetailsHtml());
-        verifyToken(() -> asDetailsHtml());
         final String id = form.id;
         final String id = form.id;
+        validate(form, messages -> {}, () -> asDetailsHtml(id));
+        verifyToken(() -> asDetailsHtml(id));
         scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
         scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
             try {
             try {
                 entity.start();
                 entity.start();
@@ -256,12 +258,12 @@ public class AdminSchedulerAction extends FessAdminAction {
             } catch (final Exception e) {
             } catch (final Exception e) {
                 throwValidationError(messages -> {
                 throwValidationError(messages -> {
                     messages.addErrorsFailedToStartJob(GLOBAL, entity.getName());
                     messages.addErrorsFailedToStartJob(GLOBAL, entity.getName());
-                }, () -> asDetailsHtml());
+                }, () -> asDetailsHtml(id));
             }
             }
         }).orElse(() -> {
         }).orElse(() -> {
             throwValidationError(messages -> {
             throwValidationError(messages -> {
                 messages.addErrorsFailedToStartJob(GLOBAL, id);
                 messages.addErrorsFailedToStartJob(GLOBAL, id);
-            }, () -> asDetailsHtml());
+            }, () -> asDetailsHtml(id));
         });
         });
         return redirect(getClass());
         return redirect(getClass());
     }
     }
@@ -269,9 +271,9 @@ public class AdminSchedulerAction extends FessAdminAction {
     @Execute
     @Execute
     public HtmlResponse stop(final EditForm form) {
     public HtmlResponse stop(final EditForm form) {
         verifyCrudMode(form.crudMode, CrudMode.DETAILS);
         verifyCrudMode(form.crudMode, CrudMode.DETAILS);
-        validate(form, messages -> {}, () -> asDetailsHtml());
-        verifyToken(() -> asDetailsHtml());
         final String id = form.id;
         final String id = form.id;
+        validate(form, messages -> {}, () -> asDetailsHtml(id));
+        verifyToken(() -> asDetailsHtml(id));
         scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
         scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
             try {
             try {
                 final JobExecutor jobExecutoer = jobHelper.getJobExecutoer(entity.getId());
                 final JobExecutor jobExecutoer = jobHelper.getJobExecutoer(entity.getId());
@@ -280,12 +282,12 @@ public class AdminSchedulerAction extends FessAdminAction {
             } catch (final Exception e) {
             } catch (final Exception e) {
                 throwValidationError(messages -> {
                 throwValidationError(messages -> {
                     messages.addErrorsFailedToStopJob(GLOBAL, entity.getName());
                     messages.addErrorsFailedToStopJob(GLOBAL, entity.getName());
-                }, () -> asDetailsHtml());
+                }, () -> asDetailsHtml(id));
             }
             }
         }).orElse(() -> {
         }).orElse(() -> {
             throwValidationError(messages -> {
             throwValidationError(messages -> {
                 messages.addErrorsFailedToStartJob(GLOBAL, id);
                 messages.addErrorsFailedToStartJob(GLOBAL, id);
-            }, () -> asDetailsHtml());
+            }, () -> asDetailsHtml(id));
         });
         });
         return redirect(getClass());
         return redirect(getClass());
     }
     }
@@ -365,7 +367,9 @@ public class AdminSchedulerAction extends FessAdminAction {
         return asHtml(path_AdminScheduler_AdminSchedulerEditJsp);
         return asHtml(path_AdminScheduler_AdminSchedulerEditJsp);
     }
     }
 
 
-    private HtmlResponse asDetailsHtml() {
-        return asHtml(path_AdminScheduler_AdminSchedulerDetailsJsp);
+    private HtmlResponse asDetailsHtml(String id) {
+        return asHtml(path_AdminScheduler_AdminSchedulerDetailsJsp).renderWith(data -> {
+            data.register("systemJobId", fessConfig.isSystemJobId(id));
+        });
     }
     }
 }
 }

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

@@ -66,6 +66,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
     -XX:+DisableExplicitGC */
     -XX:+DisableExplicitGC */
     String JVM_SUGGEST_OPTIONS = "jvm.suggest.options";
     String JVM_SUGGEST_OPTIONS = "jvm.suggest.options";
 
 
+    /** 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. 50 */
     /** The key of the configuration. e.g. 50 */
     String CRAWLER_DOCUMENT_MAX_SITE_LENGTH = "crawler.document.max.site.length";
     String CRAWLER_DOCUMENT_MAX_SITE_LENGTH = "crawler.document.max.site.length";
 
 
@@ -438,6 +441,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
     /** The key of the configuration. e.g. crawlinginfo */
     /** The key of the configuration. e.g. crawlinginfo */
     String ONLINE_HELP_NAME_CRAWLINGINFO = "online.help.name.crawlinginfo";
     String ONLINE_HELP_NAME_CRAWLINGINFO = "online.help.name.crawlinginfo";
 
 
+    /** The key of the configuration. e.g. backup */
+    String ONLINE_HELP_NAME_BACKUP = "online.help.name.backup";
+
     /** The key of the configuration. e.g. 0 */
     /** The key of the configuration. e.g. 0 */
     String SUGGEST_POPULAR_WORD_SEED = "suggest.popular.word.seed";
     String SUGGEST_POPULAR_WORD_SEED = "suggest.popular.word.seed";
 
 
@@ -573,6 +579,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
      */
      */
     String getJvmSuggestOptions();
     String getJvmSuggestOptions();
 
 
+    /**
+     * Get the value for the key 'job.system.job.ids'. <br>
+     * The value is, e.g. default_crawler <br>
+     * comment: job
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getJobSystemJobIds();
+
     /**
     /**
      * Get the value for the key 'crawler.document.max.site.length'. <br>
      * Get the value for the key 'crawler.document.max.site.length'. <br>
      * The value is, e.g. 50 <br>
      * The value is, e.g. 50 <br>
@@ -1828,6 +1842,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
      */
      */
     String getOnlineHelpNameCrawlinginfo();
     String getOnlineHelpNameCrawlinginfo();
 
 
+    /**
+     * Get the value for the key 'online.help.name.backup'. <br>
+     * The value is, e.g. backup <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getOnlineHelpNameBackup();
+
     /**
     /**
      * Get the value for the key 'suggest.popular.word.seed'. <br>
      * Get the value for the key 'suggest.popular.word.seed'. <br>
      * The value is, e.g. 0 <br>
      * The value is, e.g. 0 <br>
@@ -2026,6 +2047,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             return get(FessConfig.JVM_SUGGEST_OPTIONS);
             return get(FessConfig.JVM_SUGGEST_OPTIONS);
         }
         }
 
 
+        public String getJobSystemJobIds() {
+            return get(FessConfig.JOB_SYSTEM_JOB_IDS);
+        }
+
         public String getCrawlerDocumentMaxSiteLength() {
         public String getCrawlerDocumentMaxSiteLength() {
             return get(FessConfig.CRAWLER_DOCUMENT_MAX_SITE_LENGTH);
             return get(FessConfig.CRAWLER_DOCUMENT_MAX_SITE_LENGTH);
         }
         }
@@ -2702,6 +2727,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             return get(FessConfig.ONLINE_HELP_NAME_CRAWLINGINFO);
             return get(FessConfig.ONLINE_HELP_NAME_CRAWLINGINFO);
         }
         }
 
 
+        public String getOnlineHelpNameBackup() {
+            return get(FessConfig.ONLINE_HELP_NAME_BACKUP);
+        }
+
         public String getSuggestPopularWordSeed() {
         public String getSuggestPopularWordSeed() {
             return get(FessConfig.SUGGEST_POPULAR_WORD_SEED);
             return get(FessConfig.SUGGEST_POPULAR_WORD_SEED);
         }
         }

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

@@ -130,4 +130,12 @@ public interface FessProp {
         return getIndexBackupTargets().split(",");
         return getIndexBackupTargets().split(",");
     }
     }
 
 
+    String getJobSystemJobIds();
+
+    public default boolean isSystemJobId(String id) {
+        if (StringUtil.isBlank(getJobSystemJobIds())) {
+            return false;
+        }
+        return StreamUtil.of(getJobSystemJobIds().split(",")).anyMatch(s -> s.equals(id));
+    }
 }
 }

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

@@ -46,6 +46,9 @@ jvm.suggest.options=\
 #-Xdebug\n\
 #-Xdebug\n\
 #-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=127.0.0.1:8000\n\
 #-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=127.0.0.1:8000\n\
 
 
+# job
+job.system.job.ids=default_crawler
+
 # ========================================================================================
 # ========================================================================================
 #                                                                                   Index
 #                                                                                   Index
 #                                                                                     ====
 #                                                                                     ====
@@ -241,6 +244,7 @@ online.help.name.labeltype=labeltype
 online.help.name.duplicatehost=duplicatehost
 online.help.name.duplicatehost=duplicatehost
 online.help.name.scheduler=scheduler
 online.help.name.scheduler=scheduler
 online.help.name.crawlinginfo=crawlinginfo
 online.help.name.crawlinginfo=crawlinginfo
+online.help.name.backup=backup
 
 
 # ----------------------------------------------------------
 # ----------------------------------------------------------
 #                                                   Suggest
 #                                                   Suggest

+ 50 - 1
src/main/webapp/WEB-INF/view/admin/scheduler/admin_scheduler_details.jsp

@@ -106,7 +106,56 @@
 								</div>
 								</div>
 								<!-- /.box-body -->
 								<!-- /.box-body -->
 								<div class="box-footer">
 								<div class="box-footer">
-									<jsp:include page="/WEB-INF/view/common/admin/crud/buttons.jsp"></jsp:include>
+									<button type="submit" class="btn btn-default" name="list" value="back">
+										<i class="fa fa-arrow-circle-left"></i>
+										<la:message key="labels.crud_button_back" />
+									</button>
+									<button type="submit" class="btn btn-warning" name="edit"
+										value="<la:message key="labels.crud_button_edit" />">
+										<i class="fa fa-pencil"></i>
+										<la:message key="labels.crud_button_edit" />
+									</button>
+									<c:if test="${!running and !systemJobId}">
+									<button type="button" class="btn btn-danger" name="delete"
+										data-toggle="modal" data-target="#confirmToDelete"
+										value="<la:message key="labels.crud_button_delete" />">
+										<i class="fa fa-trash"></i>
+										<la:message key="labels.crud_button_delete" />
+									</button>
+									<div class="modal modal-danger fade" id="confirmToDelete" tabindex="-1"
+										role="dialog">
+										<div class="modal-dialog">
+											<div class="modal-content">
+												<div class="modal-header">
+													<button type="button" class="close" data-dismiss="modal"
+														aria-label="Close">
+														<span aria-hidden="true">×</span>
+													</button>
+													<h4 class="modal-title">
+														<la:message key="labels.crud_title_delete" />
+													</h4>
+												</div>
+												<div class="modal-body">
+													<p>
+														<la:message key="labels.crud_delete_confirmation" />
+													</p>
+												</div>
+												<div class="modal-footer">
+													<button type="button" class="btn btn-outline pull-left"
+														data-dismiss="modal">
+														<la:message key="labels.crud_button_cancel" />
+													</button>
+													<button type="submit" class="btn btn-outline btn-danger"
+														name="delete"
+														value="<la:message key="labels.crud_button_delete" />">
+														<i class="fa fa-trash"></i>
+														<la:message key="labels.crud_button_delete" />
+													</button>
+												</div>
+											</div>
+										</div>
+									</div>
+									</c:if>
 									<c:if test="${running}">
 									<c:if test="${running}">
 										<button type="submit" class="btn btn-danger" name="stop"
 										<button type="submit" class="btn btn-danger" name="stop"
 											value="<la:message key="labels.scheduledjob_button_stop" />">
 											value="<la:message key="labels.scheduledjob_button_stop" />">

+ 2 - 0
src/main/webapp/WEB-INF/view/common/admin/header.jsp

@@ -21,6 +21,8 @@
 		<!-- Navbar Right Menu -->
 		<!-- Navbar Right Menu -->
 		<div class="navbar-custom-menu">
 		<div class="navbar-custom-menu">
 			<ul class="nav navbar-nav">
 			<ul class="nav navbar-nav">
+				<li><a href="${contextPath}/admin/scheduler/details/4/default_crawler"><i
+						class="fa fa-play-circle"></i></a></li>
 				<li><a href="${helpLink}" target="_olh"><i
 				<li><a href="${helpLink}" target="_olh"><i
 						class="fa fa-question-circle"></i></a></li>
 						class="fa fa-question-circle"></i></a></li>
 				<li><a href="${contextPath}/logout"><i
 				<li><a href="${contextPath}/logout"><i