When you create a WebdavResource there is a ctor with an action
parameter, there is also a setDefaultAction() method.  An action of
WebdavResource.NOACTION will prevent any lookups from occurring and as a
side effect, make many of the WebdavResource property tests no longer
function.
I use the NOACTION parameter almost exclusively because I don't like the
problems I had with the alternative and I don't want to query the server
multiple times if I need additional properties.  It would be possible to
modify (heavily) the WebdavResource class to get the best of both
worlds, behind the scenes property population on demand with no overhead
if you don't use them but I have never had the time to pursue it.  

A note on existence checking. I accomplish my existence checks by
reading a standard property, in my case DISPLAY_NAME, and trap any
errors that occur when it is not found.  If the property doesn't exist
for the path, then the object doesn't exist.  It is not wise to use this
as a form of duplicate checking prior to a create operation, because the
create could still fail due to a duplicate exception.  

-----Original Message-----
From: Lixin Chu [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 22, 2006 8:52 PM
To: Slide Users Mailing List
Subject: Re: How to test is a folder exists ?

Hi Ray,

>>You can tell WebdavResource not to do the default lookups,
How do I do this ? I went through the API but did not find something
close to do this.

>>but you end up having other problems in that case.
Can I set to 'do not load property' before calling setPath(), then set
to 'load property' before calling exists() ?

thanks
lixin


On 3/21/06, Ray Sprinkle <[EMAIL PROTECTED]> wrote:
> By default a WebdavResource loads a set of properties from the server 
> when it is created or the path is changed.  I believe you are having 
> problems with this behaviour.  You can tell WebdavResource not to do 
> the default lookups, but you end up having other problems in that
case.
> Many/most of the properties of WebdavResource are set behind the 
> scenes using these default property lookups, including exists().
> WebdavResource will not dynamically load the needed properties to 
> calculate things, but instead depends on the properties being loaded 
> ahead of time.  If you don't load the properties you get invalid 
> answers.
>
> -----Original Message-----
> From: Lixin Chu [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 20, 2006 7:11 PM
> To: Slide Users Mailing List; [EMAIL PROTECTED]
> Subject: Re: How to test is a folder exists ?
>
> Hi,
> I forgot to put this but the problem is that setPath() throws 
> HttpException already the folder does not exist.
>
> rgds
> lixin
>
> On 3/19/06, Marco Ferretti <[EMAIL PROTECTED]> wrote:
> >
> > On Sunday 19 March 2006 09:24, Lixin Chu wrote:
> > > How to test is a folder exists ?
> > >
> > > I try to use webdavResource.setPath (path) and then
> > webdavResource.exists()
> > >
> > > but setPath throws HttpException with reason code 404. is this the

> > > only way to  know if a folder does not exit:
> > >
> > >   try {
> > >          webdavResource.setPath (path);
> > >   } catch (HttpException he) {
> > >          if (he.getReasonCode() == 404) {
> > >             // create the folde here ...
> > >          }
> > >   }
> > >
> > > thanks !
> > > lx
> > >
> > > ------------------------------------------------------------------
> > > --
> > > - To unsubscribe, e-mail: 
> > > [EMAIL PROTECTED]
> > > For additional commands, e-mail: 
> > > [EMAIL PROTECTED]
> >
> > you forgot to query the exists() method of WebdavResource ;
> >
> > so your code shall look like :
> >
> >
> >           webdavResource.setPath (path);
> >           if (webdavResource.exists()){
> >                 // do something
> >           } else {
> >                 // do something else
> >           }
> >
> >
> > cheers
> >
> > Marco
> > --
> > A Tale of Two Cities LITE(tm)
> >         -- by Charles Dickens
> >
> >         A man in love with a girl who loves another man who looks
just
> >         like him has his head chopped off in France because of a
mean
> >         lady who knits.
> >
> > Crime and Punishment LITE(tm)
> >         -- by Fyodor Dostoevski
> >
> >         A man sends a nasty letter to a pawnbroker, but later
> >         feels guilty and apologizes.
> >
> > The Odyssey LITE(tm)
> >         -- by Homer
> >
> >         After working late, a valiant warrior gets lost on his way
> home.
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to