implemented the post search facility at the engine level

This commit is contained in:
Eric J. Bowersox 2001-12-07 23:11:15 +00:00
parent 01356557da
commit 4b1acef325
11 changed files with 713 additions and 3 deletions

View File

@ -183,4 +183,9 @@ public interface CommunityContext extends SearchMode
public abstract void massMail(String subject, String text) throws AccessError, DataException;
public abstract List searchPosts(String search_terms, int offset, int count)
throws AccessError, DataException;
public abstract int getSearchPostCount(String search_terms) throws AccessError, DataException;
} // end interface CommunityContext

View File

@ -183,4 +183,9 @@ public interface ConferenceContext
public abstract void removeCustomBlocks() throws AccessError, DataException;
public abstract List searchPosts(String search_terms, int offset, int count)
throws AccessError, DataException;
public abstract int getSearchPostCount(String search_terms) throws AccessError, DataException;
} // end interface ConferenceContext

View File

@ -113,5 +113,9 @@ public interface TopicContext
public abstract void sendMailToParticipants(boolean posters, int day_limit, String subject, String text)
throws AccessError, DataException;
} // end interface TopicContext
public abstract List searchPosts(String search_terms, int offset, int count)
throws AccessError, DataException;
public abstract int getSearchPostCount(String search_terms) throws AccessError, DataException;
} // end interface TopicContext

View File

@ -0,0 +1,34 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core;
import java.util.Date;
public interface TopicMessageFound
{
public abstract String getIdentifier();
public abstract String getAuthor();
public abstract Date getPostDate();
public abstract int getLineCount();
public abstract String getText();
} // end interface TopicMessageFound

View File

@ -123,4 +123,10 @@ public interface UserContext extends SearchMode
public abstract boolean canSetUserPhoto() throws DataException;
public abstract List searchPosts(String search_terms, int offset, int count)
throws AccessError, DataException;
public abstract int getSearchPostCount(String search_terms) throws AccessError, DataException;
} // end interface UserContext

View File

@ -1394,6 +1394,116 @@ class CommunityUserContextImpl implements CommunityContext, CommunityBackend
} // end massMail
public List searchPosts(String search_terms, int offset, int count) throws AccessError, DataException
{
if (logger.isDebugEnabled())
logger.debug("searchPosts('" + search_terms + "', " + offset + ", " + count + ") entry");
if (search_terms==null)
throw new NullPointerException("invalid search terms");
if (offset<0)
throw new IllegalArgumentException("invalid offset parameter");
if (count<=0)
throw new IllegalArgumentException("invalid count parameter");
Connection conn = null;
ArrayList rc = new ArrayList();
try
{ // get a database connection
conn = env.getConnection();
TopicMessageFoundHelper helper = new TopicMessageFoundHelper(conn);
Statement stmt = conn.createStatement();
// create the SQL statement
StringBuffer sql =
new StringBuffer("SELECT c.confid, t.topicid, t.topicnum, p.postid, p.num, p.creator_uid, "
+ "p.posted, p.linecount, d.data FROM confs c, sigtoconf s, topics t, posts p, "
+ "postdata d, users u LEFT JOIN sigmember m ON (s.sigid = m.sigid "
+ "AND u.uid = m.uid) LEFT JOIN confmember x ON (c.confid = x.confid AND "
+ "u.uid = x.uid) WHERE u.uid = ");
sql.append(env.getUserID()).append(" AND c.confid = s.confid AND s.sigid = ");
sql.append(cid);
sql.append(" AND GREATEST(u.base_lvl,IFNULL(m.granted_lvl,0),s.granted_lvl,IFNULL(x.granted_lvl,0)) "
+ ">= c.read_lvl AND t.confid = c.confid AND t.topicid = p.topicid AND "
+ "p.scribble_uid IS NULL AND p.postid = d.postid AND MATCH(d.data) AGAINST (");
sql.append(SQLUtil.encodeStringArg(search_terms)).append(") LIMIT ").append(offset).append(", ");
sql.append(count).append(';');
// execute the query and load the results into the return arraylist
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next())
rc.add(new TopicMessageFoundImpl(helper,cid,rs.getInt(1),rs.getInt(2),rs.getInt(3),rs.getLong(4),
rs.getInt(5),rs.getInt(6),SQLUtil.getFullDateTime(rs,7),rs.getInt(8),
rs.getString(9)));
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error searching for posts: " + e.getMessage(),e);
throw new DataException("unable to search: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
env.releaseConnection(conn);
} // end finally
if (rc.isEmpty())
return Collections.EMPTY_LIST;
else
return Collections.unmodifiableList(rc);
} // end searchPosts
public int getSearchPostCount(String search_terms) throws AccessError, DataException
{
if (logger.isDebugEnabled())
logger.debug("getSearchPostCount('" + search_terms + ") entry");
if (search_terms==null)
throw new NullPointerException("invalid search terms");
Connection conn = null;
try
{ // get a database connection
conn = env.getConnection();
Statement stmt = conn.createStatement();
// create the SQL statement
StringBuffer sql =
new StringBuffer("SELECT COUNT(*) FROM confs c, sigtoconf s, topics t, posts p, postdata d, "
+ "users u LEFT JOIN sigmember m ON (s.sigid = m.sigid AND u.uid = m.uid) "
+ "LEFT JOIN confmember x ON (c.confid = x.confid AND u.uid = x.uid) "
+ "WHERE u.uid = ");
sql.append(env.getUserID()).append(" AND c.confid = s.confid AND s.sigid = ");
sql.append(cid);
sql.append(" AND GREATEST(u.base_lvl,IFNULL(m.granted_lvl,0),s.granted_lvl,IFNULL(x.granted_lvl,0)) "
+ ">= c.read_lvl AND t.confid = c.confid AND t.topicid = p.topicid AND "
+ "p.scribble_uid IS NULL AND p.postid = d.postid AND MATCH(d.data) AGAINST (");
sql.append(SQLUtil.encodeStringArg(search_terms)).append(");");
// execute the query and load the results
ResultSet rs = stmt.executeQuery(sql.toString());
if (!(rs.next()))
throw new InternalStateError("query failure in CommunityUserContextImpl.getSearchPostCount!");
return rs.getInt(1);
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error searching for posts: " + e.getMessage(),e);
throw new DataException("unable to search: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
env.releaseConnection(conn);
} // end finally
} // end getSearchPostCount
/*--------------------------------------------------------------------------------
* Implementations from interface CommunityBackend
*--------------------------------------------------------------------------------

View File

@ -1625,6 +1625,111 @@ class ConferenceUserContextImpl implements ConferenceContext, ConferenceBackend
} // end removeCustomBlocks
public List searchPosts(String search_terms, int offset, int count) throws AccessError, DataException
{
if (logger.isDebugEnabled())
logger.debug("searchPosts('" + search_terms + "', " + offset + ", " + count + ") entry");
if (search_terms==null)
throw new NullPointerException("invalid search terms");
if (offset<0)
throw new IllegalArgumentException("invalid offset parameter");
if (count<=0)
throw new IllegalArgumentException("invalid count parameter");
if (getConferenceData().canReadConference(level))
throw new AccessError("You are not permitted to search for posts within this conference.");
Connection conn = null;
ArrayList rc = new ArrayList();
try
{ // get a database connection
conn = env.getConnection();
TopicMessageFoundHelper helper = new TopicMessageFoundHelper(conn);
Statement stmt = conn.createStatement();
// create the SQL statement
StringBuffer sql =
new StringBuffer("SELECT t.topicid, t.topicnum, p.postid, p.num, p.creator_uid, p.posted, "
+ "p.linecount, d.data FROM topics t, posts p, postdata d WHERE t.confid = ");
sql.append(confid);
sql.append(" AND t.topicid = p.topicid AND p.scribble_uid IS NULL AND p.postid = d.postid "
+ "AND MATCH(d.data) AGAINST(");
sql.append(SQLUtil.encodeStringArg(search_terms)).append(") LIMIT ").append(offset).append(", ");
sql.append(count+1).append(';');
// execute the query and load the results into the return arraylist
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next())
rc.add(new TopicMessageFoundImpl(helper,env.getCommunityID(),confid,rs.getInt(1),rs.getInt(2),
rs.getLong(3),rs.getInt(4),rs.getInt(5),
SQLUtil.getFullDateTime(rs,6),rs.getInt(7),rs.getString(8)));
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error searching for posts: " + e.getMessage(),e);
throw new DataException("unable to search: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
env.releaseConnection(conn);
} // end finally
if (rc.isEmpty())
return Collections.EMPTY_LIST;
else
return Collections.unmodifiableList(rc);
} // end searchPosts
public int getSearchPostCount(String search_terms) throws AccessError, DataException
{
if (logger.isDebugEnabled())
logger.debug("getSearchPostCount('" + search_terms + ") entry");
if (search_terms==null)
throw new NullPointerException("invalid search terms");
if (getConferenceData().canReadConference(level))
throw new AccessError("You are not permitted to search for posts within this conference.");
Connection conn = null;
try
{ // get a database connection
conn = env.getConnection();
Statement stmt = conn.createStatement();
// create the SQL statement
StringBuffer sql =
new StringBuffer("SELECT COUNT(*) FROM topics t, posts p, postdata d WHERE t.confid = ");
sql.append(confid);
sql.append(" AND t.topicid = p.topicid AND p.scribble_uid IS NULL AND p.postid = d.postid "
+ "AND MATCH(d.data) AGAINST(");
sql.append(SQLUtil.encodeStringArg(search_terms)).append(");");
// execute the query and load the results
ResultSet rs = stmt.executeQuery(sql.toString());
if (!(rs.next()))
throw new InternalStateError("query failure in ConferenceUserContextImpl.getSearchPostCount!");
return rs.getInt(1);
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error searching for posts: " + e.getMessage(),e);
throw new DataException("unable to search: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
env.releaseConnection(conn);
} // end finally
} // end getSearchPostCount
/*--------------------------------------------------------------------------------
* Implementations from interface ConferenceBackend
*--------------------------------------------------------------------------------

View File

@ -0,0 +1,115 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.impl;
import java.sql.*;
import java.util.*;
class TopicMessageFoundHelper
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private Connection conn;
private HashMap comm_aliases = new HashMap();
private HashMap conf_aliases = new HashMap();
private HashMap user_names = new HashMap();
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
TopicMessageFoundHelper(Connection conn)
{
this.conn = conn;
} // end constructor
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
final String getCommunityAlias(int cid) throws SQLException
{
Integer key = new Integer(cid);
String rc = (String)(comm_aliases.get(key));
if (rc==null)
{ // create an SQL statement to find the alias
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT alias FROM sigs WHERE sigid = " + cid + ";");
if (rs.next())
rc = rs.getString(1);
else
rc = "(unknown)";
comm_aliases.put(key,rc);
} // end if
return rc;
} // end getCommunityAlias
final String getConferenceAlias(int confid) throws SQLException
{
Integer key = new Integer(confid);
String rc = (String)(conf_aliases.get(key));
if (rc==null)
{ // create an SQL statement to find the alias
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT alias FROM confalias WHERE confid = " + confid + " LIMIT 1;");
if (rs.next())
rc = rs.getString(1);
else
rc = "(unknown)";
conf_aliases.put(key,rc);
} // end if
return rc;
} // end getConferenceAlias
final String getUserName(int uid) throws SQLException
{
Integer key = new Integer(uid);
String rc = (String)(user_names.get(key));
if (rc==null)
{ // create an SQL statement to find the username
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT username FROM users WHERE uid = " + uid + ";");
if (rs.next())
rc = rs.getString(1);
else
rc = "(unknown)";
user_names.put(key,rc);
} // end if
return rc;
} // end getUserName
} // end TopicMessageFoundHelper

View File

@ -0,0 +1,118 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.core.impl;
import java.sql.SQLException;
import java.util.*;
import com.silverwrist.venice.core.*;
class TopicMessageFoundImpl implements TopicMessageFound
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int cid;
private int confid;
private int topicid;
private int topicnum;
private long postid;
private int postnum;
private String ident;
private int creator_uid;
private String creator_name;
private Date postdate;
private int linecount;
private String text;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
TopicMessageFoundImpl(TopicMessageFoundHelper helper, int cid, int confid, int topicid, int topicnum,
long postid, int postnum, int creator_uid, Date postdate, int linecount, String text)
throws SQLException
{
this.cid = cid;
this.confid = confid;
this.topicid = topicid;
this.topicnum = topicnum;
this.postid = postid;
this.postnum = postnum;
this.ident = helper.getCommunityAlias(cid) + "!" + helper.getConferenceAlias(confid) + "." + topicnum
+ "." + postnum;
this.creator_uid = creator_uid;
this.creator_name = helper.getUserName(creator_uid);
this.postdate = postdate;
this.linecount = linecount;
this.text = transformText(text);
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private static final String transformText(String text)
{
return text; // TEMP
} // end transformText
/*--------------------------------------------------------------------------------
* Implementations from interface TopicMessageFound
*--------------------------------------------------------------------------------
*/
public String getIdentifier()
{
return ident;
} // end getIdentifier
public String getAuthor()
{
return creator_name;
} // end getAuthor
public Date getPostDate()
{
return postdate;
} // end getPostDate
public int getLineCount()
{
return linecount;
} // end getLineCount
public String getText()
{
return text;
} // end getText
} // end class TopicMessageFoundImpl

View File

@ -1408,6 +1408,108 @@ class TopicUserContextImpl implements TopicContext
} // end sendMailToParticipants
public List searchPosts(String search_terms, int offset, int count) throws AccessError, DataException
{
if (logger.isDebugEnabled())
logger.debug("searchPosts('" + search_terms + "', " + offset + ", " + count + ") entry");
if (search_terms==null)
throw new NullPointerException("invalid search terms");
if (offset<0)
throw new IllegalArgumentException("invalid offset parameter");
if (count<=0)
throw new IllegalArgumentException("invalid count parameter");
if (!(env.getConference().userCanRead()))
throw new AccessError("You are not permitted to search for posts within this topic.");
Connection conn = null;
ArrayList rc = new ArrayList();
try
{ // get a database connection
conn = env.getConnection();
TopicMessageFoundHelper helper = new TopicMessageFoundHelper(conn);
Statement stmt = conn.createStatement();
// create the SQL statement
StringBuffer sql =
new StringBuffer("SELECT p.postid, p.num, p.creator_uid, p.posted, p.linecount, d.data "
+ "FROM posts p, postdata d WHERE p.topicid = ");
sql.append(topicid);
sql.append(" AND p.scribble_uid IS NULL AND d.postid = p.postid AND MATCH (d.data) AGAINST (");
sql.append(SQLUtil.encodeStringArg(search_terms)).append(") LIMIT ").append(offset).append(", ");
sql.append(count+1).append(';');
// execute the query and load the results into the return arraylist
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next())
rc.add(new TopicMessageFoundImpl(helper,env.getCommunityID(),env.getConfID(),topicid,topicnum,
rs.getLong(1),rs.getInt(2),rs.getInt(3),
SQLUtil.getFullDateTime(rs,4),rs.getInt(5),rs.getString(6)));
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error searching for posts: " + e.getMessage(),e);
throw new DataException("unable to search: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
env.releaseConnection(conn);
} // end finally
if (rc.isEmpty())
return Collections.EMPTY_LIST;
else
return Collections.unmodifiableList(rc);
} // end searchPosts
public int getSearchPostCount(String search_terms) throws AccessError, DataException
{
if (logger.isDebugEnabled())
logger.debug("getSearchPostCount('" + search_terms + ") entry");
if (search_terms==null)
throw new NullPointerException("invalid search terms");
if (!(env.getConference().userCanRead()))
throw new AccessError("You are not permitted to search for posts within this topic.");
Connection conn = null;
try
{ // get a database connection
conn = env.getConnection();
Statement stmt = conn.createStatement();
// create the SQL statement
StringBuffer sql =
new StringBuffer("SELECT COUNT(*) FROM posts p, postdata d WHERE p.topicid = ");
sql.append(topicid);
sql.append(" AND p.scribble_uid IS NULL AND d.postid = p.postid AND MATCH (d.data) AGAINST (");
sql.append(SQLUtil.encodeStringArg(search_terms)).append(");");
// execute the query and load the results into the return arraylist
ResultSet rs = stmt.executeQuery(sql.toString());
if (!(rs.next()))
throw new InternalStateError("query failure in TopicUserContextImpl.getSearchPostCount!");
return rs.getInt(1);
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error searching for posts: " + e.getMessage(),e);
throw new DataException("unable to search: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
env.releaseConnection(conn);
} // end finally
} // end getSearchPostCount
/*--------------------------------------------------------------------------------
* External operations usable only from within the package
*--------------------------------------------------------------------------------
@ -1663,5 +1765,3 @@ class TopicUserContextImpl implements TopicContext
} // end getTopicByNumber
} // end class TopicUserContextImpl

View File

@ -1431,6 +1431,114 @@ class UserContextImpl implements UserContext, UserBackend
} // end canSetUserPhoto
public List searchPosts(String search_terms, int offset, int count) throws AccessError, DataException
{
if (logger.isDebugEnabled())
logger.debug("searchPosts('" + search_terms + "', " + offset + ", " + count + ") entry");
if (search_terms==null)
throw new NullPointerException("invalid search terms");
if (offset<0)
throw new IllegalArgumentException("invalid offset parameter");
if (count<=0)
throw new IllegalArgumentException("invalid count parameter");
Connection conn = null;
ArrayList rc = new ArrayList();
try
{ // get a database connection
conn = env.getConnection();
TopicMessageFoundHelper helper = new TopicMessageFoundHelper(conn);
Statement stmt = conn.createStatement();
// create the SQL statement
StringBuffer sql =
new StringBuffer("SELECT s.sigid, c.confid, t.topicid, t.topicnum, p.postid, p.num, p.creator_uid, "
+ "p.posted, p.linecount, d.data FROM confs c, sigtoconf s, topics t, posts p, "
+ "postdata d, users u, sigmember m LEFT JOIN confmember x "
+ "ON (c.confid = x.confid AND u.uid = x.uid) WHERE u.uid = ");
sql.append(uid);
sql.append(" AND c.confid = s.confid AND s.sigid = m.sigid AND m.uid = u.uid AND "
+ "GREATEST(u.base_lvl,m.granted_lvl,s.granted_lvl,IFNULL(x.granted_lvl,0)) >= c.read_lvl "
+ "AND t.confid = c.confid AND t.topicid = p.topicid AND p.scribble_uid IS NULL AND "
+ "p.postid = d.postid AND MATCH(d.data) AGAINST (");
sql.append(SQLUtil.encodeStringArg(search_terms)).append(") LIMIT ").append(offset).append(", ");
sql.append(count).append(';');
// execute the query and load the results into the return arraylist
ResultSet rs = stmt.executeQuery(sql.toString());
while (rs.next())
rc.add(new TopicMessageFoundImpl(helper,rs.getInt(1),rs.getInt(2),rs.getInt(3),rs.getInt(4),
rs.getLong(5),rs.getInt(6),rs.getInt(7),
SQLUtil.getFullDateTime(rs,8),rs.getInt(9),rs.getString(10)));
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error searching for posts: " + e.getMessage(),e);
throw new DataException("unable to search: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
env.releaseConnection(conn);
} // end finally
if (rc.isEmpty())
return Collections.EMPTY_LIST;
else
return Collections.unmodifiableList(rc);
} // end searchPosts
public int getSearchPostCount(String search_terms) throws AccessError, DataException
{
if (logger.isDebugEnabled())
logger.debug("getSearchPostCount('" + search_terms + ") entry");
if (search_terms==null)
throw new NullPointerException("invalid search terms");
Connection conn = null;
try
{ // get a database connection
conn = env.getConnection();
Statement stmt = conn.createStatement();
// create the SQL statement
StringBuffer sql =
new StringBuffer("SELECT COUNT(*) FROM confs c, sigtoconf s, topics t, posts p, postdata d, "
+ "users u, sigmember m LEFT JOIN confmember x ON (c.confid = x.confid AND "
+ "u.uid = x.uid) WHERE u.uid = ");
sql.append(uid);
sql.append(" AND c.confid = s.confid AND s.sigid = m.sigid AND m.uid = u.uid AND "
+ "GREATEST(u.base_lvl,m.granted_lvl,s.granted_lvl,IFNULL(x.granted_lvl,0)) >= c.read_lvl "
+ "AND t.confid = c.confid AND t.topicid = p.topicid AND p.scribble_uid IS NULL AND "
+ "p.postid = d.postid AND MATCH(d.data) AGAINST (");
sql.append(SQLUtil.encodeStringArg(search_terms)).append(");");
// execute the query and load the results
ResultSet rs = stmt.executeQuery(sql.toString());
if (!(rs.next()))
throw new InternalStateError("query failure in UserContextImpl.getSearchPostCount!");
return rs.getInt(1);
} // end try
catch (SQLException e)
{ // this becomes a DataException
logger.error("DB error searching for posts: " + e.getMessage(),e);
throw new DataException("unable to search: " + e.getMessage(),e);
} // end catch
finally
{ // make sure we release the connection before we go
env.releaseConnection(conn);
} // end finally
} // end getSearchPostCount
/*--------------------------------------------------------------------------------
* Implementations from interface UserBackend
*--------------------------------------------------------------------------------