@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
resp.setContentType("application/xhtml+xml");
Page page = newPage(req, resp, "azkaban/web/pages/flow_instance.vm");
final FlowManager allFlows = this.getApplication().getAllFlows();
if (hasParam(req, "job_id")) {
String jobID = getParam(req, "job_id");
ExecutableFlow flow = allFlows.createNewExecutableFlow(jobID);
page.add("id", "0");
page.add("name", jobID);
if (flow == null) {
addError(req, "Job " + jobID + " not found.");
page.render();
return;
}
// This will be used the other
Flow displayFlow = new Flow(flow.getName(), (Props)null);
fillFlow(displayFlow, flow);
displayFlow.validateFlow();
String flowJSON = createJsonFlow(displayFlow);
page.add("jsonflow", flowJSON);
page.add("action", "run");
page.add("joblist", createJsonJobList(displayFlow));
}
else if (hasParam(req, "id")) {
long id = Long.parseLong(getParam(req, "id"));
FlowExecutionHolder holder = allFlows.loadExecutableFlow(id);
ExecutableFlow executableFlow = holder.getFlow();
// This will be used the other
Flow displayFlow = new Flow(executableFlow.getName(), (Props)null);
fillFlow(displayFlow, executableFlow);
displayFlow.validateFlow();
String flowJSON = createJsonFlow(displayFlow);
page.add("jsonflow", flowJSON);
page.add("id", id);
if (executableFlow.getStartTime() != null) {
page.add("startTime", executableFlow.getStartTime());
if (executableFlow.getEndTime() != null) {
page.add("endTime", executableFlow.getEndTime());
page.add("period", new Duration(executableFlow.getStartTime(), executableFlow.getEndTime()).toPeriod());
}
else {
page.add("period", new Duration(executableFlow.getStartTime(), new DateTime()).toPeriod());
}
}
page.add("showTimes", true);
page.add("name", executableFlow.getName());
page.add("action", "restart");
page.add("joblist", createJsonJobList(displayFlow));
}
page.render();
}