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

vincent-kali
Star Contributor
Star Contributor
additional comment: unlocking document from share UI works fine.

mrogers
Star Contributor
Star Contributor
you need to unlock the node first.

thanks for your response.
How to do that ? I thought it was made by removing the aspect lockable ….
Am'I wrong ?

mrogers
Star Contributor
Star Contributor
What you are doing is going behind the lock service.   You need to call unlock.   (And lock)

OK. I was starting to write a JS Web Script, but it seems that I need to write de Backend Web Script in Java to access the lock service,
which is NOT accessible in JS.
Could you please confirm this ?

Thanks for your help !

niketapatel
Star Contributor
Star Contributor
Yes, unlock a node api is available in js

You can use nodeRef.unlock() which internally uses - lockService().unlock(nodeRef)

vincent-kali
Star Contributor
Star Contributor
it works. thanks a lot !
do you know where to find an up to date documentation for js API ?
I checked out a lot of sites but never found anything regarding lockService in JS….
(http://wiki.alfresco.com/wiki/4.0_JavaScript_API, http://wiki.alfresco.com/wiki/4.0_JavaScript_Services_API……)

thanks,
Vincent


Yes, you are referring correct document but I think unlock() is not there in this wiki.

You can directly check  - ScriptNode.java too.

https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/repository/source/ja...

vincent-kali
Star Contributor
Star Contributor
Honestly I'm lost: In JS, calling nodeRef.unlock() works fine,
but calling nodeRef.lock("READ_ONLY_LOCK") throw exception

   org.springframework.extensions.webscripts.WebScriptException - 06180034 Cannot find function lock.
Does it make sense to implement unlock() without lock() ?

thanks for your help,
Vincent