You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-user@jakarta.apache.org by Elodie Tasia <e....@ever-team.com> on 2002/04/02 16:05:46 UTC

Lock and Unlock

Hi,

I'm implementing the lock/unlock mechanism using the Slide client API.
When I lock a resource with a given user and a given timeout, and if I want to unlock it, the api doesn't see that the user is the same : it says that the resource is locked (code 423), but in the code, it finds a lock value null in this part of the unlockMethod :

        setClient();
        // Get the lock for the given path.
        WebdavState state = (WebdavState) client.getState();
        // Check the given path is alright.
        path = HttpURL.getPath(path);
        String lock = state.getLock(path);
        if (lock == null)
            return false;    // so it stops there

Can someone tell me why ?
How can I 'keep' the lock to be sure I can unlock a resource ?

Thanx

Re: Lock and Unlock

Posted by Elodie Tasia <e....@ever-team.com>.
> Elodie,
>          I found it necessary to use the same WebdavResource to lock,
> upadate, and then unlock the resource or I got a similar error.
What you mean is that I must use the same instance of WebdavResource to lock
and unlock ?


>  Here a
> code fragment that demonstrates my solution,
>
>      SDRFrame.startAnimation();
>      try {
>        if(resourceExists_) {
>          oldResource_.lockMethod();
>          result = oldResource_.putMethod(file_);
>        } else {
>          result = web_.putMethod(path_, file_);
>        }
>
>        if(result) {
>          PropertyChangeEvent pce = new PropertyChangeEvent(rNode_,
> "childAdded", Boolean.FALSE, Boolean.TRUE);
>          changes_.firePropertyChange(pce);
>        } else {
>          JOptionPane.showMessageDialog(resource_, web_.getStatusMessage(),
>                                        "Put operation failed",
>                                        JOptionPane.ERROR_MESSAGE);
>        }
>        if(resourceExists_) oldResource_.unlockMethod();
>      } catch (IOException ioe) {
>        ioe.printStackTrace();
>      } catch (HttpException he) {
>        he.printStackTrace();
>      } finally {
>        SDRFrame.stopAnimation();
>      }
>
Mmmmh, soory, I didn't tried nor understood your demonstration. What result
do you have with that ?


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


Re: Lock and Unlock

Posted by Elodie Tasia <e....@ever-team.com>.
OK, so, I just have to understand your code, now, Mr Denbo ;o)
What I've understood it that you wait for an event before unlocking, isn't
it ?
But could you tell me was is that rNode ? I don't where it comes from...

Thanx



>
>      SDRFrame.startAnimation();
>      try {
>        if(resourceExists_) {
>          oldResource_.lockMethod();
>          result = oldResource_.putMethod(file_);
>        } else {
>          result = web_.putMethod(path_, file_);
>        }
>
>        if(result) {
>          PropertyChangeEvent pce = new PropertyChangeEvent(rNode_,
> "childAdded", Boolean.FALSE, Boolean.TRUE);
>          changes_.firePropertyChange(pce);
>        } else {
>          JOptionPane.showMessageDialog(resource_, web_.getStatusMessage(),
>                                        "Put operation failed",
>                                        JOptionPane.ERROR_MESSAGE);
>        }
>        if(resourceExists_) oldResource_.unlockMethod();
>      } catch (IOException ioe) {
>        ioe.printStackTrace();
>      } catch (HttpException he) {
>        he.printStackTrace();
>      } finally {
>        SDRFrame.stopAnimation();
>      }
>
>
> At 04:05 PM 4/2/2002 +0200, you wrote:
> >Hi,
> >
> >I'm implementing the lock/unlock mechanism using the Slide client API.
> >When I lock a resource with a given user and a given timeout, and if I
> >want to unlock it, the api doesn't see that the user is the same : it
says
> >that the resource is locked (code 423), but in the code, it finds a lock
> >value null in this part of the unlockMethod :
> >
> >         setClient();
> >         // Get the lock for the given path.
> >         WebdavState state = (WebdavState) client.getState();
> >         // Check the given path is alright.
> >         path = HttpURL.getPath(path);
> >         String lock = state.getLock(path);
> >         if (lock == null)
> >             return false;    // so it stops there
> >
> >Can someone tell me why ?
> >How can I 'keep' the lock to be sure I can unlock a resource ?
> >
> >Thanx
>
> ==================================================
> Donald W. Denbo    dwd@pmel.noaa.gov
> Ph: (206) 526-4487   Fax: (206) 526-6744
> Collaborative tools: http://www.epic.noaa.gov/collab/
> Netcdf Browser: http://www.epic.noaa.gov/java/ncBrowse
> Scientific Java Graphics: http://www.epic.noaa.gov/java/sgt
> EPIC Oceangraphic Data Management: http://www.pmel.noaa.gov/epic
> ==================================================
>
>
> --
> 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>


Re: Lock and Unlock

Posted by Donald Denbo <dw...@pmel.noaa.gov>.
Elodie,
         I found it necessary to use the same WebdavResource to lock, 
upadate, and then unlock the resource or I got a similar error.  Here a 
code fragment that demonstrates my solution,

     SDRFrame.startAnimation();
     try {
       if(resourceExists_) {
         oldResource_.lockMethod();
         result = oldResource_.putMethod(file_);
       } else {
         result = web_.putMethod(path_, file_);
       }

       if(result) {
         PropertyChangeEvent pce = new PropertyChangeEvent(rNode_, 
"childAdded", Boolean.FALSE, Boolean.TRUE);
         changes_.firePropertyChange(pce);
       } else {
         JOptionPane.showMessageDialog(resource_, web_.getStatusMessage(),
                                       "Put operation failed",
                                       JOptionPane.ERROR_MESSAGE);
       }
       if(resourceExists_) oldResource_.unlockMethod();
     } catch (IOException ioe) {
       ioe.printStackTrace();
     } catch (HttpException he) {
       he.printStackTrace();
     } finally {
       SDRFrame.stopAnimation();
     }


At 04:05 PM 4/2/2002 +0200, you wrote:
>Hi,
>
>I'm implementing the lock/unlock mechanism using the Slide client API.
>When I lock a resource with a given user and a given timeout, and if I 
>want to unlock it, the api doesn't see that the user is the same : it says 
>that the resource is locked (code 423), but in the code, it finds a lock 
>value null in this part of the unlockMethod :
>
>         setClient();
>         // Get the lock for the given path.
>         WebdavState state = (WebdavState) client.getState();
>         // Check the given path is alright.
>         path = HttpURL.getPath(path);
>         String lock = state.getLock(path);
>         if (lock == null)
>             return false;    // so it stops there
>
>Can someone tell me why ?
>How can I 'keep' the lock to be sure I can unlock a resource ?
>
>Thanx

==================================================
Donald W. Denbo    dwd@pmel.noaa.gov
Ph: (206) 526-4487   Fax: (206) 526-6744
Collaborative tools: http://www.epic.noaa.gov/collab/
Netcdf Browser: http://www.epic.noaa.gov/java/ncBrowse
Scientific Java Graphics: http://www.epic.noaa.gov/java/sgt
EPIC Oceangraphic Data Management: http://www.pmel.noaa.gov/epic
==================================================


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