You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Philippe Poulard <Ph...@sophia.inria.fr> on 2005/08/08 10:42:45 UTC

[VFS] FallbackFileObject

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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [VFS] FallbackFileObject

Posted by Philippe Poulard <Ph...@sophia.inria.fr>.
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:john.doe@acme.com")
> 
> 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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [VFS] FallbackFileObject

Posted by Mario Ivankovits <ma...@ops.co.at>.
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:john.doe@acme.com")
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [VFS] FallbackFileObject

Posted by Philippe Poulard <Ph...@sophia.inria.fr>.
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:john.doe@acme.com")

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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [VFS] FallbackFileObject

Posted by Mario Ivankovits <ma...@ops.co.at>.
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org