Home

removeAspect("cm:lockable") failed

You are here

12 posts / 0 new
Last post
removeAspect("cm:lockable") failed

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

4.2.e

Vincent.

additional comment: unlocking

additional comment: unlocking document from share UI works fine.

Vincent.

you need to unlock the node

you need to unlock the node first.

Senior Software Engineer
Alfresco

thanks for your response.

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

Vincent.

What you are doing is going

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

Senior Software Engineer
Alfresco

OK. I was starting to write a

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 !

Vincent.

Yes, unlock a node api is

Yes, unlock a node api is available in js

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

Niketa Patel
Senior Alfresco Consultant
CIGNEX Datamatics

Blog:http://niketa-alfresco3.blogspot.in/

it works. thanks a lot !

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

Vincent.

Yes, you are referring

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/java/org/alfresco/repo/jscript/ScriptNode.java

Niketa Patel
Senior Alfresco Consultant
CIGNEX Datamatics

Blog:http://niketa-alfresco3.blogspot.in/

Honestly I'm lost: In JS,

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

Vincent.

ScriptNode

ScriptNode object dose not have lock function,only has unlock function.

If this post was helpful, please click Yes on the Post Rating

Thanks for your help !!

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

Vincent.