tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r707751 - /tomcat/trunk/java/org/apache/naming/resources/ResourceAttributes.java
Date Fri, 24 Oct 2008 21:23:09 GMT
Author: markt
Date: Fri Oct 24 14:23:08 2008
New Revision: 707751

URL: http://svn.apache.org/viewvc?rev=707751&view=rev
Log:
Apply Remy's patch for 45735 and align trunk with 6.0.x.

Modified:
    tomcat/trunk/java/org/apache/naming/resources/ResourceAttributes.java

Modified: tomcat/trunk/java/org/apache/naming/resources/ResourceAttributes.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/ResourceAttributes.java?rev=707751&r1=707750&r2=707751&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/ResourceAttributes.java (original)
+++ tomcat/trunk/java/org/apache/naming/resources/ResourceAttributes.java Fri Oct 24 14:23:08
2008
@@ -710,38 +710,43 @@
     /**
      * Get ETag.
      * 
-     * @return strong ETag if available, else weak ETag.
+     * @return Weak ETag
      */
     public String getETag() {
-        String result = null;
-        if (attributes != null) {
-            Attribute attribute = attributes.get(ETAG);
-            if (attribute != null) {
-                try {
-                    result = attribute.get().toString();
-                } catch (NamingException e) {
-                    ; // No value for the attribute
-                }
-            }
-        }
-        if (result == null) {
-            if (strongETag != null) {
-                // The strong ETag must always be calculated by the resources
-                result = strongETag;
-            } else {
-                // The weakETag is contentLength + lastModified
-                if (weakETag == null) {
-                    long contentLength = getContentLength();
-                    long lastModified = getLastModified();
-                    if ((contentLength >= 0) || (lastModified >= 0)) {
-                        weakETag = "W/\"" + contentLength + "-" 
-                        + lastModified + "\"";
+        return getETag(false);
+    }
+
+
+    /**
+     * Get ETag.
+     * 
+     * @param strong If true, the strong ETag will be returned
+     * @return ETag
+     */
+    public String getETag(boolean strong) {
+        if (strong) {
+            // The strong ETag must always be calculated by the resources
+            if (strongETag != null)
+                return strongETag;
+            if (attributes != null) {
+                Attribute attribute = attributes.get(ETAG);
+                if (attribute != null) {
+                    try {
+                        strongETag = attribute.get().toString();
+                    } catch (NamingException e) {
+                        ; // No value for the attribute
                     }
                 }
-                result = weakETag;
             }
+            return strongETag;
+        } else {
+            // The weakETag is contentLenght + lastModified
+            if (weakETag == null) {
+                weakETag = "W/\"" + getContentLength() + "-" 
+                    + getLastModified() + "\"";
+            }
+            return weakETag;
         }
-        return result;
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message