use of nl.nn.adapterframework.unmanaged.DefaultIbisManager in project iaf by ibissource.
the class ShowScheduler method trigger.
@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/schedules/{groupName}/{jobName}")
@Relation("schedules")
@Produces(MediaType.APPLICATION_JSON)
public Response trigger(@PathParam("jobName") String jobName, @PathParam("groupName") String groupName) throws ApiException {
initBase(servletConfig);
DefaultIbisManager manager = (DefaultIbisManager) ibisManager;
SchedulerHelper sh = manager.getSchedulerHelper();
Scheduler scheduler;
try {
scheduler = sh.getScheduler();
} catch (SchedulerException e) {
throw new ApiException("Cannot find scheduler");
}
try {
String commandIssuedBy = servletConfig.getInitParameter("remoteHost");
commandIssuedBy += servletConfig.getInitParameter("remoteAddress");
commandIssuedBy += servletConfig.getInitParameter("remoteUser");
log.info("trigger job jobName [" + jobName + "] groupName [" + groupName + "] " + commandIssuedBy);
scheduler.triggerJob(jobName, groupName);
} catch (Exception e) {
throw new ApiException("Failed to trigger job");
}
return Response.status(Response.Status.OK).build();
}
use of nl.nn.adapterframework.unmanaged.DefaultIbisManager in project iaf by ibissource.
the class ShowScheduler method PutSchedules.
@DELETE
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/schedules/{groupName}/{jobName}")
@Relation("schedules")
@Produces(MediaType.APPLICATION_JSON)
public Response PutSchedules(@PathParam("jobName") String jobName, @QueryParam("groupName") String groupName) throws ApiException {
initBase(servletConfig);
DefaultIbisManager manager = (DefaultIbisManager) ibisManager;
SchedulerHelper sh = manager.getSchedulerHelper();
Scheduler scheduler;
try {
scheduler = sh.getScheduler();
} catch (SchedulerException e) {
throw new ApiException("Cannot find scheduler");
}
try {
String commandIssuedBy = servletConfig.getInitParameter("remoteHost");
commandIssuedBy += servletConfig.getInitParameter("remoteAddress");
commandIssuedBy += servletConfig.getInitParameter("remoteUser");
log.info("delete job jobName [" + jobName + "] groupName [" + groupName + "] " + commandIssuedBy);
scheduler.deleteJob(jobName, groupName);
} catch (Exception e) {
throw new ApiException("Failed to delete job");
}
return Response.status(Response.Status.OK).build();
}
use of nl.nn.adapterframework.unmanaged.DefaultIbisManager 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.unmanaged.DefaultIbisManager in project iaf by ibissource.
the class ShowScheduler method putSchedules.
@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/schedules/")
@Relation("schedules")
@Produces(MediaType.APPLICATION_JSON)
public Response putSchedules(LinkedHashMap<String, Object> json) throws ApiException {
initBase(servletConfig);
DefaultIbisManager manager = (DefaultIbisManager) ibisManager;
SchedulerHelper sh = manager.getSchedulerHelper();
Scheduler scheduler;
try {
scheduler = sh.getScheduler();
} catch (SchedulerException e) {
throw new ApiException("Cannot find scheduler");
}
String action = null;
for (Entry<String, Object> entry : json.entrySet()) {
String key = entry.getKey();
if (key.equalsIgnoreCase("action")) {
action = entry.getValue().toString();
}
}
try {
String commandIssuedBy = servletConfig.getInitParameter("remoteHost");
commandIssuedBy += servletConfig.getInitParameter("remoteAddress");
commandIssuedBy += servletConfig.getInitParameter("remoteUser");
if (action.equalsIgnoreCase("start")) {
if (scheduler.isInStandbyMode() || scheduler.isShutdown()) {
scheduler.start();
log.info("start scheduler:" + new Date() + commandIssuedBy);
} else {
throw new ApiException("Failed to start scheduler");
}
} else if (action.equalsIgnoreCase("pause")) {
if (scheduler.isStarted()) {
scheduler.standby();
log.info("pause scheduler:" + new Date() + commandIssuedBy);
} else {
throw new ApiException("Failed to pause scheduler");
}
} else if (action.equalsIgnoreCase("stop")) {
if (scheduler.isStarted() || scheduler.isInStandbyMode()) {
scheduler.shutdown();
log.info("shutdown scheduler:" + new Date() + commandIssuedBy);
} else {
throw new ApiException("Failed to stop scheduler");
}
} else {
return Response.status(Response.Status.BAD_REQUEST).build();
}
} catch (Exception e) {
log.error("", e);
}
return Response.status(Response.Status.OK).build();
}
use of nl.nn.adapterframework.unmanaged.DefaultIbisManager 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