Home | History | Annotate | Download | only in web
      1 <%-- 
      2 CDDL HEADER START
      3 
      4 The contents of this file are subject to the terms of the
      5 Common Development and Distribution License (the "License").  
      6 You may not use this file except in compliance with the License.
      7 
      8 See LICENSE.txt included in this distribution for the specific
      9 language governing permissions and limitations under the License.
     10 
     11 When distributing Covered Code, include this CDDL HEADER in each
     12 file and include the License file at LICENSE.txt.
     13 If applicable, add the following below this CDDL HEADER, with the
     14 fields enclosed by brackets "[]" replaced with your own identifying
     15 information: Portions Copyright [yyyy] [name of copyright owner]
     16 
     17 CDDL HEADER END
     18 
     19 Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
     20 Use is subject to license terms.
     21 
     22 --%><%@ page import="org.opensolaris.opengrok.configuration.*,
     23 java.util.List" %><%
     24 boolean hasProjects = false;
     25 String project = null;
     26 List<Project> projects;
     27 String context = request.getContextPath();
     28 RuntimeEnvironment env = RuntimeEnvironment.getInstance();
     29 env.setUrlPrefix(context + "/s?");
     30 env.register();
     31 
     32 if (env.hasProjects()) {
     33     hasProjects = true;
     34     projects = env.getProjects();
     35     Project defaultProject = env.getDefaultProject();
     36     if (defaultProject != null) {
     37        project = defaultProject.getPath();
     38     }
     39 
     40     
     41     Cookie[] cookies = request.getCookies();
     42     if (cookies != null) {
     43         for (Cookie cookie : cookies) {
     44             if (cookie.getName().equals("OpenGrok/project")) {
     45                 project = cookie.getValue();
     46                 break;
     47             }
     48         }
     49     }
     50     
     51     // see if a new parameter is passed...
     52     String p[] = request.getParameterValues("project");
     53     if (p != null && p.length > 0) {
     54         project = p[0];
     55     }
     56 
     57     // Check that the project exists
     58     if (project != null) {
     59         if (Project.getProject(project) == null) {
     60             project = "";    
     61         }
     62     } else {
     63         project = "";
     64     }
     65     
     66     // update the cookie
     67     Cookie cookie = new Cookie("OpenGrok/project", project);
     68     response.addCookie(cookie);
     69 }
     70 %>