Implementing Microsoft Office Merging in Java WebDAV Server
Microsoft Office can merge changes with updates made by other user(s). Here is how merging works:
- User1 opens a document for editing. The document is locked for editing by User1.
-
User2 opens same document for editing. As soon as the document is locked by User1, the server throws LockedException in Lock.lock() method implementation:
@Override public LockResult lock(...){ if (/* item is locked */) { throw new LockedException(); } ... }
The server replies with 423, "Locked", code. User2 is presented with the following dialog:
User2 selects "Edit the file and merge your changes with the server file when it becomes available." option and edits the document.
- User1 saves and closes the document. The document ETag is updated and the document is unlocked.
- User2 saves the document. The document is locked by User2. The WebDAV server automatically compares ETag associated with a document with ETag sent by User2. If they do not match, the documents are automatically merged by MS Office or a merging UI is presented by MS Office.