cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject svn commit: rev 36301 - in cocoon/branches/butterfly/src: java java/org/apache/butterfly/reading java/org/apache/butterfly/serialization java/org/apache/butterfly/servlet java/org/apache/butterfly/sitemap test/org/apache/butterfly/components/pipeline/impl webapp
Date Thu, 12 Aug 2004 21:17:45 GMT
Author: ugo
Date: Thu Aug 12 14:17:45 2004
New Revision: 36301

Modified:
   cocoon/branches/butterfly/src/java/applicationContext.xml
   cocoon/branches/butterfly/src/java/org/apache/butterfly/reading/ResourceReader.java
   cocoon/branches/butterfly/src/java/org/apache/butterfly/serialization/TextSerializer.java
   cocoon/branches/butterfly/src/java/org/apache/butterfly/serialization/XMLSerializer.java
   cocoon/branches/butterfly/src/java/org/apache/butterfly/servlet/Pipeline.groovy
   cocoon/branches/butterfly/src/java/org/apache/butterfly/sitemap/SitemapOutputComponent.java
   cocoon/branches/butterfly/src/test/org/apache/butterfly/components/pipeline/impl/NonCachingProcessingPipelineTestCase.java
   cocoon/branches/butterfly/src/webapp/sitemap.groovy
Log:
Set mime-type on serializer

Modified: cocoon/branches/butterfly/src/java/applicationContext.xml
==============================================================================
--- cocoon/branches/butterfly/src/java/applicationContext.xml	(original)
+++ cocoon/branches/butterfly/src/java/applicationContext.xml	Thu Aug 12 14:17:45 2004
@@ -72,6 +72,9 @@
     <property name="encoding">
       <value>UTF-8</value>
     </property>
+    <property name="mimeType">
+      <value>text/xml</value>
+    </property>
   </bean>
 
   <bean id="textSerializer" class="org.apache.butterfly.serialization.TextSerializer"
singleton="false">
@@ -80,6 +83,9 @@
     </property>
     <property name="encoding">
       <value>UTF-8</value>
+    </property>
+    <property name="mimeType">
+      <value>text/plain</value>
     </property>
   </bean>
   

Modified: cocoon/branches/butterfly/src/java/org/apache/butterfly/reading/ResourceReader.java
==============================================================================
--- cocoon/branches/butterfly/src/java/org/apache/butterfly/reading/ResourceReader.java	(original)
+++ cocoon/branches/butterfly/src/java/org/apache/butterfly/reading/ResourceReader.java	Thu
Aug 12 14:17:45 2004
@@ -41,6 +41,7 @@
 public class ResourceReader implements Reader {
     protected static final Log logger = LogFactory.getLog(ResourceReader.class);
     private SourceResolver sourceResolver;
+    protected String mimeType;
     protected long expires = -1;
     protected int bufferSize = 8192;
     protected boolean byteRanges = true;
@@ -153,12 +154,12 @@
            }
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.butterfly.sitemap.SitemapOutputComponent#getMimeType()
-     */
     public String getMimeType() {
-        // TODO Auto-generated method stub
-        return null;
+        return mimeType;
+    }
+    
+    public void setMimeType(String mimeType) {
+        this.mimeType = mimeType;
     }
 
     /* (non-Javadoc)

Modified: cocoon/branches/butterfly/src/java/org/apache/butterfly/serialization/TextSerializer.java
==============================================================================
--- cocoon/branches/butterfly/src/java/org/apache/butterfly/serialization/TextSerializer.java
(original)
+++ cocoon/branches/butterfly/src/java/org/apache/butterfly/serialization/TextSerializer.java
Thu Aug 12 14:17:45 2004
@@ -63,6 +63,7 @@
      * The <code>Properties</code> used by this serializer.
      */
     protected Properties format = new Properties();
+    private String mimeType;
 
     public TextSerializer() {
         this.format.put(OutputKeys.METHOD, "text");
@@ -118,13 +119,14 @@
         return (String) format.get(OutputKeys.ENCODING);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.butterfly.sitemap.SitemapOutputComponent#getMimeType()
-     */
     public String getMimeType() {
-        return null;
+        return this.mimeType;
     }
 
+    public void setMimeType(String mimeType) {
+        this.mimeType = mimeType;
+    }
+    
     /* (non-Javadoc)
      * @see org.apache.butterfly.sitemap.SitemapOutputComponent#shouldSetContentLength()
      */

Modified: cocoon/branches/butterfly/src/java/org/apache/butterfly/serialization/XMLSerializer.java
==============================================================================
--- cocoon/branches/butterfly/src/java/org/apache/butterfly/serialization/XMLSerializer.java
(original)
+++ cocoon/branches/butterfly/src/java/org/apache/butterfly/serialization/XMLSerializer.java
Thu Aug 12 14:17:45 2004
@@ -44,6 +44,7 @@
      * The <code>Properties</code> used by this serializer.
      */
     protected Properties format = new Properties();
+    private String mimeType;
     
     /**
      * 
@@ -112,11 +113,12 @@
         this.setLexicalHandler(handler);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.butterfly.sitemap.SitemapOutputComponent#getMimeType()
-     */
     public String getMimeType() {
-        return null;
+        return this.mimeType;
+    }
+
+    public void setMimeType(String mimeType) {
+        this.mimeType = mimeType;
     }
 
     /* (non-Javadoc)

Modified: cocoon/branches/butterfly/src/java/org/apache/butterfly/servlet/Pipeline.groovy
==============================================================================
--- cocoon/branches/butterfly/src/java/org/apache/butterfly/servlet/Pipeline.groovy	(original)
+++ cocoon/branches/butterfly/src/java/org/apache/butterfly/servlet/Pipeline.groovy	Thu Aug
12 14:17:45 2004
@@ -49,8 +49,8 @@
         this.pipeline.setSerializer(serializer);
     }
     
-    protected void read(src, type, parameters) {
-        reader = beanFactory.getBean("resourceReader");
+    protected void read(type, src, parameters) {
+        reader = beanFactory.getBean(type + "Reader");
         reader.inputSource = src;
         parameters.each { reader[it.key] = it.value }
         this.pipeline.reader = reader;

Modified: cocoon/branches/butterfly/src/java/org/apache/butterfly/sitemap/SitemapOutputComponent.java
==============================================================================
--- cocoon/branches/butterfly/src/java/org/apache/butterfly/sitemap/SitemapOutputComponent.java
(original)
+++ cocoon/branches/butterfly/src/java/org/apache/butterfly/sitemap/SitemapOutputComponent.java
Thu Aug 12 14:17:45 2004
@@ -36,6 +36,11 @@
      * Get the mime-type of the output of this <code>Component</code>.
      */
     String getMimeType();
+
+    /**
+     * Set the mime-type of the output of this <code>Component</code>.
+     */
+    void setMimeType(String mimeType);
     
     /**
      * Test if the component wants to set the content length

Modified: cocoon/branches/butterfly/src/test/org/apache/butterfly/components/pipeline/impl/NonCachingProcessingPipelineTestCase.java
==============================================================================
--- cocoon/branches/butterfly/src/test/org/apache/butterfly/components/pipeline/impl/NonCachingProcessingPipelineTestCase.java
(original)
+++ cocoon/branches/butterfly/src/test/org/apache/butterfly/components/pipeline/impl/NonCachingProcessingPipelineTestCase.java
Thu Aug 12 14:17:45 2004
@@ -82,8 +82,8 @@
             public boolean shouldSetContentLength() {
                 return false;
             }
-            public void setObjectModel(Map objectModel) {
-            }
+            public void setObjectModel(Map objectModel) {}
+            public void setMimeType(String mimeType) {}
         }; 
         
         stubTransformer = new Transformer() {
@@ -140,6 +140,7 @@
                 return null;
             }
             public void setEncoding(String encoding) {}
+            public void setMimeType(String mimeType) {}            
         };
         
         // Set up real components

Modified: cocoon/branches/butterfly/src/webapp/sitemap.groovy
==============================================================================
--- cocoon/branches/butterfly/src/webapp/sitemap.groovy	(original)
+++ cocoon/branches/butterfly/src/webapp/sitemap.groovy	Thu Aug 12 14:17:45 2004
@@ -26,19 +26,21 @@
         if (uri == "") {
             generate "file", "welcome.xml", []
             transform "trax", "welcome.xslt", [] 
-            serialize "xml", [ 'encoding': 'UTF-8' ]
+            serialize "xml", [ "encoding": "UTF-8", "mimeType": "text/html" ]
         } else if (m = (uri =~ "(.*)\.html")) {
             generate "file", m.group(1) + ".xml", []
             transform "trax", "welcome.xslt", []
-            serialize "xml", [ 'encoding': 'UTF-8' ] 
+            serialize "xml", [ "encoding": "UTF-8", "mimeType": "text/html" ] 
         } else if (m = (uri =~ "images/(.*)\.gif")) {
-            read "resources/images/" + m.group(1) + ".gif", "image/gif", []
+            read "resource", "resources/images/" + m.group(1) + ".gif", 
+                [ "mimeType": "image/gif" ]
         } else if (m = (uri =~ "styles/(.*)\.css")) {
-            read "resources/styles/" + m.group(1) + ".css", "text/css", []
+            read "resource", "resources/styles/" + m.group(1) + ".css",
+                [ "mimeType": "text/css" ]
         } else if (m = (uri == "sitemap.groovy")) {
             generate "file", "sitemap.xmap", []
             transform "trax", "sitemap.xslt", [] 
-            serialize "text", [ "mime-type": "text/plain" ]
+            serialize "text", []
         } else {
             return false;
         }

Mime
View raw message