use of nl.nn.adapterframework.scheduler.SchedulerAdapter in project iaf by ibissource.
the class SchedulerHandler method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Extract attributes we will need
initAction(request);
String action = request.getParameter("action");
if (null == action)
action = mapping.getParameter();
String jobName = request.getParameter("jobName");
String groupName = request.getParameter("groupName");
if (ibisManager == null) {
error("Cannot find ibismanager", null);
return null;
}
// TODO Dit moet natuurlijk netter...
DefaultIbisManager manager = (DefaultIbisManager) ibisManager;
SchedulerHelper sh = manager.getSchedulerHelper();
SchedulerAdapter schedulerAdapter = new SchedulerAdapter();
Scheduler scheduler;
try {
scheduler = sh.getScheduler();
} catch (SchedulerException e) {
error("Cannot find scheduler", e);
return null;
}
try {
String msg = null;
if (action.equalsIgnoreCase("startScheduler")) {
msg = "start scheduler:" + new Date() + HttpUtils.getCommandIssuedBy(request);
log.info(msg);
secLog.info(msg);
scheduler.start();
} else if (action.equalsIgnoreCase("pauseScheduler")) {
msg = "pause scheduler:" + new Date() + HttpUtils.getCommandIssuedBy(request);
log.info(msg);
secLog.info(msg);
scheduler.standby();
} else if (action.equalsIgnoreCase("deleteJob")) {
msg = "delete job jobName [" + jobName + "] groupName [" + groupName + "] " + HttpUtils.getCommandIssuedBy(request);
log.info(msg);
secLog.info(msg);
scheduler.deleteJob(jobName, groupName);
} else if (action.equalsIgnoreCase("triggerJob")) {
msg = "trigger job jobName [" + jobName + "] groupName [" + groupName + "] " + HttpUtils.getCommandIssuedBy(request);
log.info(msg);
secLog.info(msg);
scheduler.triggerJob(jobName, groupName);
} else {
log.error("no valid argument for SchedulerHandler:" + action);
}
} catch (Exception e) {
error("", e);
}
// Report any errors
if (!errors.isEmpty()) {
saveErrors(request, errors);
}
// Remove the obsolete form bean
if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope()))
request.removeAttribute(mapping.getAttribute());
else
session.removeAttribute(mapping.getAttribute());
}
// Forward control to the specified success URI
return (mapping.findForward("success"));
}
use of nl.nn.adapterframework.scheduler.SchedulerAdapter in project iaf by ibissource.
the class ShowSchedulerStatus method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
if (ibisManager == null)
return (mapping.findForward("noIbisContext"));
if (ibisManager == null) {
error("Cannot find ibismanager", null);
return null;
}
// TODO Dit moet natuurlijk netter...
DefaultIbisManager manager = (DefaultIbisManager) ibisManager;
SchedulerHelper sh = manager.getSchedulerHelper();
SchedulerAdapter schedulerAdapter = new SchedulerAdapter();
Scheduler scheduler;
try {
scheduler = sh.getScheduler();
} catch (SchedulerException e) {
error("Cannot find scheduler", e);
return null;
}
SchedulerAdapter sa = new SchedulerAdapter();
if (log.isDebugEnabled()) {
log.debug("set metadata [" + sa.getSchedulerMetaDataToXml(scheduler).toXML() + "]");
log.debug("set jobdata [" + sa.getJobGroupNamesWithJobsToXml(scheduler, ibisManager).toXML() + "]");
}
request.setAttribute("metadata", sa.getSchedulerMetaDataToXml(scheduler).toXML());
request.setAttribute("jobdata", sa.getJobGroupNamesWithJobsToXml(scheduler, ibisManager).toXML());
// Forward control to the specified success URI
log.debug("forward to success");
return (mapping.findForward("success"));
}
Aggregations