-2

I have managed document named 123456.xml and I am trying to update it with dls library function as below,

declare variable $uri:= "/abc/123456_xml_versions/1-123456.xml";

dls:document-is-managed($uri),
dls:document-checkout-update-checkin($uri, $xml, 'Update', fn:true())

Above script snip is throwing below exception,

[1.0-ml] DLS-DOCUMENTVERSION: (err:FOER0000) Cannot update or checkout document version /abc/123456_xml_versions/1-123456.xml

This is an existing migration operation of the application which is updating all versions of the document.

Mike Gardner
  • 6,611
  • 5
  • 24
  • 34
IAM
  • 11
  • 4

3 Answers3

1

Don't give DLS functions URIs from the versions directory. Those URIs are managed by DLS. Just give it the canonical URI of the document you want to update, and DLS will automatically increment the version for you:

declare variable $uri:= "/abc/123456/123456.xml";
...
wst
  • 11,681
  • 1
  • 24
  • 39
  • In the existing working application, there are some MarkLogic migration scripts written such a way that, it iterates through all the documents and perform a common update. Those scripts were written for MarkLogic 7 and I am trying to run those on MarkLogic 10. – IAM Jul 25 '19 at 18:18
  • Let me give a brief history, `xdmp:document-insert` preserve the document in the managed document collection in MarkLogic 7 during the update process. As per discussion with @rob-s he recommended to use `dls:document-checkout-update-checkin` to maintain that document in collection in MarkLogic 10. – IAM Jul 25 '19 at 18:20
  • 1
    @IAM It sounds like your script modifies DLS-managed data and/or misuses the public API. Undefined behavior like this following a major version change should not come as a surprise. – wst Jul 25 '19 at 18:29
0
dls:document-checkout-update-checkin($uri, , 'Update', fn:true())

The second parameter should be the document node you are replacing the existing document with.

You may also want to check dls:document-checkout-status to see if another user currently has the document checked out.

Rob S.
  • 3,599
  • 6
  • 30
  • 39
  • Rob, there is XML document present as a second parameter but not showing in UI. There is no way here to share a screen shot. – IAM Jul 25 '19 at 18:13
0

I recommend that you study, fully understand (or ask for support if you do not) and implement the procedures here https://docs.marklogic.com/guide/relnotes/chap4#id_65479 prior to any work with DLS documents after an ML update (from V8- to 9+). DLS V9 ships out of the box INCOMPATIBLE with prior versions until you perform the upgrade. The upgrade is NOT performed automatically, and the symptoms of not upgrading or partial upgrade may not be noticed (at first). There is good detail on the new functions for checking the status of all your DLS documents. These are useful even after you upgrade to validate that the required permissions, properties and collections are still intact.

Then I encourage you to study the architecture and procedures for working with DLS documents. Anything outside of these procedures is not supported, and very tricky to get right (which is why its not supported). Note that you may find doing a bulk checkout , then update then bulk check in works better for your use case then the one-shot document-checkout-insert-checkin. Also note the permission and index requirements for DLS documented.

DALDEI
  • 3,722
  • 13
  • 9