You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2011/10/29 01:44:37 UTC

svn commit: r1190679 [2/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...

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestTemplateContext.java Fri Oct 28 23:44:35 2011
@@ -10,13 +10,21 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.templates.Context;
 import org.apache.abdera2.common.templates.DelegatingContext;
 
-public class RequestTemplateContext extends DelegatingContext {
+/**
+ * A Template Context implementation based on a RequestContext object.
+ * this allows a URI Template to be expanded using properties and 
+ * attributes from the RequestContext
+ */
+public class RequestTemplateContext 
+  extends DelegatingContext {
 
   private static final long serialVersionUID = 4332356546022014897L;
 
   private final RequestContext request;
 
-  public RequestTemplateContext(RequestContext request, Context subcontext) {
+  public RequestTemplateContext(
+    RequestContext request, 
+    Context subcontext) {
       super(subcontext);
       this.request = request;
   }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RouteManager.java Fri Oct 28 23:44:35 2011
@@ -33,6 +33,7 @@ import org.apache.abdera2.common.templat
 import org.apache.abdera2.common.templates.Route;
 
 import com.google.common.base.Function;
+import com.google.common.base.Supplier;
 
 /**
  * This is a largely experimental implementation of a Target Resolver and Target Builder based on URL patterns similar
@@ -46,98 +47,131 @@ import com.google.common.base.Function;
  * 
  * The RouteManager can be used by Provider implementations as the target resolver and target builder
  */
-public class RouteManager<T,X extends RequestContext> 
+public class RouteManager<T,X extends RequestContext,R> 
   implements Function<X,Target>, 
-             TargetBuilder<T> {
+             TargetBuilder<R> {
 
-    protected class RouteTargetType {
-        protected Route<T> route;
-        protected TargetType targetType;
-
-        RouteTargetType(Route<T> route, TargetType targetType) {
-            this.route = route;
-            this.targetType = targetType;
-        }
-
-        public Route<T> getRoute() {
-            return route;
-        }
-
-        public TargetType getTargetType() {
-            return targetType;
-        }
-    }
-
-    protected List<RouteTargetType> targets = new ArrayList<RouteTargetType>();
-
-    protected Map<T, Route<T>> routes = new HashMap<T, Route<T>>();
-
-    protected Map<Route<T>, CollectionAdapter> route2CA = new HashMap<Route<T>, CollectionAdapter>();
-
-    public RouteManager<T,X> addRoute(Route<T> route) {
-        return addRoute(route, null);
-    }
-
-    public RouteManager<T,X> addRoute(T key, String pattern) {
-        return addRoute(key, pattern, null);
+    public static <T,X extends RequestContext,R>Generator<T,X,R> make() {
+      return new Generator<T,X,R>();
     }
-
-    public RouteManager<T,X> addRoute(Route<T> route, TargetType type) {
+  
+    public static class Generator<T, X extends RequestContext,R> 
+      implements Supplier<RouteManager<T,X,R>> {
+
+      protected final List<RouteTargetType<R>> targets = 
+        new ArrayList<RouteTargetType<R>>();
+      protected final Map<R, Route<R>> routes = 
+        new HashMap<R, Route<R>>();
+      protected final Map<Route<R>, CollectionAdapter> route2CA = 
+        new HashMap<Route<R>, CollectionAdapter>();
+      public Generator<T,X,R> withAll(RouteManager<T,X,R> other) {
+        this.targets.addAll(other.targets);
+        this.routes.putAll(other.routes);
+        this.route2CA.putAll(other.route2CA);
+        return this;
+      }
+      public Generator<T,X,R> with(Route<R>... routes) {
+        for (Route<R> route : routes)
+          with(route, null);
+        return this;
+      }
+      public Generator<T,X,R> with(R key, String pattern) {
+        return with(key, pattern, null);
+      }
+      public Generator<T,X,R> with(
+        Route<R> route, 
+        TargetType type) {
         routes.put(route.getKey(), route);
         if (type != null)
-            targets.add(new RouteTargetType(route, type));
+          targets.add(new RouteTargetType<R>(route, type));
         return this;
-    }
-
-    public RouteManager<T,X> addRoute(T key, String pattern, TargetType type) {
-        return addRoute(new Route<T>(key, pattern), type);
-    }
-
-    public RouteManager<T,X> addRoute(T key, String pattern, TargetType type, CollectionAdapter collectionAdapter) {
-
-        Route<T> route = new Route<T>(key, pattern);
+      }
+      public Generator<T,X,R> with(
+        R key, 
+        String pattern, 
+        TargetType type) {
+        return with(new Route<R>(key, pattern), type);
+      }
+      public Generator<T,X,R> with(
+        R key, 
+        String pattern, 
+        TargetType type, 
+        CollectionAdapter collectionAdapter) {
+        Route<R> route = new Route<R>(key, pattern);
         route2CA.put(route, collectionAdapter);
-        return addRoute(route, type);
+        return with(route, type);
+      }
+      public RouteManager<T, X, R> get() {
+        return new RouteManager<T,X,R>(this);
+      }
+    }
+  
+    protected static class RouteTargetType<T> {
+      protected Route<T> route;
+      protected TargetType targetType;
+      RouteTargetType(Route<T> route, TargetType targetType) {
+        this.route = route;
+        this.targetType = targetType;
+      }
+      public Route<T> getRoute() {
+        return route;
+      }
+      public TargetType getTargetType() {
+        return targetType;
+      }
+    }
+
+    protected final List<RouteTargetType<R>> targets = 
+      new ArrayList<RouteTargetType<R>>();
+    protected final Map<R, Route<R>> routes = 
+      new HashMap<R, Route<R>>();
+    protected final Map<Route<R>, CollectionAdapter> route2CA = 
+      new HashMap<Route<R>, CollectionAdapter>();
+
+    private RouteManager(Generator<T,X,R> gen) {
+      this.targets.addAll(gen.targets);
+      this.routes.putAll(gen.routes);
+      this.route2CA.putAll(gen.route2CA);
     }
-
+    
     public Target apply(X request) {
-        String uri = request.getTargetPath();
-        int idx = uri.indexOf('?');
-        if (idx != -1) {
-            uri = uri.substring(0, idx);
-        }
+      String uri = request.getTargetPath();
+      int idx = uri.indexOf('?');
+      if (idx != -1) {
+          uri = uri.substring(0, idx);
+      }
 
-        RouteTargetType target = get(uri);
-        if (target == null) {
-            target = match(uri);
-        }
+      RouteTargetType<R> target = get(uri);
+      if (target == null) {
+          target = match(uri);
+      }
 
-        if (target != null) {
-            return getTarget(request, target, uri);
-        }
+      if (target != null) {
+          return getTarget(request, target, uri);
+      }
 
-        return null;
+      return null;
     }
 
-    private RouteTargetType get(String uri) {
-        for (RouteTargetType target : targets) {
-            if (target.route.getPattern().equals(uri)) {
-                return target;
-            }
+    private RouteTargetType<R> get(String uri) {
+      for (RouteTargetType<R> target : targets) {
+        if (target.route.getPattern().equals(uri)) {
+          return target;
         }
-        return null;
+      }
+      return null;
     }
 
-    private RouteTargetType match(String uri) {
-        for (RouteTargetType target : targets) {
-            if (target.route.match(uri)) {
-                return target;
-            }
+    private RouteTargetType<R> match(String uri) {
+      for (RouteTargetType<R> target : targets) {
+        if (target.route.match(uri)) {
+          return target;
         }
-        return null;
+      }
+      return null;
     }
 
-    private Target getTarget(RequestContext context, RouteTargetType target, String uri) {
+    private Target getTarget(RequestContext context, RouteTargetType<R> target, String uri) {
         CollectionAdapter ca = route2CA.get(target.route);
         if (ca != null) {
             context.setAttribute(AbstractWorkspaceManager.COLLECTION_ADAPTER_ATTRIBUTE, ca);
@@ -145,13 +179,13 @@ public class RouteManager<T,X extends Re
         return getTarget(context, target.route, uri, target.targetType);
     }
 
-    private Target getTarget(RequestContext context, Route<T> route, String uri, TargetType type) {
+    private Target getTarget(RequestContext context, Route<R> route, String uri, TargetType type) {
         return new RouteTarget(type, context, route, uri);
     }
 
-    public String urlFor(Request context, T key, Object param) {
+    public String urlFor(Request context, R key, Object param) {
         RequestContext rc = (RequestContext) context;
-        Route<T> route = routes.get(key);
+        Route<R> route = routes.get(key);
         return route != null ? rc.getContextPath() + route.expand(getContext(param)) : null;
     }
 
@@ -201,7 +235,10 @@ public class RouteManager<T,X extends Re
         private final Map<String, String> params;
         private final Route<?> route;
 
-        public RouteTarget(TargetType type, RequestContext context, Route<?> route, String uri) {
+        public RouteTarget(
+          TargetType type, 
+          RequestContext context, 
+          Route<?> route, String uri) {
             super(type, context);
             this.route = route;
             this.params = route.parse(uri);

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleSubjectResolver.java Fri Oct 28 23:44:35 2011
@@ -30,7 +30,8 @@ import com.google.common.base.Function;
 public class SimpleSubjectResolver 
   implements Function<Request,Subject> {
 
-    public static final Principal ANONYMOUS = new AnonymousPrincipal();
+    public static final Principal ANONYMOUS = 
+      new AnonymousPrincipal();
 
     public Subject apply(Request request) {
         RequestContext context = (RequestContext)request;

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/SimpleTarget.java Fri Oct 28 23:44:35 2011
@@ -58,7 +58,7 @@ public class SimpleTarget
     }
 
     public String toString() {
-        return getType() + " - " + getIdentity();
+        return String.format("%s - %s",getType(),getIdentity());
     }
 
     public <T> T getMatcher() {

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TransactionalRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TransactionalRequestProcessor.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TransactionalRequestProcessor.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/TransactionalRequestProcessor.java Fri Oct 28 23:44:35 2011
@@ -7,8 +7,7 @@ import org.apache.commons.logging.LogFac
 import com.google.common.base.Predicate;
 
 public abstract class TransactionalRequestProcessor 
-  extends RequestProcessor
-  implements Transactional {
+  extends RequestProcessor {
 
   private final static Log log = 
     LogFactory.getLog(

Added: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/Pushers.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/Pushers.java?rev=1190679&view=auto
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/Pushers.java (added)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/pusher/Pushers.java Fri Oct 28 23:44:35 2011
@@ -0,0 +1,71 @@
+package org.apache.abdera2.common.pusher;
+
+import java.util.concurrent.Future;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.util.concurrent.AbstractFuture;
+
+public class Pushers {
+
+  public static <T>Function<T,Void> pushAsFunction(
+    final Pusher<T> pusher) {
+    return new Function<T,Void>() {
+      public Void apply(T input) {
+        pusher.push(input);
+        return null;
+      }
+    };
+  }
+  
+  public static <T>Function<Iterable<T>,Void> pushAllAsFunction(
+    final Pusher<T> pusher) {
+    return new Function<Iterable<T>,Void>() {
+      public Void apply(Iterable<T> input) {
+        pusher.pushAll(input);
+        return null;
+      }
+    };
+  }
+  
+  /**
+   * Wraps a receiver with a Future that will listen for a single 
+   * item and then unregister the listener.
+   */
+  public static <T>Future<T> receiveAsFuture(Receiver<T> receiver) {
+    return new ReceiverFuture<T>(receiver,null);
+  }
+  
+  /**
+   * Wraps a receiver with a Future that will listen for a single 
+   * item that matches the predicate and then unregister the listener.
+   */
+  public static <T>Future<T> receiveAsFuture(Receiver<T> receiver, Predicate<T> check) {
+    return new ReceiverFuture<T>(receiver,check);
+  }
+  
+  private static class ReceiverFuture<T> 
+    extends AbstractFuture<T>
+    implements Listener<T> {
+    private final Receiver<T> receiver;
+    private final Predicate<T> check;
+    ReceiverFuture(Receiver<T> receiver, Predicate<T> check) {
+      this.receiver = receiver;
+      this.check = check;
+      receiver.startListening(this);
+    }
+    public boolean cancel(boolean mayInterruptIfRunning) {
+      receiver.stopListening(this);
+      return super.cancel(mayInterruptIfRunning);
+    }
+    public void beforeItems() {}
+    public void onItem(T t) {
+      if (check == null || check.apply(t))
+        this.set(t);
+    }
+    public void afterItems() {
+      receiver.stopListening(this);
+      if (!isDone()) this.cancel(true);
+    }
+  }
+}

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

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Entry.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Entry.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Entry.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Entry.java Fri Oct 28 23:44:35 2011
@@ -480,6 +480,15 @@ public interface Entry extends Extensibl
      * @return The newly created atom:link
      * @throws IRISyntaxException if the href is malformed
      */
+    Link addLink(IRI href);
+    
+    /**
+     * Add a link to the entry
+     * 
+     * @param href The IRI of the link
+     * @return The newly created atom:link
+     * @throws IRISyntaxException if the href is malformed
+     */
     Link addLink(String href);
 
     /**
@@ -490,6 +499,16 @@ public interface Entry extends Extensibl
      * @return The newly created atom:link
      * @throws IRISyntaxException if the href is malformed
      */
+    Link addLink(IRI href, String rel);
+    
+    /**
+     * Add a link to the entry
+     * 
+     * @param href The IRI of the link
+     * @param rel The link rel attribute
+     * @return The newly created atom:link
+     * @throws IRISyntaxException if the href is malformed
+     */
     Link addLink(String href, String rel);
 
     /**
@@ -503,6 +522,19 @@ public interface Entry extends Extensibl
      * @return The newly created atom:link
      * @throws IRISyntaxException if the href is malformed
      */
+    Link addLink(IRI href, String rel, String type, String title, String hreflang, long length);
+    
+    /**
+     * Add a link to the entry
+     * 
+     * @param href The IRI of the link
+     * @param rel The link rel attribute
+     * @param type The media type of the link
+     * @param hreflang The language of the target
+     * @param length The length of the resource
+     * @return The newly created atom:link
+     * @throws IRISyntaxException if the href is malformed
+     */
     Link addLink(String href, String rel, String type, String title, String hreflang, long length);
 
     /**

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Source.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Source.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Source.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/model/Source.java Fri Oct 28 23:44:35 2011
@@ -370,6 +370,39 @@ public interface Source extends Extensib
     Link addLink(String href, String rel, String type, String title, String hreflang, long length);
 
     /**
+     * Adds an individual link element
+     * 
+     * @param href The href IRI of the link
+     * @return The newly created atom:link
+     * @throws IRISyntaxException if the href is malformed
+     */
+    Link addLink(IRI href);
+
+    /**
+     * Adds an individual link element
+     * 
+     * @param href The href IRI of the link
+     * @param rel The link rel attribute
+     * @return The newly created atom:link
+     * @throws IRISyntaxException if the href is malformed
+     */
+    Link addLink(IRI href, String rel);
+
+    /**
+     * Adds an individual link element
+     * 
+     * @param href The href IRI of the link
+     * @param rel The link rel attribute
+     * @param type The link type attribute
+     * @param hreflang The link hreflang attribute
+     * @param length The length attribute
+     * @return The newly created atom:link
+     * @throws IRISyntaxException if the href is malformed
+     */
+    Link addLink(IRI href, String rel, String type, String title, String hreflang, long length);
+
+    
+    /**
      * RFC4287: The "atom:logo" element's content is an IRI reference [RFC3987] that identifies an image that provides
      * visual identification for a feed. The image SHOULD have an aspect ratio of 2 (horizontal) to 1 (vertical).
      * 

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java Fri Oct 28 23:44:35 2011
@@ -55,6 +55,8 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 
+import static com.google.common.base.Preconditions.*;
+
 @SuppressWarnings({"deprecation","rawtypes"})
 public class FOMEntry extends FOMExtensibleElement implements Entry {
 
@@ -1009,4 +1011,20 @@ public class FOMEntry extends FOMExtensi
     public DateTime setEditedNow() {
       return setEdited(org.joda.time.DateTime.now());
     }
+
+    public Link addLink(IRI href) {
+      checkNotNull(href);
+      return addLink(href.toString());
+    }
+
+    public Link addLink(IRI href, String rel) {
+      checkNotNull(href);
+      return addLink(href.toString(),rel);
+    }
+
+    public Link addLink(IRI href, String rel, String type, String title,
+        String hreflang, long length) {
+      checkNotNull(href);
+      return addLink(href.toString(),rel,type,title,hreflang,length);
+    }
 }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMSource.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMSource.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMSource.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMSource.java Fri Oct 28 23:44:35 2011
@@ -17,6 +17,8 @@
  */
 package org.apache.abdera2.parser.axiom;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
@@ -661,4 +663,19 @@ public class FOMSource extends FOMExtens
       return setUpdated(org.joda.time.DateTime.now());
     }
 
+    public Link addLink(IRI href) {
+      checkNotNull(href);
+      return addLink(href.toString());
+    }
+
+    public Link addLink(IRI href, String rel) {
+      checkNotNull(href);
+      return addLink(href.toString(),rel);
+    }
+
+    public Link addLink(IRI href, String rel, String type, String title,
+        String hreflang, long length) {
+      checkNotNull(href);
+      return addLink(href.toString(),rel,type,title,hreflang,length);
+    }
 }

Added: abdera/abdera2/core/src/main/java/org/apache/abdera2/util/MorePredicates.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/util/MorePredicates.java?rev=1190679&view=auto
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/util/MorePredicates.java (added)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/util/MorePredicates.java Fri Oct 28 23:44:35 2011
@@ -0,0 +1,91 @@
+package org.apache.abdera2.util;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera2.common.Constants;
+import org.apache.abdera2.common.Localizer;
+import org.apache.abdera2.common.iri.IRI;
+import org.apache.abdera2.common.protocol.ProviderHelper;
+import org.apache.abdera2.model.Content;
+import org.apache.abdera2.model.Element;
+import org.apache.abdera2.model.Entry;
+import org.apache.abdera2.model.ExtensibleElement;
+
+import com.google.common.base.Predicate;
+
+public class MorePredicates {
+
+  public static final Predicate<IRI> VALID_ATOM_ID = 
+    new Predicate<IRI>() {
+      public boolean apply(IRI input) {
+        return input != null && 
+               input.toString().trim().length() > 0 &&
+               input.isAbsolute();
+      }
+  };
+  
+  private static boolean is_media(Content content) {
+    return content.getSrc() != null || 
+           content.getContentType() == Content.Type.MEDIA;
+  }
+  
+  /**
+   * Check to see if the entry is minimally valid according to RFC4287. This is not a complete check. It just verifies
+   * that the appropriate elements are present and that their values can be accessed.
+   */
+  public static final Predicate<Entry> VALID_ENTRY = 
+    new Predicate<Entry>() {
+      public boolean apply(Entry entry) {
+        try {
+          if (!VALID_ATOM_ID.apply(entry.getId()))
+              return false;
+          if (entry.getTitle() == null)
+              return false;
+          if (entry.getUpdated() == null)
+              return false;
+          if (entry.getAuthorInherited() == null)
+              return false;
+          Content content = entry.getContentElement();
+          if (content == null)
+            if (entry.getAlternateLink() == null)
+              return false;
+          else
+            if (is_media(content) && !entry.has(Constants.SUMMARY))
+              return false;
+        } catch (Exception e) {
+          ProviderHelper.log.debug(Localizer.sprintf("CHECKING.VALID.ENTRY", false));
+          return false;
+        }
+        ProviderHelper.log.debug(Localizer.sprintf("CHECKING.VALID.ENTRY", true));
+        return true;
+      }
+  }; 
+  
+  public static Predicate<Element> checkElementNamespaces(
+    final Set<String> ignore) {
+    return new Predicate<Element>() {
+      public boolean apply(Element element) {
+        List<QName> attrs = 
+          element.getExtensionAttributes();
+        for (QName qname : attrs)
+          if (!ignore.contains(qname.getNamespaceURI()))
+            return false;
+        if (element instanceof ExtensibleElement) {
+          ExtensibleElement ext = (ExtensibleElement)element;
+          for (Element el : ext.getExtensions()) {
+            QName qname = el.getQName();
+            String ns = qname.getNamespaceURI();
+            if (!ignore.contains(ns))
+              return false;
+            if (!apply(el))
+              return false;
+          }
+        }
+        return true;
+      }
+    };
+  }
+}

Propchange: abdera/abdera2/core/src/main/java/org/apache/abdera2/util/MorePredicates.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PusherExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PusherExample.java?rev=1190679&view=auto
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PusherExample.java (added)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PusherExample.java Fri Oct 28 23:44:35 2011
@@ -0,0 +1,44 @@
+package org.apache.abdera2.examples.simple;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadPoolExecutor;
+import org.apache.abdera2.common.pusher.ChannelManager;
+import org.apache.abdera2.common.pusher.Listener;
+import org.apache.abdera2.common.pusher.Pusher;
+import org.apache.abdera2.common.pusher.Receiver;
+import org.apache.abdera2.common.pusher.SimpleChannelManager;
+
+public class PusherExample {
+  
+    public static void main(String... args) throws Exception {
+     
+      final ChannelManager cm = new SimpleChannelManager();
+      ThreadPoolExecutor exec = (ThreadPoolExecutor) Executors.newCachedThreadPool();
+      final CountDownLatch latch = new CountDownLatch(3);
+      exec.execute(
+        new Runnable() {
+          public void run() {
+            Receiver<String> r = cm.getReceiver("foo");
+            r.startListening(
+              new Listener<String>() {
+                public void beforeItems() {}
+                public void onItem(String t) {
+                  latch.countDown();
+                }
+                public void afterItems() {}
+              }
+            );
+          }
+        }
+      );
+      Pusher<String> pusher = cm.getPusher("foo");
+      pusher.push("a");
+      pusher.push("b");
+      pusher.push("c");
+      latch.await();
+      cm.shutdown();
+      exec.shutdown();
+    }
+  
+}

Propchange: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/simple/PusherExample.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/xsltxpath/XPathExample.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/xsltxpath/XPathExample.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/xsltxpath/XPathExample.java (original)
+++ abdera/abdera2/examples/src/main/java/org/apache/abdera2/examples/xsltxpath/XPathExample.java Fri Oct 28 23:44:35 2011
@@ -45,7 +45,7 @@ public class XPathExample {
         System.out.println(xpath.selectSingleNode("/a:feed", feed));
         System.out.println(xpath.selectSingleNode("..", feed.getTitleElement()));
         System.out.println(xpath.selectSingleNode("ancestor::*", feed.getEntries().get(0)));
-        System.out.println(xpath.valueOf("concat('The feed is is ',/a:feed/a:id)", feed)); // "The feed is is urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"
+        System.out.println(xpath.valueOf("concat('The feed id is ',/a:feed/a:id)", feed)); // "The feed id is urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"
 
     }
 

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssFeed.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssFeed.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssFeed.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssFeed.java Fri Oct 28 23:44:35 2011
@@ -583,5 +583,16 @@ public class RssFeed extends ExtensibleE
     public DateTime setUpdatedNow() {
       throw new UnsupportedOperationException("Modifications are not allowed");
     }
+    public Link addLink(IRI href) {
+      throw new UnsupportedOperationException("Modifications are not allowed");
+    }
 
+    public Link addLink(IRI href, String rel) {
+      throw new UnsupportedOperationException("Modifications are not allowed");
+    }
+
+    public Link addLink(IRI href, String rel, String type, String title,
+        String hreflang, long length) {
+      throw new UnsupportedOperationException("Modifications are not allowed");
+    }
 }

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssItem.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssItem.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssItem.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssItem.java Fri Oct 28 23:44:35 2011
@@ -704,4 +704,17 @@ public class RssItem extends ExtensibleE
     public DateTime setEditedNow() {
       throw new UnsupportedOperationException("Modifications are not allowed");
     }
+
+    public Link addLink(IRI href) {
+      throw new UnsupportedOperationException("Modifications are not allowed");
+    }
+
+    public Link addLink(IRI href, String rel) {
+      throw new UnsupportedOperationException("Modifications are not allowed");
+    }
+
+    public Link addLink(IRI href, String rel, String type, String title,
+        String hreflang, long length) {
+      throw new UnsupportedOperationException("Modifications are not allowed");
+    }
 }

Modified: abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssSource.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssSource.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssSource.java (original)
+++ abdera/abdera2/ext/src/main/java/org/apache/abdera2/ext/rss/RssSource.java Fri Oct 28 23:44:35 2011
@@ -406,4 +406,16 @@ public class RssSource extends Extensibl
       throw new UnsupportedOperationException("Modifications are not allowed");
     }
 
+    public Link addLink(IRI href) {
+      throw new UnsupportedOperationException("Modifications are not allowed");
+    }
+
+    public Link addLink(IRI href, String rel) {
+      throw new UnsupportedOperationException("Modifications are not allowed");
+    }
+
+    public Link addLink(IRI href, String rel, String type, String title,
+        String hreflang, long length) {
+      throw new UnsupportedOperationException("Modifications are not allowed");
+    }
 }

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/StreamWriterResponseContext.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/StreamWriterResponseContext.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/StreamWriterResponseContext.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/StreamWriterResponseContext.java Fri Oct 28 23:44:35 2011
@@ -119,11 +119,11 @@ public abstract class StreamWriterRespon
       throw new UnsupportedOperationException();
     }
 
-  public void writeTo(OutputStream out, org.apache.abdera2.writer.Writer writer) throws IOException {
-  throw new UnsupportedOperationException();
-}
+    public void writeTo(OutputStream out, org.apache.abdera2.writer.Writer writer) throws IOException {
+      throw new UnsupportedOperationException();
+    }
 
-public void writeTo(Writer javaWriter, org.apache.abdera2.writer.Writer abderaWriter) throws IOException {
-  throw new UnsupportedOperationException();
-}
+    public void writeTo(Writer javaWriter, org.apache.abdera2.writer.Writer abderaWriter) throws IOException {
+      throw new UnsupportedOperationException();
+    }
 }

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubCollectionAdapter.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubCollectionAdapter.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubCollectionAdapter.java Fri Oct 28 23:44:35 2011
@@ -36,7 +36,6 @@ import org.apache.abdera2.parser.Parser;
 import org.apache.abdera2.protocol.server.context.FOMResponseContext;
 import org.apache.abdera2.protocol.server.model.AtompubCategoriesInfo;
 import org.apache.abdera2.protocol.server.model.AtompubCollectionInfo;
-import org.joda.time.DateTime;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -114,7 +113,7 @@ public abstract class AbstractAtompubCol
         feed.addLink("");
         feed.addLink("", "self");
         feed.addAuthor(getAuthor(request));
-        feed.setUpdated(DateTime.now());
+        feed.setUpdatedNow();
         return feed;
     }
 

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubProvider.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubProvider.java Fri Oct 28 23:44:35 2011
@@ -22,7 +22,6 @@ import java.util.List;
 import java.util.Map;
 
 import javax.activation.MimeType;
-import javax.xml.namespace.QName;
 
 import org.apache.abdera2.Abdera;
 import org.apache.abdera2.common.Constants;
@@ -31,17 +30,14 @@ import org.apache.abdera2.common.date.Da
 import org.apache.abdera2.common.http.EntityTag;
 import org.apache.abdera2.common.http.QualityHelper;
 import org.apache.abdera2.common.http.QualityHelper.QToken;
-import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.common.misc.ExceptionHelper;
-import org.apache.abdera2.common.protocol.AbstractResponseContext;
-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.MediaRequestProcessor;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.RequestContext.Scope;
-import org.apache.abdera2.common.protocol.RequestProcessor;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.Provider;
 import org.apache.abdera2.common.protocol.ProviderHelper;
@@ -49,11 +45,9 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.WorkspaceInfo;
 import org.apache.abdera2.common.protocol.WorkspaceManager;
 import org.apache.abdera2.model.Base;
-import org.apache.abdera2.model.Content;
 import org.apache.abdera2.model.Document;
 import org.apache.abdera2.model.Element;
 import org.apache.abdera2.model.Entry;
-import org.apache.abdera2.model.ExtensibleElement;
 import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.model.Link;
 import org.apache.abdera2.model.Service;
@@ -82,7 +76,7 @@ import com.google.common.base.Predicate;
  * basic request routing logic.
  */
 public abstract class AbstractAtompubProvider 
-  extends BaseProvider
+  extends AbstractProvider
   implements AtompubProvider {
 
     private final static Log log = LogFactory.getLog(AbstractAtompubProvider.class);
@@ -100,32 +94,27 @@ public abstract class AbstractAtompubPro
     protected AbstractAtompubProvider(
       WorkspaceManager workspaceManager) {
       this.workspaceManager = workspaceManager;
-        this.requestProcessors.put(
-          TargetType.TYPE_SERVICE, 
-          RequestProcessor.forClass(
-            ServiceRequestProcessor.class, 
-            workspaceManager));
-        this.requestProcessors.put(
-          TargetType.TYPE_CATEGORIES, 
-          RequestProcessor.forClass(
-            CategoriesRequestProcessor.class,
-            workspaceManager));
-        this.requestProcessors.put(
-          TargetType.TYPE_COLLECTION, 
-          RequestProcessor.forClass(
-            CollectionRequestProcessor.class,
-            workspaceManager,
-            ProviderHelper.isAtom()));
-        this.requestProcessors.put(
-          TargetType.TYPE_ENTRY, 
-          RequestProcessor.forClass(
-            EntryRequestProcessor.class,
-            workspaceManager));
-        this.requestProcessors.put(
-          TargetType.TYPE_MEDIA, 
-          RequestProcessor.forClass(
-            MediaRequestProcessor.class, 
-            workspaceManager));
+      addRequestProcessor(
+        TargetType.TYPE_SERVICE, 
+        ServiceRequestProcessor.class, 
+        workspaceManager);
+      addRequestProcessor(
+        TargetType.TYPE_CATEGORIES, 
+        CategoriesRequestProcessor.class,
+        workspaceManager);
+      addRequestProcessor(
+        TargetType.TYPE_COLLECTION, 
+        CollectionRequestProcessor.class,
+        ProviderHelper.isAtom(),        
+        workspaceManager);
+      addRequestProcessor(
+        TargetType.TYPE_ENTRY,
+        EntryRequestProcessor.class,
+        workspaceManager);
+      addRequestProcessor(
+        TargetType.TYPE_MEDIA, 
+        MediaRequestProcessor.class, 
+        workspaceManager);
     }
 
     public void init(Map<String, Object> properties) {
@@ -172,76 +161,17 @@ public abstract class AbstractAtompubPro
         final int code, 
         final String message,
         final Throwable t) {
-        AbstractResponseContext rc = new StreamWriterResponseContext(abdera) {
-          @Override
-          protected void writeTo(StreamWriter sw) throws IOException {
+        return
+          new StreamWriterResponseContext(abdera) {
+            protected void writeTo(StreamWriter sw) throws IOException {
               Error.create(sw, code, message, t);
+            }
           }
-        };
-        rc.setStatus(code);
-        rc.setStatusText(message);
-        return rc;
+          .setStatus(code)
+          .setStatusText(message);
       }
 
     /**
-     * Check to see if the entry is minimally valid according to RFC4287. This is not a complete check. It just verifies
-     * that the appropriate elements are present and that their values can be accessed.
-     */
-    public static boolean isValidEntry(Entry entry) {
-        try {
-            IRI id = entry.getId();
-            if (id == null || id.toString().trim().length() == 0 || !id.isAbsolute())
-                return false;
-            if (entry.getTitle() == null)
-                return false;
-            if (entry.getUpdated() == null)
-                return false;
-            if (entry.getAuthor() == null && (entry.getSource() != null && entry.getSource().getAuthor() == null))
-                return false;
-            Content content = entry.getContentElement();
-            if (content == null) {
-                if (entry.getAlternateLink() == null)
-                    return false;
-            } else {
-                if ((content.getSrc() != null || content.getContentType() == Content.Type.MEDIA) && entry
-                    .getSummaryElement() == null) {
-                    ProviderHelper.log.debug(Localizer.sprintf("CHECKING.VALID.ENTRY", false));
-                    return false;
-                }
-            }
-        } catch (Exception e) {
-            ProviderHelper.log.debug(Localizer.sprintf("CHECKING.VALID.ENTRY", false));
-            return false;
-        }
-        ProviderHelper.log.debug(Localizer.sprintf("CHECKING.VALID.ENTRY", true));
-        return true;
-    }
-
-    /**
-     * Return false if the element contains any extension elements that are not supported
-     */
-    public static boolean checkElementNamespaces(Element element, List<String> ignore) {
-        List<QName> attrs = element.getExtensionAttributes();
-        for (QName qname : attrs) {
-            String ns = qname.getNamespaceURI();
-            if (!ignore.contains(ns))
-                return false;
-        }
-        if (element instanceof ExtensibleElement) {
-            ExtensibleElement ext = (ExtensibleElement)element;
-            for (Element el : ext.getExtensions()) {
-                QName qname = el.getQName();
-                String ns = qname.getNamespaceURI();
-                if (!ignore.contains(ns))
-                    return false;
-                if (!checkElementNamespaces(el, ignore))
-                    return false;
-            }
-        }
-        return true;
-    }
-
-    /**
      * Returns an appropriate NamedWriter instance given an appropriately formatted HTTP Accept header. The header will
      * be parsed and sorted according to it's q parameter values. The first named writer capable of supporting the
      * specified type, in order of q-value preference, will be returned. The results on this are not always predictable.
@@ -250,16 +180,16 @@ public abstract class AbstractAtompubPro
      * It's always best to be very specific in the Accept headers.
      */
     public static Writer getAcceptableNamedWriter(Abdera abdera, String accept_header) {
-        QToken[] sorted_accepts = QualityHelper.orderByQ(accept_header);
-        WriterFactory factory = abdera.getWriterFactory();
-        if (factory == null)
-            return null;
-        for (QToken accept : sorted_accepts) {
-            Writer writer = factory.getWriterByMediaType(accept.token());
-            if (writer != null)
-                return writer;
-        }
-        return null;
+      QToken[] sorted_accepts = QualityHelper.orderByQ(accept_header);
+      WriterFactory factory = abdera.getWriterFactory();
+      if (factory == null)
+          return null;
+      for (QToken accept : sorted_accepts) {
+          Writer writer = factory.getWriterByMediaType(accept.token());
+          if (writer != null)
+              return writer;
+      }
+      return null;
     }
 
     public static Writer getNamedWriter(Abdera abdera, String mediatype) {
@@ -274,9 +204,13 @@ public abstract class AbstractAtompubPro
         String id = null;
         String modified = null;
         if (base instanceof Entry) {
-            Entry entry = (Entry)base;
-            id = entry.getId().toString();
-            modified = DateTimes.format(entry.getEdited() != null ? entry.getEdited() : entry.getUpdated());
+          Entry entry = (Entry)base;
+          id = entry.getId().toString();
+          modified = 
+            DateTimes.format(
+              entry.getEdited() != null ? 
+                entry.getEdited() : 
+                entry.getUpdated());
         } else if (base instanceof Feed) {
             Feed feed = (Feed)base;
             id = feed.getId().toString();

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubWorkspaceProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubWorkspaceProvider.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubWorkspaceProvider.java Fri Oct 28 23:44:35 2011
@@ -25,48 +25,42 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.EntryRequestProcessor;
 import org.apache.abdera2.common.protocol.MediaRequestProcessor;
 import org.apache.abdera2.common.protocol.ProviderHelper;
-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;
 import org.apache.abdera2.protocol.server.AtompubProvider;
-import org.apache.abdera2.protocol.server.model.AtompubWorkspaceManager;
 import org.apache.abdera2.protocol.server.processors.CategoriesRequestProcessor;
 import org.apache.abdera2.protocol.server.processors.ServiceRequestProcessor;
 
 public abstract class AbstractAtompubWorkspaceProvider 
   extends AbstractWorkspaceProvider
   implements AtompubProvider, 
-             AtompubWorkspaceManager {
+             WorkspaceManager {
 
  protected Abdera abdera;
   
   protected AbstractAtompubWorkspaceProvider() {
-    this.requestProcessors.put(
+    addRequestProcessor(
       TargetType.TYPE_SERVICE, 
-      RequestProcessor.forClass(
-        ServiceRequestProcessor.class,
-        this));
-    this.requestProcessors.put(
+      ServiceRequestProcessor.class,
+      this);
+    addRequestProcessor(
       TargetType.TYPE_CATEGORIES, 
-      RequestProcessor.forClass(
-          CategoriesRequestProcessor.class, 
-        this));
-    this.requestProcessors.put(
+      CategoriesRequestProcessor.class, 
+      this);
+    addRequestProcessor(
       TargetType.TYPE_COLLECTION,
-      RequestProcessor.forClass(
-        CollectionRequestProcessor.class,
-        this,
-        ProviderHelper.isAtom()));
-    this.requestProcessors.put(
+      CollectionRequestProcessor.class,
+      ProviderHelper.isAtom(),
+      this);
+    addRequestProcessor(
       TargetType.TYPE_ENTRY, 
-      RequestProcessor.forClass(
-        EntryRequestProcessor.class,
-        this));
-    this.requestProcessors.put(
+      EntryRequestProcessor.class,
+      this);
+    addRequestProcessor(
       TargetType.TYPE_MEDIA, 
-      RequestProcessor.forClass(
-        MediaRequestProcessor.class,
-        this));
+      MediaRequestProcessor.class,
+      this);
   }
   
   public void init(Map<String, Object> properties) {

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractEntityCollectionAdapter.java Fri Oct 28 23:44:35 2011
@@ -35,6 +35,7 @@ import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.model.Person;
 import org.apache.abdera2.model.Text;
 import org.apache.abdera2.parser.ParseException;
+import org.apache.abdera2.util.MorePredicates;
 import org.apache.abdera2.common.http.EntityTag;
 import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.common.protocol.RequestContext;
@@ -493,7 +494,7 @@ public abstract class AbstractEntityColl
                     if (!entry.getId().equals(orig_entry.getId()))
                         return new EmptyResponseContext(409);
 
-                    if (!AbstractAtompubProvider.isValidEntry(entry))
+                    if (!MorePredicates.VALID_ENTRY.apply(entry))
                         return new EmptyResponseContext(400);
 
                     putEntry(entryObj, entry.getTitle(), DateTime.now(), entry.getAuthors(), entry.getSummary(), entry
@@ -651,7 +652,7 @@ public abstract class AbstractEntityColl
         try {
             Entry entry = getEntryFromRequest(request);
             if (entry != null) {
-                if (!AbstractAtompubProvider.isValidEntry(entry))
+                if (!MorePredicates.VALID_ENTRY.apply(entry))
                     return new EmptyResponseContext(400);
 
                 entry.setUpdated(DateTime.now());

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/DefaultAtompubProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/DefaultAtompubProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/DefaultAtompubProvider.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/DefaultAtompubProvider.java Fri Oct 28 23:44:35 2011
@@ -43,23 +43,23 @@ public class DefaultAtompubProvider 
     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 DefaultAtompubProvider() {
         this("/");
     }
 
-    @SuppressWarnings({ "unchecked", "rawtypes" })
     public DefaultAtompubProvider(String base) {
       super(new DefaultWorkspaceManager());
       if (base == null)
         base = "/";
       routeManager =
-          new RouteManager()
-            .addRoute("service", base, TargetType.TYPE_SERVICE)
-            .addRoute("feed", base + ":collection", TargetType.TYPE_COLLECTION)
-            .addRoute("entry", base + ":collection/:entry", TargetType.TYPE_ENTRY)
-            .addRoute("categories", base + ":collection/:entry;categories", TargetType.TYPE_CATEGORIES);
+        RouteManager.<TargetType,RequestContext,String>make()
+          .with("service", base, TargetType.TYPE_SERVICE)
+          .with("feed", base + ":collection", TargetType.TYPE_COLLECTION)
+          .with("entry", base + ":collection/:entry", TargetType.TYPE_ENTRY)
+          .with("categories", base + ":collection/:entry;categories", TargetType.TYPE_CATEGORIES)
+          .get();
       targetBuilder = routeManager;
       targetResolver = routeManager;
     }
@@ -115,9 +115,8 @@ public class DefaultAtompubProvider 
     }
 
     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/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java Fri Oct 28 23:44:35 2011
@@ -41,23 +41,26 @@ import org.apache.abdera2.protocol.serve
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
 import org.apache.abdera2.common.Constants;
 import org.apache.abdera2.common.io.MultipartInputStream;
-import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 import org.apache.abdera2.common.protocol.AbstractCollectionAdapter;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.commons.codec.binary.Base64;
+import static org.apache.abdera2.common.mediatype.MimeTypeHelper.*;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 import com.google.common.collect.Iterables;
 
+import static org.apache.abdera2.common.misc.ExceptionHelper.*;
+import static com.google.common.base.Preconditions.*;
+
 @SuppressWarnings("unchecked")
 public abstract class AbstractMultipartCollectionAdapter 
   extends AbstractAtompubCollectionAdapter 
   implements MultipartRelatedCollectionInfo {
 
     public AbstractMultipartCollectionAdapter(String href) {
-    super(href);
-  }
+      super(href);
+    }
 
     private static final String CONTENT_TYPE_HEADER = "content-type";
     private static final String CONTENT_ID_HEADER = "content-id";
@@ -74,8 +77,8 @@ public abstract class AbstractMultipartC
         public boolean apply(RequestContext input) {
           MimeType mt = input.getContentType();
           if (mt == null) return false;
-          return MimeTypeHelper.isMultipart(mt.toString()) ||
-                 MimeTypeHelper.isAtom(mt.toString());
+          return isMultipart(mt.toString()) ||
+                 isAtom(mt.toString());
         }
       });
     }
@@ -85,166 +88,183 @@ public abstract class AbstractMultipartC
         return Iterables.unmodifiableIterable(acceptKeys);
     }
 
-    protected MultipartRelatedPost getMultipartRelatedData(RequestContext request) throws IOException, ParseException,
-        MessagingException {
-
-        MultipartInputStream multipart = getMultipartStream(request);
-        multipart.skipBoundary();
-
-        String start = request.getContentType().getParameter(START_PARAM);
-
-        Document<Entry> entry = null;
-        Map<String, String> entryHeaders = new HashMap<String, String>();
-        InputStream data = null;
-        Map<String, String> dataHeaders = new HashMap<String, String>();
-
-        Map<String, String> headers = getHeaders(multipart);
-
+    protected MultipartRelatedPost getMultipartRelatedData(
+      RequestContext request) 
+        throws IOException, 
+               ParseException,
+               MessagingException {
+      MultipartInputStream multipart = getMultipartStream(request);
+      multipart.skipBoundary();
+      String start = request.getContentType().getParameter(START_PARAM);
+      Document<Entry> entry = null;
+      Map<String, String> entryHeaders = new HashMap<String, String>();
+      InputStream data = null;
+      Map<String, String> dataHeaders = new HashMap<String, String>();
+      Map<String, String> headers = getHeaders(multipart);
         // check if the first boundary is the media link entry
-        if (start == null || start.length() == 0
-            || (headers.containsKey(CONTENT_ID_HEADER) && start.equals(headers.get(CONTENT_ID_HEADER)))
-            || (headers.containsKey(CONTENT_TYPE_HEADER) && MimeTypeHelper.isAtom(headers.get(CONTENT_TYPE_HEADER)))) {
-            entry = getEntry(multipart, request);
-            entryHeaders.putAll(headers);
-        } else {
-            data = getDataInputStream(multipart);
-            dataHeaders.putAll(headers);
-        }
-
-        multipart.skipBoundary();
-
-        headers = getHeaders(multipart);
-
-        if (start != null && (headers.containsKey(CONTENT_ID_HEADER) && start.equals(headers.get(CONTENT_ID_HEADER)))
-            && (headers.containsKey(CONTENT_TYPE_HEADER) && MimeTypeHelper.isAtom(headers.get(CONTENT_TYPE_HEADER)))) {
-            entry = getEntry(multipart, request);
-            entryHeaders.putAll(headers);
-        } else {
-            data = getDataInputStream(multipart);
-            dataHeaders.putAll(headers);
-        }
-
-        checkMultipartContent(entry, dataHeaders, request);
-
-        return new MultipartRelatedPost(entry, data, entryHeaders, dataHeaders);
-    }
-
-    private MultipartInputStream getMultipartStream(RequestContext request) throws IOException, ParseException,
-        IllegalArgumentException {
-        String boundary = request.getContentType().getParameter(BOUNDARY_PARAM);
-
-        if (boundary == null) {
-            throw new IllegalArgumentException("multipart/related stream invalid, boundary parameter is missing.");
-        }
-
-        boundary = "--" + boundary;
-
-        String type = request.getContentType().getParameter(TYPE_PARAM);
-        if (!(type != null && MimeTypeHelper.isAtom(type))) {
-            throw new ParseException(
-                                     "multipart/related stream invalid, type parameter should be " + Constants.ATOM_MEDIA_TYPE);
-        }
-
-        PushbackInputStream pushBackInput = new PushbackInputStream(request.getInputStream(), 2);
-        pushBackInput.unread("\r\n".getBytes());
-
-        return new MultipartInputStream(pushBackInput, boundary.getBytes());
-    }
-
-    private void checkMultipartContent(Document<Entry> entry, Map<String, String> dataHeaders, RequestContext request)
+      if (start == null || start.length() == 0 || 
+         (headers.containsKey(CONTENT_ID_HEADER) && 
+          start.equals(headers.get(CONTENT_ID_HEADER))) || 
+         (headers.containsKey(CONTENT_TYPE_HEADER) && 
+          isAtom(headers.get(CONTENT_TYPE_HEADER)))) {
+        entry = getEntry(multipart, request);
+        entryHeaders.putAll(headers);
+      } else {
+        data = getDataInputStream(multipart);
+        dataHeaders.putAll(headers);
+      }
+      multipart.skipBoundary();
+      headers = getHeaders(multipart);
+
+      if (start != null && 
+          (headers.containsKey(CONTENT_ID_HEADER) && 
+           start.equals(headers.get(CONTENT_ID_HEADER))) && 
+          (headers.containsKey(CONTENT_TYPE_HEADER) && 
+           isAtom(headers.get(CONTENT_TYPE_HEADER)))) {
+        entry = getEntry(multipart, request);
+        entryHeaders.putAll(headers);
+      } else {
+        data = getDataInputStream(multipart);
+        dataHeaders.putAll(headers);
+      }
+      checkMultipartContent(entry, dataHeaders, request);
+      return new MultipartRelatedPost(
+        entry, 
+        data, 
+        entryHeaders, 
+        dataHeaders);
+    }
+
+    private MultipartInputStream getMultipartStream(
+      RequestContext request) 
+        throws IOException, ParseException {
+      String boundary = request.getContentType().getParameter(BOUNDARY_PARAM);
+      checked(
+        boundary != null,
+        ParseException.class,
+        "multipart/related stream invalid, boundary parameter is missing.");
+      boundary = "--" + boundary;
+      String type = request.getContentType().getParameter(TYPE_PARAM);     
+      checked(
+        type != null && isAtom(type),
+        ParseException.class,
+        "multipart/related stream invalid, type parameter should be ",
+        Constants.ATOM_MEDIA_TYPE);
+      PushbackInputStream pushBackInput = 
+        new PushbackInputStream(request.getInputStream(), 2);
+      pushBackInput.unread("\r\n".getBytes());
+      return new MultipartInputStream(pushBackInput, boundary.getBytes());
+    }
+
+    private void checkMultipartContent(
+      Document<Entry> entry, 
+      Map<String, String> dataHeaders, 
+      RequestContext request)
         throws ParseException {
-        if (entry == null) {
-            throw new ParseException("multipart/related stream invalid, media link entry is missing");
-        }
-        if (!dataHeaders.containsKey(CONTENT_TYPE_HEADER)) {
-            throw new ParseException("multipart/related stream invalid, data content-type is missing");
-        }
-        if (!isContentTypeAccepted(dataHeaders.get(CONTENT_TYPE_HEADER), request)) {
-            throw new ParseException("multipart/related stream invalid, content-type " + dataHeaders
-                .get(CONTENT_TYPE_HEADER)
-                + " not accepted into this multipart file");
-        }
-    }
-
-    private Map<String, String> getHeaders(MultipartInputStream multipart) throws IOException, MessagingException {
+      checked(
+        entry != null, 
+        ParseException.class, 
+        "multipart/related stream invalid, media link entry is missing");
+      checked(
+        dataHeaders.containsKey(CONTENT_TYPE_HEADER), 
+        ParseException.class,
+        "multipart/related stream invalid, data content-type is missing");
+      checked(
+        isContentTypeAccepted(dataHeaders.get(CONTENT_TYPE_HEADER),request),
+        ParseException.class,
+        "multipart/related stream invalid, content-type is not acceptable", 
+        dataHeaders.get(CONTENT_TYPE_HEADER));
+    }
+
+    private Map<String, String> getHeaders(
+      MultipartInputStream multipart) 
+        throws IOException, 
+               MessagingException {
         Map<String, String> mapHeaders = new HashMap<String, String>();
         moveToHeaders(multipart);
         InternetHeaders headers = new InternetHeaders(multipart);
-
         Enumeration<Header> allHeaders = headers.getAllHeaders();
         if (allHeaders != null) {
-            while (allHeaders.hasMoreElements()) {
-                Header header = allHeaders.nextElement();
-                mapHeaders.put(header.getName().toLowerCase(), header.getValue());
-            }
+          while (allHeaders.hasMoreElements()) {
+            Header header = allHeaders.nextElement();
+            mapHeaders.put(header.getName().toLowerCase(), header.getValue());
+          }
         }
-
         return mapHeaders;
     }
 
-    private boolean moveToHeaders(InputStream stream) throws IOException {
-        boolean dash = false;
-        boolean cr = false;
-        int byteReaded;
-
-        while ((byteReaded = stream.read()) != -1) {
-            switch (byteReaded) {
-                case '\r':
-                    cr = true;
-                    dash = false;
-                    break;
-                case '\n':
-                    if (cr == true)
-                        return true;
-                    dash = false;
-                    break;
-                case '-':
-                    if (dash == true) { // two dashes
-                        stream.close();
-                        return false;
-                    }
-                    dash = true;
-                    cr = false;
-                    break;
-                default:
-                    dash = false;
-                    cr = false;
-            }
-        }
-        return false;
-    }
-
-    private InputStream getDataInputStream(InputStream stream) throws IOException {
+    private boolean moveToHeaders(
+      InputStream stream) 
+        throws IOException {
+      boolean dash = false;
+      boolean cr = false;
+      int byteReaded;
+      while ((byteReaded = stream.read()) != -1) {
+          switch (byteReaded) {
+              case '\r':
+                  cr = true;
+                  dash = false;
+                  break;
+              case '\n':
+                  if (cr == true)
+                      return true;
+                  dash = false;
+                  break;
+              case '-':
+                  if (dash == true) { // two dashes
+                      stream.close();
+                      return false;
+                  }
+                  dash = true;
+                  cr = false;
+                  break;
+              default:
+                  dash = false;
+                  cr = false;
+          }
+      }
+      return false;
+    }
+
+    private InputStream getDataInputStream(
+      InputStream stream) 
+        throws IOException {
         Base64 base64 = new Base64();
-        ByteArrayOutputStream bo = new ByteArrayOutputStream();
-
+        ByteArrayOutputStream bo = 
+          new ByteArrayOutputStream();
         byte[] buffer = new byte[1024];
-        while (stream.read(buffer) != -1) {
-            bo.write(buffer);
-        }
-        return new ByteArrayInputStream(base64.decode(bo.toByteArray()));
+        while (stream.read(buffer) != -1)
+          bo.write(buffer);
+        return new ByteArrayInputStream(
+          base64.decode(bo.toByteArray()));
     }
 
-    private <T extends Element> Document<T> getEntry(InputStream stream, RequestContext request) throws ParseException,
-        IOException {
+    private <T extends Element> Document<T> getEntry(
+      InputStream stream, 
+      RequestContext request) 
+        throws ParseException,
+               IOException {
         Parser parser = AbstractAtompubProvider.getAbdera(request).getParser();
-        if (parser == null)
-            throw new IllegalArgumentException("No Parser implementation was provided");
+        checkNotNull(parser,"No parser implementation provided");
         Document<?> document =
-            parser.parse(stream, request.getResolvedUri().toString(), parser.getDefaultParserOptions());
+          parser.parse(
+            stream, 
+            request.getResolvedUri().toString(), 
+            parser.getDefaultParserOptions());
         return (Document<T>)document;
     }
 
-    private boolean isContentTypeAccepted(String contentType, RequestContext request) {
-        if (getAlternateAccepts(request) == null) {
-            return false;
-        }
-        for (Map.Entry<String, String> accept : getAlternateAccepts(request).entrySet()) {
-            if (accept.getKey().equalsIgnoreCase(contentType) && accept.getValue() != null
-                && accept.getValue().equalsIgnoreCase(Constants.LN_ALTERNATE_MULTIPART_RELATED)) {
-                return true;
-            }
-        }
+    private boolean isContentTypeAccepted(
+      String contentType, 
+      RequestContext request) {
+        if (getAlternateAccepts(request) == null)
+          return false;
+        for (Map.Entry<String, String> accept : getAlternateAccepts(request).entrySet())
+          if (isMatch(contentType, accept.getKey()) &&
+              accept.getValue() != null && 
+              accept.getValue().equalsIgnoreCase(
+                Constants.LN_ALTERNATE_MULTIPART_RELATED))
+              return true;
         return false;
     }
 
@@ -254,10 +274,11 @@ public abstract class AbstractMultipartC
         private final Map<String, String> entryHeaders;
         private final Map<String, String> dataHeaders;
 
-        public MultipartRelatedPost(Document<Entry> entry,
-                                    InputStream data,
-                                    Map<String, String> entryHeaders,
-                                    Map<String, String> dataHeaders) {
+        public MultipartRelatedPost(
+          Document<Entry> entry,
+          InputStream data,
+          Map<String, String> entryHeaders,
+          Map<String, String> dataHeaders) {
             this.entry = entry;
             this.data = data;
             this.entryHeaders = entryHeaders;
@@ -265,20 +286,19 @@ public abstract class AbstractMultipartC
         }
 
         public Document<Entry> getEntry() {
-            return entry;
+          return entry;
         }
 
         public InputStream getData() {
-            return data;
+          return data;
         }
 
         public Map<String, String> getEntryHeaders() {
-            return entryHeaders;
+          return entryHeaders;
         }
 
         public Map<String, String> getDataHeaders() {
-            return dataHeaders;
+          return dataHeaders;
         }
-
     }
 }

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/processors/MultipartRelatedServiceRequestProcessor.java Fri Oct 28 23:44:35 2011
@@ -75,32 +75,37 @@ public class MultipartRelatedServiceRequ
                             AtompubCollectionInfo ci = (AtompubCollectionInfo) c;
                             sw.startCollection(ci.getHref(request)).writeTitle(ci.getTitle(request));
                             if (ci instanceof MultipartRelatedCollectionInfo) {
-                                MultipartRelatedCollectionInfo multipartCi = (MultipartRelatedCollectionInfo)ci;
-                                for (Map.Entry<String, String> accept : multipartCi.getAlternateAccepts(request)
-                                    .entrySet()) {
-                                    sw.startElement(Constants.ACCEPT);
-                                    if (accept.getValue() != null && accept.getValue().length() > 0) {
-                                        sw.writeAttribute(Constants.LN_ALTERNATE, accept.getValue());
-                                    }
-                                    sw.writeElementText(accept.getKey()).endElement();
-                                }
+                              MultipartRelatedCollectionInfo multipartCi = (MultipartRelatedCollectionInfo)ci;
+                              for (Map.Entry<String, String> accept : multipartCi.getAlternateAccepts(request).entrySet()) {
+                                  sw.startElement(Constants.ACCEPT);
+                                  if (accept.getValue() != null && accept.getValue().length() > 0) {
+                                      sw.writeAttribute(Constants.LN_ALTERNATE, accept.getValue());
+                                  }
+                                  sw.writeElementText(accept.getKey()).endElement();
+                              }
                             } else {
-                                sw.writeAccepts(ci.getAccepts(request));
+                              sw.writeAccepts(ci.getAccepts(request));
                             }
-                            Iterable<AtompubCategoriesInfo> catinfos = ci.getCategoriesInfo(request);
+                            Iterable<AtompubCategoriesInfo> catinfos = 
+                              ci.getCategoriesInfo(request);
                             if (catinfos != null) {
                                 for (AtompubCategoriesInfo catinfo : catinfos) {
                                     String cathref = catinfo.getHref(request);
                                     if (cathref != null) {
-                                        sw.startCategories().writeAttribute("href",
-                                                                            request.getTargetBasePath() + cathref)
-                                            .endCategories();
+                                      sw.startCategories()
+                                        .writeAttribute(
+                                          "href",
+                                          request.getTargetBasePath() + cathref)
+                                        .endCategories();
                                     } else {
-                                        sw.startCategories(catinfo.isFixed(request), catinfo.getScheme(request));
-                                        for (AtompubCategoryInfo cat : catinfo) {
-                                            sw.writeCategory(cat.getTerm(request), cat.getScheme(request), cat
-                                                .getLabel(request));
-                                        }
+                                        sw.startCategories(
+                                          catinfo.isFixed(request), 
+                                          catinfo.getScheme(request));
+                                        for (AtompubCategoryInfo cat : catinfo)
+                                          sw.writeCategory(
+                                            cat.getTerm(request), 
+                                            cat.getScheme(request), 
+                                            cat.getLabel(request));
                                         sw.endCategories();
                                     }
                                 }

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java Fri Oct 28 23:44:35 2011
@@ -34,7 +34,6 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.ProviderHelper;
 import org.apache.abdera2.common.protocol.Target;
 import org.apache.abdera2.common.protocol.TargetType;
-import org.joda.time.DateTime;
 
 import com.google.common.base.Function;
 
@@ -42,7 +41,6 @@ import com.google.common.base.Function;
  * The BasicAdapter provides a simplistic interface for working with Atompub collections with a restricted set of
  * options/features. The idea of the basic adapter is to make it easy to provide a minimally capable Atompub server
  */
-@SuppressWarnings("unchecked")
 public abstract class BasicAdapter extends ManagedCollectionAdapter {
 
     public static Logger logger = 
@@ -76,22 +74,20 @@ public abstract class BasicAdapter exten
         Feed feed = abdera.newFeed();
         feed.setId(config.getFeedUri());
         feed.setTitle(config.getFeedTitle());
-        feed.setUpdated(DateTime.now());
+        feed.setUpdatedNow();
         feed.addAuthor(config.getFeedAuthor());
         return feed;
     }
 
     protected void addEditLinkToEntry(Entry entry) throws Exception {
-        if (AbstractAtompubProvider.getEditUriFromEntry(entry) == null) {
-            entry.addLink(entry.getId().toString(), "edit");
-        }
+      if (AbstractAtompubProvider.getEditUriFromEntry(entry) == null)
+        entry.addLink(entry.getId(), "edit");
     }
 
     protected void setEntryIdIfNull(Entry entry) throws Exception {
         // if there is no id in Entry, assign one.
-        if (entry.getId() != null) {
+        if (entry.getId() != null)
             return;
-        }
         String uuidUri = abdera.getFactory().newUuidUri();
         String[] segments = uuidUri.split(":");
         String entryId = segments[segments.length - 1];
@@ -99,15 +95,15 @@ public abstract class BasicAdapter exten
     }
 
     protected String createEntryIdUri(String entryId) throws Exception {
-        return config.getFeedUri() + "/" + entryId;
+      return config.getFeedUri() + "/" + entryId;
     }
 
-    private <S extends ResponseContext>S createOrUpdateEntry(RequestContext request, boolean createFlag) {
+    private ResponseContext createOrUpdateEntry(RequestContext request, boolean createFlag) {
         try {
             MimeType mimeType = request.getContentType();
             String contentType = mimeType == null ? null : mimeType.toString();
             if (contentType != null && !MimeTypeHelper.isAtom(contentType) && !MimeTypeHelper.isXml(contentType))
-                return (S)ProviderHelper.notsupported(request);
+                return ProviderHelper.notsupported(request);
             Entry inputEntry = AbstractAtompubProvider.<Entry>getDocument(request).getRoot();
             Target target = request.getTarget();
             String entryId = !createFlag ? target.getParameter(BasicProvider.PARAM_ENTRY) : null;
@@ -115,12 +111,12 @@ public abstract class BasicAdapter exten
             if (newEntry != null) {
                 Document<Entry> newEntryDoc = newEntry.getDocument();
                 String loc = newEntry.getEditLinkResolvedHref().toString();
-                return (S)AbstractAtompubProvider.returnBase(newEntryDoc, createFlag ? 201 : 200, null).setLocation(loc);
+                return AbstractAtompubProvider.returnBase(newEntryDoc, createFlag ? 201 : 200, null).setLocation(loc);
             } else {
-                return (S)ProviderHelper.notfound(request);
+                return ProviderHelper.notfound(request);
             }
         } catch (Exception e) {
-            return (S)ProviderHelper.servererror(request, e.getMessage(), e);
+            return ProviderHelper.servererror(request, e.getMessage(), e);
         }
     }
 

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicProvider.java Fri Oct 28 23:44:35 2011
@@ -38,21 +38,22 @@ public class BasicProvider extends Manag
         init();
     }
 
-    @SuppressWarnings({ "rawtypes", "unchecked" })
     private void init() {
-        RouteManager routeManager =
-            new RouteManager().addRoute(
-                "service", 
-                "/", 
-                TargetType.TYPE_SERVICE)
-                  .addRoute(
-                      "feed",
-                      "/:feed",
-                      TargetType.TYPE_COLLECTION)
-                  .addRoute(
-                      "entry", 
-                      "/:feed/:entry", 
-                      TargetType.TYPE_ENTRY);
+        RouteManager<TargetType,RequestContext,String> routeManager =
+          RouteManager.<TargetType,RequestContext,String>make()
+            .with(
+              "service", 
+              "/", 
+              TargetType.TYPE_SERVICE)
+            .with(
+              "feed",
+              "/:feed",
+              TargetType.TYPE_COLLECTION)
+            .with(
+              "entry", 
+              "/:feed/:entry", 
+              TargetType.TYPE_ENTRY)
+            .get();
         setTargetBuilder(
             routeManager);
         setTargetResolver(

Modified: abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java?rev=1190679&r1=1190678&r2=1190679&view=diff
==============================================================================
--- abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java (original)
+++ abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/managed/CollectionAdapterConfiguration.java Fri Oct 28 23:44:35 2011
@@ -27,7 +27,9 @@ public class CollectionAdapterConfigurat
     private final String fileLocation;
     private final ServerConfiguration serverConfiguration;
 
-    public CollectionAdapterConfiguration(ServerConfiguration serverConfiguration, String fileLocation) {
+    public CollectionAdapterConfiguration(
+      ServerConfiguration serverConfiguration, 
+      String fileLocation) {
         this.fileLocation = fileLocation;
         this.serverConfiguration = serverConfiguration;
     }

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=1190679&r1=1190678&r2=1190679&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 28 23:44:35 2011
@@ -37,27 +37,23 @@ public class CustomProvider 
     private static final String privateKeyPass = "testing";
     private static final String certificateAlias = "James";
 
-    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @SuppressWarnings("unchecked")
     public CustomProvider(String href) {
-
         this.adapter = new SimpleAdapter(href);
-
-        RouteManager rm =
-            new RouteManager()
-              .addRoute("service", "/", TargetType.TYPE_SERVICE)
-              .addRoute("collection","/:collection",TargetType.TYPE_COLLECTION)
-              .addRoute("entry", "/:collection/:entry", TargetType.TYPE_ENTRY);
-
+        RouteManager<TargetType,RequestContext,String> rm =
+          RouteManager.<TargetType,RequestContext,String>make()
+            .with("service", "/", TargetType.TYPE_SERVICE)
+            .with("collection","/:collection",TargetType.TYPE_COLLECTION)
+            .with("entry", "/:collection/:entry", TargetType.TYPE_ENTRY)
+            .get();
         setTargetBuilder(rm);
         setTargetResolver(rm);
-
         addWorkspace(
           SimpleWorkspaceInfo
             .make()
             .title("A Simple Workspace")
             .collection(adapter)
             .get());
-
         addFilter(
           new SignedRequestFilter());
         addFilter(new SignedResponseFilter(

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=1190679&r1=1190678&r2=1190679&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 28 23:44:35 2011
@@ -38,6 +38,7 @@ import org.apache.abdera2.protocol.serve
 import org.apache.abdera2.protocol.server.context.StreamWriterResponseContext;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubCollectionAdapter;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
+import org.apache.abdera2.util.MorePredicates;
 import org.apache.abdera2.writer.StreamWriter;
 import org.joda.time.DateTime;
 
@@ -145,7 +146,7 @@ public class SimpleAdapter extends Abstr
             Document<Entry> entry_doc = (Document<Entry>)AbstractAtompubProvider.getDocument(request).clone();
             if (entry_doc != null) {
                 Entry entry = entry_doc.getRoot();
-                if (!AbstractAtompubProvider.isValidEntry(entry))
+                if (!MorePredicates.VALID_ENTRY.apply(entry))
                     return ProviderHelper.badrequest(request);
                 setEntryDetails(request, entry, Abdera.getInstance().getFactory().newUuidUri());
                 Feed feed = getFeedDocument(request).getRoot();
@@ -203,7 +204,7 @@ public class SimpleAdapter extends Abstr
                     Entry entry = entry_doc.getRoot();
                     if (!entry.getId().equals(orig_entry.getId()))
                         return ProviderHelper.conflict(request);
-                    if (!AbstractAtompubProvider.isValidEntry(entry))
+                    if (!MorePredicates.VALID_ENTRY.apply(entry))
                         return ProviderHelper.badrequest(request);
                     setEntryDetails(request, entry, orig_entry.getId().toString());
                     orig_entry.discard();

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=1190679&r1=1190678&r2=1190679&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 28 23:44:35 2011
@@ -38,6 +38,7 @@ import org.apache.abdera2.protocol.serve
 import org.apache.abdera2.protocol.server.context.StreamWriterResponseContext;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubCollectionAdapter;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
+import org.apache.abdera2.util.MorePredicates;
 import org.apache.abdera2.writer.StreamWriter;
 import org.joda.time.DateTime;
 
@@ -146,7 +147,7 @@ public class SimpleAdapter extends Abstr
                 (Document<Entry>) AbstractAtompubProvider.<Entry>getDocument(request).clone();
               if (entry_doc != null) {
                   Entry entry = entry_doc.getRoot();
-                  if (!AbstractAtompubProvider.isValidEntry(entry))
+                  if (!MorePredicates.VALID_ENTRY.apply(entry))
                       return ProviderHelper.badrequest(request);
                   setEntryDetails(request, entry, Abdera.getInstance().getFactory().newUuidUri());
                   Feed feed = getFeedDocument(request).getRoot();
@@ -198,7 +199,7 @@ public class SimpleAdapter extends Abstr
                       Entry entry = entry_doc.getRoot();
                       if (!entry.getId().equals(orig_entry.getId()))
                           return ProviderHelper.conflict(request);
-                      if (!AbstractAtompubProvider.isValidEntry(entry))
+                      if (!MorePredicates.VALID_ENTRY.apply(entry))
                           return ProviderHelper.badrequest(request);
                       setEntryDetails(request, entry, orig_entry.getId().toString());
                       orig_entry.discard();