Ate Douma pushed to branch master at cms-community / hippo-repository
Commits: 0a576093 by Tobias Jeger at 2016-10-27T17:25:06+02:00 REPO-1597 Don't revert draft changes when already editing - - - - - 3 changed files: - workflow/src/main/resources/documentworkflow.scxml - workflow/src/main/resources/hippoecm-extension.xml - workflow/src/test/java/org/onehippo/repository/documentworkflow/integration/DocumentWorkflowEditTest.java Changes: ===================================== workflow/src/main/resources/documentworkflow.scxml ===================================== --- a/workflow/src/main/resources/documentworkflow.scxml +++ b/workflow/src/main/resources/documentworkflow.scxml @@ -142,26 +142,29 @@ <!-- target-less transition to 'obtain' an editable draft document variant by creating or updating a draft variant by copying (the contents of) the current unpublished variant if available or else the published variant --> <transition event="obtainEditableInstance"> - <if cond="!!unpublished"> - <!-- unpublished document exists: copy it to draft first --> - <hippo:copyVariant sourceState="unpublished" targetState="draft"/> - <elseif cond="!!published"/> - <!-- else if published document exists: first copy it to unpublished --> - <hippo:copyVariant sourceState="published" targetState="unpublished"/> - <if cond="live"> - <hippo:configVariant variant="published" availabilities="live"/> - <else/> - <hippo:configVariant variant="published" availabilities=""/> + <!-- copy/update draft unless user already is holder (editing) --> + <if cond="!editor"> + <if cond="!!unpublished"> + <!-- unpublished document exists: copy it to draft first, unless we're already editor --> + <hippo:copyVariant sourceState="unpublished" targetState="draft"/> + <elseif cond="!!published"/> + <!-- else if published document exists: first copy it to unpublished --> + <hippo:copyVariant sourceState="published" targetState="unpublished"/> + <if cond="live"> + <hippo:configVariant variant="published" availabilities="live"/> + <else/> + <hippo:configVariant variant="published" availabilities=""/> + </if> + <hippo:configVariant variant="unpublished" versionable="true" availabilities="preview"/> + <!-- create a JCR version of the published document via the unpublished variant --> + <hippo:version variant="unpublished"/> + <!-- now copy the unpublished variant to draft --> + <hippo:copyVariant sourceState="unpublished" targetState="draft"/> </if> - <hippo:configVariant variant="unpublished" versionable="true" availabilities="preview"/> - <!-- create a JCR version of the published document via the unpublished variant --> - <hippo:version variant="unpublished"/> - <!-- now copy the unpublished variant to draft --> - <hippo:copyVariant sourceState="unpublished" targetState="draft"/> + <!-- mark the draft document as modified, set the user as editor and remove possibly copied availabilities --> + <hippo:configVariant variant="draft" applyModified="true" setHolder="true" availabilities=""/> </if> - <!-- mark the draft document as modified, set the user as editor and remove possibly copied availabilities --> - <hippo:configVariant variant="draft" applyModified="true" setHolder="true" availabilities=""/> - <!-- store the newly created or updated draft document as result --> + <!-- store the (newly created or updated) draft document as result --> <hippo:result value="draft"/> </transition> ===================================== workflow/src/main/resources/hippoecm-extension.xml ===================================== --- a/workflow/src/main/resources/hippoecm-extension.xml +++ b/workflow/src/main/resources/hippoecm-extension.xml @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> -<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="hippo:initialize"> +<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:h="http://www.onehippo.org/jcr/xmlimport" sv:name="hippo:initialize"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>hippo:initializefolder</sv:value> </sv:property> @@ -565,5 +565,20 @@ <sv:value>4.0.0</sv:value> </sv:property> </sv:node> + <!-- Update workflow definition to fix REPO-1597, should be turned into reload-on-startup when we release 12.0 --> + <sv:node sv:name="hipposcxml-scxml-configuration-documentworkflow-delta"> + <sv:property sv:name="jcr:primaryType" sv:type="Name"> + <sv:value>hippo:initializeitem</sv:value> + </sv:property> + <sv:property sv:name="hippo:sequence" sv:type="Double"> + <sv:value>603.0</sv:value> + </sv:property> + <sv:property sv:name="hippo:contentroot" sv:type="String"> + <sv:value>/hippo:configuration/hippo:modules/scxmlregistry/hippo:moduleconfig/hipposcxml:definitions/documentworkflow/hipposcxml:source</sv:value> + </sv:property> + <sv:property sv:name="hippo:contentpropset" sv:type="String"> + <sv:value h:file="documentworkflow.scxml"/> + </sv:property> + </sv:node> </sv:node> ===================================== workflow/src/test/java/org/onehippo/repository/documentworkflow/integration/DocumentWorkflowEditTest.java ===================================== --- a/workflow/src/test/java/org/onehippo/repository/documentworkflow/integration/DocumentWorkflowEditTest.java +++ b/workflow/src/test/java/org/onehippo/repository/documentworkflow/integration/DocumentWorkflowEditTest.java @@ -16,6 +16,7 @@ package org.onehippo.repository.documentworkflow.integration; import javax.jcr.Node; +import javax.jcr.Session; import javax.jcr.UnsupportedRepositoryOperationException; import javax.jcr.Value; import javax.jcr.version.VersionHistory; @@ -36,6 +37,7 @@ import static org.hippoecm.repository.HippoStdNodeType.DRAFT; import static org.hippoecm.repository.HippoStdNodeType.HIPPOSTD_STATE; import static org.hippoecm.repository.HippoStdNodeType.UNPUBLISHED; import static org.hippoecm.repository.HippoStdNodeType.PUBLISHED; +import static org.hippoecm.repository.HippoStdPubWfNodeType.HIPPOSTDPUBWF_LAST_MODIFIED_BY; import static org.hippoecm.repository.api.HippoNodeType.HIPPO_AVAILABILITY; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -115,4 +117,16 @@ public class DocumentWorkflowEditTest extends AbstractDocumentWorkflowIntegratio assertFalse((Boolean) workflow.hints().get("obtainEditableInstance")); } + @Test + public void holderObtainsEditiableInstanceAsSaved() throws Exception { + Session anotherAdmin = session.impersonate(CREDENTIALS); + DocumentWorkflow workflow = getDocumentWorkflow(handle); + final Node draft = workflow.obtainEditableInstance().getNode(session); + assertEquals(SYSTEMUSER_ID, draft.getProperty(HIPPOSTDPUBWF_LAST_MODIFIED_BY).getString()); + draft.setProperty(HIPPOSTDPUBWF_LAST_MODIFIED_BY, "test-user"); + session.save(); + DocumentWorkflow anotherWorkflow = getDocumentWorkflow(anotherAdmin.getNodeByIdentifier(handle.getIdentifier())); + final Node anotherDraft = anotherWorkflow.obtainEditableInstance().getNode(anotherAdmin); + assertEquals("test-user", anotherDraft.getProperty(HIPPOSTDPUBWF_LAST_MODIFIED_BY).getString()); + } } View it on GitLab: https://code.onehippo.org/cms-community/hippo-repository/commit/0a5760938727b1a76bc954e8a98d35fb485509ba
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn