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:

  1. User1 opens a document for editing. The document is locked for editing by User1.
  2. 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:

    WebDAV MS Office Merge dialog. User selects: Edit the file and merge your changes with the server file when it becomes available.

    User2 selects "Edit the file and merge your changes with the server file when it becomes available." option and edits the document.

  3. User1 saves and closes the document. The document ETag is updated and the document is unlocked.
  4. 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.

Important! During lock and unlock requests your file modification date should NOT change. If the file modification date changes and you have Protected View enabled, Microsoft Office displays the "File updated. <File> has been changed by another author." dialog:
 File Updated. file.docx has been changed by another author. Do you want to: Combine your changes with the other authors’ changes. All changes will be merged into a single document and marked up so that you can pick which individual changes to keep. Save a copy of file.docx. Your changes will be saved in a file separate from the other authors’ changes.

 

Next Article:

Java WebDAV Server Authentication