[VFS] FallbackFileObject

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[VFS] FallbackFileObject

Philippe Poulard
hi,

i have to deal with some schemes that are not necessary registered to
the VFS manager ; in fact, i don't really know in advance if an URI has
a scheme known by VFS

it would be kind if the manager had an option that can be turned on/off
and that dictates the behaviour when an unknown scheme is encountered :
-fire an exception (this is always the case)
-supply a FallbackFileObject (for which one can't access the content, of
course)

of course, it is possible to act outside from VFS, but it's a kind of
feature that could be part of VFS, isn't it ?

--
Cordialement,

            ///
           (. .)
  -----ooO--(_)--Ooo-----
|   Philippe Poulard    |
  -----------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [VFS] FallbackFileObject

Mario Ivankovits
Hi Philippe!

> i have to deal with some schemes that are not necessary registered to
> the VFS manager ; in fact, i don't really know in advance if an URI
> has a scheme known by VFS
>
...
> -supply a FallbackFileObject (for which one can't access the content,
> of course)
But what will you do with such kind of fileObject?

However. The DefaultFileSystemManager knows something like a
defaultProvider. You can override to default defaultProvider ;-) using
DefaultFileSystemManager.setDefaultProvider.
If you provide something like FallbackFileProvider you should be able to
return a FallbackFileObject.

The default defaultProvider is the UrlFileProvider, if you need its
functionality (which is guess you dont) you have to wrap it in your
FallbackFileObject.
Unhappily there is no getDefaultProvider now.

Might this fit your needs?

Ciao.
---
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [VFS] FallbackFileObject

Philippe Poulard
Mario Ivankovits wrote:

> Hi Philippe!
>
>> i have to deal with some schemes that are not necessary registered to
>> the VFS manager ; in fact, i don't really know in advance if an URI
>> has a scheme known by VFS
>>
> ...
>
>> -supply a FallbackFileObject (for which one can't access the content,
>> of course)
>
> But what will you do with such kind of fileObject?

this is used for example to retrieve resources in a catalog

>
> However. The DefaultFileSystemManager knows something like a
> defaultProvider. You can override to default defaultProvider ;-) using
> DefaultFileSystemManager.setDefaultProvider.
> If you provide something like FallbackFileProvider you should be able to
> return a FallbackFileObject.
>
> The default defaultProvider is the UrlFileProvider, if you need its
> functionality (which is guess you dont) you have to wrap it in your
> FallbackFileObject.
> Unhappily there is no getDefaultProvider now.
>
> Might this fit your needs?

in fact, the default FSM and the fallback FSM are not really the same :
the former is used when a file is expressed relatively (which denotes
that we are in a hierarchical URI), whereas the latter for absolute URIs
for which the scheme is not registered to VFS (that can be opaque URIs,
such as "urn:schemas-microsoft-com:office:office", or
"mailto:[hidden email]")

anyway, i understand that the tip is to set my own default provider,
that could use either the UrlFileProvider, or the FallbackFileProvider

thanks for your reply, Mario

--
Cordialement,

            ///
           (. .)
  -----ooO--(_)--Ooo-----
|   Philippe Poulard    |
  -----------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [VFS] FallbackFileObject

Mario Ivankovits
Hi!
> in fact, the default FSM and the fallback FSM are not really the same :
> the former is used when a file is expressed relatively (which denotes
> that we are in a hierarchical URI), whereas the latter for absolute
> URIs for which the scheme is not registered to VFS (that can be opaque
> URIs, such as "urn:schemas-microsoft-com:office:office", or
> "mailto:[hidden email]")
Thats not true. The defaultProvider is used if the filename do have a
scheme (thus is absolute) which is not known by VFS.

Extract from code:
        if (scheme != null)
        {
// An unknown scheme - hand it to the default provider
            if (defaultProvider == null)

(With the funny consequence that if you do not have commons-net in your
classpath ftp works (using default urlConnection) but with very limited
capabilities.)
   
So IMHO its clean to solve your need that way.

---
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [VFS] FallbackFileObject

Philippe Poulard
Mario Ivankovits wrote:

> Hi!
>
>> in fact, the default FSM and the fallback FSM are not really the same :
>> the former is used when a file is expressed relatively (which denotes
>> that we are in a hierarchical URI), whereas the latter for absolute
>> URIs for which the scheme is not registered to VFS (that can be opaque
>> URIs, such as "urn:schemas-microsoft-com:office:office", or
>> "mailto:[hidden email]")
>
> Thats not true. The defaultProvider is used if the filename do have a
> scheme (thus is absolute) which is not known by VFS.
>
> Extract from code:
>        if (scheme != null)
>        {
> // An unknown scheme - hand it to the default provider
>            if (defaultProvider == null)
>
> (With the funny consequence that if you do not have commons-net in your
> classpath ftp works (using default urlConnection) but with very limited
> capabilities.)
>   So IMHO its clean to solve your need that way.
>

ok, i understand that the error comes from UrlFileXXX (which is the
default that can't handle unknown schemes), not from the manager

my work will be much more simpler, now :)

thanks

--
Cordialement,

            ///
           (. .)
  -----ooO--(_)--Ooo-----
|   Philippe Poulard    |
  -----------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]