cancel
Showing results for 
Search instead for 
Did you mean: 

removeAspect('cm:lockable') failed

vincent-kali
Star Contributor
Star Contributor
Hi all,
I've created a Web Script to lock/unlock files.
File locking is working fine:

if (!nodeRef.hasAspect("cm:lockable"))
   {// not already locked
   var properties = new Array(2);
   properties["cm:lockType"] = "READ_ONLY_LOCK";
   properties["cm:lockOwner"] = "admin";
   if (nodeRef.addAspect("cm:lockable", properties))
      {//node successfully locked
      nodeRef.save;
      …

But I can't unlock the document using nodeRef.removeAspect("cm:lockable"), because … the document is locked !

org.mozilla.javascript.WrappedException: Wrapped org.alfresco.service.cmr.lock.NodeLockedException: 06150419 Cannot perform operation since the node (id:829a6498-8901-4897-8945-9dad57f9997b) is locked. (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/rLockService.get.js#70)
        at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1757)
        at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:170)
        at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
        at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
        at org.mozilla.javascript.gen.c93._c0(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/rLockService.get.js:70)
        at org.mozilla.javascript.gen.c93.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/rLockService.get.js)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at org.mozilla.javascript.gen.c93.call(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/rLockService.get.js)
        at org.mozilla.javascript.gen.c93.exec(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/rLockService.get.js)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:502)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:200)
        at org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:212)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:174)
        at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)

Any idea ?

Thanks for your help,
Vincent


13 REPLIES 13

kaynezhang
World-Class Innovator
World-Class Innovator
ScriptNode object dose not have lock function,only has unlock function.

vincent-kali
Star Contributor
Star Contributor
Thanks for your help !!
I'm finally having some trouble when trying to lock "manually" by adding aspects and properties.
In case lifetime is PERSISTENT, I can't succeed to set expiryDate to null….Still working on it,
I'll post updates here.
Any advice are welcomed.
Vincent



Hi Vincent,

could you please share the js which you used for unlocking the document. My requirement is sending document from scanner to alfresco by mentioning path in scanner console. its getting uploaded in alfresco. but its getting locked by default by the user mentioned for scanning purpose.

You can unlock the document using ScriptNode API.

On node object in your javascript you can directly call unlock() method to unlock your locked document.

For example.


node.unlock()