|
@@ -17,33 +17,41 @@
|
|
|
package org.codelibs.fess.action.admin;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
-import org.apache.commons.logging.Log;
|
|
|
-import org.apache.commons.logging.LogFactory;
|
|
|
-import org.codelibs.fess.Constants;
|
|
|
-import org.codelibs.fess.beans.FessBeans;
|
|
|
import org.codelibs.fess.crud.CommonConstants;
|
|
|
import org.codelibs.fess.crud.CrudMessageException;
|
|
|
-import org.codelibs.fess.crud.action.admin.BsScheduledJobAction;
|
|
|
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
|
|
-import org.codelibs.fess.db.exentity.RoleType;
|
|
|
import org.codelibs.fess.db.exentity.ScheduledJob;
|
|
|
+import org.codelibs.fess.form.admin.ScheduledJobForm;
|
|
|
+import org.codelibs.fess.pager.ScheduledJobPager;
|
|
|
+import org.codelibs.fess.service.ScheduledJobService;
|
|
|
+import org.codelibs.sastruts.core.annotation.Token;
|
|
|
+import org.seasar.framework.beans.util.Beans;
|
|
|
+import org.seasar.framework.util.StringUtil;
|
|
|
+import org.seasar.struts.annotation.ActionForm;
|
|
|
+import org.seasar.struts.annotation.Execute;
|
|
|
+import org.seasar.struts.exception.ActionMessagesException;
|
|
|
+
|
|
|
+import org.codelibs.fess.Constants;
|
|
|
+import org.codelibs.fess.action.base.FessAdminAction;
|
|
|
+import org.codelibs.fess.beans.FessBeans;
|
|
|
+import org.codelibs.fess.db.exentity.RoleType;
|
|
|
import org.codelibs.fess.helper.JobHelper;
|
|
|
import org.codelibs.fess.helper.SystemHelper;
|
|
|
import org.codelibs.fess.job.JobExecutor;
|
|
|
import org.codelibs.fess.service.RoleTypeService;
|
|
|
import org.codelibs.sastruts.core.exception.SSCActionMessagesException;
|
|
|
-import org.seasar.struts.annotation.Execute;
|
|
|
-import org.seasar.struts.exception.ActionMessagesException;
|
|
|
-
|
|
|
-public class ScheduledJobAction extends BsScheduledJobAction {
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
- private static final long serialVersionUID = 1L;
|
|
|
+public class ScheduledJobAction extends FessAdminAction {
|
|
|
|
|
|
- private static final Log log = LogFactory.getLog(ScheduledJobAction.class);
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(ScheduledJobAction.class);
|
|
|
|
|
|
@Resource
|
|
|
protected RoleTypeService roleTypeService;
|
|
@@ -54,13 +62,28 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|
|
@Resource
|
|
|
protected JobHelper jobHelper;
|
|
|
|
|
|
+ // for list
|
|
|
+
|
|
|
+ public List<ScheduledJob> scheduledJobItems;
|
|
|
+
|
|
|
+ // for edit/confirm/delete
|
|
|
+
|
|
|
+ @ActionForm
|
|
|
+ @Resource
|
|
|
+ protected ScheduledJobForm scheduledJobForm;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ protected ScheduledJobService scheduledJobService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ protected ScheduledJobPager scheduledJobPager;
|
|
|
+
|
|
|
public boolean running = false;
|
|
|
|
|
|
public String getHelpLink() {
|
|
|
return systemHelper.getHelpLink("scheduledJob");
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
protected void loadScheduledJob() {
|
|
|
|
|
|
final ScheduledJob scheduledJob = getScheduledJob();
|
|
@@ -72,7 +95,6 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|
|
running = scheduledJob.isRunning();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
protected ScheduledJob createScheduledJob() {
|
|
|
ScheduledJob scheduledJob;
|
|
|
final String username = systemHelper.getUsername();
|
|
@@ -98,7 +120,6 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|
|
return scheduledJob;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
@Execute(validator = false, input = "error.jsp")
|
|
|
public String delete() {
|
|
|
if (scheduledJobForm.crudMode != CommonConstants.DELETE_MODE) {
|
|
@@ -118,13 +139,13 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|
|
|
|
|
return displayList(true);
|
|
|
} catch (final ActionMessagesException e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
throw e;
|
|
|
} catch (final CrudMessageException e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
|
|
} catch (final Exception e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table");
|
|
|
}
|
|
|
}
|
|
@@ -137,7 +158,7 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|
|
SAStrutsUtil.addSessionMessage("success.job_started", scheduledJob.getName());
|
|
|
return displayList(true);
|
|
|
} catch (final Exception e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
throw new SSCActionMessagesException(e, "errors.failed_to_start_job", scheduledJob.getName());
|
|
|
}
|
|
|
|
|
@@ -152,7 +173,7 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|
|
SAStrutsUtil.addSessionMessage("success.job_stopped", scheduledJob.getName());
|
|
|
return displayList(true);
|
|
|
} catch (final Exception e) {
|
|
|
- log.error(e.getMessage(), e);
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
throw new SSCActionMessagesException(e, "errors.failed_to_stop_job", scheduledJob.getName());
|
|
|
}
|
|
|
}
|
|
@@ -169,4 +190,198 @@ public class ScheduledJobAction extends BsScheduledJobAction {
|
|
|
}
|
|
|
return scheduledJob;
|
|
|
}
|
|
|
+
|
|
|
+ protected String displayList(final boolean redirect) {
|
|
|
+ // page navi
|
|
|
+ scheduledJobItems = scheduledJobService.getScheduledJobList(scheduledJobPager);
|
|
|
+
|
|
|
+ // restore from pager
|
|
|
+ Beans.copy(scheduledJobPager, scheduledJobForm.searchParams).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
|
|
+
|
|
|
+ .execute();
|
|
|
+
|
|
|
+ if (redirect) {
|
|
|
+ return "index?redirect=true";
|
|
|
+ } else {
|
|
|
+ return "index.jsp";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
+ public String index() {
|
|
|
+ return displayList(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "list/{pageNumber}")
|
|
|
+ public String list() {
|
|
|
+ // page navi
|
|
|
+ if (StringUtil.isNotBlank(scheduledJobForm.pageNumber)) {
|
|
|
+ try {
|
|
|
+ scheduledJobPager.setCurrentPageNumber(Integer.parseInt(scheduledJobForm.pageNumber));
|
|
|
+ } catch (final NumberFormatException e) {
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
+ logger.debug("Invalid value: " + scheduledJobForm.pageNumber, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return displayList(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
+ public String search() {
|
|
|
+ Beans.copy(scheduledJobForm.searchParams, scheduledJobPager).excludes(CommonConstants.PAGER_CONVERSION_RULE)
|
|
|
+
|
|
|
+ .execute();
|
|
|
+
|
|
|
+ return displayList(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
+ public String reset() {
|
|
|
+ scheduledJobPager.clear();
|
|
|
+
|
|
|
+ return displayList(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
+ public String back() {
|
|
|
+ return displayList(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = true, validate = false)
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
+ public String editagain() {
|
|
|
+ return "edit.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}")
|
|
|
+ public String confirmpage() {
|
|
|
+ if (scheduledJobForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
|
|
+ scheduledJobForm.crudMode });
|
|
|
+ }
|
|
|
+
|
|
|
+ loadScheduledJob();
|
|
|
+
|
|
|
+ return "confirm.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = true, validate = false)
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
+ public String createpage() {
|
|
|
+ // page navi
|
|
|
+ scheduledJobForm.initialize();
|
|
|
+ scheduledJobForm.crudMode = CommonConstants.CREATE_MODE;
|
|
|
+
|
|
|
+ return "edit.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = true, validate = false)
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}")
|
|
|
+ public String editpage() {
|
|
|
+ if (scheduledJobForm.crudMode != CommonConstants.EDIT_MODE) {
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
|
|
+ scheduledJobForm.crudMode });
|
|
|
+ }
|
|
|
+
|
|
|
+ loadScheduledJob();
|
|
|
+
|
|
|
+ return "edit.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = true, validate = false)
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
+ public String editfromconfirm() {
|
|
|
+ scheduledJobForm.crudMode = CommonConstants.EDIT_MODE;
|
|
|
+
|
|
|
+ loadScheduledJob();
|
|
|
+
|
|
|
+ return "edit.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = false, validate = true, keep = true)
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
+ public String confirmfromcreate() {
|
|
|
+ return "confirm.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = false, validate = true, keep = true)
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
+ public String confirmfromupdate() {
|
|
|
+ return "confirm.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = true, validate = false)
|
|
|
+ @Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}")
|
|
|
+ public String deletepage() {
|
|
|
+ if (scheduledJobForm.crudMode != CommonConstants.DELETE_MODE) {
|
|
|
+ throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
|
|
+ scheduledJobForm.crudMode });
|
|
|
+ }
|
|
|
+
|
|
|
+ loadScheduledJob();
|
|
|
+
|
|
|
+ return "confirm.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = true, validate = false)
|
|
|
+ @Execute(validator = false, input = "error.jsp")
|
|
|
+ public String deletefromconfirm() {
|
|
|
+ scheduledJobForm.crudMode = CommonConstants.DELETE_MODE;
|
|
|
+
|
|
|
+ loadScheduledJob();
|
|
|
+
|
|
|
+ return "confirm.jsp";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = false, validate = true)
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
+ public String create() {
|
|
|
+ try {
|
|
|
+ final ScheduledJob scheduledJob = createScheduledJob();
|
|
|
+ scheduledJobService.store(scheduledJob);
|
|
|
+ SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
|
|
+
|
|
|
+ return displayList(true);
|
|
|
+ } catch (final ActionMessagesException e) {
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ throw e;
|
|
|
+ } catch (final CrudMessageException e) {
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
|
|
+ } catch (final Exception e) {
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ throw new ActionMessagesException("errors.crud_failed_to_create_crud_table");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Token(save = false, validate = true)
|
|
|
+ @Execute(validator = true, input = "edit.jsp")
|
|
|
+ public String update() {
|
|
|
+ try {
|
|
|
+ final ScheduledJob scheduledJob = createScheduledJob();
|
|
|
+ scheduledJobService.store(scheduledJob);
|
|
|
+ SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
|
|
+
|
|
|
+ return displayList(true);
|
|
|
+ } catch (final ActionMessagesException e) {
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ throw e;
|
|
|
+ } catch (final CrudMessageException e) {
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
|
|
+ } catch (final Exception e) {
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ throw new ActionMessagesException("errors.crud_failed_to_update_crud_table");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected Map<String, String> createKeyMap() {
|
|
|
+ final Map<String, String> keys = new HashMap<String, String>();
|
|
|
+
|
|
|
+ keys.put("id", scheduledJobForm.id);
|
|
|
+
|
|
|
+ return keys;
|
|
|
+ }
|
|
|
}
|