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