added community find page and some necessary patches to the framework, fixed
bugs
This commit is contained in:
@@ -608,4 +608,10 @@ class GroupObject implements DynamoGroup
|
||||
|
||||
} // end setAcl
|
||||
|
||||
public synchronized int getMemberCount() throws DatabaseException
|
||||
{
|
||||
return m_ops.getMemberCount(m_gid);
|
||||
|
||||
} // end getMemberCount
|
||||
|
||||
} // end class GroupObject
|
||||
|
||||
@@ -60,4 +60,6 @@ abstract class GroupObjectOps extends OpsBase
|
||||
|
||||
abstract void setAclID(int gid, int aclid) throws DatabaseException;
|
||||
|
||||
abstract int getMemberCount(int gid) throws DatabaseException;
|
||||
|
||||
} // end class GroupObjectOps
|
||||
|
||||
@@ -553,4 +553,36 @@ class GroupObjectOps_mysql extends GroupObjectOps
|
||||
|
||||
} // end setAclID
|
||||
|
||||
int getMemberCount(int gid) throws DatabaseException
|
||||
{
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
ArrayList tmp = null;
|
||||
try
|
||||
{ // get a connection
|
||||
conn = getConnection();
|
||||
|
||||
// create a query to get all the UIDs
|
||||
stmt = conn.prepareStatement("SELECT COUNT(*) FROM groupmembers WHERE gid = ?;");
|
||||
stmt.setInt(1,gid);
|
||||
rs = stmt.executeQuery();
|
||||
return SQLUtils.getReturnCountInt(rs,1);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
{ // translate to a general DatabaseException
|
||||
throw generalException(e);
|
||||
|
||||
} // end catch
|
||||
finally
|
||||
{ // shut everything down
|
||||
SQLUtils.shutdown(rs);
|
||||
SQLUtils.shutdown(stmt);
|
||||
SQLUtils.shutdown(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end getMemberCount
|
||||
|
||||
} // end class GroupObjectOps_mysql
|
||||
|
||||
@@ -235,6 +235,12 @@ abstract class GroupProxy implements DynamoGroup, DynamicWrapper
|
||||
|
||||
} // end setAcl
|
||||
|
||||
public int getMemberCount() throws DatabaseException
|
||||
{
|
||||
return getRealGroup().getMemberCount();
|
||||
|
||||
} // end getMemberCount
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface DynamicWrapper
|
||||
*--------------------------------------------------------------------------------
|
||||
|
||||
@@ -45,4 +45,6 @@ public interface DynamoGroup extends Group, NamedObject, SecureObjectStore
|
||||
|
||||
public void setAcl(DynamoUser caller, DynamoAcl acl) throws DatabaseException, DynamoSecurityException;
|
||||
|
||||
public int getMemberCount() throws DatabaseException;
|
||||
|
||||
} // end interface DynamoGroup
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user