Upayavira wrote:
Sounds like a reasonable case for a patch to the DirectoryGenerator.
Anyone fancy creating one?
The code change required is at the bottom (it's a 1-liner).
Semantically, the old code said
/**************************************/
If the resolved file is Not a directory:
Throw a ResourceNotFoundException
/**************************************/
My version says:
/**************************************/
If the resolved file is Not a directory
Try using the configuration string verbatim (i.e. don't run it
through the resolver)
IF that doesn't work:
Throw a ResourceNotFoundException
/**************************************/
This works for fully resolved network paths. The correct solution would
be to change the MutableEnvironmentFacade to correctly resolve the name.
However, my knowledge of Cocoon is not sufficient to be able to assess
the impact of that. Also, the string is run through the resolver for a
reason. I am loath to circumvent that without knowing more.
You never know, it might be fixed in 2.1.6.1 :oP
The following is my definition of the generate() method of the
DirectoryGenerator class (based on 2.1.5.1 release, look for XXXXX for
change). I ran it by the dev mailing list yesterday, but have had no
response.
public void generate() throws SAXException, ProcessingException {
String directory = super.source;
Source inputSource = null;
try {
inputSource = this.resolver.resolveURI(directory);
String systemId = inputSource.getURI();
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()) {
// XXXXXXXXXXXX THIS ASSIGNMENT AND FOLLOWING IF
STATEMENT ARE NEW, PREVIOUSLY IT JUST THREW THE EXCEPTION XXXXXXXXXXXXX
directoryFile = new File(directory);
if (directoryFile.isDirectory() == false){
throw new ResourceNotFoundException(directory + " is
not a directory.");
}
}
this.contentHandler.startDocument();
this.contentHandler.startPrefixMapping(PREFIX, URI);
Stack ancestors = getAncestors(directoryFile);
addAncestorPath(directoryFile, ancestors);
this.contentHandler.endPrefixMapping(PREFIX);
this.contentHandler.endDocument();
} catch (SourceException se) {
throw SourceUtil.handle(se);
} catch (IOException ioe) {
throw new ResourceNotFoundException("Could not read
directory " + directory, ioe);
} finally {
this.resolver.release(inputSource);
}
}
Matt Innes, UTB Consulting
[EMAIL PROTECTED]
07795 300 735
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]