<%@ page import="org.apache.lucene.document.Document,
                 java.util.Enumeration,
                 org.apache.lucene.document.Field,
                 org.apache.lucene.index.IndexReader,
                 java.io.IOException,
				 java.net.URLEncoder,
                 com.opensymphony.util.TextUtils" %>

<%@ page contentType="text/html; charset=UTF-8" %>                  

<%

	IndexReader reader = null;
    String indexDir = null;

	if (session.getAttribute("lucene.index.dir") != null)
	{
		indexDir = (String)session.getAttribute("lucene.index.dir");

		try
		{
			reader = IndexReader.open(indexDir);
		}
		catch (IOException e)
		{
			out.println("<b>Error</b>: Could not open index: " + e);
		}
	}

	int documentNumber = Integer.parseInt(request.getParameter("doc"));
%>

<html>

	<head>

		<title>View Document</title>

	</head>

	<body>



	<% if (reader != null) { %>



	<b>Index</b>: <a href="indexbrowser.jsp?index.dir=<%= URLEncoder.encode(indexDir) %>"><%= indexDir %></a><br/>

	<b>Index Location</b>: <%= indexDir %><br/>

	<b>Number of Documents</b>: <%= reader.numDocs() %><br/>



	<%

		Document doc = reader.document(documentNumber);

	%>

		<p>

		<%--<b><a href="<%= request.getContextPath() %>/display/ViewIssue.jspa?id=<%= doc.get(DocumentConstants.ISSUE_ID) %>"><%= doc.get("title") %></a></b>--%>
		<b>Page Title:</b> <%= doc.get("title") %>



        <table cellspacing=0 cellpadding=0 border=0 bgcolor=cccccc><tr><td>
		<table cellpadding=2 cellspacing=1 border=0>
			<tr>

				<td valign=top><font face="Verdana" size=-2><b>Name</b></td>

				<td valign=top><font face="Verdana" size=-2><b>Indexed</b></td>

				<td valign=top><font face="Verdana" size=-2><b>Stored</b></td>

				<td valign=top><font face="Verdana" size=-2><b>Tokenized</b></td>

				<td valign=top><font face="Verdana" size=-2><b>Content</b></td>

			</tr>

			<%

				Enumeration fields = doc.fields();



				while (fields.hasMoreElements())

				{

					Field f = (Field) fields.nextElement();

			%>

				<tr bgcolor=ffffff>

				<td valign=top><font face="Verdana" size=-2><b><%= f.name() %></b></td>

				<td valign=top><font face="Verdana" size=-2><b><%= f.isIndexed() %></b></td>

				<td valign=top><font face="Verdana" size=-2><b><%= f.isStored() %></b></td>

				<td valign=top><font face="Verdana" size=-2><b><%= f.isTokenized() %></b></td>

				<td valign=top><font face="Verdana" size=-2>

					<%= TextUtils.htmlEncode(f.stringValue()) %>

				</td>

				</tr>

			<%

				}

			%>

		</table>

        </td></tr></table>

		</p>

	<% } %>



</body>

</html>