02-28-2021 02:49 AM
I am trying to unlock node using cancel editing but due to some error, it is not getting unlock.
I am not able to perform any type of operation on that node.
How Can I forcefully unlock?
02-28-2021 08:28 PM
If you know how to create javascript webscript, you can inspire from this one:
var nodeId = url.templateArgs.id;
var workNode = null;
var workNodeStatus = null;
model.msg = "";
model.nodeId = nodeId;
workNode = search.findNode("node", ["workspace", "SpacesStore", nodeId]);
if (workNode != undefined) {
workNodeStatus = workNode.hasAspect("cm:lockable");
}
if (workNode == undefined) {
status.code = 404;
status.message = "Object " + nodeId + " not found.";
status.redirect = true;
}
if (workNode != undefined && workNodeStatus == true) {
workNode.properties["cm:lockOwner"]="admin";
workNode.unlock();
workNode.properties["cm:lockOwner"]="admin";
workNode.removeAspect("cm:lockable");
workNode.save();
delete workNode.properties["webdav:opaquelocktoken"];
delete workNode.properties["webdav:lockScope"];
delete workNode.properties["webdav:lockDepth"];
workNode.save();
model.msg = "is unlocked";
} else if (workNode != undefined && workNodeStatus == false) {
model.msg = "is not locked";
} else {
status.code = 500;
status.message = "Sorry, something went wrong. See log file.";
status.redirect = true;
}<webscript>
<shortname>Unlock document</shortname>
<description>Unlock document</description>
<url>/AdminTools/unlock/{id}</url>
<format default="xml">argument</format>
<authentication>user</authentication>
<transaction>required</transaction>
<cache>
<never>true</never>
</cache>
</webscript><?xml version="1.0" encoding="UTF-8"?>
<node>
<id>${nodeId?xml}</id>
<updated>${xmldate(date)}</updated>
<message>${msg}</message>
</node>
03-01-2021 10:40 AM
See if this is helpful, i had a similar issue so i documented the details here:
https://javaworld-abhinav.blogspot.com/2020/06/unlock-node-in-alfresco-which-could-not.html
Explore our Alfresco products with the links below. Use labels to filter content by product module.