summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/common-http/src/main
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-04-30 20:44:28 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-04-30 20:44:28 +0000
commitf8dee028695c57d27ddfc59936d073cfccaa1d4b (patch)
treedbc5f64055e28eabf9d8f61d5731ddb186bdd0c6 /sca-java-2.x/trunk/modules/common-http/src/main
parent95e2233ee7c33168a6c33a98d63a12ca35a6500f (diff)
Updating REST binding to use common-http cache context class and minor update to HTTPCacheContext factory method
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@939810 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/common-http/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPCacheContext.java99
1 files changed, 51 insertions, 48 deletions
diff --git a/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPCacheContext.java b/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPCacheContext.java
index 6688fb8a94..7f8048098c 100644
--- a/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPCacheContext.java
+++ b/sca-java-2.x/trunk/modules/common-http/src/main/java/org/apache/tuscany/sca/common/http/HTTPCacheContext.java
@@ -50,6 +50,57 @@ public class HTTPCacheContext {
public boolean ifRange;
/**
+ * Gets the cache context information (ETag, LastModified, predicates) from the Http request.
+ * @param request
+ * @return
+ */
+ public static HTTPCacheContext createCacheContextFromRequest( HttpServletRequest request ) throws java.text.ParseException {
+ HTTPCacheContext context = new HTTPCacheContext();
+
+ String eTag = request.getHeader( "If-Match" );
+ if ( eTag != null ) {
+ context.setETag( eTag );
+ context.setIfMatch( true );
+ }
+ eTag = request.getHeader( "If-None-Match" );
+ if ( eTag != null ) {
+ context.setETag( eTag );
+ context.setIfNoneMatch( true );
+ }
+ String lastModifiedString = request.getHeader( "If-Modified-Since" );
+ if ( lastModifiedString != null ) {
+ context.setLastModified( lastModifiedString );
+ context.setIfModifiedSince( true );
+ }
+ lastModifiedString = request.getHeader( "If-Unmodified-Since" );
+ if ( lastModifiedString != null ) {
+ context.setLastModified( lastModifiedString );
+ context.setIfUnmodifiedSince( true );
+ }
+ lastModifiedString = request.getHeader( "If-Range" );
+ if ( lastModifiedString != null ) {
+ context.setLastModified( lastModifiedString );
+ context.setIfRange( true );
+ }
+ return context;
+ }
+
+ /**
+ * Enabled is true whenever ETag, LastModified, or predicate is set.
+ * @return the enabled
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ /**
* An ETag is a unique ID for an item. It changes when
* a field in the item or the update date changes.
* See HTTP specification for how ETags work:
@@ -206,52 +257,4 @@ public class HTTPCacheContext {
+ sb.toString();
}
- /**
- * Gets the cache context information (ETag, LastModified, predicates) from the Http request.
- * @param request
- * @return
- */
- public static HTTPCacheContext getCacheContextFromRequest( HttpServletRequest request ) throws java.text.ParseException {
- HTTPCacheContext context = new HTTPCacheContext();
-
- String eTag = request.getHeader( "If-Match" );
- if ( eTag != null ) {
- context.setETag( eTag );
- context.setIfMatch( true );
- }
- eTag = request.getHeader( "If-None-Match" );
- if ( eTag != null ) {
- context.setETag( eTag );
- context.setIfNoneMatch( true );
- }
- String lastModifiedString = request.getHeader( "If-Modified-Since" );
- if ( lastModifiedString != null ) {
- context.setLastModified( lastModifiedString );
- context.setIfModifiedSince( true );
- }
- lastModifiedString = request.getHeader( "If-Unmodified-Since" );
- if ( lastModifiedString != null ) {
- context.setLastModified( lastModifiedString );
- context.setIfUnmodifiedSince( true );
- }
- lastModifiedString = request.getHeader( "If-Range" );
- if ( lastModifiedString != null ) {
- context.setLastModified( lastModifiedString );
- context.setIfRange( true );
- }
- return context;
- }
- /**
- * Enabled is true whenever ETag, LastModified, or predicate is set.
- * @return the enabled
- */
- public boolean isEnabled() {
- return enabled;
- }
- /**
- * @param enabled the enabled to set
- */
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
}