list.jsp revision eef29f7a9e60072b7dc0e4cf5c8bb0ad6fa9ba89
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenCDDL HEADER START
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 SirainenSee LICENSE.txt included in this distribution for the specific
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenlanguage governing permissions and limitations under the License.
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
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfields enclosed by brackets "[]" replaced with your own identifying
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Siraineninformation: Portions Copyright [yyyy] [name of copyright owner]
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenCDDL HEADER END
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenCopyright 2009 Sun Microsystems, Inc. All rights reserved.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenUse is subject to license terms.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen--%><%@ page import = "javax.servlet.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.configuration.Project,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.analysis.FileAnalyzer.Genre,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen%><%@include file="mast.jsp"%><script type="text/javascript">/* <![CDATA[ */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfunction lntoggle() {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen for (var i = 0; i < a.length; i++) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen var el = a[i];
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (el.className == 'l' || el.className == 'hl') {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen else if (el.className == 'l-hide' || el.className == 'hl-hide') {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen el.className=el.className.substr(0,el.className.indexOf('-'));
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* ]]> */</script><%
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenString rev = null;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenif(!isDir && ef != null) {
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen } catch (IOException e) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen // verify that the current path is part of the selected project
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen Project activeProject = Project.getProject(resourceFile);
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if (activeProject != null) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen List<String> project = new ArrayList<String>();
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen Cookie[] cookies = request.getCookies();
3f190f4cbb9233a3a6830956cb5c7ae56a577b79Timo Sirainen if (cookies != null) {
3f190f4cbb9233a3a6830956cb5c7ae56a577b79Timo Sirainen for (Cookie cookie : cookies) {
f3f8d30207fd7d6c430361039dbfa88e6ffce411Timo Sirainen if (cookie.getName().equals("OpenGrok/project")) {
f3f8d30207fd7d6c430361039dbfa88e6ffce411Timo Sirainen for (String proj : cookie.getValue().split(",")) {
f3f8d30207fd7d6c430361039dbfa88e6ffce411Timo Sirainen if (proj != "") {
f3f8d30207fd7d6c430361039dbfa88e6ffce411Timo Sirainen if (Project.getByDescription(proj) != null) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen boolean set = false;
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if (project != null) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen boolean found = false;
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen for (Iterator it = project.iterator(); it.hasNext();) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if (activeProject.getDescription().equalsIgnoreCase( (String)it.next() ) ) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen found = true;
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if (!found) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen// set this in case there is no project selected or current cookie doesn't contain current project from the link, so the rest of search works 100% :)
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen StringBuffer sproject=new StringBuffer(activeProject.getDescription()+",");
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if (project!=null) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen //only save found projects into cookies
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen for (Iterator it = project.iterator(); it.hasNext();) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen // update the cookie
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen Cookie cookie = new Cookie("OpenGrok/project", sproject.toString());
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen cookie.setPath(context + "/");
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen // If requesting a Directory listing -------------
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen DirectoryListing dl = new DirectoryListing(ef);
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen String[] files = resourceFile.list();
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen if (files != null) {
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen List<String> readMes = dl.listTo(resourceFile, out, path, files);
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen if(readMes != null && readMes.size() > 0) {
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen File xdir = new File(environment.getDataRootPath() + "/xref" + path);
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen char[] buf = new char[8192];
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen for (String readme : readMes) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen File readmeFile = new File(xdir, readme + ".gz");
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen Reader br = null;
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen if (environment.isCompressXref() && readmeFile.exists()) {
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen br = new InputStreamReader(new GZIPInputStream(new FileInputStream(readmeFile)));
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen readmeFile = new File(xdir, readme);
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen br = new FileReader(readmeFile);
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen if (br != null) {
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen %><h3><%=readme%></h3><div id="src"><pre><%
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen while((len = br.read(buf)) > 0) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen %></pre></div><%
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen } catch(IOException e) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen OpenGrokLogger.getLogger().log(Level.WARNING, "An error occured while reading/writing readme:", e);
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen if (br != null) {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen } catch (IOException e) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen OpenGrokLogger.getLogger().log(Level.WARNING, "An error occured while closing file:", e);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen } else if ((rev = request.getParameter("r")) != null && !rev.equals("")) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen // Else if requesting a previous revision -------------
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if (noHistory) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen response.sendError(404, "Revision not found");
659fe5d24825b160cae512538088020d97a60239Timo Sirainen FileAnalyzerFactory a = AnalyzerGuru.find(basename);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if (g == Genre.PLAIN|| g == Genre.HTML || g == null) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen InputStream in = null;
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen in = HistoryGuru.getInstance().getRevision(resourceFile.getParent(), basename, rev);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen } catch (Exception e) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen response.sendError(404, "Revision not found");
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if (in != null) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if (g == null) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if (g == Genre.DATA || g == Genre.XREFABLE || g == null) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen %><div id="src">Binary file [Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">here</a> to download] </div><%
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen %><div id="src"><span class="pagetitle"><%=basename%> revision <%=rev%> </span><pre><%
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen Annotation annotation = annotate ? HistoryGuru.getInstance().annotate(resourceFile, rev) : null;
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen //annotation.writeTooltipMap(out); //not needed yet
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen AnalyzerGuru.writeXref(a, in, out, annotation, Project.getProject(resourceFile));
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen } else if (g == Genre.IMAGE) {
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen %><img src="<%=context%>/raw<%=path%>?r=<%=rev%>"/><%
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen } else if (g == Genre.HTML) {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen char[] buf = new char[8192];
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen Reader br = new InputStreamReader(in);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen while((len = br.read(buf)) > 0) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen %> Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">download <%=basename%></a><%
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen } catch (IOException e) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen %> <h3 class="error">IO Error</h3> <p> <%=e.getMessage() %> </p> <%
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen %></pre></div><%
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen %> <h3 class="error">Error reading file</h3> <%
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen } else if(g == Genre.IMAGE) {
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen %><div id="src"><img src="<%=context%>/raw<%=path%>?r=<%=rev%>"/></div><%
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen %><div id="src"> Binary file [Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">here</a> to download] </div><%
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen // requesting cross referenced file -------------
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen File xrefSource = new File(environment.getDataRootFile(), "/xref");
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen File xrefFile = new File(xrefSource, path + ".gz");
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen Reader fileReader = null;
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen fileReader = new InputStreamReader(new GZIPInputStream(new FileInputStream(xrefFile)));
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen xrefFile = new File(xrefSource, path);
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen fileReader = new FileReader(xrefFile);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen if (fileReader != null && !annotate) {
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen char[] buf = new char[8192];
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen BufferedReader br = new BufferedReader(fileReader);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen %><div id="src"><pre><%
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen while((len = br.read(buf)) > 0) {
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen %></pre></div><%
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen BufferedInputStream bin = new BufferedInputStream(new FileInputStream(resourceFile));
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen FileAnalyzerFactory a = AnalyzerGuru.find(basename);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen if(g == null) {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen %><div id="src"><img src="<%=context%>/raw<%=path%>"/></div><%
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen } else if( g == Genre.HTML) {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen char[] buf = new char[8192];
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen Reader br = new InputStreamReader(bin);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen while((len = br.read(buf)) > 0) {
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen } else if(g == Genre.PLAIN) {
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen %><div id="src"><pre><%
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen Annotation annotation = annotate ? HistoryGuru.getInstance().annotate(resourceFile, rev) : null;
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen AnalyzerGuru.writeXref(a, bin, out, annotation, Project.getProject(resourceFile));
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen %></pre></div><%
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen %> Click <a href="<%=context%>/raw<%=path%>">download <%=basename%></a><%
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen %><%@include file="foot.jspf"%><%
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenif (ef != null) {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen } catch (IOException e) {