list.jsp revision 43
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync<%--
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncCDDL HEADER START
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncThe contents of this file are subject to the terms of the
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncCommon Development and Distribution License (the "License").
e64031e20c39650a7bc902a3e1aba613b9415deevboxsyncYou may not use this file except in compliance with the License.
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncSee LICENSE.txt included in this distribution for the specific
ca0ee85505c252493a3ee53577848ef8939f991bvboxsynclanguage governing permissions and limitations under the License.
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncWhen distributing Covered Code, include this CDDL HEADER in each
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncfile and include the License file at LICENSE.txt.
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncIf applicable, add the following below this CDDL HEADER, with the
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncfields enclosed by brackets "[]" replaced with your own identifying
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncinformation: Portions Copyright [yyyy] [name of copyright owner]
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncCDDL HEADER END
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncCopyright 2005 Sun Microsystems, Inc. All rights reserved.
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncUse is subject to license terms.
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncident "%Z%%M% %I% %E% SMI"
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync--%><%@ page import = "javax.servlet.*,
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncjava.lang.*,
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncjavax.servlet.http.*,
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncjava.util.*,
11d817ec366e01926a69295682502feb90d1d859vboxsyncjava.io.*,
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncjava.text.*,
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncorg.opensolaris.opengrok.analysis.*,
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncorg.opensolaris.opengrok.index.*,
468c2bcb36eb9a032f5dd0fcb34db10bd58e9996vboxsyncorg.opensolaris.opengrok.analysis.FileAnalyzer.Genre,
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncorg.opensolaris.opengrok.web.*,
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncorg.opensolaris.opengrok.history.*
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync"
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync%><%@include file="mast.jsp"%><%
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncString rev = null;
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncif(!isDir && ef != null) {
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync try {
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync ef.close();
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync } catch (IOException e) {
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync }
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync ef = null;
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync}
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync
ca0ee85505c252493a3ee53577848ef8939f991bvboxsyncif (valid) {
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync if (isDir) {
ca0ee85505c252493a3ee53577848ef8939f991bvboxsync// If requesting a Directory listing -------------
DirectoryListing dl = new DirectoryListing(IgnoredNames.ignore, ef);
String[] files = resourceFile.list();
if (files != null) {
Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
ArrayList readMes = dl.listTo(resourceFile, out, path, files);
if(readMes != null && readMes.size() > 0) {
File xdir = new File(getServletContext().getInitParameter("DATA_ROOT") + "/xref" + path);
if(xdir.exists() && xdir.isDirectory()) {
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) {
System.setProperty("urlPrefix", context+"/s?");
AnalyzerGuru.writeXref(a, in, out);
} 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 = getServletContext().getInitParameter("DATA_ROOT") + "/xref";
String resourceXFile = xrefSource + path;
File xrefFile = new File(resourceXFile);
if(xrefFile.exists()) {
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><%
System.setProperty("urlPrefix", context+"/s?");
AnalyzerGuru.writeXref(a, bin, out);
%></pre></div><%
} else {
%> Click <a href="<%=context%>/raw<%=path%>">download <%=basename%></a><%
}
}
}
%><%@include file="foot.jsp"%><%
}
if(ef != null) {
try {
ef.close();
} catch (IOException e) {
}
}
%>