cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r225254 - in /cocoon/trunk: src/java/org/apache/cocoon/generation/DirectoryGenerator.java src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java status.xml
Date Tue, 26 Jul 2005 08:02:12 GMT
Author: cziegeler
Date: Tue Jul 26 01:02:05 2005
New Revision: 225254

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

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

Modified: cocoon/trunk/src/java/org/apache/cocoon/generation/DirectoryGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/generation/DirectoryGenerator.java?rev=225254&r1=225253&r2=225254&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/generation/DirectoryGenerator.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/generation/DirectoryGenerator.java Tue Jul 26
01:02:05 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.
@@ -45,6 +45,7 @@
 /**
  * @cocoon.sitemap.component.documentation
  * Generates an XML directory listing.
+ * A more general approach is implemented by the TraversableGenerator (src/blocks/repository/java/org/apache/cocoon/generation/TraversableGenerator.java)
  * 
  * @cocoon.sitemap.component.name   directory
  * @cocoon.sitemap.component.label  content
@@ -127,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.
      *
@@ -142,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));
@@ -238,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();
@@ -260,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);
         }
     }
 
@@ -484,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/trunk/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java?rev=225254&r1=225253&r2=225254&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/generation/MP3DirectoryGenerator.java Tue Jul
26 01:02:05 2005
@@ -34,7 +34,7 @@
  * 
  *
  * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
- * @version CVS $Id: MP3DirectoryGenerator.java,v 1.6 2004/05/27 08:23:58 cziegeler Exp $
+ * @version CVS $Id$
  */
 public class MP3DirectoryGenerator extends DirectoryGenerator
 {
@@ -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,9 +238,8 @@
     }
 
     // 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"},
         // MPEG2 - layer 2
@@ -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/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=225254&r1=225253&r2=225254&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Tue Jul 26 01:02:05 2005
@@ -509,6 +509,9 @@
    </action>
   </release>
   <release version="2.1.8" date="TBD">
+    <action dev="CZ" type="fix" fixes-bug="29506" due-to-email="tobias@lentus.se">
+      Fix wrong caching behaviour in DirectoryGenerator.
+    </action>
     <action dev="CZ" type="add">
       Portal block: Add easier to use event handling mechanism by introducing the new Receiver
interface.
                     Deprecated Publisher, Subscriber, Filter and Register.



Mime
View raw message