abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1190679 [1/3] - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/model/ activities/src/main/java/org/apache/abdera2/activities/protocol/ activities/src/main/java/org/apache/abdera2/activities/protocol/basic/ activ...
Date Fri, 28 Oct 2011 23:44:37 GMT
Author: jmsnell
Date: Fri Oct 28 23:44:35 2011
New Revision: 1190679

URL: http://svn.apache.org/viewvc?rev=1190679&view=rev
Log:
More refactoring.. simplification, code improvements, etc

Added:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractProvider.java   (contents, props changed)
      - copied, changed from r1190093, abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/Pushers.java   (with props)
    abdera/abdera2/core/src/main/java/org/apache/abdera2/util/MorePredicates.java   (with props)
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PusherExample.java   (with props)
Removed:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Transactional.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/model/AtompubWorkspaceManager.java
Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedWorkspace.java
    abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseImpl.java
    abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseWrapper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/QualityHelper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractRequest.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponse.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CompressionFilter.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Message.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TransactionalRequestProcessor.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Entry.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Source.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMSource.java
    abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/xsltxpath/XPathExample.java
    abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssFeed.java
    abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssItem.java
    abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssSource.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/StreamWriterResponseContext.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubCollectionAdapter.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubWorkspaceProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/DefaultAtompubProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/CustomProvider.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/SimpleAdapter.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/ASBase.java Fri Oct 28 23:44:35 2011
@@ -35,6 +35,8 @@ import org.apache.abdera2.common.iri.IRI
 import org.apache.abdera2.common.lang.Lang;
 import org.apache.abdera2.common.mediatype.MimeTypeParseException;
 
+import com.google.common.base.Function;
+
 /**
  * Root of the Activity Streams object hierarchy, provides the core property
  * management and can be used to represent simple, untyped objects.
@@ -66,6 +68,10 @@ public class ASBase 
     return (T)exts.get(name);
   }
   
+  public <T,R>R getProperty(String name, Function<T,R> transform) {
+    return (R)transform.apply(this.<T>getProperty(name));
+  }
+  
   public void setProperty(String name, Object value) {
     if (value != null)
       exts.put(name, value);

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/Collection.java Fri Oct 28 23:44:35 2011
@@ -132,6 +132,7 @@ public class Collection<T extends ASObje
   public static class CollectionGenerator<T extends ASObject> 
     extends ASObjectGenerator<Collection<T>> {
     
+    @SuppressWarnings("rawtypes")
     private static <T extends ASObject>Class<? extends Collection<T>> t(Class _class) {
       return (Class<? extends Collection<T>>) _class;
     }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java Fri Oct 28 23:44:35 2011
@@ -32,7 +32,8 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.ResponseContextException;
-import org.joda.time.DateTime;
+
+import static org.apache.abdera2.activities.protocol.AbstractActivitiesProvider.*;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -50,30 +51,37 @@ public abstract class AbstractActivities
     return Arrays.asList("application/json");
   }
   
-  protected ResponseContext buildCreateEntryResponse(String link, ASBase base) {
+  protected ResponseContext buildCreateEntryResponse(
+    String link, 
+    ASBase base) {
     return
       new ActivitiesResponseContext<ASBase>(base)
         .setLocation(link)
         .setContentLocation(link)
-        .setEntityTag(AbstractActivitiesProvider.calculateEntityTag(base))
+        .setEntityTag(calculateEntityTag(base))
         .setStatus(201);
   }
 
-  protected ResponseContext buildGetEntryResponse(RequestContext request, ASObject base)
+  protected ResponseContext buildGetEntryResponse(
+    RequestContext request, 
+    ASObject base)
       throws ResponseContextException {
       base.setSource(createSourceObject(request));
       return 
         new ActivitiesResponseContext<ASObject>(base)
-         .setEntityTag(AbstractActivitiesProvider.calculateEntityTag(base));
+         .setEntityTag(calculateEntityTag(base));
   }
 
-  protected ResponseContext buildGetFeedResponse(Collection<ASObject> collection) {
+  protected ResponseContext buildGetFeedResponse(
+    Collection<ASObject> collection) {
       return 
         new ActivitiesResponseContext<Collection<ASObject>>(collection)
-          .setEntityTag(AbstractActivitiesProvider.calculateEntityTag(collection));
+          .setEntityTag(calculateEntityTag(collection));
   }
 
-  protected ServiceObject createSourceObject(RequestContext request) throws ResponseContextException {
+  protected ServiceObject createSourceObject(
+    RequestContext request) 
+      throws ResponseContextException {
     return 
       ServiceObject
         .makeService()
@@ -90,18 +98,20 @@ public abstract class AbstractActivities
   /**
    * Create the base feed for the requested collection.
    */
-  protected Collection<ASObject> createCollectionBase(RequestContext request) throws ResponseContextException {
+  protected Collection<ASObject> createCollectionBase(
+    RequestContext request) 
+      throws ResponseContextException {
     return 
       Collection
         .makeCollection()
         .id(getId(request))
-        .set("title", getTitle(request))
-        .set("updated", DateTime.now())
-        .set("author", 
+        .updatedNow()
+        .author( 
           PersonObject
             .makePerson()
             .displayName(getAuthor(request))
-            .get()) 
+            .get())
+        .displayName(getTitle(request))
         .get();
   }
 
@@ -120,6 +130,8 @@ public abstract class AbstractActivities
   }
 
   public Predicate<RequestContext> acceptable() {
-    return Predicates.or(super.acceptable(),AbstractActivitiesWorkspaceProvider.isJson());
+    return Predicates.or(
+      super.acceptable(),
+      AbstractActivitiesWorkspaceProvider.isJson());
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java Fri Oct 28 23:44:35 2011
@@ -33,11 +33,10 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.common.http.EntityTag;
 import org.apache.abdera2.common.misc.ExceptionHelper;
-import org.apache.abdera2.common.protocol.BaseProvider;
+import org.apache.abdera2.common.protocol.AbstractProvider;
 import org.apache.abdera2.common.protocol.CollectionRequestProcessor;
 import org.apache.abdera2.common.protocol.EntryRequestProcessor;
 import org.apache.abdera2.common.protocol.RequestContext;
-import org.apache.abdera2.common.protocol.RequestProcessor;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.TargetType;
 import org.apache.abdera2.common.protocol.WorkspaceManager;
@@ -45,26 +44,26 @@ import org.apache.abdera2.common.protoco
 import org.joda.time.DateTime;
 
 public abstract class AbstractActivitiesProvider 
-  extends BaseProvider
+  extends AbstractProvider
   implements ActivitiesProvider {
 
-  protected Set<TypeAdapter<?>> typeAdapters = new HashSet<TypeAdapter<?>>();
+  protected Set<TypeAdapter<?>> typeAdapters = 
+    new HashSet<TypeAdapter<?>>();
   protected final WorkspaceManager workspaceManager;
   
   protected AbstractActivitiesProvider(
     WorkspaceManager workspaceManager) {
     this.workspaceManager = workspaceManager;
-    this.requestProcessors.put(
-      TargetType.TYPE_COLLECTION, 
-      RequestProcessor.forClass(
-        CollectionRequestProcessor.class,
-        workspaceManager,
-        AbstractActivitiesWorkspaceProvider.isJson()));
-    this.requestProcessors.put(
-      TargetType.TYPE_ENTRY, 
-      RequestProcessor.forClass(
-        EntryRequestProcessor.class,
-        workspaceManager));
+    addRequestProcessor(
+      TargetType.TYPE_COLLECTION,
+      CollectionRequestProcessor.class,
+      AbstractActivitiesWorkspaceProvider.isJson(),
+      workspaceManager
+      );
+    addRequestProcessor(
+      TargetType.TYPE_ENTRY,
+      EntryRequestProcessor.class,
+      workspaceManager);
   }
   
   public void addTypeAdapter(TypeAdapter<?> typeAdapter) {
@@ -100,7 +99,10 @@ public abstract class AbstractActivities
     if (base instanceof Activity) {
         Activity ac = (Activity)base;
         id = ac.getId();
-        modified = DateTimes.format(ac.getUpdated() != null ? ac.getUpdated() : ac.getPublished());
+        modified = DateTimes.format(
+          ac.getUpdated() != null ? 
+            ac.getUpdated() : 
+            ac.getPublished());
     } else if (base instanceof Collection) {
         Collection<?> col = (Collection<?>)base;
         id = col.getProperty("id");
@@ -109,7 +111,10 @@ public abstract class AbstractActivities
     } else if (base instanceof ASObject) {
         ASObject as = (ASObject)base;
         id = as.getId().toString();
-        modified = DateTimes.format(as.getUpdated() != null ? as.getUpdated() : as.getPublished());
+        modified = DateTimes.format(
+          as.getUpdated() != null ? 
+            as.getUpdated() : 
+            as.getPublished());
     }
     if (modified == null) modified = DateTimes.formatNow();
     return EntityTag.generate(id, modified);
@@ -122,7 +127,9 @@ public abstract class AbstractActivities
   
   
   
-  public static IO getIO(ActivitiesProvider provider, TypeAdapter<?>... adapters) {
+  public static IO getIO(
+    ActivitiesProvider provider, 
+    TypeAdapter<?>... adapters) {
     Set<TypeAdapter<?>> as = 
       new HashSet<TypeAdapter<?>>(provider.getTypeAdapters());
     for (TypeAdapter<?> ta : adapters)
@@ -131,7 +138,9 @@ public abstract class AbstractActivities
   }
   
   @SuppressWarnings("unchecked")
-  public static <T extends ASBase>T getASBaseFromRequestContext(RequestContext context) throws IOException {
+  public static <T extends ASBase>T getASBaseFromRequestContext(
+    RequestContext context) 
+      throws IOException {
     ASBase entity = context.getAttribute(Scope.REQUEST, ASBase.class.getName());
       try {
       if (entity == null) {

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java Fri Oct 28 23:44:35 2011
@@ -29,7 +29,6 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.EntryRequestProcessor;
 import org.apache.abdera2.common.protocol.Provider;
 import org.apache.abdera2.common.protocol.RequestContext;
-import org.apache.abdera2.common.protocol.RequestProcessor;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.TargetType;
 import org.apache.abdera2.common.protocol.WorkspaceManager;
@@ -42,7 +41,8 @@ public abstract class AbstractActivities
              WorkspaceManager,
              ActivitiesProvider {
   
-  protected Set<TypeAdapter<?>> typeAdapters = new HashSet<TypeAdapter<?>>();
+  protected final Set<TypeAdapter<?>> typeAdapters = 
+    new HashSet<TypeAdapter<?>>();
   
   public static Predicate<RequestContext> isJson() {
     return new Predicate<RequestContext>() {
@@ -55,16 +55,15 @@ public abstract class AbstractActivities
   }
   
   protected AbstractActivitiesWorkspaceProvider() {
-    this.requestProcessors.put(
+    addRequestProcessor(
       TargetType.TYPE_COLLECTION, 
-      RequestProcessor.forClass(
-        CollectionRequestProcessor.class, 
-        this,isJson()));
-    this.requestProcessors.put(
-      TargetType.TYPE_ENTRY, 
-      RequestProcessor.forClass(
-        EntryRequestProcessor.class,
-        this));
+      CollectionRequestProcessor.class, 
+      isJson(),
+      this);
+    addRequestProcessor(
+      TargetType.TYPE_ENTRY,
+      EntryRequestProcessor.class,
+      this);
   }
   
   public void addTypeAdapter(TypeAdapter<?> typeAdapter) {

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/DefaultActivitiesProvider.java Fri Oct 28 23:44:35 2011
@@ -39,21 +39,22 @@ public class DefaultActivitiesProvider
   protected Function<RequestContext,Target> targetResolver;
   protected Function<Request,Subject> subjectResolver;
   protected TargetBuilder<?> targetBuilder;
-  protected RouteManager<TargetType,RequestContext> routeManager;
+  protected RouteManager<TargetType,RequestContext,String> routeManager;
   
   public DefaultActivitiesProvider() {
     this("/");
   }
   
-  @SuppressWarnings({ "unchecked", "rawtypes" })
   public DefaultActivitiesProvider(String base) {
     super(new DefaultWorkspaceManager());
     if (base == null) base = "/";
     routeManager =
-        new RouteManager()
-          .addRoute("stream", base + ":stream", TargetType.TYPE_COLLECTION)
-          .addRoute("activity", base + ":stream/:activity", TargetType.TYPE_ENTRY)
-        ;
+      RouteManager.<TargetType,RequestContext,String>make()
+        .with("stream", base + ":stream", TargetType.TYPE_COLLECTION)
+        .with("activity", base + ":stream/:activity", TargetType.TYPE_ENTRY)
+        .get()
+      ;
+    
     targetBuilder = routeManager;
     targetResolver = routeManager;
   }
@@ -105,13 +106,12 @@ public class DefaultActivitiesProvider
   }
 
   public void addWorkspace(WorkspaceInfo workspace) {
-      ((DefaultWorkspaceManager)getWorkspaceManager()).addWorkspace(workspace);
+    ((DefaultWorkspaceManager)getWorkspaceManager()).addWorkspace(workspace);
   }
 
   public void addWorkspaces(Collection<WorkspaceInfo> workspaces) {
-      for (WorkspaceInfo w : workspaces) {
-          ((DefaultWorkspaceManager)getWorkspaceManager()).addWorkspace(w);
-      }
+    for (WorkspaceInfo w : workspaces)
+      ((DefaultWorkspaceManager)getWorkspaceManager()).addWorkspace(w);
   }
 
   @SuppressWarnings("rawtypes")

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java Fri Oct 28 23:44:35 2011
@@ -44,6 +44,8 @@ import org.apache.abdera2.common.pusher.
 import org.joda.time.DateTime;
 
 import com.google.common.base.Function;
+import static com.google.common.base.Preconditions.*;
+import static org.apache.abdera2.common.misc.ExceptionHelper.*;
 
 /**
  * The BasicAdapter provides a simplistic interface for working with Atompub collections with a restricted set of
@@ -67,13 +69,15 @@ public abstract class BasicAdapter exten
 
     public String getProperty(String key) throws Exception {
         Object val = config.getProperty(key);
-        if (val == null) {
-            logger.warning("Cannot find property " + key + "in Adapter properties file for feed " + config.getFeedId());
-            throw new RuntimeException();
-        }
-        if (val instanceof String)
-            return (String)val;
-        throw new RuntimeException();
+        checkNotNull(
+          val,
+          "Cannot find property in Adapter properties file for feed ", 
+          key, 
+          config.getFeedId());
+        checked(
+          val instanceof String, 
+          RuntimeException.class);
+        return (String)val;
     }
 
     protected Collection<ASObject> createCollection() {
@@ -99,12 +103,12 @@ public abstract class BasicAdapter exten
     }
 
     protected void setObjectIdIfNull(ASObject object) throws Exception {
-        if (object.getId() != null)
-            return;
-        String uuidUri = UUID.randomUUID().toString();
-        String[] segments = uuidUri.split(":");
-        String entryId = segments[segments.length - 1];
-        object.setId(createEntryIdUri(entryId));
+      if (object.getId() != null)
+        return;
+      String uuidUri = UUID.randomUUID().toString();
+      String[] segments = uuidUri.split(":");
+      String entryId = segments[segments.length - 1];
+      object.setId(createEntryIdUri(entryId));
     }
 
     protected String createEntryIdUri(String entryId) throws Exception {
@@ -113,68 +117,71 @@ public abstract class BasicAdapter exten
 
     private void push(RequestContext context, String channel, ASObject object) {
       if (context.getAttribute(Scope.CONTAINER, "AbderaChannelManager") != null) {
-        ChannelManager cm = (ChannelManager) context.getAttribute(Scope.CONTAINER, "AbderaChannelManager");
+        ChannelManager cm = (ChannelManager) context.getAttribute(
+          Scope.CONTAINER, "AbderaChannelManager");
         if (cm != null) {
-          Pusher<ASObject> pusher = cm.getPusher(channel);
-          if (pusher != null) {
+          Pusher<ASObject> pusher = 
+            cm.getPusher(channel);
+          if (pusher != null)
             pusher.push(object);
-          }
         }
       }
     }
     
     private ResponseContext createOrUpdateObject(RequestContext request, boolean createFlag) {
-        try {
-            MimeType mimeType = request.getContentType();
-            String contentType = mimeType == null ? null : mimeType.toString();
-            if (contentType != null && !MimeTypeHelper.isJson(contentType))
-                return ProviderHelper.notsupported(request);
+      try {
+        MimeType mimeType = request.getContentType();
+        String contentType = mimeType == null ? null : mimeType.toString();
+        if (contentType != null && !MimeTypeHelper.isJson(contentType))
+          return ProviderHelper.notsupported(request);
            
-            ASBase base = getEntryFromRequest(request);
-            Target target = request.getTarget();
+        ASBase base = getEntryFromRequest(request);
+        Target target = request.getTarget();
 
-            if (base instanceof Collection && createFlag && target.getType() == TargetType.TYPE_COLLECTION) {
-              // only allow multiposts on collections.. these always create, never update
-              Collection<ASObject> coll = (Collection<ASObject>) base;
-              Collection<ASObject> retl = new Collection<ASObject>();
-              int c = 0;
-              for (ASObject inputEntry : coll.getItems()) {
-                ASObject newEntry = createItem(inputEntry,c++);
-                push(request,target.getParameter(BasicProvider.PARAM_FEED),newEntry);
-                if (newEntry != null) {
-                  retl.addItem(newEntry);
-                } else {
-                  ErrorObject err = new ErrorObject();
-                  err.setCode(-100);
-                  err.setDisplayName("Error adding object");
-                  retl.addItem(err);
-                }
-              }
-              return
-                new ActivitiesResponseContext<Collection<ASObject>>(retl)
-                  .setStatus(createFlag?201:200);
-            } else if (base instanceof ASObject){
-              String entryId = !createFlag ? target.getParameter(BasicProvider.PARAM_ENTRY) : null;
-              ASObject inputEntry = (ASObject) base;
-              ASObject newEntry = createFlag ? createItem(inputEntry) : updateItem(entryId, inputEntry);
-              push(request,target.getParameter(BasicProvider.PARAM_FEED),newEntry);
+        if (base instanceof Collection && 
+            createFlag && 
+            target.getType() == TargetType.TYPE_COLLECTION) {
+            // only allow multiposts on collections.. these always create, never update
+            Collection<ASObject> coll = (Collection<ASObject>) base;
+            Collection<ASObject> retl = new Collection<ASObject>();
+            int c = 0;
+            for (ASObject inputEntry : coll.getItems()) {
+              ASObject newEntry = createItem(inputEntry,c++);
               if (newEntry != null) {
-                  String loc = newEntry.getProperty("editLink");
-                  ActivitiesResponseContext<ASObject> rc = 
-                    new ActivitiesResponseContext<ASObject>(newEntry);
-                  rc.setStatus(createFlag?201:200);
-                  rc.setLocation(loc);
-                  return rc;
+                push(request,target.getParameter(BasicProvider.PARAM_FEED),newEntry);
+                retl.addItem(newEntry);
               } else {
-                  return ProviderHelper.notfound(request);
+                ErrorObject err = new ErrorObject();
+                err.setCode(-100);
+                err.setDisplayName("Error adding object");
+                retl.addItem(err);
               }
-            } else {
-              return ProviderHelper.notallowed(request);
             }
-            
-        } catch (Exception e) {
-            return ProviderHelper.servererror(request, e.getMessage(), e);
-        }
+            return
+              new ActivitiesResponseContext<Collection<ASObject>>(retl)
+                .setStatus(createFlag?201:200);
+        } else if (base instanceof ASObject){
+          String entryId = !createFlag ? 
+            target.getParameter(BasicProvider.PARAM_ENTRY) : 
+              null;
+          ASObject inputEntry = (ASObject) base;
+          ASObject newEntry = createFlag ? 
+            createItem(inputEntry) : 
+            updateItem(entryId, inputEntry);
+          if (newEntry != null) {
+            push(request,target.getParameter(BasicProvider.PARAM_FEED),newEntry);
+            String loc = newEntry.getProperty("editLink");
+            return 
+              new ActivitiesResponseContext<ASObject>(newEntry)
+                .setStatus(createFlag?201:200)
+                .setLocation(loc);
+          } else
+            return ProviderHelper.notfound(request);
+        } else
+          return ProviderHelper.notallowed(request);
+      } catch (Exception e) {
+        return ProviderHelper.servererror(request, e.getMessage(), e);
+      }
     }
 
     private Function<RequestContext,ResponseContext> postItem() {
@@ -241,9 +248,9 @@ public abstract class BasicAdapter exten
                 new ActivitiesResponseContext<Collection<ASObject>>(collection)
                   .setStatus(200);
             } else return ProviderHelper.notfound(input);
-        } catch (Exception e) {
+          } catch (Exception e) {
             return ProviderHelper.servererror(input, e.getMessage(), e);
-        }
+          }
         }
       };
     }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicProvider.java Fri Oct 28 23:44:35 2011
@@ -28,7 +28,8 @@ import org.apache.abdera2.common.protoco
 /**
  * Provider implementation intended to be used with BasicAdapter implementations
  */
-public class BasicProvider extends ManagedProvider {
+public class BasicProvider 
+  extends ManagedProvider {
 
     public static final String PARAM_FEED = "stream";
     public static final String PARAM_ENTRY = "activity";
@@ -38,18 +39,18 @@ public class BasicProvider extends Manag
         init();
     }
 
-    @SuppressWarnings({ "rawtypes", "unchecked" })
     private void init() {
-        RouteManager routeManager =
-            new RouteManager()
-              .addRoute(
-                "stream",
-                "/:stream",
-                TargetType.TYPE_COLLECTION)
-              .addRoute(
-                "activity", 
-                "/:stream/:activity", 
-                TargetType.TYPE_ENTRY);
+        RouteManager<TargetType,RequestContext,String> routeManager =
+          RouteManager.<TargetType,RequestContext,String>make()
+            .with(
+              "stream",
+              "/:stream",
+              TargetType.TYPE_COLLECTION)
+            .with(
+              "activity", 
+              "/:stream/:activity", 
+              TargetType.TYPE_ENTRY)
+            .get();
         setTargetBuilder(
             routeManager);
         setTargetResolver(
@@ -58,9 +59,9 @@ public class BasicProvider extends Manag
 
     public CollectionAdapter getCollectionAdapter(RequestContext request) {
         try {
-            return getCollectionAdapterManager(request)
-              .getAdapter(
-                request.getTarget().getParameter(PARAM_FEED));
+          return getCollectionAdapterManager(request)
+            .getAdapter(
+              request.getTarget().getParameter(PARAM_FEED));
         } catch (Exception e) {
             return null;
         }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedProvider.java Fri Oct 28 23:44:35 2011
@@ -29,14 +29,14 @@ import org.apache.abdera2.common.protoco
 public abstract class ManagedProvider 
   extends AbstractActivitiesWorkspaceProvider {
   
-    protected abstract ServerConfiguration getServerConfiguration(RequestContext request);
+  protected abstract ServerConfiguration getServerConfiguration(RequestContext request);
 
-    protected ManagedProvider() {
-        addWorkspace(new ManagedWorkspace(this));
-    }
+  protected ManagedProvider() {
+    addWorkspace(new ManagedWorkspace(this));
+  }
 
-    public CollectionAdapterManager getCollectionAdapterManager(RequestContext request) {
-      return new CollectionAdapterManager(getServerConfiguration(request));
+  public CollectionAdapterManager getCollectionAdapterManager(RequestContext request) {
+    return new CollectionAdapterManager(getServerConfiguration(request));
   }
 
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedWorkspace.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedWorkspace.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedWorkspace.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/managed/ManagedWorkspace.java Fri Oct 28 23:44:35 2011
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.CollectionInfo;
 import org.apache.abdera2.common.protocol.WorkspaceInfo;
@@ -33,27 +34,27 @@ public class ManagedWorkspace implements
     private String title = "Abdera - Activities";
 
     public ManagedWorkspace(ManagedProvider provider) {
-        this.provider = provider;
+      this.provider = provider;
     }
 
     public Collection<CollectionInfo> getCollections(RequestContext request) {
-        CollectionAdapterManager cam = provider.getCollectionAdapterManager(request);
-        List<CollectionInfo> collections = new ArrayList<CollectionInfo>();
-        try {
-            Map<String, FeedConfiguration> map = cam.listAdapters();
-            for (FeedConfiguration config : map.values())
-                collections.add(config);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-        return collections;
+      CollectionAdapterManager cam = provider.getCollectionAdapterManager(request);
+      List<CollectionInfo> collections = new ArrayList<CollectionInfo>();
+      try {
+        Map<String, FeedConfiguration> map = cam.listAdapters();
+        for (FeedConfiguration config : map.values())
+          collections.add(config);
+      } catch (Throwable e) {
+        throw ExceptionHelper.propogate(e);
+      }
+      return collections;
     }
     
     public String getTitle(RequestContext request) {
-        return title;
+      return title;
     }
 
     public void setTitle(String title) {
-        this.title = title;
+      this.title = title;
     }
 }

Modified: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseImpl.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseImpl.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseImpl.java (original)
+++ abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseImpl.java Fri Oct 28 23:44:35 2011
@@ -53,6 +53,11 @@ import org.apache.http.protocol.HttpCont
 import org.apache.http.util.EntityUtils;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import static com.google.common.base.Preconditions.*;
+
 class ClientResponseImpl 
   implements ClientResponse {
 
@@ -305,4 +310,17 @@ class ClientResponseImpl 
     }
     return links;
   }
+
+  public <T> T getHeader(String name, Function<String, T> transform) {
+    checkNotNull(transform);
+    return transform.apply(getHeader(name));
+  }
+
+  public <T> Iterable<T> getHeaders(String name, Function<String, T> transform) {
+    Iterable<Object> objs = getHeaders(name);
+    List<T> list = new ArrayList<T>();
+    for (Object obj : objs)
+      list.add(transform.apply(obj.toString()));
+    return Iterables.unmodifiableIterable(list);
+  }
 }
\ No newline at end of file

Modified: abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseWrapper.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseWrapper.java (original)
+++ abdera/abdera2/client/src/main/java/org/apache/abdera2/protocol/client/ClientResponseWrapper.java Fri Oct 28 23:44:35 2011
@@ -17,6 +17,8 @@ import org.apache.abdera2.common.http.We
 import org.apache.abdera2.common.iri.IRI;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Function;
+
 public class ClientResponseWrapper 
   implements ClientResponse {
 
@@ -166,4 +168,12 @@ public class ClientResponseWrapper 
     return internal.getSession();
   }
 
+  public <T> T getHeader(String name, Function<String, T> transform) {
+    return internal.getHeader(name, transform);
+  }
+
+  public <T> Iterable<T> getHeaders(String name, Function<String, T> transform) {
+    return internal.getHeaders(name, transform);
+  }
+
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/Authentication.java Fri Oct 28 23:44:35 2011
@@ -20,6 +20,7 @@ import static com.google.common.base.Pre
 import java.io.ByteArrayOutputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -38,6 +39,7 @@ import static org.apache.abdera2.common.
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.codec.binary.StringUtils;
 
+import com.google.common.base.Function;
 import com.google.common.base.Supplier;
 
 /**
@@ -81,6 +83,15 @@ public class Authentication implements I
       ALWAYS.add(name);
   }
   
+  public static final Function<String, Iterable<Authentication>> parser = 
+    new Function<String,Iterable<Authentication>>() {
+      public Iterable<Authentication> apply(String input) {
+        return input != null ? 
+          parse(input) : 
+          Collections.<Authentication>emptySet();
+      }
+  };
+  
   public static Iterable<Authentication> parse(String challenge) {
     checkNotNull(challenge);
     List<Authentication> challenges = new ArrayList<Authentication>();

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/CacheControl.java Fri Oct 28 23:44:35 2011
@@ -23,6 +23,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.google.common.base.Function;
 import com.google.common.base.Supplier;
 import com.google.common.collect.Iterables;
 
@@ -187,6 +188,13 @@ public final class CacheControl implemen
   
   }
   
+  public static final Function<String,CacheControl> parser = 
+    new Function<String,CacheControl>() {
+      public CacheControl apply(String input) {
+        return input != null ? parse(input) : null;
+      }
+  };
+  
   public static CacheControl parse(String cc) {
     return CacheControlUtil.parseCacheControl(cc, make()).get();
   }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/EntityTag.java Fri Oct 28 23:44:35 2011
@@ -375,6 +375,22 @@ public class EntityTag 
       };
     }
     
+    public static Function<String, EntityTag> parser = 
+      new Function<String,EntityTag>() {
+        public EntityTag apply(String input) {
+          return input != null ? parse(input) : null;
+        }
+    };
+    
+    public static Function<String, Iterable<EntityTag>> parseMultiple = 
+      new Function<String,Iterable<EntityTag>>() {
+        public Iterable<EntityTag> apply(String input) {
+          return input != null ? 
+            parseTags(input) : 
+            Collections.<EntityTag>emptySet();
+        }
+    };
+    
     /**
      * Utility method for generating ETags. Works by concatenating the UTF-8 bytes of the provided strings then
      * generating an MD5 hash of the result.

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/QualityHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/QualityHelper.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/QualityHelper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/QualityHelper.java Fri Oct 28 23:44:35 2011
@@ -20,6 +20,8 @@ package org.apache.abdera2.common.http;
 import java.io.Serializable;
 import java.util.Arrays;
 
+import com.google.common.base.Function;
+
 public final class QualityHelper {
 
   private QualityHelper() {}
@@ -129,4 +131,10 @@ public final class QualityHelper {
       return qtokens;
   }
   
+  public static final Function<String,QToken[]> parser = 
+    new Function<String,QToken[]>() {
+      public QToken[] apply(String input) {
+        return input != null ? QualityHelper.orderByQ(input) : new QToken[0];
+      }
+    };
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/http/WebLink.java Fri Oct 28 23:44:35 2011
@@ -18,6 +18,7 @@ import org.apache.abdera2.common.lang.La
 import org.apache.abdera2.common.text.CharUtils;
 import org.apache.abdera2.common.text.Codec;
 
+import com.google.common.base.Function;
 import com.google.common.base.Supplier;
 import com.google.common.collect.Iterables;
 
@@ -463,6 +464,16 @@ public class WebLink implements Serializ
     return buf.toString();
   }
 
+  public static final Function<String,Iterable<WebLink>> parser = 
+    new Function<String,Iterable<WebLink>>() {
+      public Iterable<WebLink> apply(String input) {
+        return
+          input != null ?
+          parse(input) :
+          Collections.<WebLink>emptySet();
+      }
+  };
+  
   public static Iterable<WebLink> parse(String text) {
     List<WebLink> links = new ArrayList<WebLink>();
     if (text == null) return Collections.emptyList();

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/iri/IRI.java Fri Oct 28 23:44:35 2011
@@ -621,4 +621,10 @@ public final class IRI implements Serial
       };
     }
     
+    public static final Function<String,IRI> parser = 
+      new Function<String,IRI>() {
+        public IRI apply(String input) {
+          return input != null ? new IRI(input) : null;
+        }
+    };
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/mediatype/MimeTypeHelper.java Fri Oct 28 23:44:35 2011
@@ -401,4 +401,12 @@ public final class MimeTypeHelper {
         }        
       };
     }
+    
+    public static final Function<String,MimeType> parser = 
+      new Function<String,MimeType>() {
+        public MimeType apply(String input) {
+          return input != null ? MimeTypeHelper.create(input) : null;
+        }
+      
+    };
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/ExceptionHelper.java Fri Oct 28 23:44:35 2011
@@ -7,6 +7,44 @@ import org.apache.commons.logging.Log;
 
 public class ExceptionHelper {
 
+  public static <T extends Throwable>void checked(
+      boolean expression, 
+      Class<T> _class) throws T {
+    checked(expression,_class,null);
+  }
+  
+  public static <T extends Throwable>void checked(
+    boolean expression, 
+    Class<T> _class, 
+    String message, 
+    Object... args) throws T {
+      if (!expression) {
+        T t = null;
+        try {
+          if (message != null) {
+            StringBuilder buf = 
+              new StringBuilder(message);
+            if (args.length > 0)
+              buf.append(" ");
+            for (Object arg : args) {
+              buf.append('[')
+                 .append(arg)
+                 .append(']');
+            }
+            t =  _class
+              .getConstructor(String.class)
+              .newInstance(buf.toString());
+          } else
+            t = _class
+              .getConstructor()
+              .newInstance(); 
+        } catch (Throwable e) {
+          throw propogate(e);
+        }
+        throw t;
+      }
+  }
+  
   public static RuntimeException propogate(Throwable t) {
     if (t instanceof RuntimeException)
       throw (RuntimeException)t;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/misc/MoreFunctions.java Fri Oct 28 23:44:35 2011
@@ -300,4 +300,14 @@ public class MoreFunctions {
     }
   }
   
+  public static final Function<String,Long> parseLong =
+    new Function<String,Long>() {
+      public Long apply(String input) {
+        try {
+          return (input != null) ? Long.valueOf(input) : -1;
+        } catch (NumberFormatException e) {
+          return -1L;
+        }
+      }
+  };
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractCollectionAdapter.java Fri Oct 28 23:44:35 2011
@@ -21,7 +21,6 @@ import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.abdera2.activities.protocol.AbstractActivitiesWorkspaceProvider;
 import org.apache.abdera2.common.text.UrlEncoding;
 import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.common.http.EntityTag;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractMessage.java Fri Oct 28 23:44:35 2011
@@ -26,48 +26,64 @@ import org.apache.abdera2.common.http.Ca
 import org.apache.abdera2.common.http.Preference;
 import org.apache.abdera2.common.http.WebLink;
 import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.common.text.Codec;
 import org.apache.abdera2.common.text.UrlEncoding;
 
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+import com.google.common.collect.Iterables;
+
+import static com.google.common.base.Preconditions.*;
 /**
  * Root impl for Message interface impls. This is provided solely as a way of keeping the interface and impl's
  * consistent across the Request and Response objects.
  */
-public abstract class AbstractMessage implements Message {
+public abstract class AbstractMessage 
+  implements Message {
 
+    public <T>T getHeader(String name, Function<String,T> transform) {
+      checkNotNull(transform);
+      return transform.apply(getHeader(name));
+    }
+    
+    public <T>Iterable<T> getHeaders(String name, Function<String,T> transform) {
+      Iterable<Object> objs = this.getHeaders(name);
+      List<T> list = new ArrayList<T>();
+      for (Object obj : objs)
+        list.add(transform.apply(obj.toString()));
+      return Iterables.unmodifiableIterable(list);
+    }
+  
     public CacheControl getCacheControl() {
-        String cc = getHeader("Cache-Control");
-        return cc != null ? CacheControl.parse(cc) : null;
+      return getHeader("Cache-Control", CacheControl.parser);
     }
 
     public String getContentLanguage() {
-        return getHeader("Content-Language");
+      return getHeader("Content-Language");
     }
 
     public IRI getContentLocation() {
-        String value = getHeader("Content-Location");
-        return (value != null) ? new IRI(value) : null;
+      return getHeader("Content-Location", IRI.parser);
     }
 
     public MimeType getContentType() {
-        try {
-            String value = getHeader("Content-Type");
-            return (value != null) ? new MimeType(value) : null;
-        } catch (javax.activation.MimeTypeParseException e) {
-            throw new org.apache.abdera2.common.mediatype.MimeTypeParseException(e);
-        }
+      return getHeader("Content-Type", MimeTypeHelper.parser);
     }
 
+    private static final Function<String,String> DEC = 
+      Functions.<String,String,String>compose(
+        UrlEncoding.decoder(),
+        Codec.decode());
+    
     public String getDecodedHeader(String header) {
-        return UrlEncoding.decode(Codec.decode(getHeader(header)));
+      return getHeader(
+        header, 
+        DEC);
     }
 
     public Iterable<String> getDecodedHeaders(String header) {
-        Iterable<Object> headers = getHeaders(header);
-        List<String> items = new ArrayList<String>();
-        for (Object h : headers)
-          items.add(UrlEncoding.decode(Codec.decode(h.toString())));
-        return items;
+      return getHeaders(header, DEC);
     }
 
     public String getSlug() {
@@ -76,7 +92,7 @@ public abstract class AbstractMessage im
 
     public Iterable<WebLink> getWebLinks() {
       List<WebLink> links = new ArrayList<WebLink>();
-      Iterable<Object> headers = this.getHeaders("Link");
+      Iterable<Object> headers = this.getHeaders("Link");      
       for (Object obj : headers) {
         Iterable<WebLink> list = WebLink.parse(obj.toString());
         for (WebLink link : list)

Copied: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractProvider.java (from r1190093, abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractProvider.java?p2=abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractProvider.java&p1=abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java&r1=1190093&r2=1190679&rev=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractProvider.java Fri Oct 28 23:44:35 2011
@@ -32,16 +32,17 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import com.google.common.base.Function;
+import com.google.common.base.Predicate;
 
 /**
  * Base Provider implementation that provides the core implementation details for all Providers. This class provides the
  * basic request routing logic.
  */
 @SuppressWarnings({"unchecked","rawtypes"})
-public abstract class BaseProvider
+public abstract class AbstractProvider
   implements Provider {
 
-    private final static Log log = LogFactory.getLog(BaseProvider.class);
+    private final static Log log = LogFactory.getLog(AbstractProvider.class);
     protected Map<String, Object> properties;
     protected Set<Task<RequestContext,ResponseContext>> filters = 
       new LinkedHashSet<Task<RequestContext,ResponseContext>>();
@@ -99,7 +100,7 @@ public abstract class BaseProvider
       if (adapter == null && type != TargetType.TYPE_SERVICE)
         return ProviderHelper.notfound(request);
       RequestProcessor processor = 
-        (RequestProcessor) this.requestProcessors
+        this.requestProcessors
           .get(type)
           .apply(adapter);
       if (processor == null)
@@ -143,12 +144,48 @@ public abstract class BaseProvider
         }
     }
 
-    public void setRequestProcessors(Map<TargetType, Function<CollectionAdapter,? extends RequestProcessor>> requestProcessors) {
+    public void setRequestProcessors(
+      Map<
+        TargetType, 
+        Function<
+          CollectionAdapter,
+          ? extends RequestProcessor>> 
+            requestProcessors) {
         this.requestProcessors.clear();
         this.requestProcessors.putAll(requestProcessors);
     }
 
-    public void addRequestProcessors(Map<TargetType, Function<CollectionAdapter,? extends RequestProcessor>> requestProcessors) {
+    public void addRequestProcessor(
+      TargetType type, 
+      Class<? extends RequestProcessor> _class, 
+      Predicate<RequestContext> predicate,
+      WorkspaceManager workspaceManager) {
+        this.requestProcessors.put(
+          type, 
+          RequestProcessor.forClass(
+            _class,
+            workspaceManager,
+            predicate));
+    }
+    
+    public void addRequestProcessor(
+        TargetType type, 
+        Class<? extends RequestProcessor> _class,
+        WorkspaceManager workspaceManager) {
+          this.requestProcessors.put(
+            type, 
+            RequestProcessor.forClass(
+              _class,
+              workspaceManager));
+    }
+    
+    public void addRequestProcessors(
+      Map<
+        TargetType, 
+        Function<
+          CollectionAdapter,
+          ? extends RequestProcessor>> 
+            requestProcessors) {
         this.requestProcessors.putAll(requestProcessors);
     }
 

Propchange: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractRequest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractRequest.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractRequest.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractRequest.java Fri Oct 28 23:44:35 2011
@@ -40,12 +40,11 @@ public abstract class AbstractRequest ex
     }
 
     public Iterable<Authentication> getAuthentication() {
-        String auth =  getHeader("Authorization");
-        return auth != null ? Authentication.parse(auth) : null;
+      return getHeader("Authorization", Authentication.parser);
     }
     
     public Iterable<EntityTag> getIfMatch() {
-        return EntityTag.parseTags(getHeader("If-Match"));
+      return getHeader("If-Match", EntityTag.parseMultiple);
     }
 
     public DateTime getIfModifiedSince() {
@@ -53,7 +52,7 @@ public abstract class AbstractRequest ex
     }
 
     public Iterable<EntityTag> getIfNoneMatch() {
-        return EntityTag.parseTags(getHeader("If-None-Match"));
+      return getHeader("If-None-Match", EntityTag.parseMultiple);
     }
 
     public DateTime getIfUnmodifiedSince() {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponse.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponse.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponse.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponse.java Fri Oct 28 23:44:35 2011
@@ -18,20 +18,16 @@
 package org.apache.abdera2.common.protocol;
 
 import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.misc.MoreFunctions;
 import org.apache.abdera2.common.http.Authentication;
 import org.apache.abdera2.common.http.EntityTag;
 import org.apache.abdera2.common.http.ResponseType;
 import org.joda.time.DateTime;
 
 public abstract class AbstractResponse extends AbstractMessage implements Response {
-
+  
     public long getAge() {
-        String value = getHeader("Age");
-        try {
-            return (value != null) ? Long.parseLong(value) : -1;
-        } catch (NumberFormatException e) {
-            return -1;
-        }
+      return getHeader("Age", MoreFunctions.parseLong);
     }
 
     public String getAllow() {
@@ -39,17 +35,11 @@ public abstract class AbstractResponse e
     }
 
     public long getContentLength() {
-        String value = getHeader("Content-Length");
-        try {
-            return (value != null) ? Long.parseLong(value) : -1;
-        } catch (NumberFormatException e) {
-            return -1;
-        }
+      return getHeader("Content-Length", MoreFunctions.parseLong);
     }
 
     public EntityTag getEntityTag() {
-        String etag = getHeader("ETag");
-        return (etag != null) ? EntityTag.parse(getHeader("ETag")) : null;
+      return getHeader("ETag", EntityTag.parser);
     }
 
     public DateTime getExpires() {
@@ -61,16 +51,14 @@ public abstract class AbstractResponse e
     }
 
     public IRI getLocation() {
-        String l = getHeader("Location");
-        return l != null ? new IRI(l) : null;
+      return getHeader("Location",IRI.parser);
     }
 
     public ResponseType getType() {
-        return ResponseType.select(getStatus());
+      return ResponseType.select(getStatus());
     }
 
     public Iterable<Authentication> getAuthentication() {
-      String auth =  getHeader("WWW-Authenticate");
-      return auth != null ? Authentication.parse(auth) : null;
+      return getHeader("WWW-Authenticate", Authentication.parser);
   }
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractResponseContext.java Fri Oct 28 23:44:35 2011
@@ -52,7 +52,8 @@ public abstract class AbstractResponseCo
     protected String status_text = null;
     protected boolean binary = false;
 
-    protected Map<String, Iterable<Object>> headers = null;
+    protected final Map<String, Iterable<Object>> headers = 
+      new HashMap<String,Iterable<Object>>();
 
     public <T extends ResponseContext>T setBinary(boolean binary) {
         this.binary = binary;
@@ -72,7 +73,7 @@ public abstract class AbstractResponseCo
     }
     
     public <T extends ResponseContext>T removeHeader(String name) {
-        getHeaders().remove(name);
+        headers.remove(name);
         return (T)this;
     }
 
@@ -96,7 +97,6 @@ public abstract class AbstractResponseCo
     }
 
     public <T extends ResponseContext>T setHeader(String name, Object... vals) {
-        Map<String, Iterable<Object>> headers = getHeaders();
         Set<Object> values = new HashSet<Object>();
         values.addAll(Arrays.asList(vals));
         headers.put(name, values);
@@ -118,7 +118,6 @@ public abstract class AbstractResponseCo
     }
 
     public <T extends ResponseContext>T addHeaders(String name, Object... vals) {
-        Map<String, Iterable<Object>> headers = getHeaders();
         Iterable<Object> values = headers.get(name);
         Set<Object> l = 
           values == null ? 
@@ -130,13 +129,10 @@ public abstract class AbstractResponseCo
     }
 
     public Map<String, Iterable<Object>> getHeaders() {
-        if (headers == null)
-            headers = new HashMap<String, Iterable<Object>>();
         return headers;
     }
 
     public DateTime getDateHeader(String name) {
-        Map<String, Iterable<Object>> headers = getHeaders();
         Iterable<Object> values = headers.get(name);
         if (values != null) {
             for (Object value : values) {
@@ -144,6 +140,10 @@ public abstract class AbstractResponseCo
                     return new DateTime(value);
                 else if (value instanceof DateTime)
                     return (DateTime)value;
+                else if (value instanceof Long)
+                    return new DateTime((Long)value);
+                else if (value instanceof String)
+                    return new DateTime(value);
                 else if (value instanceof Calendar)
                     return new DateTime(value);
             }
@@ -157,36 +157,41 @@ public abstract class AbstractResponseCo
     }
     
     public String getHeader(String name) {
-      Map<String, Iterable<Object>> headers = getHeaders();
       Iterable<Object> values = headers.get(name);
       Object obj = getFirst(values,null);
       return obj != null ? obj.toString() : null;
     }
 
     public Iterable<Object> getHeaders(String name) {
-        Map<String, Iterable<Object>> headers = getHeaders();
         return headers.get(name);
     }
 
     public Iterable<String> getHeaderNames() {
-        Map<String, Iterable<Object>> headers = getHeaders();
         return headers.keySet();
     }
 
     public <T extends ResponseContext>T setAge(long age) {
-        return (T)(age <= -1 ? removeHeader("Age") : setHeader("Age", String.valueOf(age)));
+        return (T)(age <= -1 ? 
+          removeHeader("Age") : 
+            setHeader("Age", String.valueOf(age)));
     }
 
     public <T extends ResponseContext>T setContentLanguage(String language) {
-        return (T)(language == null ? removeHeader("Content-Language") : setHeader("Content-Language", language));
+        return (T)(language == null ? 
+          removeHeader("Content-Language") : 
+          setHeader("Content-Language", language));
     }
 
     public <T extends ResponseContext>T setContentLength(long length) {
-        return (T)(length <= -1 ? removeHeader("Content-Length") : setHeader("Content-Length", String.valueOf(length)));
+        return (T)(length <= -1 ? 
+          removeHeader("Content-Length") : 
+          setHeader("Content-Length", String.valueOf(length)));
     }
 
     public <T extends ResponseContext>T setContentLocation(String uri) {
-        return (T)(uri == null ? removeHeader("Content-Location") : setHeader("Content-Location", uri));
+        return (T)(uri == null ? 
+          removeHeader("Content-Location") : 
+          setHeader("Content-Location", uri));
     }
 
     public <T extends ResponseContext>T setSlug(String slug) {
@@ -215,23 +220,33 @@ public abstract class AbstractResponseCo
     }
 
     public <T extends ResponseContext>T setEntityTag(String etag) {
-        return (T)(etag != null ? setEntityTag(new EntityTag(etag)) : removeHeader("ETag"));
+        return (T)(etag != null ? 
+          setEntityTag(new EntityTag(etag)) : 
+          removeHeader("ETag"));
     }
 
     public <T extends ResponseContext>T setEntityTag(EntityTag etag) {
-        return (T)(etag == null ? removeHeader("ETag") : setHeader("ETag", etag.toString()));
+        return (T)(etag == null ? 
+          removeHeader("ETag") : 
+          setHeader("ETag", etag.toString()));
     }
 
     public <T extends ResponseContext>T setExpires(DateTime date) {
-        return (T)(date == null ? removeHeader("Expires") : setHeader("Expires", date));
+        return (T)(date == null ? 
+          removeHeader("Expires") : 
+          setHeader("Expires", date));
     }
 
     public <T extends ResponseContext>T setLastModified(DateTime date) {
-        return (T)(date == null ? removeHeader("Last-Modified") : setHeader("Last-Modified", date));
+        return (T)(date == null ? 
+          removeHeader("Last-Modified") : 
+          setHeader("Last-Modified", date));
     }
 
     public <T extends ResponseContext>T setLocation(String uri) {
-        return (T)(uri == null ? removeHeader("Location") : setHeader("Location", uri));
+        return (T)(uri == null ? 
+          removeHeader("Location") : 
+          setHeader("Location", uri));
     }
     public <T extends ResponseContext>T setLocation(IRI iri) {
       return setLocation(iri == null ? null : iri.toString());

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/AbstractWorkspaceProvider.java Fri Oct 28 23:44:35 2011
@@ -28,12 +28,13 @@ import org.joda.time.DateTime;
 import com.google.common.base.Function;
 
 /**
- * An abstract base Provider implementation that implements the WorkspaceManager interface. This is intended to be used
- * by Provider's that do not wish to use a separate WorkspaceManager object.
+ * An abstract base Provider implementation that implements the 
+ * WorkspaceManager interface. This is intended to be used by 
+ * Provider's that do not wish to use a separate WorkspaceManager object.
  */
 public abstract class AbstractWorkspaceProvider
-    extends BaseProvider 
-      implements WorkspaceManager {
+  extends AbstractProvider 
+  implements WorkspaceManager {
 
     protected Function<RequestContext,Target> targetResolver;
     protected TargetBuilder<?> targetBuilder;
@@ -44,8 +45,9 @@ public abstract class AbstractWorkspaceP
       return this;
     }
 
-    protected Function<RequestContext,Target> getTargetResolver(RequestContext request) {
-        return targetResolver;
+    protected Function<RequestContext,Target> getTargetResolver(
+      RequestContext request) {
+      return targetResolver;
     }
 
     @SuppressWarnings("rawtypes")

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseRequestContextWrapper.java Fri Oct 28 23:44:35 2011
@@ -35,6 +35,8 @@ import org.apache.abdera2.common.http.Pr
 import org.apache.abdera2.common.http.WebLink;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Function;
+
 @SuppressWarnings("unchecked")
 public class BaseRequestContextWrapper
   implements RequestContext{
@@ -247,4 +249,12 @@ public class BaseRequestContextWrapper
       return request.getPreferApplied();
     }
 
+    public <T> T getHeader(String name, Function<String, T> transform) {
+      return request.getHeader(name,transform);
+    }
+
+    public <T> Iterable<T> getHeaders(String name, Function<String, T> transform) {
+      return request.getHeaders(name,transform);
+    }
+
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseResponseContextWrapper.java Fri Oct 28 23:44:35 2011
@@ -33,6 +33,8 @@ import org.apache.abdera2.common.http.Re
 import org.apache.abdera2.common.http.WebLink;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Function;
+
 @SuppressWarnings("unchecked")
 public class BaseResponseContextWrapper implements ResponseContext {
 
@@ -326,4 +328,12 @@ public class BaseResponseContextWrapper 
       return (T)this;
     }
 
+    public <T> T getHeader(String name, Function<String, T> transform) {
+      return response.getHeader(name,transform);
+    }
+
+    public <T> Iterable<T> getHeaders(String name, Function<String, T> transform) {
+      return response.getHeaders(name, transform);
+    }
+
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CompressionFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CompressionFilter.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CompressionFilter.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CompressionFilter.java Fri Oct 28 23:44:35 2011
@@ -34,13 +34,20 @@ import org.apache.abdera2.common.misc.Ta
  */
 public class CompressionFilter implements Task<RequestContext,ResponseContext> {
 
-    public ResponseContext apply(RequestContext request, Chain<RequestContext,ResponseContext> chain) {
-        String encoding = request.getHeader("Accept-Encoding");
-        QToken[] encodings = encoding != null ? QualityHelper.orderByQ(encoding) : new QToken[0];
+    public ResponseContext apply(
+      RequestContext request, 
+      Chain<RequestContext,ResponseContext> chain) {
+        QToken[] encodings = 
+          request.getHeader(
+            "Accept-Encoding", 
+            QualityHelper.parser);
         for (QToken enc : encodings) {
           try {
-              CompressionCodec codec = CompressionCodec.valueOf(enc.token().toUpperCase());
-              return new CompressingResponseContextWrapper(chain.next(request), codec);
+              CompressionCodec codec = 
+                CompressionCodec.valueOf(
+                  enc.token().toUpperCase());
+              return new CompressingResponseContextWrapper(
+                chain.next(request), codec);
           } catch (Exception e) {}
         }
         return chain.next(request);
@@ -49,36 +56,38 @@ public class CompressionFilter implement
     /**
      * A HttpServletResponseWrapper implementation that applies GZip or Deflate compression to response output.
      */
-    public static class CompressingResponseContextWrapper extends BaseResponseContextWrapper {
-
+    public static class CompressingResponseContextWrapper 
+      extends BaseResponseContextWrapper {
         private final CompressionCodec codec;
-
-        public CompressingResponseContextWrapper(ResponseContext response, CompressionCodec codec) {
+        public CompressingResponseContextWrapper(
+          ResponseContext response, 
+          CompressionCodec codec) {
             super(response);
             this.codec = codec;
         }
-
         private OutputStream wrap(OutputStream out) {
-            return new CompressingOutputStream(codec, out);
+          return new CompressingOutputStream(codec, out);
         }
-
         public void writeTo(OutputStream out) throws IOException {
-            super.writeTo(wrap(out));
-            out.flush();
+          super.writeTo(wrap(out));
+          out.flush();
         }
     }
 
-    public static class CompressingOutputStream extends FilterOutputStream {
-
-        public CompressingOutputStream(CompressionCodec codec, OutputStream out) {
+    public static class CompressingOutputStream 
+      extends FilterOutputStream {
+        public CompressingOutputStream(
+          CompressionCodec codec, 
+          OutputStream out) {
             super(initStream(codec, out));
         }
-
-        public CompressingOutputStream(DeflaterOutputStream dout) {
+        public CompressingOutputStream(
+          DeflaterOutputStream dout) {
             super(dout);
         }
-
-        private static OutputStream initStream(CompressionCodec codec, OutputStream out) {
+        private static OutputStream initStream(
+          CompressionCodec codec, 
+          OutputStream out) {
             try {
                 return Compression.wrap(out, new CompressionCodec[] {codec});
             } catch (Exception e) {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Message.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Message.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Message.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/Message.java Fri Oct 28 23:44:35 2011
@@ -26,12 +26,18 @@ import org.apache.abdera2.common.http.We
 import org.apache.abdera2.common.iri.IRI;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Function;
+
 /**
  * A protocol message. This is used as the basis for both request and response objects in order to provide a consistent
  * interface.
  */
 public interface Message {
 
+    <T>T getHeader(String name, Function<String,T> transform);
+  
+    <T>Iterable<T> getHeaders(String name, Function<String,T> transform);
+    
     /**
      * Get the value of the specified header
      */

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/MethodOverrideFilter.java Fri Oct 28 23:44:35 2011
@@ -27,7 +27,8 @@ import org.apache.abdera2.common.misc.Ta
 /**
  * Abdera Filter implementation that supports the use of the X-HTTP-Method-Override header used by GData.
  */
-public class MethodOverrideFilter implements Task<RequestContext,ResponseContext> {
+public class MethodOverrideFilter 
+  implements Task<RequestContext,ResponseContext> {
 
     private Set<String> methods = new HashSet<String>();
 
@@ -73,7 +74,8 @@ public class MethodOverrideFilter implem
                 xheader = xheader.toUpperCase().trim();
             if (method.equals("POST") && 
                 xheader != null && 
-                methods.contains(method))
+                (methods.contains(method) || 
+                 methods.contains("*")))
                   method = xheader;
             this.method = method;
         }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/ProviderHelper.java Fri Oct 28 23:44:35 2011
@@ -17,8 +17,6 @@
  */
 package org.apache.abdera2.common.protocol;
 
-import java.util.Date;
-
 import javax.activation.MimeType;
 
 import org.apache.abdera2.common.Localizer;
@@ -27,55 +25,76 @@ import org.apache.abdera2.common.text.Sl
 import org.apache.abdera2.common.http.QualityHelper;
 import org.apache.abdera2.common.http.QualityHelper.QToken;
 import org.apache.abdera2.common.mediatype.MimeTypeHelper;
+import org.apache.abdera2.common.misc.MoreFunctions;
+import static org.apache.abdera2.common.misc.MoreFunctions.array;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import com.google.common.base.Function;
 import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
 
 public class ProviderHelper {
     public final static Log log = LogFactory.getLog(ProviderHelper.class);
 
-    private ProviderHelper() {
-    }
+    private ProviderHelper() {}
 
-    public static int getPageSize(RequestContext request, String pagesizeparam, int defaultpagesize) {
-        int size = defaultpagesize;
-        try {
-            String _ps = request.getParameter(pagesizeparam);
-            size = (_ps != null) ? Math.min(Math.max(Integer.parseInt(_ps), 0), defaultpagesize) : defaultpagesize;
-        } catch (Exception e) {
+    public static final Function<RequestContext,Integer> getPageSize(
+      final String param, 
+      final int def) {
+      return new Function<RequestContext,Integer>() {
+        public Integer apply(RequestContext input) {
+          int size = def;
+          try {
+              String _ps = input.getParameter(param);
+              size = (_ps != null) ? 
+                Math.min(
+                  Math.max(Integer.parseInt(_ps), 0), def) : 
+                  def;
+          } catch (Exception e) {}
+          log.debug(Localizer.sprintf("PAGE.SIZE", size));
+          return size;
         }
-        log.debug(Localizer.sprintf("PAGE.SIZE", size));
-        return size;
+      };
     }
-
-    public static int getOffset(RequestContext request, String pageparam, int pageSize) {
-        int offset = 0;
-        try {
-            String _page = request.getParameter(pageparam);
-            int page = (_page != null) ? Integer.parseInt(_page) : 1;
-            page = Math.max(page, 1) - 1;
-            offset = pageSize * page;
-        } catch (Exception e) {
-        }
-        log.debug(Localizer.sprintf("OFFSET", offset));
-        return offset;
+    
+    public static final Function<RequestContext,Integer> getOffset(
+      final String param, 
+      final int pagesize) {
+        return new Function<RequestContext,Integer>() {
+          public Integer apply(RequestContext input) {
+            int offset = 0;
+            try {
+              String _page = input.getParameter(param);
+              int page = (_page != null) ? 
+                Integer.parseInt(_page) : 1;
+              page = Math.max(page, 1) - 1;
+              offset = pagesize * page;
+            } catch (Exception e) {}
+            log.debug(Localizer.sprintf("OFFSET", offset));
+            return offset;
+          }
+        };
     }
 
     /**
      * Returns an Error document based on the StreamWriter
      */
-    public static ResponseContext createErrorResponse(Provider provider, final int code, final String message) {
+    public static ResponseContext createErrorResponse(
+      Provider provider, 
+      final int code, 
+      final String message) {
         return createErrorResponse(provider, code, message, null);
     }
 
     /**
      * Returns an Error document based on the StreamWriter
      */
-    public static ResponseContext createErrorResponse(Provider provider,
-                                                              final int code,
-                                                              final String message,
-                                                              final Throwable t) {
+    public static ResponseContext createErrorResponse(
+      Provider provider,
+      final int code,
+      final String message,
+      final Throwable t) {
         return (ResponseContext)provider.createErrorResponse(code, message, t);
     }
 
@@ -248,12 +267,6 @@ public class ProviderHelper {
         return sanitized;
     }
 
-    public static boolean beforeOrEqual(Date d1, Date d2) {
-        long l1 = d1.getTime() / 1000; // drop milliseconds
-        long l2 = d2.getTime() / 1000; // drop milliseconds
-        return l1 <= l2;
-    }
-
     public static IRI resolveBase(RequestContext request) {
         return request.getBaseUri().resolve(request.getUri());
     }
@@ -268,21 +281,20 @@ public class ProviderHelper {
         return buf.toString();
     }
 
+    static private final Function<TargetType,String[]> METHODS_CHOICE = 
+      MoreFunctions.<TargetType,String[]>choice()
+        .of(Predicates.<TargetType>isNull(), MoreFunctions.<String>array())
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_COLLECTION), array("GET", "HEAD", "OPTIONS", "POST"))
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_CATEGORIES), array("GET", "HEAD", "OPTIONS"))
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_ENTRY), array("DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"))
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_MEDIA), array("DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"))
+        .of(Predicates.<TargetType>equalTo(TargetType.TYPE_SERVICE), array("GET", "HEAD", "OPTIONS"))
+        .otherwise(array("GET","HEAD","OPTIONS"))
+        .get();
+    
     public static String[] getDefaultMethods(RequestContext request) {
         TargetType type = request.getTarget().getType();
-        if (type == null)
-            return new String[0];
-        if (type == TargetType.TYPE_COLLECTION)
-            return new String[] {"GET", "HEAD", "OPTIONS", "POST"};
-        if (type == TargetType.TYPE_CATEGORIES)
-            return new String[] {"GET", "HEAD", "OPTIONS"};
-        if (type == TargetType.TYPE_ENTRY)
-            return new String[] {"DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"};
-        if (type == TargetType.TYPE_MEDIA)
-            return new String[] {"DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"};
-        if (type == TargetType.TYPE_SERVICE)
-            return new String[] {"GET", "HEAD", "OPTIONS"};
-        return new String[] {"GET", "HEAD", "OPTIONS"};
+        return METHODS_CHOICE.apply(type);
     }
 
     public static boolean defaultCheckMethod(RequestContext request, String[] methods) {



Mime
View raw message