sakaiproject/nakamura — pull request #745 by mrvisser (2012-04-16 20:55:35+00:00)
Title: KERN-2771 Creating a special operation for publishing sakaidoc pages

The solution to this, to avoid having to muck with the Sparse move and versioning logic, is done at a higher level (SparsePostOperation). The operation "SakaiDocPagePublishOperation" wraps the MoveOperation like so:

1. Store a path in memory to all sakai/message nodes ("Collection B") in the draft (tmp_id*) space that have been modified (i.e., their _created != _lastModified)
2. Store a record in memory of each sakai/message node ("Collection A") in the live (id*) space (stores its path and properties)
3. Perform the standard move operation
4. For each node in "Collection A"
4.1 If its path is in Collection B (i.e., the message was edited in the draft space), do not replace it -- this message has now effectively been clobbered by the message in draft space.
4.2 If its path is NOT in Collection B (i.e., the message was not edited in the draft space), replace the current live node with the one in Collection A -- the draft message has effectively not been published at all.

The above algorithm assures the following:

1. If a message is edited in draft space, that edit will always get published to live space
2. If no messages in draft space have been touched, publishing a page should *never* result in changes to the live messages (majority case, I think)
3. Any messages that are added while the page is in edit mode will not be removed when the page is published

This is a sample cURL command to run the new operation:

curl -u admin:admin --referer "http://localhost:8080/" http://localhost:8080/p/l3H5csVMaa/tmp\_id4461590 \
-F:operation="publish-sakaidoc-page" \
-F:dest="/p/l3H5csVMaa/id4461590" \
-F:replace="true" \
-F_charset="utf-8"