You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by bu...@apache.org on 2002/12/09 09:12:58 UTC

DO NOT REPLY [Bug 15171] New: - directory generator (in/ex)cludes directories too

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