<%@ page language="java" %>
<%@ page contentType="text/html; charset=windows-1251" %>
<%@ page import="com.jspsmart.upload.*" %>
<%@ page import="com.kes.diplom.*" %>
<%@ page import="com.kes.diplom.agent.*" %>
<%@ page import="UuidMgr" %>
<%@ page import="com.kes.diplom.site.*" %>
<%@ page import="java.io.FileReader" %>
<%@ page import="javax.swing.text.html.parser.*" %>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<%!
private final static String MIME_PLAIN = "text/plain";
private final static String MIME_HTML = "text/html";
%>
<HTML>
<HEAD>
<TITLE></TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="text.css">
</HEAD>
<BODY>
<H1>Результаты поиска похожих документов</H1>
<%
mySmartUpload.initialize(pageContext);
mySmartUpload.setAllowedFilesList("htm,html,txt,,");
mySmartUpload.setTotalMaxFileSize(100000);
mySmartUpload.upload();
Request request1 = mySmartUpload.getRequest();
int siteId = 0;
int rubricId = 0;
if (request1.getParameterNames().hasMoreElements()) {
if (request1.getParameter("site")!=null) {
siteId = Integer.parseInt( request1.getParameter("site") );
}
if (request1.getParameter("rubric")!=null) {
rubricId = Integer.parseInt( request1.getParameter("rubric") );
}
}
Site site = new Site(siteId);
Rubric rubric = new Rubric(rubricId);
Files files = mySmartUpload.getFiles();
int count = files.getCount();
if (count==0) {
%><jsp:forward page="findonsite.jsp" /><%
}
File file = files.getFile(0);
String contentType = file.getContentType().trim().toLowerCase();
if (contentType.equals(MIME_PLAIN) || contentType.equals(MIME_HTML))
{
UuidMgr uuidMgr = UuidMgr.getInstance();
String uuid = uuidMgr.createUUID();
String physicalFilePath = Config.SITE_UPLOAD_DIR+uuid+".txt";
file.saveAs(physicalFilePath, File.SAVEAS_PHYSICAL);
Document doc = new Document();
FileReader reader = new FileReader(physicalFilePath);
if (contentType.equals(MIME_HTML)) {
DTD dtd = DTD.getDTD("html32");
DocumentParser parser = new DocumentParser(dtd);
ParserHandler handler = new ParserHandler(doc);
parser.parse(reader,handler,true);
} else if (contentType.equals(MIME_PLAIN)) {
String text = "";
while (reader.ready()) {
text += (char)reader.read();
}
doc.addText(text);
}
reader.close();
Documents docs = new Documents(site);
docs.store(doc);
Vector kwords = doc.getKeywords();
String test = "";
Dictionary stems = new Dictionary();
for (int i=0; i<kwords.size(); i++) {
Word kword = (Word)kwords.elementAt(i);
stems.add( kword.getStemId() );
test += kword.getText() + ",";
}
%><P>Ключевые слова: <%=test%><P>
<%
Finder finder = new Finder(site);
Result ress = finder.find( stems,rubric );
Vector res = ress.getItems();
if (res.size()==0) {
%><B>Ничего не найдено!</B><%
} else {
%><TABLE BORDER="0"><%
for (int i=0; i<res.size(); i++) {
ResultItem item = (ResultItem)res.elementAt(i);
Document doci = item.getDocument();
%>
<TR><TD><IMG SRC="doc.gif" BORDER="0"></TD><TD><A HREF="<%=doci.getUrl()%>" TITLE="<%=doci.getDescription()%>"><%=doci.getTitle()%></A></TD></TR>
<%
}
%></TABLE><%
}
}
%>
</BODY>
</HTML>
|
Рис. 10.1. Зона "Поиск" |
|
Рис. 10.2. Зона "Администрирование сайта" |
|
Рис. 10.3. Зона "Управление рубриками сайта" |
|
Рис. 10.4. Зона "Управление документами" |
|
Рис. 10.5. Зона "Управление документом" |
|