abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1187599 [4/4] - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/client/ activities/src/main/java/org/apache/abdera2/activities/protocol/ activities/src/main/java/org/apache/abdera2/activities/protocol/basic/ acti...
Date Fri, 21 Oct 2011 23:47:53 GMT
Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/FeedConfiguration.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/FeedConfiguration.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/FeedConfiguration.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/FeedConfiguration.java Fri Oct 21 23:47:50 2011
@@ -17,6 +17,9 @@
  */
 package org.apache.abdera2.protocol.server.provider.managed;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
@@ -26,7 +29,11 @@ import org.apache.abdera2.protocol.serve
 import org.apache.abdera2.protocol.server.model.AtompubCategoriesInfo;
 import org.apache.abdera2.protocol.server.model.AtompubCollectionInfo;
 
-public class FeedConfiguration extends Configuration implements AtompubCollectionInfo {
+import com.google.common.base.Supplier;
+
+public class FeedConfiguration 
+  extends Configuration 
+  implements AtompubCollectionInfo {
     public static final String PROP_NAME_ADAPTER_CLASS = "adapterClassName";
     public static final String PROP_SUB_URI_NAME = "subUri";
     public static final String PROP_AUTHOR_NAME = "author";
@@ -42,45 +49,126 @@ public class FeedConfiguration extends C
     public static final String ENTRY_ELEM_NAME_UPDATED = "updated";
     public static final String ENTRY_ELEM_NAME_LINK = "link";
 
+    public static class Generator implements Supplier<FeedConfiguration> {
+
+      private String feedId;
+      private String subUri;
+      private String adapterClassName;
+      private String feedConfigLocation;
+      private ServerConfiguration serverConfiguration;
+      private String feedTitle = "unknown";
+      private String feedAuthor = "unknown";
+      private final Map<Object, Object> optionalProperties = 
+        new HashMap<Object,Object>();
+      private CollectionAdapterConfiguration adapterConfiguration;      
+      
+      public Generator id(String id) {
+        this.feedId = id;
+        return this;
+      }
+      
+      public Generator subUri(String uri) {
+        this.subUri = uri;
+        return this;
+      }
+      
+      public Generator adapter(String className) {
+        this.adapterClassName = className;
+        return this;
+      }
+      
+      public Generator location(String location) {
+        this.feedConfigLocation = location;
+        return this;
+      }
+      
+      public Generator serverConfig(ServerConfiguration config) {
+        this.serverConfiguration = config;
+        return this;
+      }
+      
+      public Generator title(String title) {
+        this.feedTitle = title;
+        return this;
+      }
+      
+      public Generator author(String author) {
+        this.feedAuthor = author;
+        return this;
+      }
+      
+      public Generator set(Object key, Object val) {
+        this.optionalProperties.put(key, val);
+        return this;
+      }
+      
+      public Generator setAll(Map<Object,Object> props) {
+        this.optionalProperties.putAll(props);
+        return this;
+      }
+      
+      public Generator adapterConfif(CollectionAdapterConfiguration config) {
+        this.adapterConfiguration = config;
+        return this;
+      }
+      
+      public FeedConfiguration get() {
+        return new FeedConfiguration(this);
+      }
+      
+    }
+    
+    public static Generator make() {
+      return new Generator();
+    }
+    
     private final String feedId;
     private final String subUri;
     private final String adapterClassName;
     private final String feedConfigLocation;
     private final ServerConfiguration serverConfiguration;
-    private String feedTitle = "unknown";
-    private String feedAuthor = "unknown";
-    private Map<Object, Object> optionalProperties;
+    private final String feedTitle ;
+    private final String feedAuthor;
+    private final Map<Object, Object> optionalProperties = 
+      new HashMap<Object,Object>();
     private final CollectionAdapterConfiguration adapterConfiguration;
-
-    public FeedConfiguration(String feedId,
-                             String subUri,
-                             String adapterClassName,
-                             String feedConfigLocation,
-                             ServerConfiguration serverConfiguration) {
-        this.feedId = feedId;
-        this.subUri = subUri;
-        this.adapterClassName = adapterClassName;
-        this.feedConfigLocation = feedConfigLocation;
-        this.adapterConfiguration = new CollectionAdapterConfiguration(serverConfiguration, feedConfigLocation);
-        this.serverConfiguration = serverConfiguration;
-    }
-
-    public static FeedConfiguration getFeedConfiguration(String feedId,
-                                                         Properties properties,
-                                                         ServerConfiguration serverConfiguration) {
-        FeedConfiguration feedConfiguration =
-            new FeedConfiguration(feedId, Configuration.getProperty(properties, PROP_SUB_URI_NAME), Configuration
-                .getProperty(properties, PROP_NAME_ADAPTER_CLASS), Configuration
-                .getProperty(properties, PROP_FEED_CONFIG_LOCATION_NAME), serverConfiguration);
-        if (properties.containsKey(PROP_AUTHOR_NAME)) {
-            feedConfiguration.setFeedAuthor(Configuration.getProperty(properties, PROP_AUTHOR_NAME));
-        }
-
-        if (properties.containsKey(PROP_TITLE_NAME)) {
-            feedConfiguration.setFeedTitle(Configuration.getProperty(properties, PROP_TITLE_NAME));
-        }
-        feedConfiguration.optionalProperties = properties;
-        return feedConfiguration;
+    
+    protected FeedConfiguration(Generator gen) {
+      this.feedId = gen.feedId;
+      this.subUri = gen.subUri;
+      this.adapterClassName = gen.adapterClassName;
+      this.feedConfigLocation = gen.feedConfigLocation;
+      this.serverConfiguration = gen.serverConfiguration;
+      this.feedTitle = gen.feedTitle;
+      this.feedAuthor = gen.feedAuthor;
+      this.optionalProperties.putAll(gen.optionalProperties);
+      this.adapterConfiguration = gen.adapterConfiguration;
+    }
+
+    public static FeedConfiguration getFeedConfiguration(
+      String feedId,
+      Properties properties,
+      ServerConfiguration serverConfiguration) {
+      
+      String author = "unknown";
+      String title = "unknown";
+      
+      if (properties.containsKey(PROP_AUTHOR_NAME))
+        author = Configuration.getProperty(properties, PROP_AUTHOR_NAME);
+      if (properties.containsKey(PROP_TITLE_NAME))
+        title = Configuration.getProperty(properties, PROP_TITLE_NAME);
+      
+      return FeedConfiguration
+        .make()
+          .id(feedId)
+          .subUri(Configuration.getProperty(properties, PROP_SUB_URI_NAME))
+          .adapter(Configuration.getProperty(properties, PROP_NAME_ADAPTER_CLASS))
+          .location(Configuration.getProperty(properties, PROP_FEED_CONFIG_LOCATION_NAME))
+          .serverConfig(serverConfiguration)
+          .title(title)
+          .author(author)
+          .setAll(properties)
+        .get();
     }
 
     public String getAdapterClassName() {
@@ -107,14 +195,6 @@ public class FeedConfiguration extends C
         return subUri;
     }
 
-    public void setFeedAuthor(String feedAuthor) {
-        this.feedAuthor = feedAuthor;
-    }
-
-    public void setFeedTitle(String feedTitle) {
-        this.feedTitle = feedTitle;
-    }
-
     public String getFeedUri() {
         return serverConfiguration.getServerUri() + "/" + getSubUri();
     }
@@ -142,15 +222,17 @@ public class FeedConfiguration extends C
         return collection;
     }
 
-    public String[] getAccepts(RequestContext request) {
+    public Iterable<String> getAccepts(RequestContext request) {
         Object accepts = optionalProperties.get(PROP_ACCEPTS);
+        String[] arr = null;
         if (accepts == null || !(accepts instanceof String))
-            return new String[] {"application/atom+xml;type=entry"};
-        return ((String)accepts).split("\\s*,\\s*");
+            arr = new String[] {"application/atom+xml;type=entry"};
+        else arr = ((String)accepts).split("\\s*,\\s*");
+        return Arrays.asList(arr);
     }
 
-    public AtompubCategoriesInfo[] getCategoriesInfo(RequestContext request) {
-        return new AtompubCategoriesInfo[0];
+    public Iterable<AtompubCategoriesInfo> getCategoriesInfo(RequestContext request) {
+        return Collections.<AtompubCategoriesInfo>emptySet();
     }
 
     public String getHref(RequestContext request) {

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedCollectionAdapter.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedCollectionAdapter.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/ManagedCollectionAdapter.java Fri Oct 21 23:47:50 2011
@@ -20,17 +20,16 @@ package org.apache.abdera2.protocol.serv
 import org.apache.abdera2.Abdera;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.ResponseContextException;
-import org.apache.abdera2.protocol.server.AtompubCollectionAdapter;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubCollectionAdapter;
 
 public abstract class ManagedCollectionAdapter 
-  extends AbstractAtompubCollectionAdapter 
-  implements AtompubCollectionAdapter {
+  extends AbstractAtompubCollectionAdapter {
 
     protected final FeedConfiguration config;
     protected final Abdera abdera;
 
     protected ManagedCollectionAdapter(Abdera abdera, FeedConfiguration config) {
+      super(null);
         this.config = config;
         this.abdera = abdera;
     }

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/client/AppTest.java Fri Oct 21 23:47:50 2011
@@ -27,7 +27,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -57,6 +56,7 @@ import org.apache.abdera2.protocol.clien
 import org.apache.abdera2.protocol.client.Client;
 import org.apache.abdera2.protocol.client.RequestOptions;
 import org.apache.abdera2.protocol.client.Session;
+import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.common.http.CacheControl;
 import org.apache.abdera2.common.http.EntityTag;
 import org.apache.abdera2.common.mediatype.MimeTypeHelper;
@@ -384,7 +384,7 @@ public class AppTest {
         Client abderaClient = new BasicClient();
         Session session = abderaClient.newSession();
         RequestOptions options = session.getDefaultRequestOptions();
-        options.setIfModifiedSince(new Date());
+        options.setIfModifiedSince(DateTimes.now());
         assertNotNull(options.getIfModifiedSince());
 
         options.set4xxRequestException(true);

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/CustomProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/CustomProvider.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/CustomProvider.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/CustomProvider.java Fri Oct 21 23:47:50 2011
@@ -17,10 +17,10 @@
  */
 package org.apache.abdera2.test.security.filter;
 
+import org.apache.abdera2.common.protocol.CollectionAdapter;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.RouteManager;
 import org.apache.abdera2.common.protocol.TargetType;
-import org.apache.abdera2.protocol.server.AtompubCollectionAdapter;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubWorkspaceProvider;
 import org.apache.abdera2.protocol.server.impl.SimpleWorkspaceInfo;
 import org.apache.abdera2.security.util.filters.SignedRequestFilter;
@@ -38,9 +38,9 @@ public class CustomProvider 
     private static final String certificateAlias = "James";
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    public CustomProvider() {
+    public CustomProvider(String href) {
 
-        this.adapter = new SimpleAdapter();
+        this.adapter = new SimpleAdapter(href);
 
         RouteManager rm =
             new RouteManager()
@@ -51,10 +51,12 @@ public class CustomProvider 
         setTargetBuilder(rm);
         setTargetResolver(rm);
 
-        SimpleWorkspaceInfo workspace = new SimpleWorkspaceInfo();
-        workspace.setTitle("A Simple Workspace");
-        workspace.addCollection(adapter);
-        addWorkspace(workspace);
+        addWorkspace(
+          SimpleWorkspaceInfo
+            .make()
+            .title("A Simple Workspace")
+            .collection(adapter)
+            .get());
 
         addFilter(
           new SignedRequestFilter());
@@ -67,7 +69,7 @@ public class CustomProvider 
               null));
     }
 
-    public AtompubCollectionAdapter getCollectionAdapter(RequestContext request) {
+    public CollectionAdapter getCollectionAdapter(RequestContext request) {
         return adapter;
     }
 

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/SimpleAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/SimpleAdapter.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/SimpleAdapter.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/SimpleAdapter.java Fri Oct 21 23:47:50 2011
@@ -42,83 +42,108 @@ import org.apache.abdera2.protocol.serve
 import org.apache.abdera2.writer.StreamWriter;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Function;
+
 @SuppressWarnings("unchecked")
 public class SimpleAdapter extends AbstractAtompubCollectionAdapter {
 
-    @Override
-    public String getAuthor(RequestContext request) throws ResponseContextException {
-        return "Simple McGee";
-    }
-
-    @Override
-    public String getId(RequestContext request) {
-        return "tag:example.org,2008:feed";
-    }
-
-    public String getHref(RequestContext request) {
-        Map<String, Object> params = new HashMap<String, Object>();
-        params.put("collection", "feed");
-        return request.urlFor("feed", params);
-    }
-
-    public String getTitle(RequestContext request) {
-        return "A simple feed";
-    }
-
-    public ResponseContext extensionRequest(RequestContext request) {
-        return ProviderHelper.notallowed(request, "Method Not Allowed", ProviderHelper.getDefaultMethods(request));
-    }
-
-    private Document<Feed> getFeedDocument(RequestContext context) throws ResponseContextException {
-        Feed feed = (Feed)context.getAttribute(Scope.SESSION, "feed");
-        if (feed == null) {
-            feed = createFeedBase(context);
-            feed.setBaseUri(getHref(context));
-            context.setAttribute(Scope.SESSION, "feed", feed);
-        }
-        return feed.getDocument();
-    }
-
-    public ResponseContext getItemList(RequestContext request) {
+  public SimpleAdapter(String href) {
+    super(href);
+    putHandler(TargetType.TYPE_COLLECTION,"GET",getItemList());
+    putHandler(TargetType.TYPE_COLLECTION,"HEAD",getItemList());
+    putHandler(TargetType.TYPE_COLLECTION,"POST",postItem());
+    putHandler(TargetType.TYPE_ENTRY,"DELETE",deleteItem());
+    putHandler(TargetType.TYPE_ENTRY,"GET",getItem());
+    putHandler(TargetType.TYPE_ENTRY,"HEAD",getItem());
+    putHandler(TargetType.TYPE_ENTRY,"PUT",putItem());
+    putHandler(TargetType.TYPE_CATEGORIES,"GET",getCategories());
+    putHandler(TargetType.TYPE_CATEGORIES,"HEAD",getCategories());
+  }
+
+  @Override
+  public String getAuthor(RequestContext request) throws ResponseContextException {
+      return "Simple McGee";
+  }
+
+  @Override
+  public String getId(RequestContext request) {
+      return "tag:example.org,2008:feed";
+  }
+
+  public String getHref(RequestContext request) {
+      Map<String, Object> params = new HashMap<String, Object>();
+      params.put("collection", "feed");
+      return request.urlFor(TargetType.TYPE_COLLECTION, params);
+  }
+
+  public String getTitle(RequestContext request) {
+      return "A simple feed";
+  }
+
+  private Document<Feed> getFeedDocument(RequestContext context) throws ResponseContextException {
+      Feed feed = (Feed)context.getAttribute(Scope.SESSION, "feed");
+      if (feed == null) {
+          feed = createFeedBase(context);
+          feed.setBaseUri(getHref(context));
+          context.setAttribute(Scope.SESSION, "feed", feed);
+      }
+      return feed.getDocument();
+  }
+
+  private Function<RequestContext,ResponseContext> getItemList() {
+    return new Function<RequestContext,ResponseContext>() {
+      public ResponseContext apply(RequestContext input) {
         Document<Feed> feed;
         try {
-            feed = getFeedDocument(request);
+            feed = getFeedDocument(input);
         } catch (ResponseContextException e) {
             return e.getResponseContext();
         }
-
-        return AbstractAtompubProvider.returnBase(feed, 200, feed.getRoot().getUpdated()).setEntityTag(AbstractAtompubProvider
-            .calculateEntityTag(feed.getRoot()));
-    }
-
-    public ResponseContext deleteItem(RequestContext request) {
-        Entry entry = getAbderaEntry(request);
+        return AbstractAtompubProvider
+          .returnBase(feed, 200, feed.getRoot().getUpdated())
+          .setEntityTag(
+            AbstractAtompubProvider
+              .calculateEntityTag(feed.getRoot()));
+      }
+    };
+  }
+
+  public Function<RequestContext,ResponseContext> deleteItem() {
+    return new Function<RequestContext,ResponseContext>() {
+      public ResponseContext apply(RequestContext input) {
+        Entry entry = getAbderaEntry(input);
         if (entry != null)
             entry.discard();
         return ProviderHelper.nocontent();
-    }
-
-    public ResponseContext getItem(RequestContext request) {
-        Entry entry = (Entry)getAbderaEntry(request);
+      }
+    };
+  }
+
+  private Function<RequestContext,ResponseContext> getItem() {
+    return new Function<RequestContext,ResponseContext>() {
+      public ResponseContext apply(RequestContext input) {
+        Entry entry = (Entry)getAbderaEntry(input);
         if (entry != null) {
             Feed feed = entry.getParentElement();
             entry = (Entry)entry.clone();
             entry.setSource(feed.getAsSource());
             Document<Entry> entry_doc = entry.getDocument();
-            return AbstractAtompubProvider.returnBase(entry_doc, 200, entry.getEdited()).setEntityTag(AbstractAtompubProvider
+            return AbstractAtompubProvider
+              .returnBase(entry_doc, 200, entry.getEdited())
+              .setEntityTag(AbstractAtompubProvider
                 .calculateEntityTag(entry));
         } else {
-            return ProviderHelper.notfound(request);
+            return ProviderHelper.notfound(input);
         }
-    }
-
-    private static Abdera getAbdera(RequestContext request) {
-      return AbstractAtompubProvider.getAbdera(request);
-    }
-    
-    public ResponseContext postItem(RequestContext context) {
-        Abdera abdera = getAbdera(context);
-        AtompubRequestContext request = (AtompubRequestContext) context;
+      }
+    };
+  }
+  
+  private Function<RequestContext,ResponseContext> postItem() {
+    return new Function<RequestContext,ResponseContext>() {
+      public ResponseContext apply(RequestContext input) {
+        AtompubRequestContext request = (AtompubRequestContext) input;
+        Abdera abdera = request.getAbdera();
         try {
             Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
             if (entry_doc != null) {
@@ -144,25 +169,29 @@ public class SimpleAdapter extends Abstr
         } catch (Exception e) {
             return ProviderHelper.badrequest(request);
         }
-    }
-
-    private void setEntryDetails(RequestContext request, Entry entry, String id) {
-        entry.setUpdated(DateTime.now());
-        entry.setEdited(entry.getUpdated());
-        entry.getIdElement().setValue(id);
-        entry.addLink(getEntryLink(request, entry.getId().toASCIIString()), "edit");
-    }
-
-    private String getEntryLink(RequestContext request, String entryid) {
-        Map<String, String> params = new HashMap<String, String>();
-        params.put("collection", request.getTarget().getParameter("collection"));
-        params.put("entry", entryid);
-        return request.urlFor("entry", params);
-    }
-
-    public ResponseContext putItem(RequestContext context) {
-        Abdera abdera = getAbdera(context);
-        AtompubRequestContext request = (AtompubRequestContext) context;
+      }
+    };
+  }
+  
+  private void setEntryDetails(RequestContext request, Entry entry, String id) {
+      entry.setUpdated(DateTime.now());
+      entry.setEdited(entry.getUpdated());
+      entry.getIdElement().setValue(id);
+      entry.addLink(getEntryLink(request, entry.getId().toASCIIString()), "edit");
+  }
+
+  private String getEntryLink(RequestContext request, String entryid) {
+      Map<String, String> params = new HashMap<String, String>();
+      params.put("collection", request.getTarget().getParameter("collection"));
+      params.put("entry", entryid);
+      return request.urlFor(TargetType.TYPE_ENTRY, params);
+  }
+
+  private Function<RequestContext,ResponseContext> putItem() {
+    return new Function<RequestContext,ResponseContext>() {
+      public ResponseContext apply(RequestContext input) {
+        AtompubRequestContext request = (AtompubRequestContext) input;
+        Abdera abdera = request.getAbdera();
         Entry orig_entry = getAbderaEntry(request);
         if (orig_entry != null) {
             try {
@@ -192,29 +221,36 @@ public class SimpleAdapter extends Abstr
         } else {
             return ProviderHelper.notfound(request);
         }
-    }
-
-    private Entry getAbderaEntry(RequestContext request) {
-        try {
-            return getFeedDocument(request).getRoot().getEntry(getResourceName(request));
-        } catch (Exception e) {
-        }
-        return null;
-    }
-
-    public String getResourceName(RequestContext request) {
-        if (request.getTarget().getType() != TargetType.TYPE_ENTRY)
-            return null;
-        String[] segments = request.getUri().toString().split("/");
-        return UrlEncoding.decode(segments[segments.length - 1]);
-    }
-
-    public ResponseContext getCategories(RequestContext request) {
-        return new StreamWriterResponseContext(getAbdera(request)) {
+      }
+    };
+  }
+  
+  private Entry getAbderaEntry(RequestContext request) {
+      try {
+          return getFeedDocument(request).getRoot().getEntry(getResourceName(request));
+      } catch (Exception e) {
+      }
+      return null;
+  }
+
+  public String getResourceName(RequestContext request) {
+      if (request.getTarget().getType() != TargetType.TYPE_ENTRY)
+          return null;
+      String[] segments = request.getUri().toString().split("/");
+      return UrlEncoding.decode(segments[segments.length - 1]);
+  }
+
+  private Function<RequestContext,ResponseContext> getCategories() {
+    return new Function<RequestContext,ResponseContext>() {
+      public ResponseContext apply(RequestContext input) {
+        AtompubRequestContext request = (AtompubRequestContext) input;
+        return new StreamWriterResponseContext(request.getAbdera()) {
             protected void writeTo(StreamWriter sw) throws IOException {
                 sw.startDocument().startCategories(false).writeCategory("foo").writeCategory("bar")
                     .writeCategory("baz").endCategories().endDocument();
             }
         }.setStatus(200).setContentType(Constants.CAT_MEDIA_TYPE);
-    }
+      }
+    };
+  }
 }

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomProvider.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomProvider.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/CustomProvider.java Fri Oct 21 23:47:50 2011
@@ -18,14 +18,14 @@
 package org.apache.abdera2.test.server.custom;
 
 import org.apache.abdera2.common.misc.Chain;
+import org.apache.abdera2.common.misc.Task;
+import org.apache.abdera2.common.protocol.CollectionAdapter;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.BaseRequestContextWrapper;
 import org.apache.abdera2.common.protocol.ResponseContext;
-import org.apache.abdera2.common.protocol.Filter;
 import org.apache.abdera2.common.protocol.RegexTargetResolver;
 import org.apache.abdera2.common.protocol.TargetType;
 import org.apache.abdera2.common.protocol.TemplateManagerTargetBuilder;
-import org.apache.abdera2.protocol.server.AtompubCollectionAdapter;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubWorkspaceProvider;
 import org.apache.abdera2.protocol.server.impl.SimpleWorkspaceInfo;
 
@@ -33,8 +33,9 @@ public class CustomProvider extends Abst
 
     private final SimpleAdapter adapter;
 
-    public CustomProvider() {
-        this.adapter = new SimpleAdapter();
+    @SuppressWarnings("unchecked")
+    public CustomProvider(String href) {
+        this.adapter = new SimpleAdapter(href);
         RegexTargetResolver<RequestContext> resolver = 
           new RegexTargetResolver<RequestContext>()
             .setPattern("/atom(\\?[^#]*)?", TargetType.TYPE_SERVICE)
@@ -53,18 +54,21 @@ public class CustomProvider extends Abst
               .add(TargetType.TYPE_ENTRY, "{target_base}/atom/{collection}/{entry}")
               .get();
         setTargetBuilder(tmb);
-        SimpleWorkspaceInfo workspace = new SimpleWorkspaceInfo();
-        workspace.setTitle("A Simple Workspace");
-        workspace.addCollection(adapter);
-        addWorkspace(workspace);
+        addWorkspace(
+          SimpleWorkspaceInfo
+            .make()
+            .title("A Simple Workspace")
+            .collection(adapter)
+            .get()
+        );
         addFilter(new SimpleFilter());
     }
 
-    public AtompubCollectionAdapter getCollectionAdapter(RequestContext request) {
+    public CollectionAdapter getCollectionAdapter(RequestContext request) {
         return adapter;
     }
 
-    public class SimpleFilter implements Filter {
+    public class SimpleFilter implements Task<RequestContext,ResponseContext> {
         public ResponseContext apply(RequestContext request, Chain<RequestContext,ResponseContext> chain) {
             BaseRequestContextWrapper rcw = new BaseRequestContextWrapper(request);
             rcw.setAttribute("offset", 10);

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java Fri Oct 21 23:47:50 2011
@@ -42,9 +42,24 @@ import org.apache.abdera2.protocol.serve
 import org.apache.abdera2.writer.StreamWriter;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Function;
+
 @SuppressWarnings("unchecked")
 public class SimpleAdapter extends AbstractAtompubCollectionAdapter {
 
+    public SimpleAdapter(String href) {
+      super(href);
+      putHandler(TargetType.TYPE_COLLECTION,"GET",getItemList());
+      putHandler(TargetType.TYPE_COLLECTION,"HEAD",getItemList());
+      putHandler(TargetType.TYPE_COLLECTION,"POST",postItem());
+      putHandler(TargetType.TYPE_ENTRY,"DELETE",deleteItem());
+      putHandler(TargetType.TYPE_ENTRY,"GET",getItem());
+      putHandler(TargetType.TYPE_ENTRY,"HEAD",getItem());
+      putHandler(TargetType.TYPE_ENTRY,"PUT",putItem());
+      putHandler(TargetType.TYPE_CATEGORIES,"GET",getCategories());
+      putHandler(TargetType.TYPE_CATEGORIES,"HEAD",getCategories());
+    }
+  
     @Override
     public String getAuthor(RequestContext request) throws ResponseContextException {
         return "Simple McGee";
@@ -65,10 +80,6 @@ public class SimpleAdapter extends Abstr
         return "A simple feed";
     }
 
-    public ResponseContext extensionRequest(RequestContext request) {
-        return ProviderHelper.notallowed(request, "Method Not Allowed", ProviderHelper.getDefaultMethods(request));
-    }
-
     private Document<Feed> getFeedDocument(RequestContext context) throws ResponseContextException {
         Feed feed = (Feed)context.getAttribute(Scope.SESSION, "feed");
         if (feed == null) {
@@ -79,69 +90,89 @@ public class SimpleAdapter extends Abstr
         return feed.getDocument();
     }
 
-    public ResponseContext getItemList(RequestContext request) {
-        Document<Feed> feed;
-        try {
-            feed = getFeedDocument(request);
-        } catch (ResponseContextException e) {
-            return e.getResponseContext();
-        }
-
-        return AbstractAtompubProvider.returnBase(feed, 200, feed.getRoot().getUpdated()).setEntityTag(AbstractAtompubProvider
-            .calculateEntityTag(feed.getRoot()));
-    }
-
-    public ResponseContext deleteItem(RequestContext request) {
-        Entry entry = getAbderaEntry(request);
-        if (entry != null)
-            entry.discard();
-        return ProviderHelper.nocontent();
-    }
-
-    public ResponseContext getItem(RequestContext request) {
-        Entry entry = (Entry)getAbderaEntry(request);
-        if (entry != null) {
-            Feed feed = entry.getParentElement();
-            entry = (Entry)entry.clone();
-            entry.setSource(feed.getAsSource());
-            Document<Entry> entry_doc = entry.getDocument();
-            return AbstractAtompubProvider.returnBase(entry_doc, 200, entry.getEdited()).setEntityTag(AbstractAtompubProvider
-                .calculateEntityTag(entry));
-        } else {
-            return ProviderHelper.notfound(request);
+    private Function<RequestContext,ResponseContext> getItemList() {
+      return new Function<RequestContext,ResponseContext>() {
+        public ResponseContext apply(RequestContext input) {
+          Document<Feed> feed;
+          try {
+              feed = getFeedDocument(input);
+          } catch (ResponseContextException e) {
+              return e.getResponseContext();
+          }
+          return AbstractAtompubProvider
+            .returnBase(feed, 200, feed.getRoot().getUpdated())
+            .setEntityTag(
+              AbstractAtompubProvider
+                .calculateEntityTag(feed.getRoot()));
+        }
+      };
+    }
+
+    public Function<RequestContext,ResponseContext> deleteItem() {
+      return new Function<RequestContext,ResponseContext>() {
+        public ResponseContext apply(RequestContext input) {
+          Entry entry = getAbderaEntry(input);
+          if (entry != null)
+              entry.discard();
+          return ProviderHelper.nocontent();
+        }
+      };
+    }
+
+    private Function<RequestContext,ResponseContext> getItem() {
+      return new Function<RequestContext,ResponseContext>() {
+        public ResponseContext apply(RequestContext input) {
+          Entry entry = (Entry)getAbderaEntry(input);
+          if (entry != null) {
+              Feed feed = entry.getParentElement();
+              entry = (Entry)entry.clone();
+              entry.setSource(feed.getAsSource());
+              Document<Entry> entry_doc = entry.getDocument();
+              return AbstractAtompubProvider
+                .returnBase(entry_doc, 200, entry.getEdited())
+                .setEntityTag(AbstractAtompubProvider
+                  .calculateEntityTag(entry));
+          } else {
+              return ProviderHelper.notfound(input);
+          }
         }
+      };
     }
     
-    public ResponseContext postItem(RequestContext context) {
-        AtompubRequestContext request = (AtompubRequestContext) context;
-        Abdera abdera = request.getAbdera();
-        try {
-            Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
-            if (entry_doc != null) {
-                Entry entry = entry_doc.getRoot();
-                if (!AbstractAtompubProvider.isValidEntry(entry))
-                    return ProviderHelper.badrequest(request);
-                setEntryDetails(request, entry, abdera.getFactory().newUuidUri());
-                Feed feed = getFeedDocument(request).getRoot();
-                feed.insertEntry(entry);
-                feed.setUpdated(DateTime.now());
-                FOMResponseContext<?> rc =
-                    (FOMResponseContext<?>)AbstractAtompubProvider.returnBase(entry_doc, 201, entry.getEdited());
-                return rc.setLocation(ProviderHelper.resolveBase(request).resolve(entry.getEditLinkResolvedHref())
-                    .toString()).setContentLocation(rc.getLocation().toString()).setEntityTag(AbstractAtompubProvider
-                    .calculateEntityTag(entry));
-            } else {
-                return ProviderHelper.badrequest(request);
-            }
-        } catch (ParseException pe) {
-            return ProviderHelper.notsupported(request);
-        } catch (ClassCastException cce) {
-            return ProviderHelper.notsupported(request);
-        } catch (Exception e) {
-            return ProviderHelper.badrequest(request);
+    private Function<RequestContext,ResponseContext> postItem() {
+      return new Function<RequestContext,ResponseContext>() {
+        public ResponseContext apply(RequestContext input) {
+          AtompubRequestContext request = (AtompubRequestContext) input;
+          Abdera abdera = request.getAbdera();
+          try {
+              Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
+              if (entry_doc != null) {
+                  Entry entry = entry_doc.getRoot();
+                  if (!AbstractAtompubProvider.isValidEntry(entry))
+                      return ProviderHelper.badrequest(request);
+                  setEntryDetails(request, entry, abdera.getFactory().newUuidUri());
+                  Feed feed = getFeedDocument(request).getRoot();
+                  feed.insertEntry(entry);
+                  feed.setUpdated(DateTime.now());
+                  FOMResponseContext<?> rc =
+                      (FOMResponseContext<?>)AbstractAtompubProvider.returnBase(entry_doc, 201, entry.getEdited());
+                  return rc.setLocation(ProviderHelper.resolveBase(request).resolve(entry.getEditLinkResolvedHref())
+                      .toString()).setContentLocation(rc.getLocation().toString()).setEntityTag(AbstractAtompubProvider
+                      .calculateEntityTag(entry));
+              } else {
+                  return ProviderHelper.badrequest(request);
+              }
+          } catch (ParseException pe) {
+              return ProviderHelper.notsupported(request);
+          } catch (ClassCastException cce) {
+              return ProviderHelper.notsupported(request);
+          } catch (Exception e) {
+              return ProviderHelper.badrequest(request);
+          }
         }
+      };
     }
-
+    
     private void setEntryDetails(RequestContext request, Entry entry, String id) {
         entry.setUpdated(DateTime.now());
         entry.setEdited(entry.getUpdated());
@@ -156,40 +187,44 @@ public class SimpleAdapter extends Abstr
         return request.urlFor(TargetType.TYPE_ENTRY, params);
     }
 
-    public ResponseContext putItem(RequestContext context) {
-        AtompubRequestContext request = (AtompubRequestContext) context;
-        Abdera abdera = request.getAbdera();
-        Entry orig_entry = getAbderaEntry(request);
-        if (orig_entry != null) {
-            try {
-                Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
-                if (entry_doc != null) {
-                    Entry entry = entry_doc.getRoot();
-                    if (!entry.getId().equals(orig_entry.getId()))
-                        return ProviderHelper.conflict(request);
-                    if (!AbstractAtompubProvider.isValidEntry(entry))
-                        return ProviderHelper.badrequest(request);
-                    setEntryDetails(request, entry, orig_entry.getId().toString());
-                    orig_entry.discard();
-                    Feed feed = getFeedDocument(request).getRoot();
-                    feed.insertEntry(entry);
-                    feed.setUpdated(DateTime.now());
-                    return ProviderHelper.nocontent();
-                } else {
-                    return ProviderHelper.badrequest(request);
-                }
-            } catch (ParseException pe) {
-                return ProviderHelper.notsupported(request);
-            } catch (ClassCastException cce) {
-                return ProviderHelper.notsupported(request);
-            } catch (Exception e) {
-                return ProviderHelper.badrequest(request);
-            }
-        } else {
-            return ProviderHelper.notfound(request);
+    private Function<RequestContext,ResponseContext> putItem() {
+      return new Function<RequestContext,ResponseContext>() {
+        public ResponseContext apply(RequestContext input) {
+          AtompubRequestContext request = (AtompubRequestContext) input;
+          Abdera abdera = request.getAbdera();
+          Entry orig_entry = getAbderaEntry(request);
+          if (orig_entry != null) {
+              try {
+                  Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
+                  if (entry_doc != null) {
+                      Entry entry = entry_doc.getRoot();
+                      if (!entry.getId().equals(orig_entry.getId()))
+                          return ProviderHelper.conflict(request);
+                      if (!AbstractAtompubProvider.isValidEntry(entry))
+                          return ProviderHelper.badrequest(request);
+                      setEntryDetails(request, entry, orig_entry.getId().toString());
+                      orig_entry.discard();
+                      Feed feed = getFeedDocument(request).getRoot();
+                      feed.insertEntry(entry);
+                      feed.setUpdated(DateTime.now());
+                      return ProviderHelper.nocontent();
+                  } else {
+                      return ProviderHelper.badrequest(request);
+                  }
+              } catch (ParseException pe) {
+                  return ProviderHelper.notsupported(request);
+              } catch (ClassCastException cce) {
+                  return ProviderHelper.notsupported(request);
+              } catch (Exception e) {
+                  return ProviderHelper.badrequest(request);
+              }
+          } else {
+              return ProviderHelper.notfound(request);
+          }
         }
+      };
     }
-
+    
     private Entry getAbderaEntry(RequestContext request) {
         try {
             return getFeedDocument(request).getRoot().getEntry(getResourceName(request));
@@ -205,13 +240,18 @@ public class SimpleAdapter extends Abstr
         return UrlEncoding.decode(segments[segments.length - 1]);
     }
 
-    public ResponseContext getCategories(RequestContext context) {
-      AtompubRequestContext request = (AtompubRequestContext) context;
-        return new StreamWriterResponseContext(request.getAbdera()) {
-            protected void writeTo(StreamWriter sw) throws IOException {
-                sw.startDocument().startCategories(false).writeCategory("foo").writeCategory("bar")
-                    .writeCategory("baz").endCategories().endDocument();
-            }
-        }.setStatus(200).setContentType(Constants.CAT_MEDIA_TYPE);
+    private Function<RequestContext,ResponseContext> getCategories() {
+      return new Function<RequestContext,ResponseContext>() {
+        public ResponseContext apply(RequestContext input) {
+          AtompubRequestContext request = (AtompubRequestContext) input;
+          return new StreamWriterResponseContext(request.getAbdera()) {
+              protected void writeTo(StreamWriter sw) throws IOException {
+                  sw.startDocument().startCategories(false).writeCategory("foo").writeCategory("bar")
+                      .writeCategory("baz").endCategories().endDocument();
+              }
+          }.setStatus(200).setContentType(Constants.CAT_MEDIA_TYPE);
+        }
+      };
     }
+
 }

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java Fri Oct 21 23:47:50 2011
@@ -30,7 +30,6 @@ import org.apache.abdera2.Abdera;
 import org.apache.abdera2.factory.Factory;
 import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.protocol.RequestContext;
-import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.ResponseContextException;
 import org.apache.abdera2.model.Content;
 import org.apache.abdera2.model.Element;
@@ -46,17 +45,14 @@ public class CustomerAdapter extends Abs
     private Map<Integer, Customer> customers = new HashMap<Integer, Customer>();
     private Factory factory = Abdera.getInstance().getFactory();
 
-    public CustomerAdapter() {
+    public CustomerAdapter(String href) {
+      super(href);
     }
     
     public String getId(RequestContext request) {
         return "tag:example.org,2007:feed";
     }
 
-    public <S extends ResponseContext>S getCategories(RequestContext request) {
-        return null;
-    }
-
     @Override
     public Customer postEntry(String title,
                               IRI id,

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapterTest.java Fri Oct 21 23:47:50 2011
@@ -60,15 +60,14 @@ public class CustomerAdapterTest {
 
     private void setupAbdera(String base) throws Exception {
         customerProvider = new DefaultAtompubProvider(base);
-
-        CustomerAdapter ca = new CustomerAdapter();
-        ca.setHref("customers");
-
-        SimpleWorkspaceInfo wi = new SimpleWorkspaceInfo();
-        wi.setTitle("Customer Workspace");
-        wi.addCollection(ca);
-
-        customerProvider.addWorkspace(wi);
+        CustomerAdapter ca = new CustomerAdapter("customers");
+        customerProvider
+          .addWorkspace(
+            SimpleWorkspaceInfo
+              .make()
+              .title("Customer Workspace")
+              .collection(ca)
+              .get());
     }
 
     @Test

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java Fri Oct 21 23:47:50 2011
@@ -7,17 +7,25 @@ import java.util.Map;
 import javax.mail.MessagingException;
 
 import org.apache.abdera2.parser.ParseException;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
 import org.apache.abdera2.protocol.server.multipart.AbstractMultipartCollectionAdapter;
 import org.apache.abdera2.common.Constants;
 import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.EmptyResponseContext;
-import org.apache.abdera2.common.protocol.ProviderHelper;
+import org.apache.abdera2.common.protocol.TargetType;
 
-@SuppressWarnings("unchecked")
-public class MultipartRelatedAdapter extends AbstractMultipartCollectionAdapter {
+import com.google.common.base.Function;
 
+public class MultipartRelatedAdapter 
+  extends AbstractMultipartCollectionAdapter {
+
+    public MultipartRelatedAdapter(String href) {
+      super(href);
+      putHandler(TargetType.TYPE_COLLECTION,"POST",handlePost());
+    }
+  
     @Override
     public String getAuthor(RequestContext request) {
         return "Acme Industries";
@@ -28,42 +36,33 @@ public class MultipartRelatedAdapter ext
         return "tag:example.org,2008:feed";
     }
 
-    public <S extends ResponseContext>S deleteItem(RequestContext request) {
-        return (S)ProviderHelper.notallowed(request);
-    }
-
-    public <S extends ResponseContext>S getItem(RequestContext request) {
-        return (S)ProviderHelper.notallowed(request);
-    }
-
-    public <S extends ResponseContext>S getItemList(RequestContext request) {
-        return (S)ProviderHelper.notallowed(request);
-    }
-
-    public <S extends ResponseContext>S postItem(RequestContext request) {
-        return (S)ProviderHelper.notallowed(request);
-    }
-
-    public <S extends ResponseContext>S putItem(RequestContext request) {
-        return (S)ProviderHelper.notallowed(request);
+    private Function<RequestContext,ResponseContext> handlePost() {
+      return new Function<RequestContext,ResponseContext>() {
+        public ResponseContext apply(RequestContext input) {
+          return AbstractAtompubProvider.IS_ATOM.apply(input) ?
+            NOT_ALLOWED.apply(input) :
+            postMedia().apply(input);
+        }
+      };
     }
-
-    public <S extends ResponseContext>S postMedia(RequestContext request) {
-        try {
-            if (MimeTypeHelper.isMultipart(request.getContentType().toString())) {
-                getMultipartRelatedData(request);
-                // Post object is a wrapper for the media resource and the media link entry.
-                // Once we get it we can save them following the rfc specification.
-            }
-
-            return (S)new EmptyResponseContext(201);
-        } catch (ParseException pe) {
-            return (S)new EmptyResponseContext(415, pe.getLocalizedMessage());
-        } catch (IOException ioe) {
-            return (S)new EmptyResponseContext(500, ioe.getLocalizedMessage());
-        } catch (MessagingException e) {
-            return (S)new EmptyResponseContext(500, e.getLocalizedMessage());
+    
+    public Function<RequestContext,ResponseContext> postMedia() {
+      return new Function<RequestContext,ResponseContext>() {
+        public ResponseContext apply(RequestContext input) {
+          try {
+              if (MimeTypeHelper.isMultipart(input.getContentType().toString())) {
+                  getMultipartRelatedData(input);
+              }
+              return new EmptyResponseContext(201);
+          } catch (ParseException pe) {
+              return new EmptyResponseContext(415, pe.getLocalizedMessage());
+          } catch (IOException ioe) {
+              return new EmptyResponseContext(500, ioe.getLocalizedMessage());
+          } catch (MessagingException e) {
+              return new EmptyResponseContext(500, e.getLocalizedMessage());
+          }
         }
+      };
     }
 
     public String getTitle(RequestContext request) {

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java?rev=1187599&r1=1187598&r2=1187599&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java Fri Oct 21 23:47:50 2011
@@ -10,6 +10,7 @@ import java.util.Map;
 import org.apache.abdera2.Abdera;
 import org.apache.abdera2.factory.Factory;
 import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.protocol.CollectionAdapter;
 import org.apache.abdera2.common.protocol.RequestProcessor;
 import org.apache.abdera2.common.protocol.TargetType;
 import org.apache.abdera2.common.protocol.servlet.AbderaServlet;
@@ -28,6 +29,8 @@ import org.eclipse.jetty.servlet.Servlet
 import org.junit.After;
 import org.junit.Test;
 
+import com.google.common.base.Function;
+
 @SuppressWarnings("serial")
 public class MultipartRelatedTest {
 
@@ -37,20 +40,24 @@ public class MultipartRelatedTest {
             @Override
             protected AtompubProvider createProvider() {
                 DefaultAtompubProvider provider = new DefaultAtompubProvider("/");
-                Map<TargetType,RequestProcessor> map = 
-                  new HashMap<TargetType,RequestProcessor>();
+
+                Map<TargetType,Function<CollectionAdapter,? extends RequestProcessor>> map = 
+                  new HashMap<TargetType,Function<CollectionAdapter,? extends RequestProcessor>>();
                 map.put(TargetType.TYPE_SERVICE, 
-                    new MultipartRelatedServiceRequestProcessor());
+                  RequestProcessor.forClass(
+                    MultipartRelatedServiceRequestProcessor.class, 
+                    provider.getWorkspaceManager()));
                 provider.addRequestProcessors(map);
-
-                MultipartRelatedAdapter ca = new MultipartRelatedAdapter();
-                ca.setHref("media");
-
-                SimpleWorkspaceInfo wi = new SimpleWorkspaceInfo();
-                wi.setTitle("multimedia/related Workspace");
-                wi.addCollection(ca);
-
-                provider.addWorkspace(wi);
+                
+                MultipartRelatedAdapter ca = new MultipartRelatedAdapter("media");
+                
+                provider
+                  .addWorkspace(
+                    SimpleWorkspaceInfo
+                      .make()
+                      .title("multipart/related Workspace")
+                      .collection(ca)
+                      .get());
 
                 provider.init(Abdera.getInstance(), null);
                 return provider;



Mime
View raw message