abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r438654 [1/2] - in /incubator/abdera/java/trunk: client/ client/src/main/java/org/apache/abdera/protocol/cache/ client/src/main/java/org/apache/abdera/protocol/client/ client/src/main/java/org/apache/abdera/protocol/util/ client/src/test/ja...
Date Wed, 30 Aug 2006 21:48:24 GMT
Author: jmsnell
Date: Wed Aug 30 14:48:22 2006
New Revision: 438654

URL: http://svn.apache.org/viewvc?rev=438654&view=rev
Log:
The Client and Server modules share many similiar APIs and code.  Refactor each so
that they extend from a common code base, allowing us to use the same APIs and
utility code on both the client and server.

Added:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbstractClientResponse.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ClientResponse.java
      - copied, changed from r434219, incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Request.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Response.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/
      - copied from r438108, incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/protocol/util/
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java
      - copied, changed from r434219, incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java
Removed:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ResponseBase.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/protocol/util/
Modified:
    incubator/abdera/java/trunk/client/pom.xml
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/Cache.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponse.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponseBase.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCache.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Client.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsResponse.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/MethodHelper.java
    incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/app/AppTest.java
    incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java
    incubator/abdera/java/trunk/examples/pom.xml
    incubator/abdera/java/trunk/server/pom.xml
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/exceptions/AbderaServerException.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/ServletRequestContext.java

Modified: incubator/abdera/java/trunk/client/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/pom.xml?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/pom.xml (original)
+++ incubator/abdera/java/trunk/client/pom.xml Wed Aug 30 14:48:22 2006
@@ -49,6 +49,12 @@
       <scope>compile</scope>
     </dependency>    
     <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-protocol</artifactId>
+      <version>0.2.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>  
+    <dependency>
       <groupId>commons-httpclient</groupId>
       <artifactId>commons-httpclient</artifactId>
     </dependency>

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/Cache.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/Cache.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/Cache.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/Cache.java Wed Aug 30 14:48:22 2006
@@ -18,7 +18,7 @@
 package org.apache.abdera.protocol.cache;
 
 import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.Response;
+import org.apache.abdera.protocol.client.ClientResponse;
 
 public interface Cache {
 
@@ -50,9 +50,9 @@
   void remove(
     CacheKey key);
   
-  Response update(
+  ClientResponse update(
     RequestOptions options, 
-    Response response,
-    Response cached_response);
+    ClientResponse response,
+    ClientResponse cached_response);
   
 }

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java Wed Aug 30 14:48:22 2006
@@ -18,9 +18,10 @@
 package org.apache.abdera.protocol.cache;
 
 import java.io.IOException;
+import java.util.List;
 
 import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.Response;
+import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.protocol.util.CacheControlUtil;
 
 public abstract class CacheBase 
@@ -36,17 +37,19 @@
       CacheKey key = getCacheKey(uri, options);
       CachedResponse response = get(key);
       if (response != null && options != null) {
-        String[] pragma = options.getHeaders("Pragma");
-        for (String s: pragma) {
-          if (s.equalsIgnoreCase("no-cache")) {
-            return CacheDisposition.TRANSPARENT;
+        List<String> pragma = options.getHeaders("Pragma");
+        if (pragma != null) {
+          for (String s: pragma) {
+            if (s.equalsIgnoreCase("no-cache")) {
+              return CacheDisposition.TRANSPARENT;
+            }
           }
         }
-        if (options.getNoCache()) 
+        if (options.isNoCache()) 
           return CacheDisposition.TRANSPARENT;
         else if (response.isNoCache())
           return CacheDisposition.STALE;
-        else if (options != null && options.getOnlyIfCached())
+        else if (options != null && options.isOnlyIfCached())
           return CacheDisposition.FRESH;
         else if (response.isMustRevalidate())
           return CacheDisposition.STALE;
@@ -93,12 +96,12 @@
     CachedResponse response);
 
   protected abstract CachedResponse createCachedResponse(
-    Response response, CacheKey key) throws IOException;
+    ClientResponse response, CacheKey key) throws IOException;
   
   protected abstract CacheKey getCacheKey(
     String uri, 
     RequestOptions options, 
-    Response response);
+    ClientResponse response);
   
   public CachedResponse getIfFreshEnough(
     String uri, 
@@ -119,7 +122,7 @@
   }
 
   private boolean shouldUpdateCache(
-    Response response,
+    ClientResponse response,
     boolean allowedByDefault) {
     // TODO: we should probably include pragma: no-cache headers in here 
       if (allowedByDefault) {
@@ -135,10 +138,10 @@
       }
   }
   
-  public Response update(
+  public ClientResponse update(
     RequestOptions options,
-    Response response,
-    Response cached_response) {
+    ClientResponse response,
+    ClientResponse cached_response) {
       int status = response.getStatus();  
       String uri = response.getUri();
       String method = response.getMethod();
@@ -170,9 +173,9 @@
       return response;
   }
    
-  private Response update(
+  private ClientResponse update(
     RequestOptions options,
-    Response response) {
+    ClientResponse response) {
       String uri = response.getUri();
       CacheKey key = getCacheKey(uri, options,response);
       try {

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponse.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponse.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponse.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponse.java Wed Aug 30 14:48:22 2006
@@ -17,9 +17,9 @@
 */
 package org.apache.abdera.protocol.cache;
 
-import org.apache.abdera.protocol.client.Response;
+import org.apache.abdera.protocol.client.ClientResponse;
 
-public interface CachedResponse extends Response {
+public interface CachedResponse extends ClientResponse {
 
   CacheKey geKey();
   

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponseBase.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponseBase.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponseBase.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CachedResponseBase.java Wed Aug 30 14:48:22 2006
@@ -19,10 +19,10 @@
 
 import java.util.Date;
 
-import org.apache.abdera.protocol.client.ResponseBase;
+import org.apache.abdera.protocol.client.AbstractClientResponse;
 
 public abstract class CachedResponseBase 
-  extends ResponseBase 
+  extends AbstractClientResponse 
   implements CachedResponse {
 
   protected CacheKey key = null;

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCache.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCache.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCache.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCache.java Wed Aug 30 14:48:22 2006
@@ -22,7 +22,7 @@
 import java.util.Map;
 
 import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.Response;
+import org.apache.abdera.protocol.client.ClientResponse;
 
 public abstract class InMemoryCache 
   extends CacheBase {
@@ -35,7 +35,7 @@
   
   @Override
   protected CachedResponse createCachedResponse(
-    Response response, 
+    ClientResponse response, 
     CacheKey key) 
       throws IOException {
     return new InMemoryCachedResponse(this, key, response);
@@ -60,7 +60,7 @@
   public CacheKey getCacheKey(
     String uri,
     RequestOptions options,
-    Response response) {
+    ClientResponse response) {
       //TODO: We need a complete solution that takes the Vary header into account
       return new SimpleCacheKey(uri);
   }

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/InMemoryCachedResponse.java Wed Aug 30 14:48:22 2006
@@ -21,13 +21,17 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.abdera.protocol.client.Response;
+import org.apache.abdera.protocol.client.ClientException;
+import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.protocol.util.CacheControlUtil;
 import org.apache.abdera.protocol.util.MethodHelper;
+import org.apache.commons.httpclient.util.DateParseException;
+import org.apache.commons.httpclient.util.DateUtil;
 
 public class InMemoryCachedResponse 
   extends CachedResponseBase
@@ -37,13 +41,13 @@
   private int status = 0;
   private String status_text = null;
   private String uri = null;
-  private Map<String,List<String>> headers = null;
+  private Map<String,List<Object>> headers = null;
   private byte[] buf = null;
   
   public InMemoryCachedResponse(
     Cache cache,
     CacheKey key,
-    Response response) 
+    ClientResponse response) 
       throws IOException {
     super(key,cache);
     this.method = response.getMethod();
@@ -74,9 +78,9 @@
     this.buf = out.toByteArray();
   }
   
-  private Map<String,List<String>> getHeaders() {
+  public Map<String,List<Object>> getHeaders() {
     if (headers == null)
-      headers = new HashMap<String,List<String>>();
+      headers = new HashMap<String,List<Object>>();
     return headers;
   }
   
@@ -85,19 +89,16 @@
   }
   
   public String getHeader(String header) {
-    List<String> values = getHeaders().get(header);
-    return (values != null) ? values.get(0) : null;
+    List<Object> values = getHeaders().get(header);
+    return (values != null) ? (String)values.get(0) : null;
   }
 
   public String[] getHeaderNames() {
     return getHeaders().keySet().toArray(new String[getHeaders().size()]);
   }
 
-  public String[] getHeaders(String header) {
-    List<String> values = getHeaders().get(header);
-    return (values != null) ?
-      values.toArray(new String[values.size()]) :
-      new String[0];
+  public List<Object> getHeaders(String header) {
+    return getHeaders().get(header);
   }
 
   public int getStatus() {
@@ -122,4 +123,14 @@
     throw new UnsupportedOperationException();
   }
     
+  public Date getDateHeader(String header) {
+    try {
+      String value = getHeader(header);
+      if (value != null)
+        return DateUtil.parseDate(value);
+      else return null;
+    } catch (DateParseException e) {
+      throw new ClientException(e); // server likely returned a bad date format
+    }
+  }
 }

Added: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbstractClientResponse.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbstractClientResponse.java?rev=438654&view=auto
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbstractClientResponse.java (added)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/AbstractClientResponse.java Wed Aug 30 14:48:22 2006
@@ -0,0 +1,101 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.client;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.parser.ParseException;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.parser.ParserOptions;
+import org.apache.abdera.protocol.util.AbstractResponse;
+import org.apache.abdera.protocol.util.CacheControlUtil;
+
+public abstract class AbstractClientResponse
+  extends AbstractResponse
+  implements ClientResponse {
+
+  protected InputStream in = null;
+  protected Date response_date = null;
+  protected Date now = new Date(); 
+  protected Abdera abdera = null;
+  protected Parser parser = null;
+  
+  protected synchronized Parser getParser() {
+    if (parser == null) {
+      if (abdera == null) abdera = new Abdera();
+      parser = abdera.getParser();
+    }
+    return parser;
+  }
+  
+  public <T extends Element>Document<T> getDocument() 
+    throws ParseException {
+      return getDocument(getParser());
+  }
+  
+  public <T extends Element>Document<T> getDocument(
+    ParserOptions options) 
+      throws ParseException {
+    return getDocument(getParser(), options);
+  }
+
+  public <T extends Element>Document<T> getDocument(
+    Parser parser) 
+      throws ParseException {
+    return getDocument(parser, parser.getDefaultParserOptions());
+  }
+  
+  public <T extends Element>Document<T> getDocument(
+    Parser parser, 
+    ParserOptions options) 
+      throws ParseException {
+    try {
+      return parser.parse(getInputStream(), getUri(), options);
+    } catch (Exception e) {
+      throw new ParseException(e);
+    }
+  }
+  
+  public InputStream getInputStream() throws IOException {
+    return in;
+  }
+
+  public void setInputStream(InputStream in) {
+    this.in = in;
+  }
+
+  public Date getServerDate() {
+    if (response_date == null) {
+      Date date = getDateHeader("Date");
+      response_date = (date != null) ? date : now;
+    }
+    return response_date;
+  }
+  
+  protected void parse_cc() {
+    String cc = getHeader("Cache-Control");
+    if (cc != null)
+      CacheControlUtil.parseCacheControl(cc, this);
+  }
+
+}

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Client.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Client.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Client.java Wed Aug 30 14:48:22 2006
@@ -110,111 +110,111 @@
     return cache;
   }
   
-  public Response head(
+  public ClientResponse head(
     String uri, 
     RequestOptions options) {
       return execute("HEAD", uri, null, options);
   }
   
-  public Response get(
+  public ClientResponse get(
     String uri, 
     RequestOptions options) {
       return execute("GET", uri, null, options);
   }
   
-  public Response post(
+  public ClientResponse post(
     String uri, 
     RequestEntity entity, 
     RequestOptions options) {
       return execute("POST", uri, entity, options);
   }
 
-  public Response post(
+  public ClientResponse post(
     String uri, 
     InputStream in, 
     RequestOptions options) {
       return execute("POST", uri, new InputStreamRequestEntity(in), options);
   }
 
-  public Response post(
+  public ClientResponse post(
     String uri, 
     Base base, 
     RequestOptions options) {
       return execute("POST", uri, new BaseRequestEntity(base), options);
   }
     
-  public Response put(
+  public ClientResponse put(
     String uri, 
     RequestEntity entity, 
     RequestOptions options) {
       return execute("PUT", uri, entity, options);
   }
 
-  public Response put(
+  public ClientResponse put(
     String uri, 
     InputStream in, 
     RequestOptions options) {
       return execute("PUT", uri, new InputStreamRequestEntity(in), options);
   }
 
-  public Response put(
+  public ClientResponse put(
       String uri, 
       Base base, 
       RequestOptions options) {
     return execute("PUT", uri, new BaseRequestEntity(base), options);
   }
       
-  public Response delete(
+  public ClientResponse delete(
     String uri, 
     RequestOptions options) {
       return execute("DELETE", uri, null, options);
   }
   
-  public Response head(String uri) {
+  public ClientResponse head(String uri) {
     return head(uri, getDefaultRequestOptions());
   }
   
-  public Response get(String uri) {
+  public ClientResponse get(String uri) {
     return get(uri, getDefaultRequestOptions());
   }
     
-  public Response post(
+  public ClientResponse post(
     String uri, 
     RequestEntity entity) {
     return post(uri, entity, getDefaultRequestOptions());
   }
   
-  public Response post(
+  public ClientResponse post(
     String uri, 
     InputStream in) {
       return post(uri, in, getDefaultRequestOptions());
   }
   
-  public Response post(
+  public ClientResponse post(
     String uri, 
     Base base) {
       return post(uri, base, getDefaultRequestOptions());
   }
 
-  public Response put(
+  public ClientResponse put(
     String uri, 
     RequestEntity entity) {
       return put(uri, entity, getDefaultRequestOptions());
   }
   
-  public Response put(
+  public ClientResponse put(
     String uri, 
     InputStream in) {
       return put(uri, in, getDefaultRequestOptions());
   }
   
-  public Response put(
+  public ClientResponse put(
     String uri, 
     Base base) {
       return put(uri, base, getDefaultRequestOptions());
   }
 
-  public Response delete(
+  public ClientResponse delete(
     String uri) {
       return delete(uri, getDefaultRequestOptions());
   }
@@ -228,7 +228,7 @@
    * @param options The options to use for this request
    * @return the server's response
    */
-  public abstract Response execute(
+  public abstract ClientResponse execute(
     String method, 
     String uri, 
     RequestEntity entity, 

Copied: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ClientResponse.java (from r434219, incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ClientResponse.java?p2=incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ClientResponse.java&p1=incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java&r1=434219&r2=438654&rev=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/Response.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/ClientResponse.java Wed Aug 30 14:48:22 2006
@@ -21,50 +21,19 @@
 import java.io.InputStream;
 import java.util.Date;
 
-import javax.activation.MimeType;
-
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Element;
 import org.apache.abdera.parser.ParseException;
 import org.apache.abdera.parser.Parser;
 import org.apache.abdera.parser.ParserOptions;
+import org.apache.abdera.protocol.Response;
 
-public interface Response {
-
-  public static enum ResponseType {
-    SUCCESS, REDIRECTION, CLIENT_ERROR, SERVER_ERROR, UNKNOWN
-  }
+public interface ClientResponse extends Response {
 
-  ResponseType getResponseClass();
-  
   String getMethod();
   
-  int getStatus();
-  
   String getUri();
   
-  String getStatusText();
-  
-  Date getLastModified();
-  
-  String getEntityTag();
-  
-  MimeType getContentType();
-  
-  Date getServerDate();
-  
-  String getLocation();
-  
-  String getContentLocation();
-  
-  String getHeader(String header);
-  
-  Date getDateHeader(String header);
-  
-  String[] getHeaders(String header);
-  
-  String[] getHeaderNames();
-  
   void release();
   
   InputStream getInputStream() throws IOException;
@@ -79,26 +48,6 @@
   
   <T extends Element>Document<T> getDocument(Parser parser, ParserOptions options) throws ParseException;
   
-  boolean isPrivate();
-  
-  boolean isPublic();
-  
-  boolean isNoCache();
-  
-  boolean isNoStore();
-  
-  boolean isNoTransform();
-  
-  boolean isMustRevalidate();
-  
-  long getMaxAge();
-  
-  long getAge();
-  
-  Date getExpires();
-  
-  String[] getNoCacheHeaders();
-  
-  String[] getPrivateHeaders();
+  Date getServerDate();
   
 }

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsClient.java Wed Aug 30 14:48:22 2006
@@ -75,8 +75,8 @@
     String method, 
     RequestOptions options) {
       return (CacheControlUtil.isIdempotent(method)) &&
-        !options.getNoCache() &&
-        !options.getNoStore() &&
+        !options.isNoCache() &&
+        !options.isNoStore() &&
         options.getUseLocalCache();
   }
   
@@ -93,7 +93,7 @@
   }
   
   @Override
-  public Response execute(
+  public ClientResponse execute(
     String method, 
     String uri, 
     RequestEntity entity,
@@ -127,7 +127,7 @@
               MethodHelper.createMethod(
                 method, uri, entity, options);
             client.executeMethod(httpMethod);
-            Response response = new CommonsResponse(httpMethod);
+            ClientResponse response = new CommonsResponse(httpMethod);
             return (options.getUseLocalCache()) ?
               response = cache.update(options, response, cached_response) : 
               response;

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsResponse.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsResponse.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsResponse.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/CommonsResponse.java Wed Aug 30 14:48:22 2006
@@ -20,7 +20,10 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.InflaterInputStream;
 import java.util.zip.ZipInputStream;
@@ -29,10 +32,12 @@
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.URIException;
+import org.apache.commons.httpclient.util.DateParseException;
+import org.apache.commons.httpclient.util.DateUtil;
 
 public class CommonsResponse 
-  extends ResponseBase
-  implements Response {
+  extends AbstractClientResponse
+  implements ClientResponse {
 
   private HttpMethod method = null;
     
@@ -71,13 +76,27 @@
     else return null;
   }
 
-  public String[] getHeaders(String header) {
+  public List<Object> getHeaders(String header) {
     Header[] headers = method.getResponseHeaders(header);
-    String[] values = new String[headers.length];
-    for (int n = 0; n < headers.length; n++) {
-      values[n] = headers[n].getValue();
+    List<Object> values = new ArrayList<Object>();
+    for (Header h : headers) {
+      values.add(h.getValue());
+    }
+    return java.util.Collections.unmodifiableList(values);
+  }
+  
+  public Map<String,List<Object>> getHeaders() {
+    Header[] headers = method.getResponseHeaders();
+    Map<String,List<Object>> map = new HashMap<String,List<Object>>();
+    for (Header header : headers) {
+      List<Object> values = map.get(header.getName());
+      if (values == null) {
+        values = new ArrayList<Object>();
+        map.put(header.getName(),values);
+      }
+      values.add(header.getValue());
     }
-    return values;
+    return java.util.Collections.unmodifiableMap(map);
   }
   
   public String[] getHeaderNames() {
@@ -123,4 +142,15 @@
     return super.getInputStream();
   }
 
+  public Date getDateHeader(String header) {
+    try {
+      String value = getHeader(header);
+      if (value != null)
+        return DateUtil.parseDate(value);
+      else return null;
+    } catch (DateParseException e) {
+      throw new ClientException(e); // server likely returned a bad date format
+    }
+  }
+  
 }

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/client/RequestOptions.java Wed Aug 30 14:48:22 2006
@@ -26,20 +26,16 @@
 
 import javax.activation.MimeType;
 
+import org.apache.abdera.protocol.Request;
+import org.apache.abdera.protocol.util.AbstractRequest;
 import org.apache.abdera.protocol.util.CacheControlUtil;
 import org.apache.commons.httpclient.util.DateParseException;
 import org.apache.commons.httpclient.util.DateUtil;
 
-public class RequestOptions {
+public class RequestOptions
+  extends AbstractRequest 
+  implements Request {
 
-  private byte flags = 0;
-  private final static byte NOCACHE = 1;
-  private final static byte NOSTORE = 2;
-  private final static byte NOTRANSFORM = 4;
-  private final static byte ONLYIFCACHED = 8;
-  private long max_age = -1;
-  private long max_stale = -1;
-  private long min_fresh = -1;
   private boolean noLocalCache = false;
   private boolean revalidateAuth = false;
   
@@ -110,18 +106,10 @@
     setHeader("Content-Type", value.toString());
   }
   
-  public String getContentType() {
-    return getHeader("Content-Type");
-  }
-  
   public void setAuthorization(String auth) {
     setHeader("Authorization", auth);
   }
   
-  public String getAuthorization() {
-    return getHeader("Authorization");
-  }
-  
   public void setHeader(String header, String value) {
     if (value != null)
       setHeader(header, new String[] {value});
@@ -171,11 +159,8 @@
     return (list != null) ? list.get(0) : null;
   }
   
-  public String[] getHeaders(String header) {
-    List<String> list = getHeaders().get(header);
-    return (list != null) ? 
-      list.toArray(new String[list.size()]) : 
-      new String[0];
+  public List<String> getHeaders(String header) {
+    return getHeaders().get(header);
   }
   
   public Date getDateHeader(String header) {
@@ -188,12 +173,8 @@
   }
 
   public String[] getHeaderNames() {
-    Set<String> set = getHeaders().keySet();
-    return set.toArray(new String[set.size()]);
-  }
-  
-  public String getIfMatch() {
-    return getHeader("If-Match");
+    Set<String> names = getHeaders().keySet(); 
+    return names.toArray(new String[names.size()]);
   }
   
   public void setIfMatch(String entity_tag) {
@@ -204,10 +185,6 @@
     setHeader("If-Match", entity_tags);
   }
   
-  public String getIfNoneMatch() {
-    return getHeader("If-None-Match");
-  }
-  
   public void setIfNoneMatch(String entity_tag) {
     setHeader("If-None-Match", entity_tag);
   }
@@ -216,26 +193,14 @@
     setHeader("If-None-Match", entity_tags);
   }
   
-  public Date getIfModifiedSince() {
-    return getDateHeader("If-Modified-Since");
-  }
-  
   public void setIfModifiedSince(Date date) {
     setDateHeader("If-Modified-Since", date);
   }
   
-  public Date getIfUnmodifiedSince() {
-    return getDateHeader("If-Unmodified-Since");
-  }
-  
   public void setIfUnmodifiedSince(Date date) {
     setDateHeader("If-Unmodified-Since", date);
   }
   
-  public String getAccept() {
-    return getHeader("Accept");
-  }
-  
   public void setAccept(String accept) {
     setAccept(new String[] {accept});
   }
@@ -244,10 +209,6 @@
     setHeader("Accept", combine(accept));
   }
   
-  public String getAcceptLanguage() {
-    return getHeader("Accept-Language");
-  }
-  
   public void setAcceptLanguage(String accept) {
     setAcceptLanguage(new String[] {accept});
   }
@@ -256,10 +217,6 @@
     setHeader("Accept-Language", combine(accept));
   }
   
-  public String getAcceptCharset() {
-    return getHeader("Accept-Charset");
-  }
-  
   public void setAcceptCharset(String accept) {
     setAcceptCharset(new String[] {accept});
   }
@@ -268,10 +225,6 @@
     setHeader("Accept-Charset", combine(accept));
   }
   
-  public String getAcceptEncoding() {
-    return getHeader("Accept-Encoding");
-  }
-  
   public void setAcceptEncoding(String accept) {
     setAcceptEncoding(new String[] {accept});
   }
@@ -288,66 +241,6 @@
     return getHeader("Slug");
   }
   
-  public boolean getOnlyIfCached() {
-    return (flags & ONLYIFCACHED) == ONLYIFCACHED;
-  }
-  
-  public void setOnlyIfCached(boolean condition) {
-    if (condition) flags |= ONLYIFCACHED;
-    else if (getOnlyIfCached()) flags ^= ONLYIFCACHED;
-  }
-  
-  public boolean getNoTransform() {
-    return (flags & NOTRANSFORM) == NOTRANSFORM;
-  }
-  
-  public void setNoTransform(boolean condition) {
-    if (condition) flags |= NOTRANSFORM;
-    else if (getNoTransform()) flags ^= NOTRANSFORM;
-  }
-  
-  public boolean getNoCache() {
-    return (flags & NOCACHE) == NOCACHE;
-  }
-  
-  public void setNoCache(boolean condition) {
-    if (condition) flags |= NOCACHE;
-    else if (getNoCache()) flags ^= NOCACHE;
-  }
-  
-  public boolean getNoStore() {
-    return (flags & NOSTORE) == NOSTORE;
-  }
-  
-  public void setNoStore(boolean condition) {
-    if (condition) flags |= NOSTORE;
-    else if (getNoStore()) flags ^= NOSTORE;
-  }
-  
-  public long getMaxAge() {
-    return max_age;
-  }
-  
-  public void setMaxAge(long condition) {
-    this.max_age = condition;
-  }
-  
-  public long getMaxStale() {
-    return max_stale;
-  }
-  
-  public void setMaxStale(long condition) {
-    this.max_stale = condition;
-  }
-  
-  public long getMinFresh() {
-    return this.min_fresh;
-  }
-  
-  public void setMinFresh(long condition) {
-    this.min_fresh = condition;
-  }
-  
   public void setCacheControl(String cc) {
     CacheControlUtil.parseCacheControl(cc, this);
   }
@@ -357,22 +250,9 @@
   }
   
   public String getCacheControl() {
-    StringBuffer buf = new StringBuffer();
-    if (getNoCache()) append(buf,"no-cache");
-    if (getNoStore()) append(buf,"no-store");
-    if (getNoTransform()) append(buf, "no-transform");
-    if (getOnlyIfCached()) append(buf, "only-if-cached");
-    if (getMaxAge() != -1) append(buf, "max-age=" + getMaxAge());
-    if (getMaxStale() != -1) append(buf, "max-stale=" + getMaxStale());
-    if (getMinFresh() != -1) append(buf, "min-fresh=" + getMinFresh());
-    return buf.toString();
-  }
-  
-  private void append(StringBuffer buf, String value) {
-    if (buf.length() > 0) buf.append(", ");
-    buf.append(value);
+    return CacheControlUtil.buildCacheControl(this);
   }
-  
+
   public boolean getRevalidateWithAuth() {
     return revalidateAuth;
   }

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/MethodHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/MethodHelper.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/MethodHelper.java (original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/MethodHelper.java Wed Aug 30 14:48:22 2006
@@ -17,13 +17,12 @@
 */
 package org.apache.abdera.protocol.util;
 
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.Response;
+import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.URI;
 import org.apache.commons.httpclient.methods.DeleteMethod;
@@ -61,13 +60,12 @@
     }
   }
 
-  public static Map<String,List<String>> getCacheableHeaders(Response response) {
-    Map<String,List<String>> map = new HashMap<String,List<String>>();
+  public static Map<String,List<Object>> getCacheableHeaders(ClientResponse response) {
+    Map<String,List<Object>> map = new HashMap<String,List<Object>>();
     String[] headers = response.getHeaderNames();
     for (String header : headers) {
       if (MethodHelper.isCacheableHeader(header, response)) {
-        String[] values = response.getHeaders(header);
-        List<String> list = Arrays.asList(values);
+        List<Object> list = response.getHeaders(header);
         map.put(header, list);
       }
     }
@@ -75,14 +73,14 @@
   }
   
   public static boolean isCacheableHeader(
-    String header, Response response) {
+    String header, ClientResponse response) {
       return !isNoCacheOrPrivate(header, response) &&
              !isHopByHop(header);
   }
   
   public static boolean isNoCacheOrPrivate(
     String header, 
-    Response response) {
+    ClientResponse response) {
       String[] no_cache_headers = response.getNoCacheHeaders();
       String[] private_headers = response.getPrivateHeaders();
       return contains(no_cache_headers,header) ||
@@ -144,7 +142,7 @@
   private static void initHeaders(RequestOptions options, HttpMethod method) {
     String[] headers = options.getHeaderNames();
     for (String header : headers) {
-      String[] values = options.getHeaders(header);
+      List<String> values = options.getHeaders(header);
       for (String value : values) {
         method.addRequestHeader(header, value);
       }

Modified: incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/app/AppTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/app/AppTest.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/app/AppTest.java (original)
+++ incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/app/AppTest.java Wed Aug 30 14:48:22 2006
@@ -45,7 +45,7 @@
 import org.apache.abdera.protocol.client.Client;
 import org.apache.abdera.protocol.client.CommonsClient;
 import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.Response;
+import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.test.client.JettyTest;
 import org.apache.abdera.util.MimeTypeHelper;
 
@@ -336,7 +336,7 @@
     RequestOptions options = client.getDefaultRequestOptions();
     options.setHeader("Connection", "close");
     // do the introspection step
-    Response response = client.get("http://localhost:8080/service",options);
+    ClientResponse response = client.get("http://localhost:8080/service",options);
     assertEquals(response.getStatus(),200);
     Document<Service> service_doc = response.getDocument();
     assertNotNull(service_doc);
@@ -356,7 +356,7 @@
     assertNotNull(response.getLocation());
     assertNotNull(response.getContentLocation());
     
-    String self_uri = response.getLocation();
+    String self_uri = response.getLocation().toString();
     
     // get the collection to see if our entry is there
     response = client.get(col_uri, options);
@@ -409,7 +409,7 @@
     assertNotNull(response.getLocation());
     assertNotNull(response.getContentLocation());
     
-    self_uri = response.getLocation();
+    self_uri = response.getLocation().toString();
 
     // was an entry created?
     options = client.getDefaultRequestOptions();

Modified: incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java (original)
+++ incubator/abdera/java/trunk/client/src/test/java/org/apache/abdera/test/client/cache/CacheTest.java Wed Aug 30 14:48:22 2006
@@ -26,7 +26,7 @@
 import org.apache.abdera.protocol.client.Client;
 import org.apache.abdera.protocol.client.CommonsClient;
 import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.Response;
+import org.apache.abdera.protocol.client.ClientResponse;
 import org.apache.abdera.test.client.JettyTest;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.mortbay.jetty.servlet.ServletHandler;
@@ -265,7 +265,7 @@
     RequestOptions options = client.getDefaultRequestOptions();
     options.setHeader("Connection", "close");
     options.setHeader("x-reqnum", "1");
-    Response response = client.get(CHECK_MUST_REVALIDATE, options);
+    ClientResponse response = client.get(CHECK_MUST_REVALIDATE, options);
   
     String resp1 = getResponse(response);
     assertEquals(resp1, "1");
@@ -292,7 +292,7 @@
     RequestOptions options = client.getDefaultRequestOptions();
     options.setHeader("Connection", "close");
     options.setHeader("x-reqnum", "1");
-    Response response = client.get(CHECK_CACHE_INVALIDATE, options);
+    ClientResponse response = client.get(CHECK_CACHE_INVALIDATE, options);
   
     String resp1 = getResponse(response);
     response.release();
@@ -335,7 +335,7 @@
     RequestOptions options = client.getDefaultRequestOptions();
     options.setHeader("Connection", "close");
     options.setHeader("x-reqnum", "1");
-    Response response = client.get(CHECK_CACHE_INVALIDATE, options);  
+    ClientResponse response = client.get(CHECK_CACHE_INVALIDATE, options);  
     String resp1 = getResponse(response);
     assertEquals(resp1, "1");
     
@@ -371,7 +371,7 @@
     options.setHeader("Connection", "close");
     options.setHeader("x-reqnum", "1");
     options.setHeader("x-reqtest", String.valueOf(type));
-    Response response = client.get(CHECK_NO_CACHE, options);
+    ClientResponse response = client.get(CHECK_NO_CACHE, options);
   
     String resp1 = getResponse(response);
     assertEquals(resp1, "1");
@@ -391,7 +391,7 @@
     assertEquals(resp3, "3");
   }
   
-  private static String getResponse(Response response) throws IOException {
+  private static String getResponse(ClientResponse response) throws IOException {
     ByteArrayOutputStream out = new ByteArrayOutputStream();
     int m = -1;
     InputStream in = response.getInputStream();

Modified: incubator/abdera/java/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/pom.xml?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/examples/pom.xml (original)
+++ incubator/abdera/java/trunk/examples/pom.xml Wed Aug 30 14:48:22 2006
@@ -47,7 +47,13 @@
       <artifactId>abdera-parser</artifactId>
       <version>0.2.0-incubating-SNAPSHOT</version>
       <scope>compile</scope>
-    </dependency>    
+    </dependency> 
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-protocol</artifactId>
+      <version>0.2.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>       
     <dependency>
       <groupId>org.apache.abdera</groupId>
       <artifactId>abdera-client</artifactId>

Added: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Request.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Request.java?rev=438654&view=auto
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Request.java (added)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Request.java Wed Aug 30 14:48:22 2006
@@ -0,0 +1,74 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+
+import org.apache.abdera.protocol.util.ProtocolConstants;
+
+public interface Request extends ProtocolConstants {
+
+  String getHeader(String name);
+  
+  List<String> getHeaders(String name);
+  
+  String[] getHeaderNames();
+  
+  String getAccept();
+  
+  String getAcceptCharset();
+  
+  String getAcceptEncoding();
+  
+  String getAcceptLanguage();
+  
+  String getAuthorization();
+  
+  String getCacheControl();
+  
+  MimeType getContentType() throws MimeTypeParseException;
+  
+  Date getDateHeader(String name);
+  
+  String getIfMatch();
+  
+  Date getIfModifiedSince();
+  
+  String getIfNoneMatch();
+  
+  Date getIfUnmodifiedSince();
+  
+  long getMaxAge();
+  
+  long getMaxStale();
+  
+  long getMinFresh();
+  
+  boolean isNoCache();
+  
+  boolean isNoStore();
+  
+  boolean isNoTransform();
+  
+  boolean isOnlyIfCached();
+  
+}

Added: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Response.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Response.java?rev=438654&view=auto
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Response.java (added)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Response.java Wed Aug 30 14:48:22 2006
@@ -0,0 +1,99 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+
+import org.apache.abdera.protocol.util.ProtocolConstants;
+
+public interface Response extends ProtocolConstants {
+
+  public static enum ResponseType {
+    SUCCESS, REDIRECTION, CLIENT_ERROR, SERVER_ERROR, UNKNOWN
+  }
+  
+  public ResponseType getType();
+  
+  public int getStatus();
+  
+  public String getStatusText();
+  
+  public Date getLastModified();
+  
+  public String getEntityTag();
+  
+  public String getContentLanguage();
+  
+  public URI getContentLocation() throws URISyntaxException;
+  
+  public long getContentLength();
+  
+  public MimeType getContentType() throws MimeTypeParseException;
+  
+  public String getAllow();
+  
+  public URI getLocation() throws URISyntaxException;
+  
+  public Date getDateHeader(String name);
+  
+  public URI getUriHeader(String name) throws URISyntaxException;
+  
+  public String getHeader(String name);
+  
+  public List<Object> getHeaders(String name);
+  
+  public Map<String, List<Object>> getHeaders();
+  
+  public String[] getHeaderNames();
+  
+  boolean isPrivate();
+  
+  boolean isPublic();
+  
+  boolean isNoCache();
+  
+  boolean isNoStore();
+  
+  boolean isNoTransform();
+  
+  boolean isMustRevalidate();
+  
+  boolean isProxyRevalidate();
+  
+  long getMaxAge();
+  
+  long getSMaxAge();
+  
+  long getAge();
+  
+  Date getExpires();
+  
+  String[] getNoCacheHeaders();
+  
+  String[] getPrivateHeaders();
+  
+  String getCacheControl();
+  
+}

Added: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java?rev=438654&view=auto
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java (added)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractRequest.java Wed Aug 30 14:48:22 2006
@@ -0,0 +1,138 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.util;
+
+import java.util.Date;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+
+import org.apache.abdera.protocol.Request;
+
+public abstract class AbstractRequest implements Request {
+
+  protected int flags = 0;
+  protected long max_age = -1;
+  protected long max_stale = -1;
+  protected long min_fresh = -1;
+  
+  public String getAccept() {
+    return getHeader("Accept");
+  }
+
+  public String getAcceptCharset() {
+    return getHeader("Accept-Charset");
+  }
+
+  public String getAcceptEncoding() {
+    return getHeader("Accept-Encoding");
+  }
+
+  public String getAcceptLanguage() {
+    return getHeader("Accept-Language");
+  }
+
+  public String getAuthorization() {
+    return getHeader("Authorization");
+  }
+
+  public String getCacheControl() {
+    return getHeader("Cache-Control");
+  }
+
+  public MimeType getContentType() throws MimeTypeParseException {
+    String value = getHeader("Content-Type");
+    return (value != null) ? new MimeType(value) : null;
+  }
+
+  public String getIfMatch() {
+    return getHeader("If-Match");
+  }
+
+  public Date getIfModifiedSince() {
+    return getDateHeader("If-Modified-Since");
+  }
+
+  public String getIfNoneMatch() {
+    return getHeader("If-None-Match");
+  }
+
+  public Date getIfUnmodifiedSince() {
+    return getDateHeader("If-Unmodified-Since");
+  }
+
+  public long getMaxAge() {
+    return max_age;
+  }
+
+  public long getMaxStale() {
+    return max_stale;
+  }
+
+  public long getMinFresh() {
+    return min_fresh;
+  }
+
+  public boolean isNoCache() {
+    return (flags & NOCACHE) == NOCACHE; 
+  }
+
+  public boolean isNoStore() {
+    return (flags & NOSTORE) == NOSTORE;
+  }
+
+  public boolean isNoTransform() {
+    return (flags & NOTRANSFORM) == NOTRANSFORM;
+  }
+
+  public boolean isOnlyIfCached() {
+    return (flags & ONLYIFCACHED) == ONLYIFCACHED;
+  }
+
+  public void setMaxAge(long max_age) {
+    this.max_age = max_age;
+  }
+  
+  public void setMaxStale(long max_stale) {
+    this.max_stale = max_stale;
+  }
+  
+  public void setMinFresh(long min_fresh) {
+    this.min_fresh = min_fresh;
+  }
+  
+  public void setNoCache(boolean val) {
+    if (val) flags |= NOCACHE;
+    else if (isNoCache()) flags ^= NOCACHE;
+  }
+  
+  public void setNoStore(boolean val) {
+    if (val) flags |= NOSTORE;
+    else if (isNoStore()) flags ^= NOSTORE;
+  }
+  
+  public void setNoTransform(boolean val) {
+    if (val) flags |= NOTRANSFORM;
+    else if (isNoTransform()) flags ^= NOTRANSFORM;
+  }
+  
+  public void setOnlyIfCached(boolean val) {
+    if (val) flags |= ONLYIFCACHED;
+    else if (isOnlyIfCached()) flags ^= ONLYIFCACHED;
+  }
+}

Added: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java?rev=438654&view=auto
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java (added)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/AbstractResponse.java Wed Aug 30 14:48:22 2006
@@ -0,0 +1,190 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.util;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Date;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+
+import org.apache.abdera.protocol.Response;
+
+public abstract class AbstractResponse 
+  implements Response {
+
+  protected int flags = 0;
+  protected String[] nocache_headers = null;
+  protected String[] private_headers = null;
+  protected long max_age = -1;
+  protected long smax_age = -1;
+  
+  public long getAge() {
+    String value = getHeader("Age");
+    return (value != null) ? Long.parseLong(value) : -1;
+  }
+
+  public String getAllow() {
+    return getHeader("Allow");
+  }
+
+  public String getCacheControl() {
+    return getHeader("Cache-Control");
+  }
+
+  public String getContentLanguage() {
+    return getHeader("Content-Language");
+  }
+
+  public long getContentLength() {
+    String value = getHeader("Content-Length");
+    return (value != null) ? Long.parseLong(value) : -1;
+  }
+
+  public URI getContentLocation() throws URISyntaxException {
+    return getUriHeader("Content-Location");
+  }
+
+  public MimeType getContentType() throws MimeTypeParseException {
+    String value = getHeader("Content-Type");
+    return (value != null) ? new MimeType(value) : null;
+  }
+
+  public String getEntityTag() {
+    return getHeader("ETag");
+  }
+
+  public Date getExpires() {
+    return getDateHeader("Expires");
+  }
+
+  public Date getLastModified() {
+    return getDateHeader("Last-Modified");
+  }
+
+  public URI getLocation() throws URISyntaxException {
+    return getUriHeader("Location");
+  }
+
+  public long getMaxAge() {
+    return max_age;
+  }
+
+  public String[] getNoCacheHeaders() {
+    return nocache_headers;
+  }
+
+  public String[] getPrivateHeaders() {
+    return private_headers;
+  }
+
+  public long getSMaxAge() {
+    return smax_age;
+  }
+
+  public ResponseType getType() {
+    int status = getStatus();
+    if (status >= 200 && status < 300) return ResponseType.SUCCESS;
+    if (status >= 300 && status < 400) return ResponseType.REDIRECTION;
+    if (status >= 400 && status < 500) return ResponseType.CLIENT_ERROR;
+    if (status >= 500 && status < 600) return ResponseType.SERVER_ERROR;
+    return ResponseType.UNKNOWN;
+  }
+
+  public URI getUriHeader(String name) throws URISyntaxException {
+    String value = getHeader(name);
+    return (value != null) ? new URI(value) : null;
+  }
+
+  public boolean isMustRevalidate() {
+    return (flags & REVALIDATE) == REVALIDATE;
+  }
+
+  public boolean isNoCache() {
+    return (flags & NOCACHE) == NOCACHE;
+  }
+
+  public boolean isNoStore() {
+    return (flags & NOSTORE) == NOSTORE;
+  }
+
+  public boolean isNoTransform() {
+    return (flags & NOTRANSFORM) == NOTRANSFORM;
+  }
+
+  public boolean isPrivate() {
+    return (flags & PRIVATE) == PRIVATE;
+  }
+
+  public boolean isProxyRevalidate() {
+    return (flags & PROXYREVALIDATE) == PROXYREVALIDATE;
+  }
+
+  public boolean isPublic() {
+    return (flags & PUBLIC) == PUBLIC;
+  }
+
+  public void setMaxAge(long max_age) {
+    this.max_age = max_age;
+  }
+  
+  public void setMustRevalidate(boolean val) {
+    if (val) flags |= REVALIDATE;
+    else if (isMustRevalidate()) flags ^= REVALIDATE;
+  }
+  
+  public void setProxyRevalidate(boolean val) {
+    if (val) flags |= PROXYREVALIDATE;
+    else if (isProxyRevalidate()) flags ^= PROXYREVALIDATE;
+  }
+  
+  public void setNoCache(boolean val) {
+    if (val) flags |= NOCACHE;
+    else if (isNoCache()) flags ^= NOCACHE;
+  }
+  
+  public void setNoStore(boolean val) {
+    if (val) flags |= NOSTORE;
+    else if (isNoStore()) flags ^= NOSTORE;
+  }
+  
+  public void setNoTransform(boolean val) {
+    if (val) flags |= NOTRANSFORM;
+    else if (isNoTransform()) flags ^= NOTRANSFORM;
+  }
+  
+  public void setPublic(boolean val) {
+    if (val) flags |= PUBLIC;
+    else if (isPublic()) flags ^= PUBLIC;
+  }
+  
+  public void setPrivate(boolean val) {
+    if (val) flags |= PRIVATE;
+    else if (isPrivate()) flags ^= PRIVATE;
+  }
+  
+  public void setPrivateHeaders(String... headers) {
+    this.private_headers = headers;
+  }
+  
+  public void setNoCacheHeaders(String... headers) {
+    this.nocache_headers = headers;
+  }
+
+}

Copied: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java (from r434219, incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java?p2=incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java&p1=incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java&r1=434219&r2=438654&rev=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java (original)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/CacheControlUtil.java Wed Aug 30 14:48:22 2006
@@ -17,9 +17,6 @@
 */
 package org.apache.abdera.protocol.util;
 
-import org.apache.abdera.protocol.client.RequestOptions;
-import org.apache.abdera.protocol.client.ResponseBase;
-
 public class CacheControlUtil {
 
   public static boolean isIdempotent(String method) {
@@ -32,38 +29,55 @@
     return (val != null) ? Long.parseLong(val) : -1; 
   }
   
+  private static void append(StringBuffer buf, String value) {
+    if (buf.length() > 0) buf.append(", ");
+    buf.append(value);
+  }
+
+  public static String buildCacheControl(AbstractRequest request) {
+    StringBuffer buf = new StringBuffer();
+    if (request.isNoCache()) append(buf,"no-cache");
+    if (request.isNoStore()) append(buf,"no-store");
+    if (request.isNoTransform()) append(buf, "no-transform");
+    if (request.isOnlyIfCached()) append(buf, "only-if-cached");
+    if (request.getMaxAge() != -1) append(buf, "max-age=" + request.getMaxAge());
+    if (request.getMaxStale() != -1) append(buf, "max-stale=" + request.getMaxStale());
+    if (request.getMinFresh() != -1) append(buf, "min-fresh=" + request.getMinFresh());
+    return buf.toString();
+  }
+  
   public static void parseCacheControl(
     String cc, 
-    RequestOptions options) {
+    AbstractRequest request) {
       CacheControlParser parser = new CacheControlParser(cc);
-      options.setNoCache(false);
-      options.setNoStore(false);
-      options.setNoTransform(false);
-      options.setOnlyIfCached(false);
-      options.setMaxAge(-1);
-      options.setMaxStale(-1);
-      options.setMinFresh(-1);
+      request.setNoCache(false);
+      request.setNoStore(false);
+      request.setNoTransform(false);
+      request.setOnlyIfCached(false);
+      request.setMaxAge(-1);
+      request.setMaxStale(-1);
+      request.setMinFresh(-1);
       for (String directive : parser) {
         if (directive.equalsIgnoreCase("no-cache")) {
-          options.setNoCache(true);
+          request.setNoCache(true);
         } else if (directive.equalsIgnoreCase("no-store"))
-          options.setNoStore(true);
+          request.setNoStore(true);
         else if (directive.equalsIgnoreCase("no-transform"))
-          options.setNoTransform(true);
+          request.setNoTransform(true);
         else if (directive.equalsIgnoreCase("only-if-cached"))
-          options.setOnlyIfCached(true);
+          request.setOnlyIfCached(true);
         else if (directive.equalsIgnoreCase("max-age"))
-          options.setMaxAge(value(parser.getValue(directive)));
+          request.setMaxAge(value(parser.getValue(directive)));
         else if (directive.equalsIgnoreCase("max-stale"))
-          options.setMaxStale(value(parser.getValue(directive)));
+          request.setMaxStale(value(parser.getValue(directive)));
         else if (directive.equalsIgnoreCase("min-fresh"))
-          options.setMinFresh(value(parser.getValue(directive)));
+          request.setMinFresh(value(parser.getValue(directive)));
       }
   }
   
   public static void parseCacheControl(
     String cc, 
-    ResponseBase response) {
+    AbstractResponse response) {
       if (cc == null) return;
       CacheControlParser parser = new CacheControlParser(cc);
       response.setNoCache(false);

Added: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java?rev=438654&view=auto
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java (added)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java Wed Aug 30 14:48:22 2006
@@ -0,0 +1,32 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.protocol.util;
+
+public interface ProtocolConstants {
+
+  public final static int NOCACHE = 1;
+  public final static int NOSTORE = 2;
+  public final static int NOTRANSFORM = 4;
+  public final static int PUBLIC = 8;
+  public final static int PRIVATE = 16;
+  public final static int REVALIDATE = 32;
+  public final static int PROXYREVALIDATE = 64;
+  public final static int ONLYIFCACHED = 128;
+
+  
+}

Modified: incubator/abdera/java/trunk/server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/pom.xml?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/pom.xml (original)
+++ incubator/abdera/java/trunk/server/pom.xml Wed Aug 30 14:48:22 2006
@@ -41,7 +41,13 @@
       <artifactId>abdera-core</artifactId>
       <version>0.2.0-incubating-SNAPSHOT</version>
       <scope>compile</scope>
-    </dependency>    
+    </dependency>   
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-protocol</artifactId>
+      <version>0.2.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>   
     <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java Wed Aug 30 14:48:22 2006
@@ -20,104 +20,29 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
-import java.util.Date;
 import java.util.List;
 
+import org.apache.abdera.protocol.Request;
 import org.apache.abdera.protocol.server.target.Target;
 
-public interface RequestContext {
+public interface RequestContext extends Request {
   
   Target getTarget();
   
-  /**
-   * Returns the method 
-   */
   String getMethod();
   
-  /**
-   * Returns the complete Request URI
-   */
   URI getUri();
   
-  /**
-   * Returns the server base URI
-   */
   URI getBaseUri();
   
-  /**
-   * Returns the relative URI (without scheme, host, or port)
-   */
   URI getPathInfo();
   
-  /**
-   * Returns a request parameter (e.g. query string param)
-   */
   String getParameter(String name);
   
-  /**
-   * Returns a list of request parameter values (e.g. query string params)
-   */
   List<String> getParameters(String name);
 
-  /**
-   * Returns a listing of request parameter names
-   */
   List<String> getParameterNames();
   
-  /**
-   * Returns a request header
-   */
-  String getHeader(String name);
-  
-  /**
-   * Returns a list of request header values
-   */
-  List<String> getHeaders(String name);
-  
-  /**
-   * Returns a list of request header names
-   */
-  List<String> getHeaderNames();
-  
-  /**
-   * Returns the input stream for the request
-   */
   InputStream getInputStream() throws IOException;
-  
-  String getAccept();
-  
-  String getAcceptCharset();
-  
-  String getAcceptEncoding();
-  
-  String getAcceptLanguage();
-  
-  String getAuthorization();
-  
-  String getCacheControl();
-  
-  String getContentType();
-  
-  Date getDateHeader(String name);
-  
-  String getIfMatch();
-  
-  Date getIfModifiedSince();
-  
-  String getIfNoneMatch();
-  
-  Date getIfUnmodifiedSince();
-  
-  long getMaxAge();
-  
-  long getMaxStale();
-  
-  long getMinFresh();
-  
-  boolean getNoCache();
-  
-  boolean getNoStore();
-  
-  boolean getNoTransform();
   
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java Wed Aug 30 14:48:22 2006
@@ -19,75 +19,13 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
 
-import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
+import org.apache.abdera.protocol.Response;
 
-public interface ResponseContext {
+public interface ResponseContext extends Response {
 
-  public int getStatus();
-  
-  public String getStatusText();
-  
-  public Date getLastModified();
-  
-  public String getEntityTag();
-  
-  public String getContentLanguage();
-  
-  public URI getContentLocation() throws URISyntaxException;
-  
-  public long getContentLength();
-  
-  public MimeType getContentType() throws MimeTypeParseException;
-  
-  public String getAllow();
-  
-  public URI getLocation() throws URISyntaxException;
-  
-  public Date getDateHeader(String name);
-  
-  public String getHeader(String name);
-  
-  public List<Object> getHeaders(String name);
-  
-  public Map<String, List<Object>> getHeaders();
-  
   public boolean hasEntity();
   
   public void writeTo(OutputStream out) throws IOException;
-  
-  boolean isPrivate();
-  
-  boolean isPublic();
-  
-  boolean isNoCache();
-  
-  boolean isNoStore();
-  
-  boolean isNoTransform();
-  
-  boolean isMustRevalidate();
-  
-  boolean isProxyRevalidate();
-  
-  long getMaxAge();
-  
-  long getSMaxAge();
-  
-  long getAge();
-  
-  Date getExpires();
-  
-  String[] getNoCacheHeaders();
-  
-  String[] getPrivateHeaders();
-  
-  String getCacheControl();
-  
+    
 }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/exceptions/AbderaServerException.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/exceptions/AbderaServerException.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/exceptions/AbderaServerException.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/exceptions/AbderaServerException.java Wed Aug 30 14:48:22 2006
@@ -305,6 +305,18 @@
     this.context.setAllow(methods);
   }
   
+  public ResponseType getType() {
+    return context.getType();
+  }
+  
+  public String[] getHeaderNames() {
+    return context.getHeaderNames();
+  }
+
+  public URI getUriHeader(String name) throws URISyntaxException {
+    return context.getUriHeader(name);
+  }
+  
   protected static class ExceptionResponseContext 
     extends AbstractResponseContext {
 

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java Wed Aug 30 14:48:22 2006
@@ -17,40 +17,25 @@
 */
 package org.apache.abdera.protocol.server.impl;
 
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
-
 import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.util.AbstractResponse;
 
-public abstract class AbstractResponseContext 
+public abstract class AbstractResponseContext
+  extends AbstractResponse
   implements ResponseContext {
 
-  protected final static byte NOCACHE = 1;
-  protected final static byte NOSTORE = 2;
-  protected final static byte NOTRANSFORM = 4;
-  protected final static byte MUSTREVALIDATE = 8;
-  protected final static byte PROXYREVALIDATE = 16;
-  protected final static byte PUBLIC = 32;
-  protected final static byte PRIVATE = 64;
   protected static final String[] EMPTY = new String[0];
   
   protected int status = 0;
   protected String status_text = null;
   
   protected Map<String,List<Object>> headers = null;
-  protected byte flags = 0;
-  protected long max_age = -1;
-  protected long smax_age = -1;
-  protected List<String> no_cache_headers = null;
-  protected List<String> private_headers = null;
 
   public void removeHeader(String name) {
     Map<String,List<Object>> headers = getHeaders();
@@ -126,6 +111,11 @@
     return headers.get(name);
   }
 
+  public String[] getHeaderNames() {
+    Map<String,List<Object>> headers = getHeaders();
+    return headers.keySet().toArray(new String[headers.size()]);
+  }
+  
   private void append(StringBuffer buf, String value) {
     if (buf.length() > 0) buf.append(", ");
     buf.append(value);
@@ -135,7 +125,7 @@
     StringBuffer buf = new StringBuffer();
     if (isPublic()) append(buf,"public");
     if (isPrivate()) append(buf,"private");
-    if (private_headers != null && private_headers.size() > 0) {
+    if (private_headers != null && private_headers.length > 0) {
       buf.append("=\"");
       for (String header : private_headers) {
         append(buf,header);
@@ -143,9 +133,9 @@
       buf.append("\"");
     }
     if (isNoCache()) append(buf,"no-cache");
-    if (no_cache_headers != null && no_cache_headers.size() > 0) {
+    if (nocache_headers != null && nocache_headers.length > 0) {
       buf.append("=\"");
-      for (String header : no_cache_headers) {
+      for (String header : nocache_headers) {
         append(buf,header);
       }
       buf.append("\"");
@@ -158,11 +148,6 @@
     return buf.toString();
   }
 
-  public long getAge() {
-    String value = getHeader("Age");
-    return (value != null) ? Long.parseLong(value) : -1;
-  }
-  
   public void setAge(long age) {
     if (age == -1) {
       removeHeader("Age"); 
@@ -171,10 +156,6 @@
     setHeader("Age", String.valueOf(age));
   }
   
-  public String getContentLanguage() {
-    return getHeader("Content-Language");
-  }
-  
   public void setContentLanguage(String language) {
     if (language == null) {
       removeHeader("Content-Language");
@@ -183,11 +164,6 @@
     setHeader("Content-Language", language);
   }
 
-  public long getContentLength() {
-    String value = getHeader("Content-Length");
-    return (value != null) ? Long.parseLong(value) : -1;
-  }
-  
   public void setContentLength(long length) {
     if (length == -1) {
       removeHeader("Content-Length");
@@ -196,11 +172,6 @@
     setHeader("Content-Length", String.valueOf(length));
   }
 
-  public URI getContentLocation() throws URISyntaxException {
-    String value = getHeader("Content-Location");
-    return (value != null) ? new URI(value) : null;
-  }
-
   public void setContentLocation(String uri) {
     if (uri == null) {
       removeHeader("Content-Location");
@@ -209,11 +180,6 @@
     setHeader("Content-Location", uri);
   }
   
-  public MimeType getContentType() throws MimeTypeParseException {
-    String value = getHeader("Content-Type");
-    return (value != null) ? new MimeType(value) : null;
-  }
-  
   public void setContentType(String type) {
     if (type == null) {
       removeHeader("Content-Type");
@@ -222,10 +188,6 @@
     setHeader("Content-Type", type);
   }
 
-  public String getEntityTag() {
-    return getHeader("ETag");
-  }
-  
   public void setEntityTag(String etag) {
     if (etag == null) {
       removeHeader("ETag");
@@ -234,10 +196,6 @@
     setHeader("ETag", etag);
   }
 
-  public Date getExpires() {
-    return getDateHeader("Expires");
-  }
-
   public void setExpires(Date date) {
     if (date == null) {
       removeHeader("Expires");
@@ -246,10 +204,6 @@
     setHeader("Expires", date);
   }
   
-  public Date getLastModified() {
-    return getDateHeader("Last-Modified");
-  }
-  
   public void setLastModified(Date date) {
     if (date == null) {
       removeHeader("Last-Modified");
@@ -258,11 +212,6 @@
     setHeader("Last-Modified", date);
   }
 
-  public URI getLocation() throws URISyntaxException {
-    String value = getHeader("Location");
-    return (value != null) ? new URI(value) : null;
-  }
-
   public void setLocation(String uri) {
     if (uri == null) {
       removeHeader("Location");
@@ -287,137 +236,6 @@
     this.status_text = text;
   }
 
-  public long getMaxAge() {
-    return max_age;
-  }
-  
-  public void setMaxAge(long max_age) {
-    this.max_age = max_age;
-  }
-
-  public String[] getNoCacheHeaders() {
-    if (no_cache_headers == null) return EMPTY;
-    return no_cache_headers.toArray(new String[no_cache_headers.size()]);
-  }
-  
-  public void setNoCacheHeaders(String header) {
-    if (no_cache_headers == null) no_cache_headers = new ArrayList<String>();
-    no_cache_headers.add(header);
-  }
-  
-  public void setNoCacheHeaders(String... headers) {
-    if (no_cache_headers == null) no_cache_headers = new ArrayList<String>();
-    for (String header : headers) {
-      no_cache_headers.add(header);
-    }
-  }
-
-  public String[] getPrivateHeaders() {
-    if (private_headers == null) return EMPTY;
-    return private_headers.toArray(new String[private_headers.size()]);
-  }
-
-  public void setPrivateHeaders(String header) {
-    if (private_headers == null) private_headers = new ArrayList<String>();
-    private_headers.add(header);
-  }
-  
-  public void setPrivateHeaders(String... headers) {
-    if (private_headers == null) private_headers = new ArrayList<String>();
-    for (String header : headers) {
-      private_headers.add(header);
-    }
-  }
-  
-  public long getSMaxAge() {
-    return smax_age;
-  }
-  
-  public void setSMaxAge(long smax_age) {
-    this.smax_age = smax_age;
-  }
-  
-  public boolean isMustRevalidate() {
-    return (flags & MUSTREVALIDATE) == MUSTREVALIDATE;
-  }
-  
-  public void setMustRevalidate(boolean val) {
-    if (isMustRevalidate() && !val)
-      flags ^= MUSTREVALIDATE;
-    else if (!isMustRevalidate() && val)
-      flags |= MUSTREVALIDATE;
-  }
-
-  public boolean isNoCache() {
-    return (flags & NOCACHE) == NOCACHE;
-  }
-
-  public void setNoCache(boolean val) {
-    if (isNoCache() && !val)
-      flags ^= NOCACHE;
-    else if (!isNoCache() && val)
-      flags |= NOCACHE;
-  }
-  
-  public boolean isNoStore() {
-    return (flags & NOSTORE) == NOSTORE;
-  }
-
-  public void setNoStore(boolean val) {
-    if (isNoStore() && !val)
-      flags ^= NOSTORE;
-    else if (!isNoStore() && val)
-      flags |= NOSTORE;
-  }
-  
-  public boolean isNoTransform() {
-    return (flags & NOTRANSFORM) == NOTRANSFORM;
-  }
-
-  public void setNoTransform(boolean val) {
-    if (isNoTransform() && !val)
-      flags ^= NOTRANSFORM;
-    else if (!isNoTransform() && val)
-      flags |= NOTRANSFORM;
-  }
-  
-  public boolean isPrivate() {
-    return (flags & PRIVATE) == PRIVATE;
-  }
-
-  public void setPrivate(boolean val) {
-    if (isPrivate() && !val)
-      flags ^= PRIVATE;
-    else if (!isPrivate() && val)
-      flags |= PRIVATE;
-  }
-  
-  public boolean isProxyRevalidate() {
-    return (flags & PROXYREVALIDATE) == PROXYREVALIDATE;
-  }
-  
-  public void setProxyRevalidate(boolean val) {
-    if (isProxyRevalidate() && !val)
-      flags ^= PROXYREVALIDATE;
-    else if (!isProxyRevalidate() && val)
-      flags |= PROXYREVALIDATE;
-  }
-
-  public boolean isPublic() {
-    return (flags & PUBLIC) == PUBLIC;
-  }
-
-  public void setPublic(boolean val) {
-    if (isPublic() && !val)
-      flags ^= PUBLIC;
-    else if (!isPublic() && val)
-      flags |= PUBLIC;
-  }  
-  
-  public String getAllow() {
-    return getHeader("Allow");
-  }
-  
   public void setAllow(String method) {
     setHeader("Allow", method);
   }

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java?rev=438654&r1=438653&r2=438654&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java Wed Aug 30 14:48:22 2006
@@ -28,7 +28,7 @@
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Element;
 
-public class BaseResponseContext<T extends Base> 
+public class BaseResponseContext<T extends Base>
   extends AbstractResponseContext {
 
   private T base = null;



Mime
View raw message