cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <scher...@gmail.com>
Subject Re: svn commit: r1142136 - in /cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/generation: ./ DirectoryGenerator.java
Date Wed, 20 Jul 2011 13:32:28 GMT
I am not sure why but since today I need to patch the optional pom when
using the optional module in our project.

thorsten@mcKenny:~/src/apache/cocoon3/cocoon-optional$ svnd
Index: pom.xml
===================================================================
--- pom.xml	(revision 1148748)
+++ pom.xml	(working copy)
@@ -128,6 +128,11 @@
       <version>2.2</version>
       <optional>true</optional>
     </dependency>
+    <dependency>
+        <groupId>jakarta-regexp</groupId>
+        <artifactId>jakarta-regexp</artifactId>
+        <version>1.4</version>
+      </dependency> 
 
     <!-- Test libraries -->
     <dependency>

Should I commit this or should I add the dep in our custom project?

WDYT?

salu2

On Sat, 2011-07-02 at 00:53 +0000, thorsten@apache.org wrote:
> Author: thorsten
> Date: Sat Jul  2 00:53:50 2011
> New Revision: 1142136
> 
> URL: http://svn.apache.org/viewvc?rev=1142136&view=rev
> Log:
> Preparing migration from c2.2 based directory generator and applying only formating changes
> 
> Added:
>     cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/generation/
>     cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/generation/DirectoryGenerator.java
>       - copied, changed from r1142135, cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/main/java/org/apache/cocoon/generation/DirectoryGenerator.java
> 
> Copied: cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/generation/DirectoryGenerator.java
(from r1142135, cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/main/java/org/apache/cocoon/generation/DirectoryGenerator.java)
> URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/generation/DirectoryGenerator.java?p2=cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/generation/DirectoryGenerator.java&p1=cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/main/java/org/apache/cocoon/generation/DirectoryGenerator.java&r1=1142135&r2=1142136&rev=1142136&view=diff
> ==============================================================================
> --- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-components/src/main/java/org/apache/cocoon/generation/DirectoryGenerator.java
(original)
> +++ cocoon/cocoon3/trunk/cocoon-optional/src/main/java/org/apache/cocoon/generation/DirectoryGenerator.java
Sat Jul  2 00:53:50 2011
> @@ -46,22 +46,25 @@ import org.xml.sax.SAXException;
>  import org.xml.sax.helpers.AttributesImpl;
>  
>  /**
> - * Generates an XML directory listing.
> - * A more general approach is implemented by the {@link TraversableGenerator}.
> - *
> - * @cocoon.sitemap.component.documentation
> - * Generates an XML directory listing.
> - * A more general approach is implemented by the {@link TraversableGenerator}.
> - * @cocoon.sitemap.component.name   directory
> - * @cocoon.sitemap.component.label  content
> - * @cocoon.sitemap.component.documentation.caching Yes.
> - * Uses the last modification date of the directory and the contained files.
> - * @cocoon.sitemap.component.pooling.max  16
> - *
> - * @version $Id$
> + * Generates an XML directory listing. A more general approach is implemented by
> + * the {@link TraversableGenerator}.
> + * 
> + * @cocoon.sitemap.component.documentation Generates an XML directory listing. A
> + *                                         more general approach is implemented
> + *                                         by the {@link TraversableGenerator}.
> + * @cocoon.sitemap.component.name directory
> + * @cocoon.sitemap.component.label content
> + * @cocoon.sitemap.component.documentation.caching Yes. Uses the last
> + *                                                 modification date of the
> + *                                                 directory and the contained
> + *                                                 files.
> + * @cocoon.sitemap.component.pooling.max 16
> + * 
> + * @version $Id: DirectoryGenerator.java 605689 2007-12-19 20:48:43Z vgritsenko
> + *          $
>   */
> -public class DirectoryGenerator extends ServiceableGenerator
> -                                implements CacheableProcessingComponent {
> +public class DirectoryGenerator extends ServiceableGenerator implements
> +        CacheableProcessingComponent {
>  
>      /** Constant for the file protocol. */
>      private static final String FILE = "file:";
> @@ -84,25 +87,30 @@ public class DirectoryGenerator extends 
>      /** The validity that is being built */
>      protected DirValidity validity;
>  
> -    /** Convenience object, so we don't need to create an AttributesImpl for every element.
*/
> +    /**
> +     * Convenience object, so we don't need to create an AttributesImpl for
> +     * every element.
> +     */
>      protected AttributesImpl attributes;
>  
>      /**
>       * The cache key needs to be generated for the configuration of this
> -     * generator, so storing the parameters for generateKey().
> -     * Using the member variables after setup() would not work I guess. I don't
> -     * know a way from the regular expressions back to the pattern or at least
> -     * a useful string.
> +     * generator, so storing the parameters for generateKey(). Using the member
> +     * variables after setup() would not work I guess. I don't know a way from
> +     * the regular expressions back to the pattern or at least a useful string.
>       */
>      protected List cacheKeyParList;
>  
> -    /** The depth parameter determines how deep the DirectoryGenerator should delve.
*/
> +    /**
> +     * The depth parameter determines how deep the DirectoryGenerator should
> +     * delve.
> +     */
>      protected int depth;
>  
>      /**
> -     * The dateFormatter determines into which date format the lastModified
> -     * time should be converted.
> -     * FIXME: SimpleDateFormat is not supported by all locales!
> +     * The dateFormatter determines into which date format the lastModified time
> +     * should be converted. FIXME: SimpleDateFormat is not supported by all
> +     * locales!
>       */
>      protected SimpleDateFormat dateFormatter;
>  
> @@ -111,13 +119,16 @@ public class DirectoryGenerator extends 
>  
>      /**
>       * The sort parameter determines by which attribute the content of one
> -     * directory should be sorted. Possible values are "name", "size", "lastmodified"
> -     * and "directory", where "directory" is the same as "name", except that
> -     * directory entries are listed first.
> +     * directory should be sorted. Possible values are "name", "size",
> +     * "lastmodified" and "directory", where "directory" is the same as "name",
> +     * except that directory entries are listed first.
>       */
>      protected String sort;
>  
> -    /** The reverse parameter reverses the sort order. <code>false</code>
is default. */
> +    /**
> +     * The reverse parameter reverses the sort order. <code>false</code>
is
> +     * default.
> +     */
>      protected boolean reverse;
>  
>      /** The regular expression for the root pattern. */
> @@ -138,19 +149,25 @@ public class DirectoryGenerator extends 
>      /** The source object for the directory. */
>      protected Source directorySource;
>  
> -
>      /**
>       * Set the request parameters. Must be called before the generate method.
> -     *
> -     * @param resolver     the SourceResolver object
> -     * @param objectModel  a <code>Map</code> containing model object
> -     * @param src          the directory to be XMLized specified as src attribute on
&lt;map:generate/>
> -     * @param par          configuration parameters
> -     */
> -    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters
par)
> -    throws ProcessingException, SAXException, IOException {
> +     * 
> +     * @param resolver
> +     *            the SourceResolver object
> +     * @param objectModel
> +     *            a <code>Map</code> containing model object
> +     * @param src
> +     *            the directory to be XMLized specified as src attribute on
> +     *            &lt;map:generate/>
> +     * @param par
> +     *            configuration parameters
> +     */
> +    public void setup(SourceResolver resolver, Map objectModel, String src,
> +            Parameters par) throws ProcessingException, SAXException,
> +            IOException {
>          if (src == null) {
> -            throw new ProcessingException("No src attribute pointing to a directory
to be XMLized specified.");
> +            throw new ProcessingException(
> +                    "No src attribute pointing to a directory to be XMLized specified.");
>          }
>          super.setup(resolver, objectModel, src, par);
>  
> @@ -185,7 +202,8 @@ public class DirectoryGenerator extends 
>  
>          if (this.getLogger().isDebugEnabled()) {
>              this.getLogger().debug("depth: " + this.depth);
> -            this.getLogger().debug("dateFormat: " + this.dateFormatter.toPattern());
> +            this.getLogger().debug(
> +                    "dateFormat: " + this.dateFormatter.toPattern());
>              this.getLogger().debug("sort: " + this.sort);
>              this.getLogger().debug("reverse: " + this.reverse);
>              this.getLogger().debug("refreshDelay: " + this.refreshDelay);
> @@ -215,14 +233,16 @@ public class DirectoryGenerator extends 
>              }
>          } catch (RESyntaxException rese) {
>              throw new ProcessingException("Syntax error in regexp pattern '"
> -                                          + rePattern + "'", rese);
> +                    + rePattern + "'", rese);
>          }
>  
>          this.isRequestedDirectory = false;
>          this.attributes = new AttributesImpl();
>      }
>  
> -    /* (non-Javadoc)
> +    /*
> +     * (non-Javadoc)
> +     * 
>       * @see org.apache.cocoon.caching.CacheableProcessingComponent#getKey()
>       */
>      public Serializable getKey() {
> @@ -252,19 +272,23 @@ public class DirectoryGenerator extends 
>      /**
>       * Generate XML data.
>       * 
> -     * @throws SAXException  if an error occurs while outputting the document
> -     * @throws ProcessingException  if the requsted URI isn't a directory on the local
filesystem
> +     * @throws SAXException
> +     *             if an error occurs while outputting the document
> +     * @throws ProcessingException
> +     *             if the requsted URI isn't a directory on the local filesystem
>       */
>      public void generate() throws SAXException, ProcessingException {
>          try {
>              String systemId = this.directorySource.getURI();
>              if (!systemId.startsWith(FILE)) {
> -                throw new ResourceNotFoundException(systemId + " does not denote a directory");
> +                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(super.source + " is not a directory.");
> +                throw new ResourceNotFoundException(super.source
> +                        + " is not a directory.");
>              }
>  
>              this.contentHandler.startDocument();
> @@ -276,14 +300,17 @@ public class DirectoryGenerator extends 
>              this.contentHandler.endPrefixMapping(PREFIX);
>              this.contentHandler.endDocument();
>          } catch (IOException ioe) {
> -            throw new ResourceNotFoundException("Could not read directory " + super.source,
ioe);
> +            throw new ResourceNotFoundException("Could not read directory "
> +                    + super.source, ioe);
>          }
>      }
>  
>      /**
> -     * Creates a stack containing the ancestors of File up to specified directory.
> +     * Creates a stack containing the ancestors of File up to specified
> +     * directory.
>       * 
> -     * @param path the File whose ancestors shall be retrieved
> +     * @param path
> +     *            the File whose ancestors shall be retrieved
>       * @return a Stack containing the ancestors.
>       */
>      protected Stack getAncestors(File path) {
> @@ -307,29 +334,35 @@ public class DirectoryGenerator extends 
>       * Adds recursively the path from the directory matched by the root pattern
>       * down to the requested directory.
>       * 
> -     * @param path       the requested directory.
> -     * @param ancestors  the stack of the ancestors.
> +     * @param path
> +     *            the requested directory.
> +     * @param ancestors
> +     *            the stack of the ancestors.
>       * @throws SAXException
>       */
> -    protected void addAncestorPath(File path, Stack ancestors) throws SAXException {
> +    protected void addAncestorPath(File path, Stack ancestors)
> +            throws SAXException {
>          if (ancestors.empty()) {
>              this.isRequestedDirectory = true;
>              addPath(path, depth);
>          } else {
> -            startNode(DIR_NODE_NAME, (File)ancestors.pop());
> +            startNode(DIR_NODE_NAME, (File) ancestors.pop());
>              addAncestorPath(path, ancestors);
>              endNode(DIR_NODE_NAME);
>          }
>      }
>  
>      /**
> -     * Adds a single node to the generated document. If the path is a
> -     * directory, and depth is greater than zero, then recursive calls
> -     * are made to add nodes for the directory's children.
> -     * 
> -     * @param path   the file/directory to process
> -     * @param depth  how deep to scan the directory
> -     * @throws SAXException  if an error occurs while constructing nodes
> +     * Adds a single node to the generated document. If the path is a directory,
> +     * and depth is greater than zero, then recursive calls are made to add
> +     * nodes for the directory's children.
> +     * 
> +     * @param path
> +     *            the file/directory to process
> +     * @param depth
> +     *            how deep to scan the directory
> +     * @throws SAXException
> +     *             if an error occurs while constructing nodes
>       */
>      protected void addPath(File path, int depth) throws SAXException {
>          if (path.isDirectory()) {
> @@ -341,38 +374,43 @@ public class DirectoryGenerator extends 
>                      Arrays.sort(contents, new Comparator() {
>                          public int compare(Object o1, Object o2) {
>                              if (reverse) {
> -                                return ((File)o2).getName().compareTo(((File)o1).getName());
> +                                return ((File) o2).getName().compareTo(
> +                                        ((File) o1).getName());
>                              }
> -                            return ((File)o1).getName().compareTo(((File)o2).getName());
> +                            return ((File) o1).getName().compareTo(
> +                                    ((File) o2).getName());
>                          }
>                      });
>                  } else if (sort.equals("size")) {
>                      Arrays.sort(contents, new Comparator() {
>                          public int compare(Object o1, Object o2) {
>                              if (reverse) {
> -                                return new Long(((File)o2).length()).compareTo(
> -                                    new Long(((File)o1).length()));
> +                                return new Long(((File) o2).length())
> +                                        .compareTo(new Long(((File) o1)
> +                                                .length()));
>                              }
> -                            return new Long(((File)o1).length()).compareTo(
> -                                new Long(((File)o2).length()));
> +                            return new Long(((File) o1).length())
> +                                    .compareTo(new Long(((File) o2).length()));
>                          }
>                      });
>                  } else if (sort.equals("lastmodified")) {
>                      Arrays.sort(contents, new Comparator() {
>                          public int compare(Object o1, Object o2) {
>                              if (reverse) {
> -                                return new Long(((File)o2).lastModified()).compareTo(
> -                                    new Long(((File)o1).lastModified()));
> +                                return new Long(((File) o2).lastModified())
> +                                        .compareTo(new Long(((File) o1)
> +                                                .lastModified()));
>                              }
> -                            return new Long(((File)o1).lastModified()).compareTo(
> -                                new Long(((File)o2).lastModified()));
> +                            return new Long(((File) o1).lastModified())
> +                                    .compareTo(new Long(((File) o2)
> +                                            .lastModified()));
>                          }
>                      });
>                  } else if (sort.equals("directory")) {
>                      Arrays.sort(contents, new Comparator() {
>                          public int compare(Object o1, Object o2) {
> -                            File f1 = (File)o1;
> -                            File f2 = (File)o2;
> +                            File f1 = (File) o1;
> +                            File f2 = (File) o2;
>  
>                              if (reverse) {
>                                  if (f2.isDirectory() && f1.isFile())
> @@ -408,42 +446,49 @@ public class DirectoryGenerator extends 
>      /**
>       * Begins a named node and calls setNodeAttributes to set its attributes.
>       * 
> -     * @param nodeName  the name of the new node
> -     * @param path      the file/directory to use when setting attributes
> -     * @throws SAXException  if an error occurs while creating the node
> +     * @param nodeName
> +     *            the name of the new node
> +     * @param path
> +     *            the file/directory to use when setting attributes
> +     * @throws SAXException
> +     *             if an error occurs while creating the node
>       */
>      protected void startNode(String nodeName, File path) throws SAXException {
>          if (this.validity != null) {
>              this.validity.addFile(path);
>          }
>          setNodeAttributes(path);
> -        super.contentHandler.startElement(URI, nodeName, PREFIX + ':' + nodeName, attributes);
> +        super.contentHandler.startElement(URI, nodeName, PREFIX + ':'
> +                + nodeName, attributes);
>      }
>  
>      /**
>       * Sets the attributes for a given path. The default method sets attributes
> -     * for the name of thefile/directory and for the last modification time
> -     * of the path.
> +     * for the name of thefile/directory and for the last modification time of
> +     * the path.
>       * 
> -     * @param path  the file/directory to use when setting attributes
> -     * @throws SAXException  if an error occurs while setting the attributes
> +     * @param path
> +     *            the file/directory to use when setting attributes
> +     * @throws SAXException
> +     *             if an error occurs while setting the attributes
>       */
>      protected void setNodeAttributes(File path) throws SAXException {
>          long lastModified = path.lastModified();
>          attributes.clear();
>          attributes.addAttribute("", FILENAME_ATTR_NAME, FILENAME_ATTR_NAME,
> -                                "CDATA", path.getName());
> +                "CDATA", path.getName());
>          attributes.addAttribute("", LASTMOD_ATTR_NAME, LASTMOD_ATTR_NAME,
> -                                "CDATA", Long.toString(path.lastModified()));
> -        attributes.addAttribute("", DATE_ATTR_NAME, DATE_ATTR_NAME,
> -                                "CDATA", dateFormatter.format(new Date(lastModified)));
> -        attributes.addAttribute("", SIZE_ATTR_NAME, SIZE_ATTR_NAME,
> -                                "CDATA", Long.toString(path.length()));
> +                "CDATA", Long.toString(path.lastModified()));
> +        attributes.addAttribute("", DATE_ATTR_NAME, DATE_ATTR_NAME, "CDATA",
> +                dateFormatter.format(new Date(lastModified)));
> +        attributes.addAttribute("", SIZE_ATTR_NAME, SIZE_ATTR_NAME, "CDATA",
> +                Long.toString(path.length()));
>          if (this.isRequestedDirectory) {
>              attributes.addAttribute("", "sort", "sort", "CDATA", this.sort);
>              attributes.addAttribute("", "reverse", "reverse", "CDATA",
> -                                    String.valueOf(this.reverse));
> -            attributes.addAttribute("", "requested", "requested", "CDATA", "true");
> +                    String.valueOf(this.reverse));
> +            attributes.addAttribute("", "requested", "requested", "CDATA",
> +                    "true");
>              this.isRequestedDirectory = false;
>          }
>      }
> @@ -451,8 +496,10 @@ public class DirectoryGenerator extends 
>      /**
>       * Ends the named node.
>       * 
> -     * @param nodeName  the name of the new node
> -     * @throws SAXException  if an error occurs while closing the node
> +     * @param nodeName
> +     *            the name of the new node
> +     * @throws SAXException
> +     *             if an error occurs while closing the node
>       */
>      protected void endNode(String nodeName) throws SAXException {
>          super.contentHandler.endElement(URI, nodeName, PREFIX + ':' + nodeName);
> @@ -461,7 +508,8 @@ public class DirectoryGenerator extends 
>      /**
>       * Determines if a given File is the defined root.
>       * 
> -     * @param path  the File to check
> +     * @param path
> +     *            the File to check
>       * @return true if the File is the root or the root pattern is not set,
>       *         false otherwise.
>       */
> @@ -472,9 +520,10 @@ public class DirectoryGenerator extends 
>      /**
>       * Determines if a given File shall be visible.
>       * 
> -     * @param path  the File to check
> -     * @return true if the File shall be visible or the include Pattern is <code>null</code>,
> -     *         false otherwise.
> +     * @param path
> +     *            the File to check
> +     * @return true if the File shall be visible or the include Pattern is
> +     *         <code>null</code>, false otherwise.
>       */
>      protected boolean isIncluded(File path) {
>          return this.includeRE == null || this.includeRE.match(path.getName());
> @@ -483,9 +532,10 @@ public class DirectoryGenerator extends 
>      /**
>       * Determines if a given File shall be excluded from viewing.
>       * 
> -     * @param path  the File to check
> -     * @return false if the given File shall not be excluded or the exclude Pattern
is <code>null</code>,
> -     *         true otherwise.
> +     * @param path
> +     *            the File to check
> +     * @return false if the given File shall not be excluded or the exclude
> +     *         Pattern is <code>null</code>, true otherwise.
>       */
>      protected boolean isExcluded(File path) {
>          return this.excludeRE != null && this.excludeRE.match(path.getName());
> @@ -529,17 +579,18 @@ public class DirectoryGenerator extends 
>  
>              int len = files.size();
>              for (int i = 0; i < len; i++) {
> -                File f = (File)files.get(i);
> +                File f = (File) files.get(i);
>                  if (!f.exists()) {
>                      return SourceValidity.INVALID; // File was removed
>                  }
>  
> -                long oldDate = ((Long)fileDates.get(i)).longValue();
> +                long oldDate = ((Long) fileDates.get(i)).longValue();
>                  long newDate = f.lastModified();
>  
>                  if (oldDate != newDate) {
>                      // File's last modified date has changed since last check
> -                    // NOTE: this occurs on directories as well when a file is added
> +                    // NOTE: this occurs on directories as well when a file is
> +                    // added
>                      return SourceValidity.INVALID;
>                  }
>              }
> 
> 

-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/


Mime
View raw message