cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Innes" <matt.in...@unity-is.com>
Subject RE: DirectoryGenerator & shared Drives under Windows
Date Fri, 19 Nov 2004 14:38:02 GMT
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
matt.innes@utbconsulting.com
07795 300 735


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message