list.jsp revision eef29f7a9e60072b7dc0e4cf5c8bb0ad6fa9ba89
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo 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
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfields enclosed by brackets "[]" replaced with your own identifying
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Siraineninformation: Portions Copyright [yyyy] [name of copyright owner]
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenCDDL HEADER END
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenCopyright 2009 Sun Microsystems, Inc. All rights reserved.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenUse is subject to license terms.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen--%><%@ page import = "javax.servlet.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenjava.lang.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenjavax.servlet.http.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenjava.util.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenjava.io.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenjava.util.zip.GZIPInputStream,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenjava.util.logging.Level,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.OpenGrokLogger,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.analysis.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.configuration.Project,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.index.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.analysis.FileAnalyzer.Genre,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.web.*,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenorg.opensolaris.opengrok.history.*
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen%><%@include file="mast.jsp"%><script type="text/javascript">/* <![CDATA[ */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfunction lntoggle() {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen var a = document.getElementsByTagName("a");
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 el.className=el.className+'-hide';
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen el.setAttribute("tmp", el.innerHTML);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen el.innerHTML='';
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen else if (el.className == 'l-hide' || el.className == 'hl-hide') {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen el.innerHTML=el.getAttribute("tmp");
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen el.className=el.className.substr(0,el.className.indexOf('-'));
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen}
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* ]]> */</script><%
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenString rev = null;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenif(!isDir && ef != null) {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen try {
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen ef.close();
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen } catch (IOException e) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen ef = null;
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen}
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenif (valid) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if (isDir) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen // verify that the current path is part of the selected project
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen Project activeProject = Project.getProject(resourceFile);
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if (activeProject != null) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen List<String> project = new ArrayList<String>();
d17a90f5ae38edc8c0e6bf42c2162c9c18edb891Timo Sirainen
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) {
f3f8d30207fd7d6c430361039dbfa88e6ffce411Timo Sirainen project.add(proj);
f3f8d30207fd7d6c430361039dbfa88e6ffce411Timo Sirainen }
f3f8d30207fd7d6c430361039dbfa88e6ffce411Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
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
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if (activeProject.getDescription().equalsIgnoreCase( (String)it.next() ) ) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen found = true;
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen break;
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if (!found) {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen set = true;
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen } else {
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen set = true;
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
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 if (set) {
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 sproject.append((String)it.next()+",");
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen // update the cookie
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen Cookie cookie = new Cookie("OpenGrok/project", sproject.toString());
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen cookie.setPath(context + "/");
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen response.addCookie(cookie);
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen }
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
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 if (xdir.exists() && xdir.isDirectory()) {
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;
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen try {
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen if (environment.isCompressXref() && readmeFile.exists()) {
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen br = new InputStreamReader(new GZIPInputStream(new FileInputStream(readmeFile)));
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen } else {
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen readmeFile = new File(xdir, readme);
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen if (readmeFile.exists()) {
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen br = new FileReader(readmeFile);
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen }
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen }
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen if (br != null) {
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen int len = 0;
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen %><h3><%=readme%></h3><div id="src"><pre><%
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen while((len = br.read(buf)) > 0) {
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen out.write(buf, 0, len);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen %></pre></div><%
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen } catch(IOException e) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen OpenGrokLogger.getLogger().log(Level.WARNING, "An error occured while reading/writing readme:", e);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen } finally {
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen if (br != null) {
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen try {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen br.close();
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen } catch (IOException e) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen OpenGrokLogger.getLogger().log(Level.WARNING, "An error occured while closing file:", e);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen }
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen }
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen }
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen }
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen }
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen }
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen }
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");
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen } else {
659fe5d24825b160cae512538088020d97a60239Timo Sirainen FileAnalyzerFactory a = AnalyzerGuru.find(basename);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen Genre g = AnalyzerGuru.getGenre(a);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if (g == Genre.PLAIN|| g == Genre.HTML || g == null) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen InputStream in = null;
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen try {
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 return;
659fe5d24825b160cae512538088020d97a60239Timo Sirainen }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if (in != null) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen try {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if (g == null) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen a = AnalyzerGuru.find(in);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen g = AnalyzerGuru.getGenre(a);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen }
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><%
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen } else {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen %><div id="src"><span class="pagetitle"><%=basename%> revision <%=rev%> </span><pre><%
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if (g == Genre.PLAIN) {
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);
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen int len = 0;
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen while((len = br.read(buf)) > 0) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen out.write(buf, 0, len);
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen }
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen } else {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen %> Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">download <%=basename%></a><%
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen }
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen } catch (IOException e) {
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen %> <h3 class="error">IO Error</h3> <p> <%=e.getMessage() %> </p> <%
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen }
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen %></pre></div><%
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen in.close();
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen } else {
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen %> <h3 class="error">Error reading file</h3> <%
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen }
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen } else if(g == Genre.IMAGE) {
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen %><div id="src"><img src="<%=context%>/raw<%=path%>?r=<%=rev%>"/></div><%
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen } else {
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen %><div id="src"> Binary file [Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">here</a> to download] </div><%
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen }
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen } else {
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;
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen if (environment.isCompressXref() ) {
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen if (xrefFile.exists()) {
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen fileReader = new InputStreamReader(new GZIPInputStream(new FileInputStream(xrefFile)));
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen }
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen } else {
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen xrefFile = new File(xrefSource, path);
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen if (xrefFile.exists()) {
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen fileReader = new FileReader(xrefFile);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen }
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen }
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen if (fileReader != null && !annotate) {
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen char[] buf = new char[8192];
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen BufferedReader br = new BufferedReader(fileReader);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen int len = 0;
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen %><div id="src"><pre><%
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen while((len = br.read(buf)) > 0) {
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen out.write(buf, 0, len);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen }
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen %></pre></div><%
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen br.close();
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen } else {
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen BufferedInputStream bin = new BufferedInputStream(new FileInputStream(resourceFile));
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen FileAnalyzerFactory a = AnalyzerGuru.find(basename);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen Genre g = AnalyzerGuru.getGenre(a);
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen if(g == null) {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen a = AnalyzerGuru.find(bin);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen g = AnalyzerGuru.getGenre(a);
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen }
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if (g == Genre.IMAGE) {
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);
3f190f4cbb9233a3a6830956cb5c7ae56a577b79Timo Sirainen int len = 0;
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen while((len = br.read(buf)) > 0) {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen out.write(buf, 0, len);
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen }
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><%
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen } else {
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen %> Click <a href="<%=context%>/raw<%=path%>">download <%=basename%></a><%
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen }
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen }
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen }
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen %><%@include file="foot.jspf"%><%
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen}
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenif (ef != null) {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen try {
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen ef.close();
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen } catch (IOException e) {
36e2fa21c22452470c1509cc63de20f7415c7b5eTimo Sirainen }
36e2fa21c22452470c1509cc63de20f7415c7b5eTimo Sirainen}
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen%>
36e2fa21c22452470c1509cc63de20f7415c7b5eTimo Sirainen