if (!dbPresent) {
throw new DatabaseException(ErrorCodes.DB_DOES_NOT_EXISTS, "DB with name '" + dbName + "' DOES NOT EXIST");
}
DB db = mongoInstance.getDB(dbName);
CommandResult stats = db.getStats();
Set<String> keys = stats.keySet();
Iterator<String> keyIterator = keys.iterator();
while (keyIterator.hasNext()) {
JSONObject temp = new JSONObject();
String key = keyIterator.next();
temp.put("Key", key);
String value = stats.get(key).toString();
temp.put("Value", value);
String type = stats.get(key).getClass().toString();
temp.put("Type", type.substring(type.lastIndexOf('.') + 1));
dbStats.put(temp);
}
} catch (MongoException m) {
throw new DatabaseException(ErrorCodes.GET_DB_STATS_EXCEPTION, m.getMessage());