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