AnsweredAssumed Answered

[Solved] LockService : does it work?

Question asked by zomurn on Feb 27, 2009
Latest reply on Feb 27, 2009 by zomurn

According to the fact that lockService allow only lock and unlock methods on a nodeRef, it is supposed to be able to unlock whatever NodeRef that is lock or not.
So why with this code, my javascript return a number greater than zero?

Java code executed on all nodeRefs (~1300)

NB : the pUsername is the owner of the lock. I attempt to unlock wih the owner and with the admin…

private void unlockWith(final NodeRef pNodeRef, String pUsername) {

      System.out.println( "pUsername:" + pUsername );
      String lCurrentUsername = AuthenticationUtil.getCurrentUserName();
      System.out.println( "lCurrentUsername:" + lCurrentUsername );
      AuthenticationUtil.RunAsWork<Object> lWork = new AuthenticationUtil.RunAsWork<Object>() {

         public Object doWork() throws Exception {

            lockService.unlock( pNodeRef );
            return null;

      AuthenticationUtil.runAs( lWork, pUsername );
//maybe usefull
      AuthenticationUtil.runAs( lWork, "admin" );

      AuthenticationUtil.setCurrentUser( lCurrentUsername );
      System.out.println( "AuthenticationUtil.getCurrentUserName():"
            + AuthenticationUtil.getCurrentUserName() );

The javascript code

var query = "TYPE:\"msc:courrier\"";
   var nodes = search.luceneSearch(query);
   var i;
   var j =0;
   for (i = 0; i < nodes.length; i++)
      if (nodes[i].isLocked || nodes[i].isLockedOwner) {
   if (logger.isLoggingEnabled())
      logger.log("noeud lockes="+j);

If I launch java code (unlock all) and then javascript code (count number of lock), the output of javascript is still  greater than one (= 16 precisely).
So my question is simple : how to unlock a document ?