mast.jsp revision 53
59190ecd61435d19ba3515b876272aee7bd12298vboxsync<%--
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncCDDL HEADER START
59190ecd61435d19ba3515b876272aee7bd12298vboxsync
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncThe contents of this file are subject to the terms of the
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncCommon Development and Distribution License (the "License").
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncYou may not use this file except in compliance with the License.
59190ecd61435d19ba3515b876272aee7bd12298vboxsync
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncSee LICENSE.txt included in this distribution for the specific
c55c68b6a3324172e9dc207926215845880b0f90vboxsynclanguage governing permissions and limitations under the License.
c55c68b6a3324172e9dc207926215845880b0f90vboxsync
c55c68b6a3324172e9dc207926215845880b0f90vboxsyncWhen distributing Covered Code, include this CDDL HEADER in each
c55c68b6a3324172e9dc207926215845880b0f90vboxsyncfile and include the License file at LICENSE.txt.
c55c68b6a3324172e9dc207926215845880b0f90vboxsyncIf applicable, add the following below this CDDL HEADER, with the
c55c68b6a3324172e9dc207926215845880b0f90vboxsyncfields enclosed by brackets "[]" replaced with your own identifying
c55c68b6a3324172e9dc207926215845880b0f90vboxsyncinformation: Portions Copyright [yyyy] [name of copyright owner]
59190ecd61435d19ba3515b876272aee7bd12298vboxsync
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncCDDL HEADER END
59190ecd61435d19ba3515b876272aee7bd12298vboxsync
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncCopyright 2005 Sun Microsystems, Inc. All rights reserved.
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncUse is subject to license terms.
59190ecd61435d19ba3515b876272aee7bd12298vboxsync
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncident "%Z%%M% %I% %E% SMI"
59190ecd61435d19ba3515b876272aee7bd12298vboxsync
59190ecd61435d19ba3515b876272aee7bd12298vboxsync--%><%@ page import = "javax.servlet.*,
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncjava.lang.*,
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncjavax.servlet.http.*,
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncjava.util.*,
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncjava.io.*,
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncjava.text.*,
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncorg.opensolaris.opengrok.index.*
59190ecd61435d19ba3515b876272aee7bd12298vboxsync"
59190ecd61435d19ba3515b876272aee7bd12298vboxsync%><%@ page session="false" %><%@ page errorPage="error.jsp"%><%
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncString context = request.getContextPath();
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncString servlet = request.getServletPath();
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncString reqURI = request.getRequestURI();
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncString path = request.getPathInfo();
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncif (path == null) path = "";
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncString rawSource = getServletContext().getInitParameter("SRC_ROOT");
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncString resourcePath = rawSource + path;
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncFile resourceFile = new File(resourcePath);
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncresourcePath = resourceFile.getAbsolutePath();
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncboolean valid = true;
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncboolean noHistory = true;
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncString basename = resourceFile.getName();
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncboolean isDir = false;
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncEftarFileReader ef = null;
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncString parent = null;
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncString parentBasename = resourceFile.getParentFile().getName();
59190ecd61435d19ba3515b876272aee7bd12298vboxsyncif(resourcePath.length() < rawSource.length()
59190ecd61435d19ba3515b876272aee7bd12298vboxsync|| IgnoredNames.ignore(path)
59190ecd61435d19ba3515b876272aee7bd12298vboxsync|| IgnoredNames.ignore(parentBasename)
59190ecd61435d19ba3515b876272aee7bd12298vboxsync|| !resourcePath.startsWith(rawSource)) {
59190ecd61435d19ba3515b876272aee7bd12298vboxsync valid = false;
59190ecd61435d19ba3515b876272aee7bd12298vboxsync response.sendError(404);
59190ecd61435d19ba3515b876272aee7bd12298vboxsync return;
59190ecd61435d19ba3515b876272aee7bd12298vboxsync} else if (!resourceFile.canRead() && resourcePath.startsWith(rawSource)) {
59190ecd61435d19ba3515b876272aee7bd12298vboxsync String newPath = rawSource + "/on/" + path;
59190ecd61435d19ba3515b876272aee7bd12298vboxsync File newFile = new File(newPath);
59190ecd61435d19ba3515b876272aee7bd12298vboxsync if(newFile.canRead()) {
59190ecd61435d19ba3515b876272aee7bd12298vboxsync if(newFile.isDirectory() && servlet.startsWith("/xref") && !path.endsWith("/")) {
59190ecd61435d19ba3515b876272aee7bd12298vboxsync response.sendRedirect(context + servlet + "/on" + path + "/");
59190ecd61435d19ba3515b876272aee7bd12298vboxsync } else {
59190ecd61435d19ba3515b876272aee7bd12298vboxsync response.sendRedirect(context + servlet + "/on" + path);
59190ecd61435d19ba3515b876272aee7bd12298vboxsync }
59190ecd61435d19ba3515b876272aee7bd12298vboxsync }
59190ecd61435d19ba3515b876272aee7bd12298vboxsync valid = false;
59190ecd61435d19ba3515b876272aee7bd12298vboxsync response.sendError(404);
59190ecd61435d19ba3515b876272aee7bd12298vboxsync return;
59190ecd61435d19ba3515b876272aee7bd12298vboxsync} else {
59190ecd61435d19ba3515b876272aee7bd12298vboxsync valid = true;
59190ecd61435d19ba3515b876272aee7bd12298vboxsync path = resourcePath.substring(rawSource.length());
59190ecd61435d19ba3515b876272aee7bd12298vboxsync if ("".equals(path)) {
59190ecd61435d19ba3515b876272aee7bd12298vboxsync path = "/";
59190ecd61435d19ba3515b876272aee7bd12298vboxsync }
if (File.separatorChar == '\\') {
path = path.replace('\\','/');
}
isDir = resourceFile.isDirectory();
if (isDir && !servlet.startsWith("/xref") && !servlet.startsWith("/hist")) { //if it is an existing directory perhaps people wanted directory xref
if(!reqURI.endsWith("/")) {
response.sendRedirect(context + "/xref" + path + "/");
} else {
response.sendRedirect(context + "/xref" + path);
}
} 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 name="robots" content="noindex,nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Cross Reference: <%=path%></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">Cross Reference: <%=path%></b><br/><%=dtag%></div>
</div>
<div id="Masthead"><tt><a href="<%=context%>/xref/">xref</a>: <%=org.opensolaris.opengrok.web.Util.breadcrumbPath(context + "/xref", path)%></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><%=path%></b><%
}
} else {
%><input type="checkbox" name="path" value="<%=parent%>"/> only in <b><%=parentBasename%></b><%
}
%></div></form><%
} // date check
} // not a directory redirect
}
%>