On Sun, Jan 30, 2011 at 3:50 PM, Gazi Mushfiqur Rahman <[email protected]> wrote: > After debugging for long long time, I found out the real problem. Actually > there's a bug in the org.apache.jackrabbit.core.lock.LockInfo class of the > '2.1.1' version of0 'jackRabbit-core' module, which is used in the latest > sling builds. > > The bug is very simple. The logic of 'isExpired()' method is wrong (just > revers). As a result after locking any non session scope lock on some node, > the node is automatically unlocked by the 'LockManager'. So, I tried to > modify the source of LockInfo in jackrabbit-core, build it again and then > rebuild Sling. But it seems not to be working. > > Jackrabbit team already resolved this issue on their latest version, i.e. > 2.2.2. So can anyone please update the jackrabbit version for Sling or just
please post your request on the sling list. cheers stefan > fix this issue or let me know how to build and integrate jackrabbit-core in > Sling? > > Any help will be much appreciated. > > Thanks & Regards. > > On Tue, Jan 25, 2011 at 9:18 PM, Gazi Mushfiqur Rahman < > [email protected]> wrote: > >> Hi all, >> >> I am facing a problem on locking a node or resource. I am using Jackrabbit >> from Apache Sling and I have the following code (esp file) to lock a node: >> >> >> <!DOCTYPE html> >> <% >> var session = >> request.getResourceResolver().adaptTo(Packages.javax.jcr.Session);; >> var wasLockableNode = currentNode.isNodeType("mix:lockable"); >> if (!wasLockableNode) { >> currentNode.addMixin("mix:lockable"); >> session.save(); >> } >> var lockOwner = null; >> var workspace = session.workspace; >> var lockManager = workspace.lockManager; >> var wasLocked = lockManager.isLocked(currentNode.path); >> var locked = false; >> if (!wasLocked) { >> var lock = lockManager.lock(currentNode.path, true, false, 120, >> lockOwner); >> lockManager.addLockToken(lock.lockToken); >> locked = true; >> } else { >> var lock = lockManager.getLock(currentNode.path); >> } >> session.save(); >> %> >> <html> >> <head> >> <title><%= currentNode.title %> is locked: <%= locked %></title> >> </head> >> <body> >> <p> >> Is Locking Supported by Repository <%= >> session.repository.getDescriptorValue(session.repository.OPTION_LOCKING_SUPPORTED).string >> %><br /> >> Is Locked <%= locked %><br /> >> Lock Owner: <span id="owner"><%= lock.lockOwner %></span><br/> >> Lock Token: <span id="token"><%= lock.lockToken %></span><br /> >> Is Deep: <span id="deep"><%= lock.deep %></span><br /> >> Is Session Scoped: <span><%= lock.sessionScoped %></span><br /> >> Is Current Session Owning Lock: <span >> id="isLockOwningSession"><%= lock.lockOwningSession %></span><br/> >> Was lockable node: <%= wasLockableNode %><br /> >> Was Locked: <%= wasLocked %><br /> >> Remaining Seconds for the Lock <%= lock.secondsRemaining %><br >> /> >> Current Lock Tokens: <%= >> Packages.java.util.Arrays.toString(lockManager.lockTokens) %><br /> >> </p> >> </body> >> </html> >> >> After executing the above script, I find that the node was locked. But if I >> execute the following script just after executing the previous one, I find >> that node ia not locked!: >> <code> >> <!DOCTYPE html> >> <html> >> <head> >> <title><%= currentNode.title %></title> >> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> >> >> </head> >> <body> >> <h1><%= currentNode.title %></h1> >> <p> >> Title: <span id="title"><%= currentNode.title %></span><br /> >> Is Locked: <span id="locked"><%= currentNode.locked %></span><br /> >> </p> >> </body> >> </html> >> </code> >> >> Can anyone help me to find out the problem in my code or give me suggestion >> on how to implement locking on nodes using Sling? >> >> Thanks & Regards. >> >> >
