You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by Meena Vyas <me...@sun.com> on 2002/06/19 18:07:47 UTC

error in PUT

	I am trying to LOCK a file and trying to do a PUT using the same user. I get the error at checkLock() method because  "slidetoken" doesn't have tokenID in its hashtable.  I guess I need to do call a addLockToken() in lock() method too just like it does in  unlock()... I am including both lock() and unlock() methods 


I suggest these two lines in lock() method in LockImpl.java

     if (slideToken.isEnforceLockTokens())
                    slideToken.addLockToken(lockId);

Let me know if I am right..

---------------------------------------
 public void lock(SlideToken slideToken, NodeLock token)^M
        throws ServiceAccessException, ObjectIsAlreadyLockedException,^M
        AccessDeniedException, ObjectNotFoundException {
      
       ...
        boolean canLock =^M
            !isLockedInternal(slideToken, token, true, nestedException);^M
       
        if (canLock) {^M
            ObjectNode lockedObject = objectUri.getStore()^M
                .retrieveObject(objectUri);^M
            securityHelper^M
                .checkCredentials(slideToken, lockedObject,^M
                                  namespaceConfig.getLockObjectAction());^M
            objectUri.getStore().putLock(objectUri, token);^M
        } else {
            throw nestedException;
        }

    }


 public void unlock(SlideToken slideToken, String objectUri,
                      String lockId)
        throws ServiceAccessException, LockTokenNotFoundException,
        ObjectNotFoundException {
        
        Enumeration locksList = enumerateLocks(slideToken, objectUri, false);
        while (locksList.hasMoreElements()) {
            NodeLock currentLock = (NodeLock) locksList.nextElement();
            if (currentLock.getLockId().equals(lockId)) {
                if (slideToken.isEnforceLockTokens())
                    slideToken.addLockToken(lockId);
                unlock(slideToken, currentLock);
            }
        }   
    }

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: error in PUT

Posted by Meena Vyas <me...@sun.com>.
Hi Remy,
       As you have written the LockImpl.java, Could you please let me know ? I am running Slide and Put is giving an error as explained below. Adding lock Token in slideToken (as I suggested earlier ) in lock() doesn't work because a new instance of SlideToken is created with every request (service method of Servlet) and this lock disappears in the next request (PUT) . Hence let me know what should I do..
Thanx a lot for your help,
Meena

Meena Vyas wrote:
> 
>         I am trying to LOCK a file and trying to do a PUT using the same user. I get the error at checkLock() method because  "slidetoken" doesn't have tokenID in its hashtable.  I guess I need to do call a addLockToken() in lock() method too just like it does in  unlock()... I am including both lock() and unlock() methods
> 
> I suggest these two lines in lock() method in LockImpl.java
> 
>      if (slideToken.isEnforceLockTokens())
>                     slideToken.addLockToken(lockId);
> 
> Let me know if I am right..
> 
> ---------------------------------------
>  public void lock(SlideToken slideToken, NodeLock token)^M
>         throws ServiceAccessException, ObjectIsAlreadyLockedException,^M
>         AccessDeniedException, ObjectNotFoundException {
> 
>        ...
>         boolean canLock =^M
>             !isLockedInternal(slideToken, token, true, nestedException);^M
> 
>         if (canLock) {^M
>             ObjectNode lockedObject = objectUri.getStore()^M
>                 .retrieveObject(objectUri);^M
>             securityHelper^M
>                 .checkCredentials(slideToken, lockedObject,^M
>                                   namespaceConfig.getLockObjectAction());^M
>             objectUri.getStore().putLock(objectUri, token);^M
>         } else {
>             throw nestedException;
>         }
> 
>     }
> 
>  public void unlock(SlideToken slideToken, String objectUri,
>                       String lockId)
>         throws ServiceAccessException, LockTokenNotFoundException,
>         ObjectNotFoundException {
> 
>         Enumeration locksList = enumerateLocks(slideToken, objectUri, false);
>         while (locksList.hasMoreElements()) {
>             NodeLock currentLock = (NodeLock) locksList.nextElement();
>             if (currentLock.getLockId().equals(lockId)) {
>                 if (slideToken.isEnforceLockTokens())
>                     slideToken.addLockToken(lockId);
>                 unlock(slideToken, currentLock);
>             }
>         }
>     }
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>