cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 15171] New: - directory generator (in/ex)cludes directories too
Date Mon, 09 Dec 2002 08:12:58 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15171>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15171

directory generator (in/ex)cludes directories too

           Summary: directory generator (in/ex)cludes directories too
           Product: Cocoon 2
           Version: 2.0.3
          Platform: All
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: sitemap components
        AssignedTo: cocoon-dev@xml.apache.org
        ReportedBy: johaneninge@yahoo.com


org.apache.cocoon.generation.DirectoryGenerator.java will skip directories that 
do not comply with the (in/ex)clude patterns if these are used. Sometimes you 
want this, but I think most of the times the (in/ex)clude patterns should only 
be used to skip files. Pruning of (sub)directories should continue regardless 
of the names of these directories:

protected void addPath(File path, int depth)
    throws SAXException {
        if (path.isDirectory()) {
            startNode(DIR_NODE_NAME, path);
            if (depth>0) {
                File contents[] = path.listFiles();
                for (int i=0; i<contents.length; i++) {
                    // if depth > 1 then the subdirectories that do not
                    // comply with the (in/ex)clude patterns will be skipped
                    // right here just like the files.
                    if (isIncluded(contents[i]) && !isExcluded(contents[i])) {
                        addPath(contents[i], depth-1);
                    }
                }
            }
            endNode(DIR_NODE_NAME);
        } else {
            if (isIncluded(path) && !isExcluded(path)) {
                startNode(FILE_NODE_NAME, path);
                endNode(FILE_NODE_NAME);
            }
        }
    }


proposed solution:

add a boolean parameter to the addPath method which says if subdirectories 
should comply to the (in/ex)clude pattern or not. Boolean testDirs in this 
proposal says if subdirectories should be tested against the (in/ex)clude 
patterns or not:

protected void addPath(File path, int depth, boolean testDirs)
    throws SAXException {
        if (path.isDirectory()) {
            startNode(DIR_NODE_NAME, path);
            if (depth>0) {
                File contents[] = path.listFiles();
                for (int i=0; i<contents.length; i++) {
                    // beginning of patch
                    if ((contents[i].isDirectory() && !testDirs) ||
                        (isIncluded(contents[i]) && !isExcluded(contents[i]))) {
                        addPath(contents[i], depth-1, testDirs);
                    }
                    // end of patch
                }
            }
            endNode(DIR_NODE_NAME);
        } else {
            if (isIncluded(path) && !isExcluded(path)) {
                startNode(FILE_NODE_NAME, path);
                endNode(FILE_NODE_NAME);
            }
        }
    }

Option testDirs could come directly from the sitemap as a parameter, just like 
the 'depth' parameter.

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


Mime
View raw message