remm 02/03/09 15:21:49 Modified: catalina/src/share/org/apache/naming/resources ResourceAttributes.java Log: - Add some hooks to allow the directory context implementation to compute strong etags. Revision Changes Path 1.5 +70 -5 jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/ResourceAttributes.java Index: ResourceAttributes.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/ResourceAttributes.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ResourceAttributes.java 28 Sep 2001 02:16:32 -0000 1.4 +++ ResourceAttributes.java 9 Mar 2002 23:21:49 -0000 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/ResourceAttributes.java,v 1.4 2001/09/28 02:16:32 remm Exp $ - * $Revision: 1.4 $ - * $Date: 2001/09/28 02:16:32 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/ResourceAttributes.java,v 1.5 2002/03/09 23:21:49 remm Exp $ + * $Revision: 1.5 $ + * $Date: 2002/03/09 23:21:49 $ * * ==================================================================== * @@ -83,7 +83,7 @@ * Attributes implementation. * * @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a> - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ public class ResourceAttributes implements Attributes { @@ -259,6 +259,18 @@ /** + * Weak ETag. + */ + protected String weakETag = null; + + + /** + * Strong ETag. + */ + protected String strongETag = null; + + + /** * External attributes. */ protected Attributes attributes = null; @@ -664,7 +676,60 @@ if (attributes != null) attributes.put(TYPE, resourceType); } - + + + /** + * Get ETag. + * + * @return Weak ETag + */ + public String getETag() { + return getETag(false); + } + + + /** + * Get ETag. + * + * @param strong If true, the strong ETag will be returned + * @return ETag + */ + public String getETag(boolean strong) { + 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 (strong) { + // The strong ETag must always be calculated by the resources + result = strongETag; + } else { + // The weakETag is contentLenght + lastModified + if (weakETag == null) { + weakETag = "W/\"" + getContentLength() + "-" + + getLastModified() + "\""; + } + result = weakETag; + } + return result; + } + + + /** + * Set strong ETag. + */ + public void setETag(String eTag) { + this.strongETag = eTag; + if (attributes != null) + attributes.put(ETAG, eTag); + } + // ----------------------------------------------------- Attributes Methods
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>