projects.jspf revision 77
90N/A<%--
943N/ACDDL HEADER START
90N/A
90N/AThe contents of this file are subject to the terms of the
919N/ACommon Development and Distribution License (the "License").
919N/AYou may not use this file except in compliance with the License.
919N/A
919N/ASee LICENSE.txt included in this distribution for the specific
919N/Alanguage governing permissions and limitations under the License.
90N/A
919N/AWhen distributing Covered Code, include this CDDL HEADER in each
919N/Afile and include the License file at LICENSE.txt.
919N/AIf applicable, add the following below this CDDL HEADER, with the
90N/Afields enclosed by brackets "[]" replaced with your own identifying
919N/Ainformation: Portions Copyright [yyyy] [name of copyright owner]
919N/A
919N/ACDDL HEADER END
919N/A
919N/ACopyright 2007 Sun Microsystems, Inc. All rights reserved.
919N/AUse is subject to license terms.
919N/A
90N/A--%><%@ page import="org.opensolaris.opengrok.configuration.*,
90N/Ajava.util.List" session="false" errorPage="error.jsp" %><%
90N/Aboolean hasProjects = false;
90N/AString project = null;
90N/AList<Project> projects;
90N/ARuntimeEnvironment env = RuntimeEnvironment.getInstance();
90N/Aenv.register();
90N/A
90N/Aif (env.hasProjects()) {
90N/A hasProjects = true;
90N/A projects = env.getProjects();
90N/A Project defaultProject = env.getDefaultProject();
90N/A if (defaultProject != null) {
90N/A project = defaultProject.getPath();
90N/A }
90N/A
90N/A
90N/A Cookie[] cookies = request.getCookies();
90N/A if (cookies != null) {
90N/A for (Cookie cookie : cookies) {
90N/A if (cookie.getName().equals("OpenGrok/project")) {
90N/A project = cookie.getValue();
90N/A break;
90N/A }
90N/A }
90N/A }
90N/A
90N/A // see if a new parameter is passed...
90N/A String p[] = request.getParameterValues("project");
90N/A if (p != null) {
90N/A StringBuilder sb = new StringBuilder();
90N/A for (String s : p) {
90N/A sb.append(s);
90N/A sb.append(" ");
90N/A }
90N/A project = sb.toString().trim();
90N/A }
90N/A
90N/A // see that this is a valid project..
90N/A if (project != null) {
90N/A StringBuilder sb = new StringBuilder();
90N/A for (String aproj : project.split(" ")) {
90N/A boolean valid = false;
for (Project proj : projects) {
if (proj.getPath().equalsIgnoreCase(aproj)) {
valid = true;
break;
}
}
if (valid) {
sb.append(aproj);
sb.append(" ");
}
}
project = sb.toString().trim();
} else {
project = "";
}
// update the cookie
Cookie cookie = new Cookie("OpenGrok/project", project);
response.addCookie(cookie);
}
%>