* The <code>HttpServletRequest</code> associated with this
* request.
*/
@SuppressWarnings("unchecked")
private void doProjectSetup(Command command, HttpServletRequest request) {
ProjectManager pm = new ProjectManager();
// since project information is regularly required for display,
// we keep a map of them in the application context so all jsps
// can reach it. the project servlet will remove any updated
// project so that it'll be picked up again in the next request.
HashMap<String, Project> projectMap;
boolean needsProjectAdded = false;
if (getServletContext().getAttribute("projectMap") == null) {
projectMap = new HashMap<String, Project>();
getServletContext().setAttribute("projectMap", projectMap);
needsProjectAdded = true;
Logger.debug("Empty project map added to context.");
} else {
projectMap = (HashMap<String, Project>) getServletContext()
.getAttribute("projectMap");
Logger.debug("Project map retrieved from context.");
if (!projectMap.containsKey(command.getProject())) {
needsProjectAdded = true;
}
}
// add the project if it wasn't found in the map
if (needsProjectAdded) {
try {
projectMap.put(command.getProject(), pm.getProject(command
.getProject()));
Logger.debug("'" + command.getProject()
+ "' added to project map");
} catch (NoSuchProjectException e) {
// just warn here, b/c the fatal errors will come soon
// enough if this happens
Logger.warn("Couldn't get project '" + command.getProject()
+ "'", e);
}
}
// then add any "support project"-related information to the servlet
// request, listing on those that the user has administrative privileges
// within
if (request.getSession().getAttribute("user") != null) {
User user = (User) request.getSession().getAttribute("user");
HashMap<String, String> userAdminRoleMap;
Project project = projectMap.get(command.getProject());
if (project.getParentId() > 0) {
// this is a support project, so get the parent project's name
// and
// handle for public face linking (LeftHandMenu.jsp)
try {
Project parentProject = pm.getProject(pm
.getProjectHandle(project.getParentId()));
userAdminRoleMap = user.getAdminRoles().get(
parentProject.getHandle());
if ((userAdminRoleMap != null)
&& (userAdminRoleMap.size() > 0)) {
request.setAttribute("parentProject", parentProject);
}
} catch (NoSuchProjectException e) {
Logger.warn("Couldn't find parent project for display.", e);
}
} else {
// this is a main project, so get any available child projects'
// names and handles for public face linking
// (LeftHandMenu.jsp)
ArrayList<Project> supportProjects = pm
.getSupportProjects(project);
if (supportProjects!=null) {
for (int m = supportProjects.size() - 1; m >= 0; m--) {
userAdminRoleMap = user.getAdminRoles().get(
supportProjects.get(m).getHandle());