上节说完了创建,这下来说跳转到Project.
======================================================================
所以,还是得用/manager对应的servlet来执行,下面稍微跟踪一下:
======================================================================
@Override
protected void handleGet(HttpServletRequest req, HttpServletResponse resp, Session session)
throws ServletException, IOException {
if (hasParam(req, "project")) {//如果有参数Project,这里有
if (hasParam(req, "ajax")) {//无
handleAJAXAction(req, resp, session);
} else if (hasParam(req, "logs")) {
handleProjectLogsPage(req, resp, session);
} else if (hasParam(req, "permissions")) {
handlePermissionPage(req, resp, session);
} else if (hasParam(req, "prop")) {
handlePropertyPage(req, resp, session);
} else if (hasParam(req, "history")) {
handleJobHistoryPage(req, resp, session);
} else if (hasParam(req, "job")) {
handleJobPage(req, resp, session);
} else if (hasParam(req, "flow")) {
handleFlowPage(req, resp, session);
} else if (hasParam(req, "delete")) {
handleRemoveProject(req, resp, session);
} else if (hasParam(req, "purge")) {
handlePurgeProject(req, resp, session);
} else if (hasParam(req, "download")) {
handleDownloadProject(req, resp, session);
} else {
handleProjectPage(req, resp, session);
}
return;
} else if (hasParam(req, "reloadProjectWhitelist")) {
handleReloadProjectWhitelist(req, resp, session);
}
Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/projectpage.vm");
page.add("errorMsg", "No project set.");
page.render();
}
到底执行哪个分支,先看看req
根据这个结果,可以得知:
handleProjectPage(req, resp, session);被执行
===
private void handleProjectPage(HttpServletRequest req, HttpServletResponse resp, Session session)
throws ServletException {
//渲染页面
Page page = newPage(req, resp, session, "azkaban/webapp/servlet/velocity/projectpage.vm");
String projectName = getParam(req, "project");
User user = session.getUser();
Project project = null;
try {、、查询此工程,其实是从本地内存里查
project = projectManager.getProject(projectName);
if (project == null) {
page.add("errorMsg", "Project " + projectName + " not found.");
} else {
if (!hasPermission(project, user, Type.READ)) {
throw new AccessControlException("No permission to view project " + projectName + ".");
}
page.add("project", project);
page.add("admins", Utils.flattenToString(project.getUsersWithPermission(Type.ADMIN), ","));
Permission perm = this.getPermissionObject(project, user, Type.ADMIN);
page.add("userpermission", perm);
page.add("validatorFixPrompt",
projectManager.getProps().getBoolean(ValidatorConfigs.VALIDATOR_AUTO_FIX_PROMPT_FLAG_PARAM,
ValidatorConfigs.DEFAULT_VALIDATOR_AUTO_FIX_PROMPT_FLAG));
page.add("validatorFixLabel",
projectManager.getProps().get(ValidatorConfigs.VALIDATOR_AUTO_FIX_PROMPT_LABEL_PARAM));
page.add("validatorFixLink",
projectManager.getProps().get(ValidatorConfigs.VALIDATOR_AUTO_FIX_PROMPT_LINK_PARAM));
boolean adminPerm = perm.isPermissionSet(Type.ADMIN);
if (adminPerm) {
page.add("admin", true);
}
// Set this so we can display execute buttons only to those who
// have
// access.
if (perm.isPermissionSet(Type.EXECUTE) || adminPerm) {
page.add("exec", true);
} else {
page.add("exec", false);
}
List<Flow> flows = project.getFlows();
if (!flows.isEmpty()) {
Collections.sort(flows, FLOW_ID_COMPARATOR);
page.add("flows", flows);
}
}
} catch (AccessControlException e) {
page.add("errorMsg", e.getMessage());
}
page.render();//渲染
}