//public void save(T doc)
public void save(BasicDBObject doc)
throws DBException
{
Object id = doc.get("_id");
final WriteResult result;// = null;
if (id == null)
{
logger.info("null ID - inserting as new object");
result = collection.insert(doc);
logger.info(result.toString());
}
else
{
logger.info("Non null ID - updating existing object");
BasicDBObject query = new BasicDBObject();
query.put("_id", id);
result = collection.update(query, doc);
logger.info(result.toString());
}
// System.out.println("N: "+result.getN());
if (result.getError() != null)
{
throw new DBException("Failed to insert/update object: "+
result.getError()+ ", N:" + result.getN());
}
}