list.jsp revision 1474
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoCDDL HEADER START
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoThe contents of this file are subject to the terms of the
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoCommon Development and Distribution License (the "License").
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoYou may not use this file except in compliance with the License.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoSee LICENSE.txt included in this distribution for the specific
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanolanguage governing permissions and limitations under the License.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoWhen distributing Covered Code, include this CDDL HEADER in each
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanofile and include the License file at LICENSE.txt.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoIf applicable, add the following below this CDDL HEADER, with the
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanofields enclosed by brackets "[]" replaced with your own identifying
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoinformation: Portions Copyright [yyyy] [name of copyright owner]
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoCDDL HEADER END
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoCopyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoPortions Copyright 2011, 2012 Jens Elkner.
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano--%><%@page import="java.util.Collections"%>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano<%@page import="java.util.Arrays"%>
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand<%@page import="java.util.HashMap"%>
10fba81b9d0221b8e47aa1e0b43236413b7d28dfMichel Normand<%@page session="false" errorPage="error.jsp" import="
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.analysis.FileAnalyzer.Genre,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcanoorg.opensolaris.opengrok.analysis.FileAnalyzerFactory,
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goaterorg.opensolaris.opengrok.index.IgnoredNames,
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goaterorg.opensolaris.opengrok.index.IndexDatabase,
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano // need to set it here since requesting parameters
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano cfg = PageConfig.get(request);
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand Annotation annotation = cfg.getAnnotation();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand if (annotation != null) {
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand float r = annotation.getWidestRevision() * 1.15f;
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand float a = annotation.getWidestAuthor() * 1.15f;
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand cfg.addHeaderData("<style type=\"text/css\">"
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand + ".r { width: " + (r == 0 ? 6 : r) + "ex; } "
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand + ".a { width: " + (a == 0 ? 6 : a) + "ex; } "
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand + "</style>");
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%><%@include
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand/* ---------------------- list.jsp start --------------------- */
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand cfg = PageConfig.get(request);
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand File resourceFile = cfg.getResourceFile();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand String path = cfg.getPath();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand String basename = resourceFile.getName();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand String rawPath = request.getContextPath() + Prefix.RAW_P + path;
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand Reader r = null;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano // directory listing
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano boolean virtual =
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano basename.isEmpty() || request.getParameter("all") != null;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano Project activeProject = Project.getProject(path);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano String cookieValue = cfg.getRequestedProjectsAsString();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (activeProject != null) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano Set<String> projects = cfg.getRequestedProjects();
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand if (!projects.contains(activeProject.getDescription())) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano // update cookie
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano cookieValue = cookieValue.length() == 0
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano : activeProject.getDescription() + '/' + cookieValue;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano Cookie cookie = new Cookie("OpenGrokProject", cookieValue);
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand // TODO hmmm, projects.jspf doesn't set a path
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand cookie.setPath(request.getContextPath() + '/');
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano LinkedHashMap<String,String> path2rev =
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater virtual ? new LinkedHashMap<String,String>() : null;
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater Map<String, Date> modTimes = HistoryGuru.getInstance()
94b81f611fde1efdda844171d7b0d1f2d8f86ce6Michel Normand .getLastModifiedTimes(new File(cfg.getSourceRootPath() + path), path2rev);
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater List<String> files = virtual
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater ? new ArrayList<String>(modTimes.keySet())
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater if (virtual) {
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater // to be consistent with resource file listing
201172806c477ecb36bc00fad92b85e067712c38Cedric Le Goater Collections.sort(files, String.CASE_INSENSITIVE_ORDER);
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano ArrayList<String> readMes = new ArrayList<String>();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano int offset = -1;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano EftarFileReader.FNode parentFNode = null;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano EftarFileReader desc = cfg.getEftarReader();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (desc != null) {
10fba81b9d0221b8e47aa1e0b43236413b7d28dfMichel Normand parentFNode = desc.getNode(path);
10fba81b9d0221b8e47aa1e0b43236413b7d28dfMichel Normand if (parentFNode != null) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%><table id="dirlist">
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <th>Name</th>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <th>Date</th>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <th><%= virtual ? "Revision" : "Size" %></th><%
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (offset > 0) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano%> <th>Description</th><%
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano IgnoredNames ignoredNames = cfg.getIgnoredNames();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano Format dateFormatter =
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano new SimpleDateFormat(cfg.getConfig().getDirlistDatePattern());
99e4008cad9e959b683c6f48411fcf15a92be3b5Michel Normand boolean useToday = cfg.getConfig().isDirlistUseToday();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano // upper directory
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (path.length() != 0) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano long lastm = 0;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano for (Date d : modTimes.values()) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano if (l > lastm) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano } else if (!virtual) {
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano lastm = resourceFile.getParentFile().lastModified();
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano lastm = now;
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano String css = now - lastm < 86400000 ? " class='x'" : "";
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <td><p class="u"/></td>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <td><b><a href="..">..</a></b></td>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <td<%= css%>><%= useToday && now - lastm < 86400000
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano ? "Today" : dateFormatter.format(lastm) %></td>
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano <td><%= virtual
d823d5b966f49d975a09a8512d084389d6d7ffc7dlezcano ? path2rev.size() + " entries"
: resourceFile.getParentFile().length() + ""
if (ignoredNames.match(file)) {
isDir = file.endsWith("/");
lastm = modTimes.get(file).getTime();
size = path2rev.get(file);
link = Util.uriEncodePath(file);
readMes.add(file);
isDir = child.isDirectory();
Date lmd = modTimes.get(isDir ? file : file + '/');
link = Util.uriEncodePath(file);
? "Today" : dateFormatter.format(lastm) %></td>
String briefDesc = desc.getChildTag(parentFNode, file); %>
<td><%= briefDesc == null ? "" : Util.htmlize(briefDesc) %></td><%
if (readMes.size() != 0) {
File[] xrefs = cfg.findDataFiles(readMes);
for (int i=0; i < xrefs.length; i++) {
readme = new File(resourceFile, readMes.get(i));
g = AnalyzerGuru.getGenre(in);
IOUtils.close(in);
if (g == Genre.IMAGE) {
<h3><%= readMes.get(i) %></h3><%
out.write("<pre>");
XrefInputStream.dump(xrefs[i], out, false);
out.write("</pre>");
<img src="<%= Util.uriEncodePath(rawPath + '/' + image) %>"/><%
} else if (rev.length() != 0) {
String parent = resourceFile.getParent();
if (basename.isEmpty()) {
int idx = path.lastIndexOf('/');
basename = path.substring(idx+1);
FileAnalyzerFactory a = AnalyzerGuru.find(basename);
Genre g = AnalyzerGuru.getGenre(a);
in = HistoryGuru.getInstance()
.getRevision(parent, basename, rev.substring(2));
error = e.getMessage();
// this little hack to emp. detect deleted/moved files
in.mark(2);
int b = in.read();
in.reset();
<p><%= basename %> for revision <%= rev.substring(2) %> is empty. It was
a = AnalyzerGuru.find(in);
g = AnalyzerGuru.getGenre(a);
<p>Binary file [Click <a href="<%= Util.uriEncodePath(rawPath) %>?<%= rev
<span class="pagetitle"><%= Util.htmlize(basename) %> revision <%=
rev.substring(2) %></span><%
if (g == Genre.PLAIN) {
Annotation annotation = cfg.getAnnotation();
AnalyzerGuru.writeXref(a, r, xout , defs,
annotation, Project.getProject(resourceFile));
} else if (g == Genre.IMAGE) {
<img src="<%= Util.uriEncodePath(rawPath) %>?<%= rev %>"/><%
} else if (g == Genre.HTML) {
Util.dump(out, r);
%> Click <a href="<%= Util.uriEncodePath(rawPath) %>?<%=
rev %>">download <%= Util.htmlize(basename) %></a><%
error = e.getMessage();
try { r.close(); in = null;}
IOUtils.close(in);
IOUtils.close(xout);
} else if (g == Genre.IMAGE) {
<img src="<%= Util.uriEncodePath(rawPath) %>?<%= rev %>"/>
<p>Binary file [Click <a href="<%= Util.uriEncodePath(rawPath) %>?<%= rev
if (!cfg.annotate()) {
xrefFile = cfg.findDataFile();
XrefInputStream.dump(xrefFile, out, true);
FileAnalyzerFactory a = AnalyzerGuru.find(basename);
Genre g = AnalyzerGuru.getGenre(a);
a = AnalyzerGuru.find(bin);
g = AnalyzerGuru.getGenre(a);
if (g == Genre.IMAGE) {
<img src="<%= Util.uriEncodePath(rawPath) %>"/>
} else if (g == Genre.HTML) {
Util.dump(out, r);
} else if (g == Genre.PLAIN) {
Definitions defs = IndexDatabase.getDefinitions(resourceFile);
Annotation annotation = cfg.getAnnotation();
AnalyzerGuru.writeXref(a, r, xout, defs, annotation,
Project.getProject(resourceFile));
Click <a href="<%= Util.uriEncodePath(rawPath) %>">download <%=
Util.htmlize(basename) %></a><%
try { r.close(); bin = null; }
IOUtils.close(bin);
IOUtils.close(xout);
/* ---------------------- list.jsp end --------------------- */
include file="foot.jspf"