mast.jsp revision 878
55a7410569737197afb302b07b488973324b0cc5Timo SirainenCDDL HEADER START
def516ea503a60f20d510c14d5070b7ff5bbddf4Timo SirainenThe contents of this file are subject to the terms of the
55a7410569737197afb302b07b488973324b0cc5Timo SirainenCommon Development and Distribution License (the "License").
5ce2084ada06ade9f44fc2914c34658e9a842dc1Timo SirainenYou may not use this file except in compliance with the License.
55a7410569737197afb302b07b488973324b0cc5Timo SirainenSee LICENSE.txt included in this distribution for the specific
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainenlanguage governing permissions and limitations under the License.
55a7410569737197afb302b07b488973324b0cc5Timo SirainenWhen distributing Covered Code, include this CDDL HEADER in each
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainenfile and include the License file at LICENSE.txt.
55a7410569737197afb302b07b488973324b0cc5Timo SirainenIf applicable, add the following below this CDDL HEADER, with the
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainenfields enclosed by brackets "[]" replaced with your own identifying
55a7410569737197afb302b07b488973324b0cc5Timo Siraineninformation: Portions Copyright [yyyy] [name of copyright owner]
55a7410569737197afb302b07b488973324b0cc5Timo SirainenCDDL HEADER END
55a7410569737197afb302b07b488973324b0cc5Timo SirainenCopyright 2009 Sun Microsystems, Inc. All rights reserved.
55a7410569737197afb302b07b488973324b0cc5Timo SirainenUse is subject to license terms.
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen--%><%@ page import = "javax.servlet.*,
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen %><%@ page session="false" %><%@ page errorPage="error.jsp"%><%
55a7410569737197afb302b07b488973324b0cc5Timo SirainenString context = request.getContextPath();
63946971b08cfb1eec698c28569e1c4aa237852dTimo SirainenString servlet = request.getServletPath();
63946971b08cfb1eec698c28569e1c4aa237852dTimo SirainenString reqURI = request.getRequestURI();
63946971b08cfb1eec698c28569e1c4aa237852dTimo Sirainenif (path == null) path = "";
63946971b08cfb1eec698c28569e1c4aa237852dTimo SirainenRuntimeEnvironment environment = RuntimeEnvironment.getInstance();
4b058f90f9e8a2c6b2eed275de4eb8cc5195a71dTimo SirainenString rawSource = environment.getSourceRootPath();
55a7410569737197afb302b07b488973324b0cc5Timo SirainenString resourcePath = rawSource + path;
55a7410569737197afb302b07b488973324b0cc5Timo SirainenFile resourceFile = new File(resourcePath);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenboolean valid = true;
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenboolean noHistory = true;
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenboolean noAnnotation = true;
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenboolean annotate = false;
55a7410569737197afb302b07b488973324b0cc5Timo SirainenString basename = resourceFile.getName();
55a7410569737197afb302b07b488973324b0cc5Timo Sirainenboolean isDir = false;
55a7410569737197afb302b07b488973324b0cc5Timo SirainenEftarFileReader ef = null;
e60a349c641bb2f4723e4a395a25f55531682d2bTimo SirainenString parent = null;
55a7410569737197afb302b07b488973324b0cc5Timo SirainenString parentBasename = resourceFile.getParentFile().getName();
55a7410569737197afb302b07b488973324b0cc5Timo SirainenIgnoredNames ignoredNames = environment.getIgnoredNames();
55a7410569737197afb302b07b488973324b0cc5Timo SirainenString uriEncodedName = Util.URIEncodePath(path);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen|| ignoredNames.ignore(parentBasename)
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen valid = false;
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen} else if (!resourceFile.canRead() && resourcePath.startsWith(rawSource)) {
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen String newPath = rawSource + "/on/" + path; //TODO do we still use "on" ???
e60a349c641bb2f4723e4a395a25f55531682d2bTimo Sirainen File newFile = new File(newPath);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen if(newFile.isDirectory() && servlet.startsWith("/xref") && !path.endsWith("/")) {
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen response.sendRedirect(context + servlet + "/on" + path + "/");
def516ea503a60f20d510c14d5070b7ff5bbddf4Timo Sirainen response.sendRedirect(context + servlet + "/on" + path);
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen valid = false;
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen valid = true;
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen path = resourcePath.substring(rawSource.length());
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen if ("".equals(path)) {
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen path = path.replace('\\','/');
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen if (isDir && !servlet.startsWith("/xref") && !servlet.startsWith("/hist")) { //if it is an existing directory perhaps people wanted directory xref
e60a349c641bb2f4723e4a395a25f55531682d2bTimo Sirainen response.sendRedirect(context + "/xref" + path + "/");
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen response.sendRedirect(context + "/xref" + path);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen } if (isDir && !reqURI.endsWith("/")) {
e60a349c641bb2f4723e4a395a25f55531682d2bTimo Sirainen response.sendRedirect(context + servlet + path +"/");
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen String dtag = "";
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen if (request.getDateHeader("If-Modified-Since") >= flast ) {
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen valid = false;
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen response.setDateHeader("Last-Modified", flast);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen int lastSlash = path.lastIndexOf('/');
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen parent = (lastSlash != -1) ? path.substring(0, lastSlash) : "";
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen int pLastSlash = parent.lastIndexOf('/');
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen parentBasename = pLastSlash != -1 ? parent.substring(pLastSlash+1) : parent;
e60a349c641bb2f4723e4a395a25f55531682d2bTimo Sirainen noHistory = !HistoryGuru.getInstance().hasHistory(resourceFile);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen noAnnotation = isDir ||
fd4632d0060b2e9eef513b544ccff1e26d1fc222Timo Sirainen !HistoryGuru.getInstance().hasAnnotation(resourceFile);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen annotate = !noAnnotation &&
4525c4a8f8d1a6365e4469c0c8f46575400a9a67Timo Sirainen Boolean.parseBoolean(request.getParameter("a"));
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen ef = new EftarFileReader(environment.getDataRootPath() + "/index/dtags.eftar");
fd4632d0060b2e9eef513b544ccff1e26d1fc222Timo Sirainen dtag = ef.get(path);
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen if(ef != null) {
e60a349c641bb2f4723e4a395a25f55531682d2bTimo Sirainen } catch (IOException e) {
e60a349c641bb2f4723e4a395a25f55531682d2bTimo Sirainen } catch (Exception e) {
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen String pageTitle="Cross Reference: " + path;
55a7410569737197afb302b07b488973324b0cc5Timo Sirainen%><%@ include file="httpheader.jspf" %>
<script type="text/javascript">/* <![CDATA[ */
var spans = document.getElementsByTagName("span");
for (var i = 0; i < spans.length; i++) {
if (span.className == 'blame') {
span.className = 'blame-hidden';
} else if (span.className == 'blame-hidden') {
span.className = 'blame';
<div id="header"><%@ include file="pageheader.jspf" %>
<div id="Masthead"><tt><a href="<%=context%>/xref/">xref</a>: <%=org.opensolaris.opengrok.web.Util.breadcrumbPath(context + "/xref", path)%></tt></div>
if (noHistory || servlet.startsWith("/hi")) {
String rev = request.getParameter("r");
} else if (rev.length() > 0) {
<a href="#" onClick="javascript:toggle_annotations(); return false;" title="Show or hide line annotation(commit revisions,authors)." >Annotate</a>
if (rev.length() > 0) {
<script type="text/javascript">
var toggle_js = document.getElementById('toggle-annotate-by-javascript');
var toggle_ss = document.getElementById('toggle-annotate');
toggle_js.style.display = 'inline';
toggle_ss.style.display = 'none';
if ( servlet.startsWith("/xr") ) {
%> | <a href="javascript:lntoggle();" title="Show or hide line numbers (might be slower if file has more than 10 000 lines).">Line #</a><%
String rev = request.getParameter("r");
if (rev == null || rev.equals("")) {
Project proj = Project.getProject(resourceFile);
if (proj != null || !environment.hasProjects()) {
%><input type="hidden" name="project" value="<%=proj.getDescription()%>"/><%
if(path.length() > 0) {