You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@excalibur.apache.org by Maodo DIOP <md...@jouve.fr> on 2008/06/10 17:24:52 UTC

Request for excalibur bug for uri and protocol fle.

Hi Team developpers,

I have found a bug in the 
class*o**rg.apache.excalibur.source.impl.SourceResolverImpl * method 
*public Source resolveURI( String location, String baseURI,Map 
parameters ) *line *176-181* . which return the uri of a given file . 
But this uri is defined under OS platform where file protocol is 
"file:/" under Windows OS and without the slash under other plateforms 
which is a real bug according to me . We know that file protocol is 
"file:/" .
Here an example
Source mySource = resolver.resolveURI(myFile);
setSession("myFilewithUri",mySource.getUri());

When i get this variable String myFilename = (String 
)getSession("myFilewithUri");

int fileLength = myFilename.length();
To delete this file we must test the plateform which is not the aim of 
Java programming  "*W*rite *O*nce *R*un *A*nywhere" .

if(isUnderWindows()){
    //Get the real file without part of "file:/"
filename = filename.substring(URL_PREFIX_LEN,end);
}else{
//Get the real file without part of "file:" under other OS
 filename = filename.substring(URL_PREFIX_LEN-1,end);
}

where
 int end =  int *end *= filename.length() ; and
 private final static String URL_PREFIX = "file:/";
 private final static int *URL_PREFIX_LEN *= URL_PREFIX.length();

This is due to the *o**rg.apache.excalibur.source.impl.SourceResolverImpl *
methode *public Source resolveURI( String location, String baseURI,Map 
parameters )* line *176-181* .

String systemID = location;
       * // special handling for windows file paths*
        if( location.length() > 1 && location.charAt( 1 ) == ':' )
            systemID = "*file:/" + location;*
        else if( location.length() > 2 && location.charAt(0) == '/' && 
location.charAt(2) == ':' )
            systemID = *"file:" + location;


*What is your comments for ?*
*


Re: Request for excalibur bug for uri and protocol fle.

Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,

the url returned by the source is a url which should be treaded as such. 
You can create a new java.net.URL object with this string and then a 
File object using the url object.

HTH
Carsten

Maodo DIOP wrote:
> Hi Team developpers,
> 
> I have found a bug in the 
> class*o**rg.apache.excalibur.source.impl.SourceResolverImpl * method 
> *public Source resolveURI( String location, String baseURI,Map 
> parameters ) *line *176-181* . which return the uri of a given file . 
> But this uri is defined under OS platform where file protocol is 
> "file:/" under Windows OS and without the slash under other plateforms 
> which is a real bug according to me . We know that file protocol is 
> "file:/" .
> Here an example
> Source mySource = resolver.resolveURI(myFile);
> setSession("myFilewithUri",mySource.getUri());
> 
> When i get this variable String myFilename = (String 
> )getSession("myFilewithUri");
> 
> int fileLength = myFilename.length();
> To delete this file we must test the plateform which is not the aim of 
> Java programming  "*W*rite *O*nce *R*un *A*nywhere" .
> 
> if(isUnderWindows()){
>     //Get the real file without part of "file:/"
> filename = filename.substring(URL_PREFIX_LEN,end);
> }else{
> //Get the real file without part of "file:" under other OS
>  filename = filename.substring(URL_PREFIX_LEN-1,end);
> }
> 
> where
>  int end =  int *end *= filename.length() ; and
>  private final static String URL_PREFIX = "file:/";
>  private final static int *URL_PREFIX_LEN *= URL_PREFIX.length();
> 
> This is due to the *o**rg.apache.excalibur.source.impl.SourceResolverImpl *
> methode *public Source resolveURI( String location, String baseURI,Map 
> parameters )* line *176-181* .
> 
> String systemID = location;
>        * // special handling for windows file paths*
>         if( location.length() > 1 && location.charAt( 1 ) == ':' )
>             systemID = "*file:/" + location;*
>         else if( location.length() > 2 && location.charAt(0) == '/' && 
> location.charAt(2) == ':' )
>             systemID = *"file:" + location;
> 
> 
> *What is your comments for ?*
> *
> 


-- 
Carsten Ziegeler
cziegeler@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@excalibur.apache.org
For additional commands, e-mail: user-help@excalibur.apache.org