Hi all,
I'm testing an adapted version of org.restlet.example.tutorial.Part06 to
make it display a directory listing of my home directory
The changed part looks like this:
// Create an application
Application application = new Application(component.getContext()) {
@Override
public Restlet createRoot() {
final Directory directory = new Directory(getContext(),
"file:///home/mpo");
directory.setListingAllowed(true);
directory.setIndexName("");
return directory;
}
};
I'm running this on a linux system with a symbolic link in /home/mpo/mnt
to /mnt
This symbolic link outside the directory-resources' root will cause a
StringIndexOutOfBound on trying to make 'external' uri's for the
local-references assembled in this.directoryContent:
Since that contains file:////mnt rather then file:////home/mpo/mnt
substracting the root-uri fails:
SEVERE: Unhandled exception or error intercepted
java.lang.StringIndexOutOfBoundsException: String index out of range: -2
at java.lang.String.substring(String.java:1768)
at java.lang.String.substring(String.java:1735)
at
com.noelios.restlet.local.DirectoryResource.getVariants(DirectoryResource.java:445)
at org.restlet.resource.Resource.handleGet(Resource.java:407)
at
com.noelios.restlet.local.DirectoryResource.handleGet(DirectoryResource.java:254)
The problem is resolved by changing the method at
org.restlet.data.LocalReference#86
public static LocalReference createFileReference(File file)
throws IOException {
return createFileReference(file.getCanonicalPath());
}
by replacing the 'getCanonicalPath' to 'getAbsolutePath'
AFAICS making the reference 'canonical' is outside the responsibility of
the LocalReference class, but I might be jumping to conclusions here.
kind regards,
-marc=