} // fi
// *********************************************************************
if (DebugFile.trace) DebugFile.writeln("new IndexWriter("+sDirectory+",[Analyzer], true)");
IndexWriter oIWrt = new IndexWriter(sDirectory, (Analyzer) oAnalyzer.newInstance(), true);
if (DebugFile.trace)
DebugFile.writeln("DriverManager.getConnection(" + oProps.getProperty("dburl") + ", ...)");
Connection oConn = DriverManager.getConnection(oProps.getProperty("dburl"), oProps.getProperty("dbuser"),oProps.getProperty("dbpassword"));
Statement oStmt = oConn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
ResultSet oRSet;
PreparedStatement oRecp = oConn.prepareStatement("SELECT tx_personal,tx_email FROM k_inet_addrs WHERE tp_recipient<>'to' AND gu_mimemsg=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
if (DebugFile.trace)
DebugFile.writeln("Statement.executeQuery(SELECT m.gu_workarea,c.nm_category,m.gu_mimemsg,m.tx_subject,m.nm_from,m.tx_email_from,m.pg_message,m.de_mimemsg,m.dt_sent,m.len_mimemsg,m.by_content FROM k_mime_msgs m, k_categories c WHERE m.bo_deleted=0 AND m.bo_draft=0 AND m.gu_category=c.gu_category AND m.gu_workarea='"+sWorkArea+"' AND c.nm_category='"+sFolder+"')");
oRSet = oStmt.executeQuery("SELECT m.gu_workarea,c.nm_category,m.gu_mimemsg,m.tx_subject,m.nm_from,m.tx_email_from,m.pg_message,m.de_mimemsg,m.dt_sent,m.len_mimemsg,m.by_content FROM k_mime_msgs m, k_categories c WHERE m.bo_deleted=0 AND m.bo_draft=0 AND m.gu_category=c.gu_category AND m.gu_workarea='"+sWorkArea+"' AND c.nm_category='"+sFolder+"'");
int nIndexed = 0;
while (oRSet.next()) {
sWorkArea = oRSet.getString(1);
sContainer = oRSet.getString(2);
sGuid = oRSet.getString(3);
sTitle = oRSet.getString(4);
sAuthor = oRSet.getString(5);
if (oRSet.wasNull()) sAuthor = "";
sAuthor += " " + oRSet.getString(6);
dNumber = oRSet.getBigDecimal(7);
if (oRSet.wasNull()) dNumber = dZero;
sComments = oRSet.getString(8);
if (oRSet.wasNull()) sComments = "";
dtCreated = oRSet.getDate(9);
iSize = oRSet.getInt(10);
if (DebugFile.trace) DebugFile.writeln("Indexing message "+sGuid+" - "+sTitle);
InputStream oStrm = oRSet.getBinaryStream(11);
String sRecipients = "";
oRecp.setString(1, sGuid);
ResultSet oRecs = oRecp.executeQuery();
while (oRecs.next()) {
String sTxPersonal = oRecs.getString(1);
if (oRecs.wasNull())
sRecipients += oRecs.getString(2)+" ";
else
sRecipients += oRecs.getString(1)+" "+oRecs.getString(2)+" ";
} // wend
oRecs.close();
MailIndexer.addMail(oIWrt, sGuid, dNumber, sWorkArea, sContainer, sTitle,
sAuthor, sRecipients, dtCreated, sComments,
oStrm, iSize);
nIndexed++;
} // wend
if (DebugFile.trace) {
DebugFile.writeln(String.valueOf(nIndexed)+" messages indexed");
}
oRSet.close();
oRecp.close();
if (DebugFile.trace) {
DebugFile.writeln("Statement.executeUpdate(UPDATE k_mime_msgs SET bo_indexed=1 WHERE gu_workarea='"+sWorkArea+"' AND gu_category IN (SELECT gu_category FROM k_categories WHERE nm_category='"+sFolder+"'))");
}
oStmt.executeUpdate("UPDATE k_mime_msgs SET bo_indexed=1 WHERE gu_workarea='"+sWorkArea+"' AND gu_category IN (SELECT gu_category FROM k_categories WHERE nm_category='"+sFolder+"')");
oStmt.close();
oConn.close();
if (DebugFile.trace) DebugFile.writeln("IndexWriter.optimize()");
oIWrt.optimize();
if (DebugFile.trace) DebugFile.writeln("IndexWriter.close()");
oIWrt.close();
if (DebugFile.trace) {
DebugFile.decIdent();
DebugFile.writeln("End MailIndexer.rebuildFolder()");
}