mast.jsp revision 50
8N/A<%--
8N/ACDDL HEADER START
8N/A
8N/AThe contents of this file are subject to the terms of the
8N/ACommon Development and Distribution License (the "License").
8N/AYou may not use this file except in compliance with the License.
8N/A
8N/ASee LICENSE.txt included in this distribution for the specific
8N/Alanguage governing permissions and limitations under the License.
8N/A
8N/AWhen distributing Covered Code, include this CDDL HEADER in each
8N/Afile and include the License file at LICENSE.txt.
8N/AIf applicable, add the following below this CDDL HEADER, with the
8N/Afields enclosed by brackets "[]" replaced with your own identifying
8N/Ainformation: Portions Copyright [yyyy] [name of copyright owner]
8N/A
8N/ACDDL HEADER END
8N/A
8N/ACopyright 2005 Sun Microsystems, Inc. All rights reserved.
8N/AUse is subject to license terms.
65N/A
8N/Aident "%Z%%M% %I% %E% SMI"
8N/A
8N/A--%><%@ page import = "javax.servlet.*,
8N/Ajava.lang.*,
65N/Ajavax.servlet.http.*,
65N/Ajava.util.*,
65N/Ajava.io.*,
262N/Ajava.text.*,
8N/Aorg.opensolaris.opengrok.index.*
24N/A"
8N/A%><%@ page session="false" %><%@ page errorPage="error.jsp"%><%
65N/AString context = request.getContextPath();
58N/AString servlet = request.getServletPath();
516N/AString reqURI = request.getRequestURI();
416N/AString path = request.getPathInfo();
95N/Aif (path == null) path = "";
95N/AString rawSource = getServletContext().getInitParameter("SRC_ROOT");
416N/AString resourcePath = rawSource + path;
516N/AFile resourceFile = new File(resourcePath);
8N/AresourcePath = resourceFile.getAbsolutePath();
8N/Aboolean valid = true;
65N/Aboolean noHistory = true;
574N/AString basename = resourceFile.getName();
8N/Aboolean isDir = false;
290N/AEftarFileReader ef = null;
574N/AString parent = null;
574N/AString parentBasename = resourceFile.getParentFile().getName();
435N/Aif(resourcePath.length() < rawSource.length()
435N/A|| IgnoredNames.ignore(path)
435N/A|| IgnoredNames.ignore(parentBasename)
24N/A|| !resourcePath.startsWith(rawSource)) {
65N/A valid = false;
75N/A response.sendError(404);
75N/A return;
75N/A} else if (!resourceFile.canRead() && resourcePath.startsWith(rawSource)) {
314N/A String newPath = rawSource + "/on/" + path;
314N/A File newFile = new File(newPath);
75N/A if(newFile.canRead()) {
574N/A if(newFile.isDirectory() && servlet.startsWith("/xref") && !path.endsWith("/")) {
574N/A response.sendRedirect(context + servlet + "/on" + path + "/");
574N/A } else {
574N/A response.sendRedirect(context + servlet + "/on" + path);
574N/A }
574N/A }
574N/A valid = false;
574N/A response.sendError(404);
574N/A return;
50N/A} else {
58N/A valid = true;
232N/A path = resourcePath.substring(rawSource.length());
50N/A if ("".equals(path)) {
50N/A path = "/";
50N/A }
24N/A if (File.separatorChar == '\\') {
574N/A path = path.replace('\\','/');
574N/A }
574N/A isDir = resourceFile.isDirectory();
574N/A if (isDir && !servlet.startsWith("/xref") && !servlet.startsWith("/hist")) { //if it is an existing directory perhaps people wanted directory xref
574N/A if(!reqURI.endsWith("/")) {
574N/A response.sendRedirect(context + "/xref" + path + "/");
435N/A } else {
574N/A response.sendRedirect(context + "/xref" + path);
8N/A }
574N/A } if (isDir && !reqURI.endsWith("/")) {
574N/A response.sendRedirect(context + servlet + path +"/");
574N/A } else {
574N/A
71N/A long flast = resourceFile.lastModified();
24N/A String dtag = "";
8N/A
65N/A if (request.getDateHeader("If-Modified-Since") >= flast ) {
65N/A response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
232N/A valid = false;
232N/A } else {
232N/A
71N/A response.setDateHeader("Last-Modified", flast);
71N/A int lastSlash = path.lastIndexOf('/');
355N/A parent = (lastSlash != -1) ? path.substring(0, lastSlash) : "";
575N/A int pLastSlash = parent.lastIndexOf('/');
575N/A parentBasename = pLastSlash != -1 ? parent.substring(pLastSlash+1) : parent;
575N/A noHistory = !(isDir || HistoryGuru.getInstance().hasHistory(rawSource + "/" + parent));
575N/A try{
575N/A ef = new EftarFileReader(getServletContext().getInitParameter("DATA_ROOT") + "/index/dtags.eftar");
58N/A dtag = ef.get(path);
575N/A if(servlet.startsWith("/xr")) {
71N/A } else {
24N/A if(ef != null) {
262N/A try {
262N/A ef.close();
355N/A } catch (IOException e) {
262N/A } finally {
262N/A ef = null;
262N/A }
262N/A }
262N/A }
262N/A } catch (Exception e) {
65N/A dtag = "";
65N/A }
262N/A%><?xml version="1.0" encoding="iso-8859-1"?>
58N/A<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
416N/A<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
71N/A<head>
355N/A <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
355N/A <title>Cross Reference: <%=path%></title>
355N/A <link rel="icon" href="<%=context%>/img/icon.png" type="image/png"/>
355N/A <link rel="stylesheet" type="text/css" href="<%=context%>/style.css"/>
508N/A <link rel="stylesheet" type="text/css" href="<%=context%>/print.css" media="print" />
355N/A <link rel="alternate stylesheet" type="text/css" media="all" title="Paper White" href="<%=context%>/print.css"/>
355N/A</head>
71N/A<body><div id="page">
71N/A<form action="<%=context%>/search">
71N/A <div id="header">
71N/A <%= getServletContext().getInitParameter("HEADER") %>
75N/A <div id="pagetitle"><b id="filename">Cross Reference: <%=path%></b><br/><%=dtag%></div>
71N/A </div>
71N/A<div id="Masthead"><tt><a href="<%=context%>/xref/">xref</a>: <%=org.opensolaris.opengrok.web.Util.breadcrumbPath(context + "/xref", path)%></tt></div>
71N/A<div id="bar"><a href="<%=context%>" id="home">Home</a> |
71N/A<%
24N/A
24N/Aif ((!isDir && noHistory) || servlet.startsWith("/hi")) {
8N/A %> <span class="c" id="history">History</span> |<%
8N/A} else {
30N/A %><a id="history" href="<%=context%>/history<%=path%>">History</a> |<%
25N/A}
25N/A if (!isDir) {
25N/A %> <a id="download" href="<%=context%>/raw<%=path%>">Download</a> | <%
95N/A }
212N/A
212N/A%> <input id="search" name="q" class="q"/>
212N/A<input type="submit" value="Search" class="submit"/><%
212N/A
95N/Aif(isDir) {
95N/A if(path.length() > 0) {
95N/A %><input type="checkbox" name="path" value="<%=path%>"/> only in <b><%=path%></b><%
95N/A }
95N/A} else {
95N/A %><input type="checkbox" name="path" value="<%=parent%>"/> only in <b><%=parentBasename%></b><%
95N/A}
95N/A
95N/A%></div></form><%
95N/A
95N/A} // date check
459N/A } // not a directory redirect
95N/A}
314N/A%>
95N/A