rss.jsp revision 85f619afce0f5860dd3265e1ac5c48efcb353921
45312f52ff3a3d4c137447be4c7556500c2f8bf2Timo Sirainen<%--
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenCDDL HEADER START
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenThe contents of this file are subject to the terms of the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenCommon Development and Distribution License (the "License").
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenYou may not use this file except in compliance with the License.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenSee LICENSE.txt included in this distribution for the specific
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenlanguage governing permissions and limitations under the License.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenWhen distributing Covered Code, include this CDDL HEADER in each
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfile and include the License file at LICENSE.txt.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenIf applicable, add the following below this CDDL HEADER, with the
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenfields enclosed by brackets "[]" replaced with your own identifying
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Siraineninformation: Portions Copyright [yyyy] [name of copyright owner]
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo SirainenCDDL HEADER END
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo SirainenCopyright 2005 Sun Microsystems, Inc. All rights reserved.
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo SirainenUse is subject to license terms.
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenident "@(#)rss.jsp 1.2 05/12/02 SMI"
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen--%><%@ page import = "javax.servlet.*,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenjava.lang.*,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenjavax.servlet.http.*,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenjava.util.*,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenjava.io.*,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenjava.net.URLDecoder,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenorg.opensolaris.opengrok.analysis.*,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenorg.opensolaris.opengrok.web.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.history.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.index.IgnoredNames,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.configuration.*,
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenorg.apache.lucene.analysis.*,
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainenorg.apache.lucene.document.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.apache.lucene.index.*,
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainenorg.apache.lucene.search.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.apache.lucene.queryParser.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenjava.text.*"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen%><%@ page session="false" %><%@ page errorPage="error.jsp"%><%
84e1634acc701d14e358e27f1beff5ad74f5004aTimo SirainenString context = request.getContextPath();
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenString servlet = request.getServletPath();
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo SirainenString reqURI = request.getRequestURI();
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenString path = request.getPathInfo();
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenif(path == null) path = "";
022412398e56a8f31ef111cfd7271498d64af9a9Timo Sirainenelse {
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen try {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen path = URLDecoder.decode(path, "ISO-8859-1");
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen } catch (UnsupportedEncodingException e) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen}
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo SirainenRuntimeEnvironment env = RuntimeEnvironment.getInstance();
7a6b45405fb1544ac476e6eb1402a70cc1ddcdcfTimo Sirainenenv.setUrlPrefix(context + "/s?");
e05ea8311ae16687295048e88ca205dfe29fbcbfTimo Sirainenenv.register();
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo SirainenString rawSource = env.getSourceRootPath();
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo SirainenString resourcePath = rawSource + path;
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo SirainenFile resourceFile = new File(resourcePath);
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo SirainenresourcePath = resourceFile.getAbsolutePath();
f7d43647acc6dc80064c8c4cacf5bf86f754c530Timo Sirainenboolean valid;
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo SirainenString basename = resourceFile.getName();
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainenif("/".equals(path)) {
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen basename = "Cross Reference";
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainen}
98c1cf256927e254f0c092acd2ddcd7ea50bd009Timo Sirainenboolean isDir = false;
a2637488c8d514ec1ac3914811deee814f9761b3Timo SirainenString parent = null;
a2637488c8d514ec1ac3914811deee814f9761b3Timo SirainenString parentBasename = resourceFile.getParentFile().getName();
a2637488c8d514ec1ac3914811deee814f9761b3Timo SirainenIgnoredNames ignoredNames = env.getIgnoredNames();
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainenif (resourcePath.length() < rawSource.length()
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen|| !resourcePath.startsWith(rawSource)
b6d817f0effeff645aadc01fd468a7d4084ba1f2Timo Sirainen|| !resourceFile.canRead()
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen|| ignoredNames.ignore(basename) || ignoredNames.ignore(parentBasename)) {
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen valid = false;
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen response.sendError(404);
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen return;
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen} else {
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen valid = true;
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen path = resourcePath.substring(rawSource.length());
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen if (File.separatorChar == '\\') {
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen path = path.replace('\\','/');
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen }
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen isDir = resourceFile.isDirectory();
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen if (isDir && !reqURI.endsWith("/")) {
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen response.sendRedirect(context + servlet + path +"/");
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen } else {
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen String dtag = "";
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen try {
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen EftarFileReader ef = new EftarFileReader(env.getDataRootPath() + "/index/dtags.eftar");
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen dtag = ef.get(path);
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen ef.close();
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen } catch (Exception e) {
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen dtag = "";
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen }
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen int lastSlash = path.lastIndexOf('/');
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen parent = (lastSlash != -1) ? path.substring(0, lastSlash) : "";
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen int pLastSlash = parent.lastIndexOf('/');
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen parentBasename = pLastSlash != -1 ? parent.substring(pLastSlash+1) : parent;
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen response.setContentType("text/xml");
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen Date start = new Date();
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen%><?xml version="1.0"?>
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen<?xml-stylesheet type="text/xsl" href="<%=context%>/rss.xsl.xml"?>
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen<channel>
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen <title>Changes in <%=basename%></title>
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen <link><%=request.getRequestURL()%></link>
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen <description><%=dtag%></description>
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen <language>en</language>
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen <copyright>Copyright 2005</copyright>
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen <generator>Java</generator>
6288d3611eda14a017dae9927b73f46afb646c96Timo Sirainen <%
a2637488c8d514ec1ac3914811deee814f9761b3Timo Sirainen Format df = new SimpleDateFormat("dd-MMM-yyyy");
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen HistoryReader hr = null;
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen if(isDir) {
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen String[] apaths = request.getParameterValues("also");
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen String apath = path;
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen if (apaths!= null && apaths.length>0) {
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen StringBuilder paths = new StringBuilder(path);
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen for(int i=0; i< apaths.length; i++) {
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen paths.append(' ');
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen paths.append(apaths[i]);
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen }
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen apath = paths.toString();
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen }
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen hr = new DirectoryHistoryReader(apath);
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen } else {
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen File f = new File(rawSource + parent, basename);
299183fbb6ec5d0828a0880da372540421ac4665Timo Sirainen hr = HistoryGuru.getInstance().getHistoryReader(f);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen }
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if (hr != null) {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen int i = 20;
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen while (hr.next() && i-- > 0) {
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen String rev = hr.getRevision();
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if(hr.isActive()) {
178511b57faa7c3f8203dd8b7e4059d00cbfc23aTimo Sirainen%>
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen<item>
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen <title><%=Util.Htmlize(hr.getComment())%></title>
2e937ed8585299b2e879a28314902a5f644813d2Timo Sirainen <description><%
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if(isDir) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen List<String> files = hr.getFiles();
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if(files != null) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen for (String ifile : files) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen %><%=ifile%>
4d25408732be27e91f0430f71e87242760c2517cTimo Sirainen<%
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen } else {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen %><%=path%> - <%=hr.getRevision()%><%
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen }
4d25408732be27e91f0430f71e87242760c2517cTimo Sirainen %></description>
c3412ddeb9abc13f99d3caf50faf76cd99f7e9d2Timo Sirainen <pubDate><%=hr.getDate()%></pubDate>
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen <dc:creator><%=hr.getAuthor()%></dc:creator>
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen</item>
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen<%
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen }
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen hr.close();
1e76a5b92f9d82d557f81f080f3dfad1c9d8f200Timo Sirainen }
1e76a5b92f9d82d557f81f080f3dfad1c9d8f200Timo Sirainen%></channel></rss>
ced118ac5caf6fe83d34339c2c65c63b2aa768acTimo Sirainen<%
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen }
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen}
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen%>
e8a35266a5ceacdfafeeffd6bddae77931ff97ebTimo Sirainen