if ( dbc.count() > 0 )
{
List<CommunityPojo> communities = CommunityPojo.listFromDb(dbc, CommunityPojo.listType());
filterCommunityMembers(communities, isSysAdmin, userIdStr);
rp.setData(communities, new CommunityPojoApiMap());
rp.setResponse(new ResponseObject("Community Info", true, "Community info returned successfully"));
}
else
{
rp.setResponse(new ResponseObject("Community Info", true, "No communities returned"));
}
}
else // Get all public communities and all private communities to which the user belongs
{
// Set up the query
BasicDBObject queryTerm1 = new BasicDBObject("communityAttributes.isPublic.value", "true");
BasicDBObject queryTerm2 = new BasicDBObject("members._id", new ObjectId(userIdStr));
BasicDBObject queryTerm3 = new BasicDBObject("ownerId", new ObjectId(userIdStr));
BasicDBObject query = new BasicDBObject(MongoDbManager.or_, Arrays.asList(queryTerm1, queryTerm2, queryTerm3));
DBCursor dbc = DbManager.getSocial().getCommunity().find(query);
if ( dbc.count() > 0 )
{
List<CommunityPojo> communities = CommunityPojo.listFromDb(dbc, CommunityPojo.listType());
filterCommunityMembers(communities, isSysAdmin, userIdStr);
//add personal community
DBObject dbo = DbManager.getSocial().getCommunity().findOne(new BasicDBObject("_id",new ObjectId(userIdStr)));
if ( dbo != null )
{
communities.add(CommunityPojo.fromDb(dbo, CommunityPojo.class));
}
rp.setData(communities, new CommunityPojoApiMap());
rp.setResponse(new ResponseObject("Community Info", true, "Community info returned successfully"));
}
else
{
rp.setResponse(new ResponseObject("Community Info", true, "No communities returned"));