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