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