projects.jspf revision 830
<%--
CDDL HEADER START
The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.
See LICENSE.txt included in this distribution for the specific
language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at LICENSE.txt.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]
CDDL HEADER END
Copyright 2009 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
--%><%@ page import="org.opensolaris.opengrok.configuration.*,
java.util.ArrayList,java.util.List" %><%
boolean hasProjects = false;
// watch for iterators for below in case you will want to change it to List<Project>
List<String> project = new ArrayList<String>();
List<Project> projects;
String context = request.getContextPath();
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setUrlPrefix(context + "/s?");
env.register();
if (env.hasProjects()) {
hasProjects = true;
projects = env.getProjects();
Project defaultProject = env.getDefaultProject();
if (defaultProject != null) {
project.add(defaultProject.getPath());
}
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals("OpenGrok/project")) {
for (String proj : cookie.getValue().split(",")) {
if (proj!="") {
project.add(proj); }
}
}
}
}
// see if a new parameter is passed...
String p[] = request.getParameterValues("project");
StringBuffer pc=new StringBuffer("");
if (p != null && p.length > 0) {
project.clear();
for (int idx = 0; idx < p.length; idx++) {
if (Project.getProject(p[idx]) != null) {
project.add(p[idx]);
pc.append(p[idx]);
pc.append(",");
}
}
}
if (pc.length()>0) {
// update the cookie
Cookie cookie = new Cookie("OpenGrok/project", pc.toString());
response.addCookie(cookie);
}
}
%>