cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r664526 - /cocoon/trunk/subprojects/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java
Date Sun, 08 Jun 2008 17:17:45 GMT
Author: reinhard
Date: Sun Jun  8 10:17:45 2008
New Revision: 664526

URL: http://svn.apache.org/viewvc?rev=664526&view=rev
Log:
. make sure that there is an existing connection before reading the Last-Modified header

Modified:
    cocoon/trunk/subprojects/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java

Modified: cocoon/trunk/subprojects/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/subprojects/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java?rev=664526&r1=664525&r2=664526&view=diff
==============================================================================
--- cocoon/trunk/subprojects/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java
(original)
+++ cocoon/trunk/subprojects/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java
Sun Jun  8 10:17:45 2008
@@ -75,7 +75,7 @@
         this.response.setOutputStream(os);
 
         try {
-            performConnect();
+            this.performConnect();
             this.response.flushBuffer();
             this.responseBody = new ByteArrayInputStream(os.toByteArray());
         } finally {
@@ -87,7 +87,7 @@
 
     /**
      * Access the servlet and fill the response object.
-     *
+     * 
      * @throws ServletException
      * @throws IOException
      */
@@ -95,7 +95,7 @@
 
     /**
      * Return an <code>InputStream</code> object to read from the source.
-     *
+     * 
      * @throws IOException
      * @throws ServletException
      */
@@ -113,28 +113,37 @@
     }
 
     public long getLastModified() {
-        return this.getHeaderFieldDate("Last-Modified", 0);
+        if (!this.connected) {
+            try {
+                this.connect();
+            } catch (Exception e) {
+                this.logger.warn("Exception while reading the getLastModified data.");
+                return 0;
+            }
+        }
+        long headerFieldDate = this.getHeaderFieldDate("Last-Modified", 0);
+        return headerFieldDate;
     }
 
     public String getContentType() {
         return this.getHeaderField("Content-Type");
     }
 
-    public long getHeaderFieldDate(String name, long Default) {
+    public long getHeaderFieldDate(String name, long defaultValue) {
         try {
             return this.response.getDateHeader(name);
         } catch (Exception e) {
-            // FIXME We should do something about it.
+            this.logger.warn("Exception while reading the response header '" + name + "'.");
         }
 
-        return Default;
+        return defaultValue;
     }
 
     public String getHeaderField(String name) {
         try {
             this.connect();
         } catch (Exception e) {
-            // FIXME We should do something about it.
+            this.logger.warn("Exception while reading the response header '" + name + "'.");
             return null;
         }
 
@@ -155,10 +164,9 @@
 
     /**
      * Returns an output stream that writes as POST to this connection.
-     *
+     * 
      * @return an output stream that writes as POST to this connection.
-     * @throws IllegalStateException -
-     *             if already connected
+     * @throws IllegalStateException - if already connected
      */
     public OutputStream getOutputStream() throws IllegalStateException {
         if (this.connected) {
@@ -187,5 +195,4 @@
 
     }
 
-
 }



Mime
View raw message