mast.jsp revision 50
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
0N/ACopyright 2005 Sun Microsystems, Inc. All rights reserved.
0N/AUse is subject to license terms.
0N/A
0N/Aident "%Z%%M% %I% %E% SMI"
0N/A
0N/A--%><%@ page import = "javax.servlet.*,
0N/Ajava.lang.*,
0N/Ajavax.servlet.http.*,
0N/Ajava.util.*,
0N/Ajava.io.*,
0N/Ajava.text.*,
0N/Aorg.opensolaris.opengrok.index.*
0N/A"
0N/A%><%@ page session="false" %><%@ page errorPage="error.jsp"%><%
0N/AString context = request.getContextPath();
0N/AString servlet = request.getServletPath();
0N/AString reqURI = request.getRequestURI();
0N/AString path = request.getPathInfo();
0N/Aif (path == null) path = "";
0N/AString rawSource = getServletContext().getInitParameter("SRC_ROOT");
0N/AString resourcePath = rawSource + path;
0N/AFile resourceFile = new File(resourcePath);
0N/AresourcePath = resourceFile.getAbsolutePath();
50N/Aboolean valid = true;
0N/Aboolean noHistory = true;
0N/AString basename = resourceFile.getName();
0N/Aboolean isDir = false;
0N/AEftarFileReader ef = null;
0N/AString parent = null;
0N/AString parentBasename = resourceFile.getParentFile().getName();
0N/Aif(resourcePath.length() < rawSource.length()
50N/A|| IgnoredNames.ignore(path)
47N/A|| IgnoredNames.ignore(parentBasename)
0N/A|| !resourcePath.startsWith(rawSource)) {
0N/A valid = false;
0N/A response.sendError(404);
27N/A return;
0N/A} else if (!resourceFile.canRead() && resourcePath.startsWith(rawSource)) {
0N/A String newPath = rawSource + "/on/" + path;
0N/A File newFile = new File(newPath);
0N/A if(newFile.canRead()) {
0N/A if(newFile.isDirectory() && servlet.startsWith("/xref") && !path.endsWith("/")) {
0N/A response.sendRedirect(context + servlet + "/on" + path + "/");
0N/A } else {
0N/A response.sendRedirect(context + servlet + "/on" + path);
0N/A }
0N/A }
0N/A valid = false;
0N/A response.sendError(404);
27N/A return;
0N/A} else {
0N/A valid = true;
0N/A path = resourcePath.substring(rawSource.length());
50N/A if ("".equals(path)) {
50N/A path = "/";
50N/A }
0N/A if (File.separatorChar == '\\') {
0N/A path = path.replace('\\','/');
0N/A }
0N/A isDir = resourceFile.isDirectory();
0N/A if (isDir && !servlet.startsWith("/xref") && !servlet.startsWith("/hist")) { //if it is an existing directory perhaps people wanted directory xref
0N/A if(!reqURI.endsWith("/")) {
0N/A response.sendRedirect(context + "/xref" + path + "/");
0N/A } else {
0N/A response.sendRedirect(context + "/xref" + path);
0N/A }
0N/A } if (isDir && !reqURI.endsWith("/")) {
0N/A response.sendRedirect(context + servlet + path +"/");
0N/A } else {
0N/A
0N/A long flast = resourceFile.lastModified();
0N/A String dtag = "";
0N/A
0N/A if (request.getDateHeader("If-Modified-Since") >= flast ) {
0N/A response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
0N/A valid = false;
0N/A } else {
0N/A
0N/A response.setDateHeader("Last-Modified", flast);
0N/A int lastSlash = path.lastIndexOf('/');
0N/A parent = (lastSlash != -1) ? path.substring(0, lastSlash) : "";
0N/A int pLastSlash = parent.lastIndexOf('/');
0N/A parentBasename = pLastSlash != -1 ? parent.substring(pLastSlash+1) : parent;
0N/A noHistory = !(isDir || HistoryGuru.getInstance().hasHistory(rawSource + "/" + parent));
0N/A try{
0N/A ef = new EftarFileReader(getServletContext().getInitParameter("DATA_ROOT") + "/index/dtags.eftar");
0N/A dtag = ef.get(path);
0N/A if(servlet.startsWith("/xr")) {
0N/A } else {
0N/A if(ef != null) {
0N/A try {
0N/A ef.close();
0N/A } catch (IOException e) {
0N/A } finally {
0N/A ef = null;
0N/A }
0N/A }
0N/A }
0N/A } catch (Exception e) {
0N/A dtag = "";
0N/A }
0N/A%><?xml version="1.0" encoding="iso-8859-1"?>
0N/A<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
0N/A<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
0N/A<head>
0N/A <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
50N/A <title>Cross Reference: <%=path%></title>
0N/A <link rel="icon" href="<%=context%>/img/icon.png" type="image/png"/>
0N/A <link rel="stylesheet" type="text/css" href="<%=context%>/style.css"/>
0N/A <link rel="stylesheet" type="text/css" href="<%=context%>/print.css" media="print" />
0N/A <link rel="alternate stylesheet" type="text/css" media="all" title="Paper White" href="<%=context%>/print.css"/>
0N/A</head>
0N/A<body><div id="page">
0N/A<form action="<%=context%>/search">
0N/A <div id="header">
0N/A <%= getServletContext().getInitParameter("HEADER") %>
50N/A <div id="pagetitle"><b id="filename">Cross Reference: <%=path%></b><br/><%=dtag%></div>
0N/A </div>
50N/A<div id="Masthead"><tt><a href="<%=context%>/xref/">xref</a>: <%=org.opensolaris.opengrok.web.Util.breadcrumbPath(context + "/xref", path)%></tt></div>
0N/A<div id="bar"><a href="<%=context%>" id="home">Home</a> |
0N/A<%
0N/A
0N/Aif ((!isDir && noHistory) || servlet.startsWith("/hi")) {
0N/A %> <span class="c" id="history">History</span> |<%
0N/A} else {
0N/A %><a id="history" href="<%=context%>/history<%=path%>">History</a> |<%
0N/A}
0N/A if (!isDir) {
0N/A %> <a id="download" href="<%=context%>/raw<%=path%>">Download</a> | <%
0N/A }
0N/A
0N/A%> <input id="search" name="q" class="q"/>
0N/A<input type="submit" value="Search" class="submit"/><%
0N/A
0N/Aif(isDir) {
0N/A if(path.length() > 0) {
50N/A %><input type="checkbox" name="path" value="<%=path%>"/> only in <b><%=path%></b><%
0N/A }
0N/A} else {
0N/A %><input type="checkbox" name="path" value="<%=parent%>"/> only in <b><%=parentBasename%></b><%
0N/A}
0N/A
0N/A%></div></form><%
0N/A
0N/A} // date check
0N/A } // not a directory redirect
0N/A}
0N/A%>