Source inputSource = null;
try {
inputSource = this.resolver.resolve(directory);
String systemId = inputSource.getSystemId();
if (!systemId.startsWith(FILE)) {
throw new ResourceNotFoundException(systemId + " does not denote a directory");
}
// This relies on systemId being of the form "file://..."
File directoryFile = new File(new URL(systemId).getFile());
if (!directoryFile.isDirectory()) {
throw new ResourceNotFoundException(directory + " is not a directory.");
}
this.contentHandler.startDocument();
this.contentHandler.startPrefixMapping(PREFIX,URI);
Stack ancestors = getAncestors(directoryFile);
addPathWithAncestors(directoryFile, ancestors);
this.contentHandler.endPrefixMapping(PREFIX);
this.contentHandler.endDocument();
} catch (IOException ioe) {
getLogger().warn("Could not read directory " + directory, ioe);
throw new ResourceNotFoundException("Could not read directory "
+ directory, ioe);
} finally {
if (inputSource != null) inputSource.recycle();
}
}