List Info

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




Request for excalibur bug for uri and protocol fle.
user name
2008-06-10 10:24:52
Hi Team developpers,

I have found a bug in the classorg.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  "Write Once Run Anywhere" .

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 org.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.
user name
2008-06-10 10:36:29
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
cziegelerapache.org

------------------------------------------------------------
---------
To unsubscribe, e-mail: user-unsubscribeexcalibur.apache.org
For additional commands, e-mail: user-helpexcalibur.apache.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )