Shinsuke Sugaya пре 8 година
родитељ
комит
fb02131c9b

+ 28 - 0
src/main/java/org/codelibs/fess/exception/JobNotFoundException.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012-2017 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.exception;
+
+import org.codelibs.fess.es.config.exentity.ScheduledJob;
+
+public class JobNotFoundException extends FessSystemException {
+
+    private static final long serialVersionUID = 1L;
+
+    public JobNotFoundException(ScheduledJob scheduledJob) {
+        super(scheduledJob.toString());
+    }
+
+}

+ 8 - 5
src/main/java/org/codelibs/fess/helper/JobHelper.java

@@ -27,6 +27,7 @@ import org.codelibs.fess.es.config.exbhv.JobLogBhv;
 import org.codelibs.fess.es.config.exbhv.ScheduledJobBhv;
 import org.codelibs.fess.es.config.exentity.JobLog;
 import org.codelibs.fess.es.config.exentity.ScheduledJob;
+import org.codelibs.fess.exception.JobNotFoundException;
 import org.codelibs.fess.job.ScheduledJobException;
 import org.codelibs.fess.mylasta.direction.FessConfig;
 import org.codelibs.fess.util.ComponentUtil;
@@ -67,11 +68,13 @@ public class JobHelper {
         }
 
         final FessConfig fessConfig = ComponentUtil.getFessConfig();
-        final CronParamsSupplier paramsOp = () -> {
-            final Map<String, Object> params = new HashMap<>();
-            params.put(Constants.SCHEDULED_JOB, scheduledJob);
-            return params;
-        };
+        final CronParamsSupplier paramsOp =
+                () -> {
+                    final Map<String, Object> params = new HashMap<>();
+                    params.put(Constants.SCHEDULED_JOB, ComponentUtil.getComponent(ScheduledJobBhv.class).selectByPK(scheduledJob.getId())
+                            .orElseThrow(() -> new JobNotFoundException(scheduledJob)));
+                    return params;
+                };
         findJobByUniqueOf(LaJobUnique.of(id)).ifPresent(job -> {
             if (!job.isUnscheduled()) {
                 if (StringUtil.isNotBlank(scheduledJob.getCronExpression())) {