You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2005/07/26 09:37:18 UTC

svn commit: r225247 - in /cocoon/branches/BRANCH_2_1_X: src/java/org/apache/cocoon/generation/DirectoryGenerator.java src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java status.xml

Author: cziegeler
Date: Tue Jul 26 00:37:04 2005
New Revision: 225247

URL: http://svn.apache.org/viewcvs?rev=225247&view=rev
Log:
Fix wrong caching behaviour in DirectoryGenerator.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/DirectoryGenerator.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/DirectoryGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/DirectoryGenerator.java?rev=225247&r1=225246&r2=225247&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/DirectoryGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/DirectoryGenerator.java Tue Jul 26 00:37:04 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -128,6 +128,9 @@
      */
     protected boolean isRequestedDirectory;
 
+    /** The source object for the directory. */
+    protected Source directorySource;
+
     /**
      * Set the request parameters. Must be called before the generate method.
      *
@@ -143,8 +146,14 @@
         }
         super.setup(resolver, objectModel, src, par);
 
+        try {
+            this.directorySource = this.resolver.resolveURI(src);
+        } catch (SourceException se) {
+            throw SourceUtil.handle(se);
+        }
+
         this.cacheKeyParList = new ArrayList();
-        this.cacheKeyParList.add(src);
+        this.cacheKeyParList.add(this.directorySource.getURI());
 
         this.depth = par.getParameterAsInteger("depth", 1);
         this.cacheKeyParList.add(String.valueOf(this.depth));
@@ -239,18 +248,15 @@
      * @throws ProcessingException  if the requsted URI isn't a directory on the local filesystem
      */
     public void generate() throws SAXException, ProcessingException {
-        String directory = super.source;
-        Source inputSource = null;
         try {
-            inputSource = this.resolver.resolveURI(directory);
-            String systemId = inputSource.getURI();
+            String systemId = this.directorySource.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()) {
-                throw new ResourceNotFoundException(directory + " is not a directory.");
+                throw new ResourceNotFoundException(super.source + " is not a directory.");
             }
 
             this.contentHandler.startDocument();
@@ -261,12 +267,8 @@
 
             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);
+            throw new ResourceNotFoundException("Could not read directory " + super.source, ioe);
         }
     }
 
@@ -485,6 +487,10 @@
      * Recycle resources
      */
     public void recycle() {
+        if ( this.resolver != null ) {
+            this.resolver.release(this.directorySource);
+            this.directorySource = null;
+        }
         this.cacheKeyParList = null;
         this.attributes = null;
         this.dateFormatter = null;

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java?rev=225247&r1=225246&r2=225247&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java Tue Jul 26 00:37:04 2005
@@ -90,8 +90,7 @@
     /**
      * Read ID3 Tag
      */
-    private void setID3TagAttributes(RandomAccessFile in) throws IOException
-    {
+    private void setID3TagAttributes(RandomAccessFile in) throws IOException  {
         String s;
 
         // TAG takes 128 bytes
@@ -135,8 +134,7 @@
         return s.trim();
     }
 
-    private void setID3HeaderAttributes(RandomAccessFile in) throws IOException
-    {
+    private void setID3HeaderAttributes(RandomAccessFile in) throws IOException {
         byte[] buffer = new byte[4];
 
         // http://floach.pimpin.net/grd/mp3info/frmheader/index.html
@@ -183,8 +181,7 @@
         }
     }
 
-    private static boolean isSyncMark(int header)
-    {
+    private static boolean isSyncMark(int header) {
         boolean sync = ((header & 0xFFF00000) == 0xFFF00000);
         // filter out invalid sample rate
         if (sync) sync = ((header >>> 10) & 3) != 3;
@@ -195,8 +192,7 @@
         return sync;
     }
 
-    private int getVBRHeaderFrames(RandomAccessFile in, int version, int mode) throws IOException
-    {
+    private int getVBRHeaderFrames(RandomAccessFile in, int version, int mode) throws IOException {
         byte[] buffer = new byte[12];
 
         // Try to detect VBR header
@@ -242,8 +238,7 @@
     }
 
     // version - layer - bitrate index
-    private static final String bitrates[][][] =
-    {
+    private static final String bitrates[][][] = {
       {
         // MPEG2 - layer 1
         {"free format", "32", "48", "56", "64", "80", "96", "112", "128", "144", "160", "176", "192", "224", "256", "forbidden"},
@@ -262,13 +257,11 @@
       }
     };
 
-    private static String bitrate(int version, int layer, int bitrate_index)
-    {
+    private static String bitrate(int version, int layer, int bitrate_index) {
         return bitrates[version & 1][layer - 1][bitrate_index];
     }
 
-    private static String mode(int mode)
-    {
+    private static String mode(int mode) {
         switch(mode)
         {
         case MODE_STEREO:
@@ -283,21 +276,18 @@
         return null;
     }
 
-    private static final int frequencies[][] =
-    {
+    private static final int frequencies[][] = {
         {32000, 16000,  8000}, //MPEG 2.5
         {    0,     0,     0}, //reserved
         {22050, 24000, 16000}, //MPEG 2
         {44100, 48000, 32000}  //MPEG 1
     };
 
-    private static int frequency(int version, int frequency)
-    {
+    private static int frequency(int version, int frequency) {
         return frequencies[version][frequency];
     }
 
-    private static String frequencyString(int version, int frequency)
-    {
+    private static String frequencyString(int version, int frequency) {
         return String.valueOf((float)frequency(version, frequency)/1000);
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=225247&r1=225246&r2=225247&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Tue Jul 26 00:37:04 2005
@@ -196,6 +196,9 @@
 
   <changes>
   <release version="@version@" date="@date@">
+    <action dev="CZ" type="fix" fixes-bug="29506" due-to-email="tobias@lentus.se">
+      Fix wrong caching behaviour in DirectoryGenerator.
+    </action>
     <action dev="JH" type="update">
       Moved following components into core: TraversableGenerator, XPathTraversableGenerator (both from repository
       block), CSVGenerator (from scratchpad block), FragmentExtractorTransformer and FragmentExtractorGenerator