rss.jsp revision 17b343cecb69da82215b124f39fed80167a6f2bd
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson<%--
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonCDDL HEADER START
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonThe contents of this file are subject to the terms of the
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonCommon Development and Distribution License (the "License").
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonYou may not use this file except in compliance with the License.
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonSee LICENSE.txt included in this distribution for the specific
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignaclanguage governing permissions and limitations under the License.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonWhen distributing Covered Code, include this CDDL HEADER in each
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonfile and include the License file at LICENSE.txt.
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonIf applicable, add the following below this CDDL HEADER, with the
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonfields enclosed by brackets "[]" replaced with your own identifying
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignacinformation: Portions Copyright [yyyy] [name of copyright owner]
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignacCDDL HEADER END
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonCopyright 2005 Sun Microsystems, Inc. All rights reserved.
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonUse is subject to license terms.
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonident "@(#)rss.jsp 1.2 05/12/02 SMI"
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson
a395dd575518d9e5280fc5d5d5ef47c61b174647ludovicp--%><%@ page import = "javax.servlet.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonjava.lang.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonjavax.servlet.http.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonjava.util.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonjava.io.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonorg.opensolaris.opengrok.analysis.*,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swiftorg.opensolaris.opengrok.web.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonorg.opensolaris.opengrok.history.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonorg.opensolaris.opengrok.index.IgnoredNames,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonorg.opensolaris.opengrok.configuration.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonorg.apache.lucene.analysis.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonorg.apache.lucene.document.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonorg.apache.lucene.index.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonorg.apache.lucene.search.*,
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonorg.apache.lucene.queryParser.*,
8d7126a8f999e88851c7dd851a17c27cb6d2ec3fneil_a_wilsonjava.text.*"
8d7126a8f999e88851c7dd851a17c27cb6d2ec3fneil_a_wilson%><%@ page session="false" %><%@ page errorPage="error.jsp"%><%
8d7126a8f999e88851c7dd851a17c27cb6d2ec3fneil_a_wilsonString context = request.getContextPath();
8d7126a8f999e88851c7dd851a17c27cb6d2ec3fneil_a_wilsonString servlet = request.getServletPath();
8d7126a8f999e88851c7dd851a17c27cb6d2ec3fneil_a_wilsonString reqURI = request.getRequestURI();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonString path = request.getPathInfo();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonif(path == null) path = "";
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonRuntimeEnvironment env = RuntimeEnvironment.getInstance();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonenv.setUrlPrefix(context + Constants.searchR+"?");
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonenv.register();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonString rawSource = env.getSourceRootPath();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonString resourcePath = rawSource + path;
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonFile resourceFile = new File(resourcePath);
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonresourcePath = resourceFile.getAbsolutePath();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonboolean valid;
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonString basename = resourceFile.getName();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonif("/".equals(path)) {
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson basename = "Cross Reference";
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson}
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonboolean isDir = false;
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonString parent = null;
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonString parentBasename = resourceFile.getParentFile().getName();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonIgnoredNames ignoredNames = env.getIgnoredNames();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilsonif (resourcePath.length() < rawSource.length()
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson|| !resourcePath.startsWith(rawSource)
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson|| !resourceFile.canRead()
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift|| ignoredNames.ignore(basename) || ignoredNames.ignore(parentBasename)) {
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson valid = false;
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson response.sendError(404);
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson return;
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson} else {
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson valid = true;
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson path = resourcePath.substring(rawSource.length());
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson if (File.separatorChar == '\\') {
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson path = path.replace('\\','/');
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson }
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson isDir = resourceFile.isDirectory();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson if (isDir && !reqURI.endsWith("/")) {
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson response.sendRedirect(context + servlet + path +"/");
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson } else {
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson String dtag = "";
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson try {
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson EftarFileReader ef = new EftarFileReader(env.getDataRootPath() + "/index/dtags.eftar");
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift dtag = ef.get(path);
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson ef.close();
b4851fc75ef4634840dcbadec085d586d36b434dneil_a_wilson } catch (Exception e) {
dtag = "";
}
int lastSlash = path.lastIndexOf('/');
parent = (lastSlash != -1) ? path.substring(0, lastSlash) : "";
int pLastSlash = parent.lastIndexOf('/');
parentBasename = pLastSlash != -1 ? parent.substring(pLastSlash+1) : parent;
response.setContentType("text/xml");
Date start = new Date();
%><?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="<%=context%>/rss.xsl.xml"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Changes in <%=Util.htmlize(basename)%></title>
<link><%=Util.htmlize(request.getRequestURL())%></link>
<description><%=Util.htmlize(dtag)%></description>
<language>en</language>
<copyright>Copyright 2005</copyright>
<generator>Java</generator>
<%
Format df = new SimpleDateFormat("dd-MMM-yyyy");
History hist = null;
if(isDir) {
String[] apaths = request.getParameterValues("also");
String apath = path;
if (apaths!= null && apaths.length>0) {
StringBuilder paths = new StringBuilder(path);
for(int i=0; i< apaths.length; i++) {
paths.append(' ');
paths.append(apaths[i]);
}
apath = paths.toString();
}
hist = new DirectoryHistoryReader(apath).getHistory();
} else {
File f = new File(rawSource + parent, basename);
hist = HistoryGuru.getInstance().getHistory(f);
}
if (hist != null) {
int i = 20;
for (HistoryEntry entry : hist.getHistoryEntries()) {
if (i-- <= 0) break;
String rev = entry.getRevision();
if (entry.isActive()) {
%>
<item>
<title><%=Util.htmlize(entry.getMessage())%></title>
<description><%
if(isDir) {
Set<String> files = entry.getFiles();
if(files != null) {
for (String ifile : files) {
%><%=Util.htmlize(ifile)%>
<%
}
}
} else {
%><%=Util.htmlize(path)%> - <%=Util.htmlize(entry.getRevision())%><%
}
%></description>
<pubDate><%=Util.htmlize(entry.getDate().toString())%></pubDate>
<dc:creator><%=Util.htmlize(entry.getAuthor())%></dc:creator>
</item>
<%
}
}
}
%></channel></rss>
<%
}
}
%>