added community find page and some necessary patches to the framework, fixed

bugs
This commit is contained in:
Eric J. Bowersox
2003-05-31 04:35:38 +00:00
parent 3fa600206e
commit b1d1f8e381
17 changed files with 430 additions and 17 deletions

View File

@@ -185,6 +185,8 @@ class CommunityImpl implements VeniceCommunity
*/
public Object getObject(String namespace, String name)
{
if (logger.isDebugEnabled())
logger.debug("CommunityImpl.getObject: namespace = " + namespace + ", name = " + name);
try
{ // convert the namespace name to an ID here
PropertyKey key = new PropertyKey(m_nscache.namespaceNameToId(namespace),name);
@@ -196,19 +198,31 @@ class CommunityImpl implements VeniceCommunity
{ // no use - need to try the database
rc = m_ops.getProperty(m_id,key);
if (rc!=null)
{ // found in the database
m_properties.put(key,rc);
logger.debug("value found in database");
} // end if
} // end if
else
logger.debug("value found in cache");
} // end synchronized block
if (rc==null)
{ // the object was not found
logger.debug("value not found");
throw new NoSuchObjectException(this.toString(),namespace,name);
} // end if
return rc;
} // end try
catch (DatabaseException e)
{ // translate into our NoSuchObjectException but retain the DatabaseException
logger.debug("Database exception while doing find",e);
throw new NoSuchObjectException(this.toString(),namespace,name,e);
} // end catch

View File

@@ -150,7 +150,7 @@ class CommunityOps_mysql extends CommunityOps
conn = getConnection();
// look up the property
stmt = conn.prepareStatement("SELECT prop_value FROM commprop WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt = conn.prepareStatement("SELECT prop_value FROM commprops WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
@@ -209,10 +209,10 @@ class CommunityOps_mysql extends CommunityOps
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES commprop WRITE, communities WRITE;");
stmt2.executeUpdate("LOCK TABLES commprops WRITE, communities WRITE;");
// look to see if the property value is already there
stmt = conn.prepareStatement("SELECT prop_value FROM commprop WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt = conn.prepareStatement("SELECT prop_value FROM commprops WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
@@ -225,7 +225,7 @@ class CommunityOps_mysql extends CommunityOps
if (old_value!=null)
{ // prepare the statement to update the existing record
stmt = conn.prepareStatement("UPDATE commprop SET prop_value = ? WHERE cid = ? AND nsid = ? "
stmt = conn.prepareStatement("UPDATE commprops SET prop_value = ? WHERE cid = ? AND nsid = ? "
+ "AND prop_name = ?;");
stmt.setString(1,serialized_value);
stmt.setInt(2,cid);
@@ -235,7 +235,7 @@ class CommunityOps_mysql extends CommunityOps
} // end if
else
{ // prepare the statement to insert a new record
stmt = conn.prepareStatement("INSERT INTO commprop (cid, nsid, prop_name, prop_value) VALUES (?, ?, ?, ?);");
stmt = conn.prepareStatement("INSERT INTO commprops (cid, nsid, prop_name, prop_value) VALUES (?, ?, ?, ?);");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
@@ -293,10 +293,10 @@ class CommunityOps_mysql extends CommunityOps
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES commprop WRITE, communities WRITE;");
stmt2.executeUpdate("LOCK TABLES commprops WRITE, communities WRITE;");
// look to see if the property value is already there
stmt = conn.prepareStatement("SELECT prop_value FROM commprop WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt = conn.prepareStatement("SELECT prop_value FROM commprops WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
@@ -311,7 +311,7 @@ class CommunityOps_mysql extends CommunityOps
SQLUtils.shutdown(stmt);
// delete the database row
stmt = conn.prepareStatement("DELETE FROM commprop WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt = conn.prepareStatement("DELETE FROM commprops WHERE cid = ? AND nsid = ? AND prop_name = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,key.getNamespaceID());
stmt.setString(3,key.getName());
@@ -358,7 +358,7 @@ class CommunityOps_mysql extends CommunityOps
conn = getConnection();
// execute the query!
stmt = conn.prepareStatement("SELECT DISTINCT nsid FROM commprop WHERE cid = ?;");
stmt = conn.prepareStatement("SELECT DISTINCT nsid FROM commprops WHERE cid = ?;");
stmt.setInt(1,cid);
rs = stmt.executeQuery();
@@ -400,7 +400,7 @@ class CommunityOps_mysql extends CommunityOps
conn = getConnection();
// execute the query!
stmt = conn.prepareStatement("SELECT prop_name, prop_value FROM commprop WHERE cid = ? AND nsid = ?;");
stmt = conn.prepareStatement("SELECT prop_name, prop_value FROM commprops WHERE cid = ? AND nsid = ?;");
stmt.setInt(1,cid);
stmt.setInt(2,namespace);
rs = stmt.executeQuery();