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