logger.error("Unable to update document without an ID: "+d);
return false;
}
mdq.requireID(md.getID());
BasicDBObjectBuilder bob = new BasicDBObjectBuilder();
if(md.isActionTouched()) {
bob.add(MongoDocument.ACTION_KEY, md.getAction().toString());
}
for(String s : md.getTouchedContent()) {
if(md.getContentField(s)!=null) {
bob.add(MongoDocument.CONTENTS_KEY+"."+s, md.getContentField(s));
}
}
for(String s : md.getTouchedMetadata()){
bob.add(MongoDocument.METADATA_KEY+"."+s, md.getMetadataField(s));
}
DBObject updateObject = getUpdateObject(bob.get());
updateObject.putAll(getUnsetObject(getNullFields(md)));
try {
WriteResult wr = documents.update(mdq.toDBObject(), updateObject, true, false, concern);
return wr.getN()==1;