rss.jsp revision 0
1N/A<%--
1N/ACDDL HEADER START
1N/A
1N/AThe contents of this file are subject to the terms of the
1N/ACommon Development and Distribution License (the "License").
1N/AYou may not use this file except in compliance with the License.
1N/A
1N/ASee LICENSE.txt included in this distribution for the specific
1N/Alanguage governing permissions and limitations under the License.
1N/A
1N/AWhen distributing Covered Code, include this CDDL HEADER in each
1N/Afile and include the License file at LICENSE.txt.
1N/AIf applicable, add the following below this CDDL HEADER, with the
1N/Afields enclosed by brackets "[]" replaced with your own identifying
1N/Ainformation: Portions Copyright [yyyy] [name of copyright owner]
1N/A
1N/ACDDL HEADER END
1N/A
1N/ACopyright 2005 Sun Microsystems, Inc. All rights reserved.
1N/AUse is subject to license terms.
1N/A
1N/Aident "@(#)rss.jsp 1.2 05/12/02 SMI"
1N/A
1N/A--%><%@ page import = "javax.servlet.*,
1N/Ajava.lang.*,
1N/Ajavax.servlet.http.*,
1N/Ajava.util.*,
1N/Ajava.io.*,
1N/Aorg.opensolaris.opengrok.analysis.*,
1N/Aorg.opensolaris.opengrok.web.*,
1N/Aorg.opensolaris.opengrok.history.*,
1N/Aorg.opensolaris.opengrok.index.IgnoredNames,
1N/Aorg.apache.lucene.analysis.*,
1N/Aorg.apache.lucene.document.*,
1N/Aorg.apache.lucene.index.*,
1N/Aorg.apache.lucene.search.*,
1N/Aorg.apache.lucene.queryParser.*,
1N/Ajava.text.*"
1N/A%><%@ page session="false" %><%@ page errorPage="error.jsp"%><%
1N/AString context = request.getContextPath();
1N/AString servlet = request.getServletPath();
1N/AString reqURI = request.getRequestURI();
1N/AString path = request.getPathInfo();
1N/Aif(path == null) path = "";
1N/AString rawSource = getServletContext().getInitParameter("SRC_ROOT");
1N/AString resourcePath = rawSource + path;
1N/AFile resourceFile = new File(resourcePath);
1N/AresourcePath = resourceFile.getAbsolutePath();
1N/Aboolean valid;
1N/AString basename = resourceFile.getName();
1N/Aif("/".equals(path)) {
1N/A basename = "Cross Reference";
1N/A}
1N/Aboolean isDir = false;
1N/AString parent = null;
1N/AString parentBasename = resourceFile.getParentFile().getName();
1N/Aif (resourcePath.length() < rawSource.length()
1N/A|| !resourcePath.startsWith(rawSource)
1N/A|| !resourceFile.canRead()
1N/A|| IgnoredNames.ignore.contains(basename) || IgnoredNames.ignore.contains(parentBasename)) {
1N/A valid = false;
1N/A response.sendError(404);
1N/A} else {
1N/A valid = true;
1N/A path = resourcePath.substring(rawSource.length());
1N/A if (File.separatorChar == '\\') {
1N/A path = path.replace('\\','/');
1N/A }
1N/A isDir = resourceFile.isDirectory();
1N/A if (isDir && !reqURI.endsWith("/")) {
1N/A response.sendRedirect(context + servlet + path +"/");
1N/A } else {
1N/A String dtag = "";
1N/A
1N/A try {
1N/A EftarFileReader ef = new EftarFileReader(getServletContext().getInitParameter("DATA_ROOT") + "/index/dtags.eftar");
1N/A dtag = ef.get(path);
1N/A ef.close();
1N/A } catch (Exception e) {
1N/A dtag = "";
1N/A }
1N/A int lastSlash = path.lastIndexOf('/');
1N/A parent = (lastSlash != -1) ? path.substring(0, lastSlash) : "";
1N/A int pLastSlash = parent.lastIndexOf('/');
1N/A parentBasename = pLastSlash != -1 ? parent.substring(pLastSlash+1) : parent;
1N/A response.setContentType("text/xml");
1N/A Date start = new Date();
1N/A%><?xml version="1.0"?>
1N/A<?xml-stylesheet type="text/xsl" href="<%=context%>/rss.xsl.xml"?>
1N/A<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
1N/A<channel>
1N/A <title>Changes in <%=basename%></title>
1N/A <link><%=request.getRequestURL()%></link>
1N/A <description><%=dtag%></description>
1N/A <language>en</language>
1N/A <copyright>Copyright 2005</copyright>
1N/A <generator>Java</generator>
1N/A <%
1N/A Format df = new SimpleDateFormat("dd-MMM-yyyy");
1N/A HistoryReader hr = null;
1N/A if(isDir) {
1N/A String[] apaths = request.getParameterValues("also");
1N/A String apath = path;
1N/A if (apaths!= null && apaths.length>0) {
1N/A StringBuilder paths = new StringBuilder(path);
1N/A for(int i=0; i< apaths.length; i++) {
1N/A paths.append(' ');
1N/A paths.append(apaths[i]);
}
apath = paths.toString();
}
hr = new DirectoryHistoryReader(getServletContext().getInitParameter("DATA_ROOT") + "/index", apath, getServletContext().getInitParameter("SRC_ROOT"));
} else {
hr = HistoryGuru.getInstance().getHistoryReader(rawSource + parent, basename);
}
if (hr != null) {
int i = 20;
while (hr.next() && i-- > 0) {
String rev = hr.getRevision();
if(hr.isActive()) {
%>
<item>
<title><%=Util.Htmlize(hr.getComment())%></title>
<description><%
if(isDir) {
ArrayList files = hr.getFiles();
if(files != null) {
Iterator ifiles = files.iterator();
while(ifiles.hasNext()) {
String ifile = (String)ifiles.next();
%><%=ifile%>
<%
}
}
} else {
%><%=path%> - <%=hr.getRevision()%><%
}
%></description>
<pubDate><%=hr.getDate()%></pubDate>
<dc:creator><%=hr.getAuthor()%></dc:creator>
</item>
<%
}
}
hr.close();
}
%></channel></rss>
<%
}
}
%>