projects.jspf revision 850
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
830N/ACopyright 2009 Sun Microsystems, Inc. All rights reserved.
58N/AUse is subject to license terms.
58N/A
58N/A--%><%@ page import="org.opensolaris.opengrok.configuration.*,
850N/Ajava.util.ArrayList,java.util.List,java.util.Iterator" %><%
58N/Aboolean hasProjects = false;
830N/A// watch for iterators for below in case you will want to change it to List<Project>
850N/A//TODO also deduplication at this point might be nice
830N/AList<String> project = new ArrayList<String>();
58N/AList<Project> projects;
128N/AString context = request.getContextPath();
58N/ARuntimeEnvironment env = RuntimeEnvironment.getInstance();
128N/Aenv.setUrlPrefix(context + "/s?");
58N/Aenv.register();
850N/AStringBuffer sproject=new StringBuffer("");
58N/A
58N/Aif (env.hasProjects()) {
58N/A hasProjects = true;
58N/A projects = env.getProjects();
77N/A Project defaultProject = env.getDefaultProject();
77N/A if (defaultProject != null) {
830N/A project.add(defaultProject.getPath());
77N/A }
77N/A
850N/A // TODO project is also in xref ... merge with cookie and existing project for multi to work ok ???
850N/A
850N/A String pr[] = request.getParameterValues("project");
850N/A // see if a new parameter is passed...
850N/A if (pr != null && pr[0].length() > 0) {
850N/A //TODO this means project name CANNOT have a "," char in it !!!
850N/A String p[] = pr[0].split(",");
850N/A for (int idx = 0; idx < p.length; idx++) {
850N/A if (Project.getByDescription(p[idx]) != null) {
850N/A project.add(p[idx]);
58N/A }
58N/A }
850N/A //only save found projects into cookies
850N/A for (Iterator it = project.iterator(); it.hasNext();) {
850N/A sproject.append((String)it.next()+",");
850N/A }
850N/A // update the cookie
850N/A Cookie cookie = new Cookie("OpenGrok/project", sproject.toString());
850N/A response.addCookie(cookie);
850N/A } else { //fill in from cookies
850N/A Cookie[] cookies = request.getCookies();
850N/A if (cookies != null) {
850N/A for (Cookie cookie : cookies) {
850N/A if (cookie.getName().equals("OpenGrok/project")) {
850N/A for (String proj : cookie.getValue().split(",")) {
850N/A if (proj != "") {
850N/A project.add(proj);
850N/A }
850N/A }
830N/A }
850N/A }
830N/A }
850N/A //only save found projects into cookies
850N/A for (Iterator it = project.iterator(); it.hasNext();) {
850N/A sproject.append((String)it.next()+",");
850N/A }
58N/A }
58N/A}
144N/A%>