04-13-2023 06:30 AM
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?
04-18-2023 03:25 AM
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();
04-24-2023 07:53 AM
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();
Explore our Alfresco products with the links below. Use labels to filter content by product module.