Hello Team,
I am using Alfresco Content Service Community 7.2.
I am checking out my node using java script api as below.
node.addAspect("cm:workingcopy");
node.properties["cm:workingCopyMode"] = "Check Out";
node.properties["cm:workingCopyLabel"] = label;
node.properties["cm:workingCopyOwner"] = user;
I wanted to cancel my Checked Out node so I am cancelling using below code
if (node.isLocked) node.removeAspect("cm:lockable");
if (node.hasAspect("cm:workingcopy")) node.removeAspect("cm:workingcopy");
node.Save();
And getting error
java.lang.UnsupportedOperationException: Use CheckOutCheckInservice to manipulate working copies.
So I changed my code to
if (node.isLocked) node.removeAspect("cm:lockable");
if (node.hasAspect("cm:workingcopy")) node.cancelCheckout();
node.Save();
And now I am getting below error.
CheckOutCheckInServiceException: 03131029 The original node cannot be found. Perhaps the copy has been corrupted or the original has been deleted or moved.
Do anyone have idea how to solve this issue?
You need to use the CheckOutCheckInService.
Changes are happening in a different node, named "workingCopy".
Following sample perform a "checkOut" operation on the original document, apply some changes on the working copy and replicate the changes in the original document.
var workingCopy = document.checkout(); workingCopy.content = 'updated text 1'; doc = workingCopy.checkin();
If you want to simply cancel the "checkOut", just apply the method to the working copy.
var workingCopy = document.checkout(); workingCopy.cancelCheckout();
Thank you @angelborroy , for your good response.
In my case it doesn't worked so I tried using below.
var webContext = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext(); var behaviourFilter = webContext.getBean("policyBehaviourFilter", org.alfresco.repo.policy.BehaviourFilter); behaviourFilter.disableAllBehaviours(); nodeRef.removeAspect("cm:workingCopy"); nodeRef.unlock(); behaviourFilter.enableAllBehaviours();
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.