Request for excalibur bug for uri and protocol fle.

View: New views
2 Messages — Rating Filter:   Alert me  

Request for excalibur bug for uri and protocol fle.

by Maodo DIOP :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

by Carsten Ziegeler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...

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

LightInTheBox - Buy quality products at wholesale price