Findwise/Hydra — pull request #199 by remen (2013-04-15 09:12:01+00:00)
Title: Added support for "atomic" insert of documents with attachments

Hey,

Here's my suggestion of a fix for the race condition when adding documents with attachments. Basically, here's what's been done:

1) Changed signature of `DocumentWriter.insert` to:

```java
boolean insert(DatabaseDocument d, DocumentFile... attachments);
```

2) Changed corresponding implementation in `MongoDocumentIO` to set a metadata flag on the document to make `getAndTag` ignore it until all the attachments have been committed.

To understand the behaviour, I suggest looking at the new tests in `MongoDocumentIOTest`.

The other commits are basically a bit of cleaning to simplify the implementation.