list.jsp revision 73b36d5a6848ae9189f4f9e35a68947e89b1fe80
50N/A<%--
50N/ACDDL HEADER START
50N/A
50N/AThe contents of this file are subject to the terms of the
50N/ACommon Development and Distribution License (the "License").
50N/AYou may not use this file except in compliance with the License.
50N/A
50N/ASee LICENSE.txt included in this distribution for the specific
50N/Alanguage governing permissions and limitations under the License.
50N/A
50N/AWhen distributing Covered Code, include this CDDL HEADER in each
50N/Afile and include the License file at LICENSE.txt.
50N/AIf applicable, add the following below this CDDL HEADER, with the
50N/Afields enclosed by brackets "[]" replaced with your own identifying
50N/Ainformation: Portions Copyright [yyyy] [name of copyright owner]
50N/A
50N/ACDDL HEADER END
50N/A
50N/ACopyright 2005 Sun Microsystems, Inc. All rights reserved.
50N/AUse is subject to license terms.
50N/A
50N/Aident "%Z%%M% %I% %E% SMI"
50N/A
50N/A--%><%@ page import = "javax.servlet.*,
50N/Ajava.lang.*,
60N/Ajavax.servlet.http.*,
202N/Ajava.util.*,
50N/Ajava.io.*,
50N/Aorg.opensolaris.opengrok.analysis.*,
72N/Aorg.opensolaris.opengrok.index.*,
119N/Aorg.opensolaris.opengrok.analysis.FileAnalyzer.Genre,
50N/Aorg.opensolaris.opengrok.web.*,
50N/Aorg.opensolaris.opengrok.history.*
50N/A"
50N/A%><%@include file="mast.jsp"%><%
66N/AString rev = null;
135N/Aif(!isDir && ef != null) {
66N/A try {
66N/A ef.close();
50N/A } catch (IOException e) {
50N/A }
50N/A ef = null;
50N/A}
72N/A
72N/Aif (valid) {
50N/A boolean annotate = Boolean.parseBoolean(request.getParameter("a"));
50N/A if (isDir) {
50N/A// If requesting a Directory listing -------------
50N/A DirectoryListing dl = new DirectoryListing(ef);
50N/A String[] files = resourceFile.list();
63N/A if (files != null) {
72N/A Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
72N/A ArrayList readMes = dl.listTo(resourceFile, out, path, files);
202N/A if(readMes != null && readMes.size() > 0) {
72N/A File xdir = new File(environment.getDataRootPath() + "/xref" + path);
72N/A if(xdir.exists() && xdir.isDirectory()) {
72N/A char[] buf = new char[8192];
63N/A for(int i = 0; i< readMes.size(); i++) {
50N/A try {
50N/A BufferedReader br = new BufferedReader(new FileReader(new File(xdir, (String)readMes.get(i))));
50N/A int len = 0;
50N/A %><h3><%=(String)readMes.get(i)%></h3><div id="src"><pre><%
50N/A while((len = br.read(buf)) > 0) {
50N/A out.write(buf, 0, len);
50N/A }
50N/A %></pre></div><%
195N/A br.close();
59N/A } catch(IOException e) {
59N/A }
66N/A }
66N/A }
66N/A }
66N/A }
195N/A } else if ((rev = request.getParameter("r")) != null && !rev.equals("")) {
66N/A// Else if requesting a previous revision -------------
66N/A if(noHistory) {
50N/A response.sendError(404, "Revision not found");
50N/A } else if (rev.matches("^[0-9]+(\\.[0-9]+)*$")) {
50N/A Class a = AnalyzerGuru.find(basename);
50N/A Genre g = AnalyzerGuru.getGenre(a);
50N/A if (g == Genre.PLAIN|| g == Genre.HTML || g == null) {
50N/A InputStream in = null;
50N/A try{
50N/A in = HistoryGuru.getInstance().getRevision(resourceFile.getParent(), basename, rev);
50N/A } catch (Exception e) {
50N/A response.sendError(404, "Revision not found");
50N/A return;
50N/A }
50N/A if(in != null) {
50N/A try {
50N/A if (g == null) {
111N/A a = AnalyzerGuru.find(in);
66N/A g = AnalyzerGuru.getGenre(a);
50N/A }
50N/A if (g == Genre.DATA || g == Genre.XREFABLE || g == null) {
66N/A %> <div id="src">Binary file [Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">here</a> to download] </div><%
66N/A } else {
66N/A %><div id="src"><span class="pagetitle"><%=basename%> revision <%=rev%> </span><pre>
50N/A<%
72N/Aif (g == Genre.PLAIN) {
50N/A Annotation annotation = annotate ?
59N/A HistoryGuru.getInstance().annotate(resourceFile, rev) : null;
59N/A AnalyzerGuru.writeXref(a, in, out, annotation);
59N/A} else if (g == Genre.IMAGE) {
72N/A %><img src="<%=context%>/raw<%=path%>?r=<%=rev%>"/><%
50N/A} else if (g == Genre.HTML) {
50N/A char[] buf = new char[8192];
50N/A Reader br = new InputStreamReader(in);
111N/A int len = 0;
111N/A while((len = br.read(buf)) > 0) {
111N/A out.write(buf, 0, len);
111N/A }
111N/A} else {
111N/A %> Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">download <%=basename%></a><%
111N/A}
111N/A }
111N/A } catch (IOException e) {
111N/A %> <h3 class="error">IO Error</h3> <p> <%=e.getMessage() %> </p> <%
135N/A
111N/A }
111N/A %></pre></div><%
111N/A in.close();
111N/A } else {
111N/A %> <h3 class="error">Error reading file</h3> <%
111N/A }
111N/A
111N/A } else if(g == Genre.IMAGE) {
111N/A %><div id="src"><img src="<%=context%>/raw<%=path%>?r=<%=rev%>"/></div><%
111N/A } else {
111N/A %><div id="src"> Binary file [Click <a href="<%=context%>/raw<%=path%>?r=<%=rev%>">here</a> to download] </div><%
111N/A }
111N/A
111N/A } else {
111N/A %><h3 class="error">Error: Invalid Revision Number!</h3><%
111N/A }
111N/A } else {
111N/A// requesting cross referenced file -------------
72N/A
72N/A String xrefSource = environment.getDataRootPath() + "/xref";
50N/A String resourceXFile = xrefSource + path;
50N/A File xrefFile = new File(resourceXFile);
66N/A if(xrefFile.exists() && !annotate) {
135N/A char[] buf = new char[8192];
66N/A BufferedReader br = new BufferedReader(new FileReader(resourceXFile));
66N/A int len = 0;
66N/A %><div id="src"><pre><%
66N/A while((len = br.read(buf)) > 0) {
119N/A out.write(buf, 0, len);
119N/A }
119N/A %></pre></div><%
50N/A br.close();
66N/A } else {
195N/A BufferedInputStream bin = new BufferedInputStream(new FileInputStream(resourceFile));
59N/A Class a = AnalyzerGuru.find(basename);
135N/A Genre g = AnalyzerGuru.getGenre(a);
135N/A if(g == null) {
135N/A a = AnalyzerGuru.find(bin);
135N/A g = AnalyzerGuru.getGenre(a);
135N/A }
135N/A if (g == Genre.IMAGE) {
135N/A %><div id="src"><img src="<%=context%>/raw<%=path%>"/></div><%
111N/A } else if( g == Genre.HTML) {
202N/A char[] buf = new char[8192];
72N/A Reader br = new InputStreamReader(bin);
136N/A int len = 0;
66N/A while((len = br.read(buf)) > 0) {
136N/A out.write(buf, 0, len);
66N/A }
119N/A } else if(g == Genre.PLAIN) {
119N/A %><div id="src"><pre><%
119N/A Annotation annotation = annotate ?
119N/A HistoryGuru.getInstance().annotate(resourceFile, rev) : null;
119N/A AnalyzerGuru.writeXref(a, bin, out, annotation);
119N/A %></pre></div><%
119N/A } else {
119N/A %> Click <a href="<%=context%>/raw<%=path%>">download <%=basename%></a><%
119N/A }
119N/A }
119N/A }
119N/A%><%@include file="foot.jspf"%><%
119N/A}
119N/Aif(ef != null) {
119N/A try {
119N/A ef.close();
119N/A } catch (IOException e) {
119N/A }
119N/A}
119N/A%>
119N/A