abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1189582 - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/protocol/ activities/src/main/java/org/apache/abdera2/activities/protocol/basic/ common/src/main/java/org/apache/abdera2/common/protocol/ security/src/mai...
Date Thu, 27 Oct 2011 02:16:57 GMT
Author: jmsnell
Date: Thu Oct 27 02:16:56 2011
New Revision: 1189582

URL: http://svn.apache.org/viewvc?rev=1189582&view=rev
Log:
More progress on fixing the test cases and simplification... 

Removed:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ActivitiesRequestContext.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/context/AtompubRequestContext.java
Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionAdapter.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java
    abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/AbstractEncryptedRequestFilter.java
    abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/SignedRequestFilter.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubCollectionAdapter.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/impl/AbstractAtompubWorkspaceProvider.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
    abdera/abdera2/server/src/main/java/org/apache/abdera2/protocol/server/provider/basic/BasicAdapter.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/security/filter/SimpleAdapter.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/custom/SimpleAdapter.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/customer/CustomerAdapter.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedAdapter.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/server/multipart/MultipartRelatedTest.java

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesCollectionAdapter.java Thu Oct 27 02:16:56 2011
@@ -25,6 +25,7 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.Collection;
 import org.apache.abdera2.activities.model.objects.PersonObject;
 import org.apache.abdera2.activities.model.objects.ServiceObject;
+import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.protocol.AbstractCollectionAdapter;
 import org.apache.abdera2.common.protocol.CollectionAdapter;
 import org.apache.abdera2.common.protocol.CollectionInfo;
@@ -33,6 +34,8 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.ResponseContextException;
 import org.joda.time.DateTime;
 
+import com.google.common.base.Predicate;
+
 public abstract class AbstractActivitiesCollectionAdapter
   extends AbstractCollectionAdapter
   implements CollectionAdapter, 
@@ -101,15 +104,21 @@ public abstract class AbstractActivities
         .get();
   }
 
-  protected ASObject getEntryFromRequest(RequestContext request) throws ResponseContextException {
+  protected ASObject getEntryFromRequest(
+    RequestContext request) 
+      throws ResponseContextException {
       ASObject object;
       try {
-          ActivitiesRequestContext context = (ActivitiesRequestContext) request;
-          object = context.getEntity();
+        object = 
+          AbstractActivitiesProvider
+            .getASBaseFromRequestContext(request);
       } catch (IOException e) {
-          throw new ResponseContextException(500, e);
+       throw ExceptionHelper.propogate(e);
       }
       return object;
   }
 
+  public Predicate<RequestContext> acceptable() {
+    return AbstractActivitiesWorkspaceProvider.isJson();
+  }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesProvider.java Thu Oct 27 02:16:56 2011
@@ -17,16 +17,22 @@
  */
 package org.apache.abdera2.activities.protocol;
 
+import java.io.IOException;
+import java.io.Reader;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.activation.MimeType;
+
 import org.apache.abdera2.activities.model.ASBase;
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.activities.model.Activity;
 import org.apache.abdera2.activities.model.Collection;
+import org.apache.abdera2.activities.model.IO;
 import org.apache.abdera2.activities.model.TypeAdapter;
 import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.common.http.EntityTag;
+import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.protocol.BaseProvider;
 import org.apache.abdera2.common.protocol.CollectionRequestProcessor;
 import org.apache.abdera2.common.protocol.EntryRequestProcessor;
@@ -35,6 +41,8 @@ import org.apache.abdera2.common.protoco
 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.common.protocol.RequestContext.Scope;
+import org.joda.time.DateTime;
 
 public abstract class AbstractActivitiesProvider 
   extends BaseProvider
@@ -86,14 +94,6 @@ public abstract class AbstractActivities
         .setStatusText(message);
   }
 
-  @Override
-  public ResponseContext apply(RequestContext request) {
-    return super.apply(
-      request instanceof ActivitiesRequestContext?
-        request:
-        new ActivitiesRequestContext(request));
-  }
-
   public static EntityTag calculateEntityTag(ASBase base) {
     String id = null;
     String modified = null;
@@ -119,4 +119,54 @@ public abstract class AbstractActivities
     String editLink = object.getProperty("editLink");
     return editLink;
   }
+  
+  
+  
+  public static IO getIO(ActivitiesProvider provider, TypeAdapter<?>... adapters) {
+    Set<TypeAdapter<?>> as = 
+      new HashSet<TypeAdapter<?>>(provider.getTypeAdapters());
+    for (TypeAdapter<?> ta : adapters)
+      as.add(ta);
+    return IO.get(as.toArray(new TypeAdapter[as.size()]));
+  }
+  
+  @SuppressWarnings("unchecked")
+  public static <T extends ASBase>T getASBaseFromRequestContext(RequestContext context) throws IOException {
+    ASBase entity = context.getAttribute(Scope.REQUEST, ASBase.class.getName());
+      try {
+      if (entity == null) {
+        Reader reader = context.getReader();
+        IO io = getIO(context.<ActivitiesProvider>getProvider());
+        if (reader != null)
+          entity = io.read(reader);
+        else // try input stream, but this should've worked
+          entity = io.read(context.getInputStream(), "UTF-8");
+      }
+      } catch (Throwable t) {
+        throw ExceptionHelper.propogate(t);
+      }
+    if (entity != null) {
+      setDocProperties(entity, context);
+      context.setAttribute(ASBase.class.getName(), entity);
+    }
+    return (T)entity;
+  }
+  
+  private static void setDocProperties(ASBase base, RequestContext context) {
+    String etag = context.getHeader("ETag");
+    if (etag != null)
+        base.setEntityTag(etag);
+    DateTime lm = context.getDateHeader("Last-Modified");
+    if (lm != null)
+        base.setLastModified(lm);
+    MimeType mt = context.getContentType();
+    if (mt != null)
+        base.setContentType(mt.toString());
+    String language = context.getContentLanguage();
+    if (language != null)
+        base.setLanguage(language);
+    String slug = context.getSlug();
+    if (slug != null)
+        base.setSlug(slug);
+  }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/AbstractActivitiesWorkspaceProvider.java Thu Oct 27 02:16:56 2011
@@ -89,12 +89,4 @@ public abstract class AbstractActivities
         .setStatus(code)
         .setStatusText(message);
   }
-
-  @Override
-  public ResponseContext apply(RequestContext request) {
-    return super.apply(
-      request instanceof ActivitiesRequestContext?
-        request:
-        new ActivitiesRequestContext(request));
-  }
 }
\ No newline at end of file

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/basic/BasicAdapter.java Thu Oct 27 02:16:56 2011
@@ -28,7 +28,6 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.activities.model.Collection;
 import org.apache.abdera2.activities.model.objects.PersonObject;
 import org.apache.abdera2.activities.protocol.AbstractActivitiesProvider;
-import org.apache.abdera2.activities.protocol.ActivitiesRequestContext;
 import org.apache.abdera2.activities.protocol.ActivitiesResponseContext;
 import org.apache.abdera2.activities.protocol.ErrorObject;
 import org.apache.abdera2.activities.protocol.managed.FeedConfiguration;
@@ -124,15 +123,14 @@ public abstract class BasicAdapter exten
       }
     }
     
-    private ResponseContext createOrUpdateObject(RequestContext context, boolean createFlag) {
+    private ResponseContext createOrUpdateObject(RequestContext request, boolean createFlag) {
         try {
-            ActivitiesRequestContext request = (ActivitiesRequestContext) context;
             MimeType mimeType = request.getContentType();
             String contentType = mimeType == null ? null : mimeType.toString();
             if (contentType != null && !MimeTypeHelper.isJson(contentType))
                 return ProviderHelper.notsupported(request);
-            
-            ASBase base = (ASBase)request.getEntity();
+           
+            ASBase base = getEntryFromRequest(request);
             Target target = request.getTarget();
 
             if (base instanceof Collection && createFlag && target.getType() == TargetType.TYPE_COLLECTION) {
@@ -142,7 +140,7 @@ public abstract class BasicAdapter exten
               int c = 0;
               for (ASObject inputEntry : coll.getItems()) {
                 ASObject newEntry = createItem(inputEntry,c++);
-                push(context,target.getParameter(BasicProvider.PARAM_FEED),newEntry);
+                push(request,target.getParameter(BasicProvider.PARAM_FEED),newEntry);
                 if (newEntry != null) {
                   retl.addItem(newEntry);
                 } else {
@@ -159,7 +157,7 @@ public abstract class BasicAdapter exten
               String entryId = !createFlag ? target.getParameter(BasicProvider.PARAM_ENTRY) : null;
               ASObject inputEntry = (ASObject) base;
               ASObject newEntry = createFlag ? createItem(inputEntry) : updateItem(entryId, inputEntry);
-              push(context,target.getParameter(BasicProvider.PARAM_FEED),newEntry);
+              push(request,target.getParameter(BasicProvider.PARAM_FEED),newEntry);
               if (newEntry != null) {
                   String loc = newEntry.getProperty("editLink");
                   ActivitiesResponseContext<ASObject> rc = 
@@ -175,7 +173,7 @@ public abstract class BasicAdapter exten
             }
             
         } catch (Exception e) {
-            return ProviderHelper.servererror(context, e.getMessage(), e);
+            return ProviderHelper.servererror(request, e.getMessage(), e);
         }
     }
 

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/BaseProvider.java Thu Oct 27 02:16:56 2011
@@ -96,7 +96,7 @@ public abstract class BaseProvider
       CollectionAdapter adapter = 
         getWorkspaceManager()
           .getCollectionAdapter(request);
-      if (adapter == null)
+      if (adapter == null && type != TargetType.TYPE_SERVICE)
         return ProviderHelper.servererror(request, null);
       RequestProcessor processor = 
         (RequestProcessor) this.requestProcessors

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionAdapter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionAdapter.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionAdapter.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/CollectionAdapter.java Thu Oct 27 02:16:56 2011
@@ -18,6 +18,7 @@
 package org.apache.abdera2.common.protocol;
 
 import com.google.common.base.Function;
+import com.google.common.base.Predicate;
 
 
 public interface CollectionAdapter {
@@ -26,4 +27,5 @@ public interface CollectionAdapter {
       Target target, 
       String method);
     
+    Predicate<RequestContext> acceptable();
 }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/DefaultWorkspaceManager.java Thu Oct 27 02:16:56 2011
@@ -55,12 +55,13 @@ public class DefaultWorkspaceManager 
       return new Predicate<CollectionInfo>() {
         public boolean apply(CollectionInfo input) {
           String href = input.getHref(rc);
-          return (
+          boolean answer = (
             path.equals(href) || 
             (href != null && 
              path.startsWith(href) && 
              URI_GEN_DELIMS.contains(
               path.substring(href.length(), href.length() + 1))));
+          return answer;
         }
       }; 
     }

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/protocol/RequestProcessor.java Thu Oct 27 02:16:56 2011
@@ -52,8 +52,14 @@ public abstract class RequestProcessor 
       this.predicate = predicate;
     }
   
+  private boolean applies(RequestContext request, Predicate<RequestContext> predicate) {
+    return predicate != null && predicate.apply(request);
+  }
+  
   protected ResponseContext actuallyApply(RequestContext request) {
-    if (predicate != null && !predicate.apply(request))
+    boolean adapter_ok = applies(request, adapter.acceptable());
+    boolean pred_ok = applies(request, predicate);
+    if (!adapter_ok && !pred_ok) // fail only if both are false
       return ProviderHelper.notallowed(request);
     Function<RequestContext,ResponseContext> handler = 
       adapter.handlerFor(

Modified: abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/AbstractEncryptedRequestFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/AbstractEncryptedRequestFilter.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/AbstractEncryptedRequestFilter.java (original)
+++ abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/AbstractEncryptedRequestFilter.java Thu Oct 27 02:16:56 2011
@@ -17,7 +17,6 @@
  */
 package org.apache.abdera2.security.util.filters;
 
-import java.io.IOException;
 import java.security.Provider;
 import java.security.Security;
 import java.util.ArrayList;
@@ -25,19 +24,16 @@ import java.util.List;
 
 import org.apache.abdera2.Abdera;
 import org.apache.abdera2.common.misc.Chain;
+import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.misc.Task;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.model.Document;
 import org.apache.abdera2.model.Element;
-import org.apache.abdera2.parser.ParseException;
-import org.apache.abdera2.parser.Parser;
-import org.apache.abdera2.parser.ParserOptions;
-import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
 import org.apache.abdera2.security.Encryption;
 import org.apache.abdera2.security.EncryptionOptions;
 
-@SuppressWarnings("unchecked")
 public abstract class AbstractEncryptedRequestFilter implements Task<RequestContext,ResponseContext> {
 
     // The methods that allow encrypted bodies
@@ -65,37 +61,40 @@ public abstract class AbstractEncryptedR
         bootstrap(request);
         String method = request.getMethod();
         if (methods.contains(method.toUpperCase())) {
-            return chain.next(new DecryptingRequestContextWrapper(request));
+            return chain.next(setDecryptedDocument(request));
         } else
             return chain.next(request);
     }
 
+    protected RequestContext setDecryptedDocument(RequestContext request) {
+      try {
+        Document<Element> doc = AbstractAtompubProvider.getDocument(request);
+        if (doc != null) {
+          Abdera abdera = Abdera.getInstance();
+          Encryption enc = new org.apache.abdera2.security.Security(abdera).getEncryption();
+          if (enc.isEncrypted(doc)) {
+            Object arg = initArg(request);
+            EncryptionOptions encoptions = 
+              initEncryptionOptions(request, enc, arg);
+            doc = enc.decrypt(doc, encoptions);
+            if (doc != null) 
+              request.setAttribute(
+                Document.class.getName(), doc);
+          }
+        }
+      } catch (Exception e) {
+        throw ExceptionHelper.propogate(e);
+      }
+      return request;
+    }
+    
     protected abstract void bootstrap(RequestContext request);
 
     protected abstract Object initArg(RequestContext request);
 
-    protected abstract EncryptionOptions initEncryptionOptions(RequestContext request, Encryption encryption, Object arg);
+    protected abstract EncryptionOptions initEncryptionOptions(
+      RequestContext request, 
+      Encryption encryption, 
+      Object arg);
 
-    private class DecryptingRequestContextWrapper extends AtompubRequestContext {
-        public DecryptingRequestContextWrapper(RequestContext request) {
-            super(request);
-        }
-        public <T extends Element> Document<T> getDocument(Parser parser, ParserOptions options) throws ParseException,
-            IOException {
-            Document<Element> doc = super.getDocument();
-            try {
-                if (doc != null) {
-                    Abdera abdera = getAbdera();
-                    Encryption enc = new org.apache.abdera2.security.Security(abdera).getEncryption();
-                    if (enc.isEncrypted(doc)) {
-                        Object arg = initArg((AtompubRequestContext)request);
-                        EncryptionOptions encoptions = initEncryptionOptions((AtompubRequestContext)request, enc, arg);
-                        doc = enc.decrypt(doc, encoptions);
-                    }
-                }
-            } catch (Exception e) {
-            }
-            return (Document<T>)doc;
-        }
-    }
 }

Modified: abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/SignedRequestFilter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/SignedRequestFilter.java?rev=1189582&r1=1189581&r2=1189582&view=diff
==============================================================================
--- abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/SignedRequestFilter.java (original)
+++ abdera/abdera2/security/src/main/java/org/apache/abdera2/security/util/filters/SignedRequestFilter.java Thu Oct 27 02:16:56 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.abdera2.security.util.filters;
 
+import org.apache.abdera2.Abdera;
 import org.apache.abdera2.common.Localizer;
 import org.apache.abdera2.common.misc.Chain;
 import org.apache.abdera2.common.misc.Task;
@@ -25,7 +26,7 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.common.protocol.ProviderHelper;
 import org.apache.abdera2.model.Document;
 import org.apache.abdera2.model.Element;
-import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
+import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
 import org.apache.abdera2.security.Security;
 import org.apache.abdera2.security.Signature;
 
@@ -39,16 +40,12 @@ public class SignedRequestFilter impleme
     public static final String CERTS = "org.apache.abdera.security.util.servlet.SignedRequestFilter.certs";
 
     public ResponseContext apply(RequestContext request, Chain<RequestContext,ResponseContext> chain) {
-        AtompubRequestContext context = 
-          request instanceof AtompubRequestContext ? 
-            (AtompubRequestContext)request : 
-            new AtompubRequestContext(request);
-        Security security = new Security(context.getAbdera());
+        Security security = new Security(Abdera.getInstance());
         Signature sig = security.getSignature();
         String method = request.getMethod();
         if (method.equals("POST") || method.equals("PUT")) {
             try {
-                Document<Element> doc = context.getDocument();
+                Document<Element> doc = AbstractAtompubProvider.getDocument(request);
                 if (security.notVerified(doc))
                     return ProviderHelper.badrequest(
                       request, 
@@ -61,7 +58,7 @@ public class SignedRequestFilter impleme
             } catch (Exception e) {
             }
         }
-        return chain.next(context);
+        return chain.next(request);
     }
 
 }

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -17,13 +17,13 @@
  */
 package org.apache.abdera2.protocol.server.impl;
 
-import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
 
 import org.apache.abdera2.Abdera;
 import org.apache.abdera2.factory.Factory;
 import org.apache.abdera2.common.protocol.AbstractCollectionAdapter;
+import org.apache.abdera2.common.protocol.ProviderHelper;
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.ResponseContextException;
@@ -33,16 +33,16 @@ import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.parser.ParseException;
 import org.apache.abdera2.parser.Parser;
-import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
 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;
+
 /**
  * Base CollectionAdapter implementation that provides a number of helper utility methods for adapter implementations.
  */
-@SuppressWarnings("unchecked")
 public abstract class AbstractAtompubCollectionAdapter 
   extends AbstractCollectionAdapter
   implements AtompubCollectionInfo {
@@ -126,17 +126,13 @@ public abstract class AbstractAtompubCol
 
         Document<Entry> entry_doc;
         try {
-            AtompubRequestContext context = (AtompubRequestContext) request;
-            entry_doc = (Document<Entry>)context.getDocument(parser).clone();
+          entry_doc = AbstractAtompubProvider.getDocument(parser,request);
         } catch (ParseException e) {
-            throw new ResponseContextException(400, e);
-        } catch (IOException e) {
-            throw new ResponseContextException(500, e);
-        }
-        if (entry_doc == null) {
-            return null;
+          throw new ResponseContextException(400, e);
+        } catch (Throwable t) {
+          throw new ResponseContextException(500, t);
         }
-        return entry_doc.getRoot();
+        return entry_doc == null ? null : entry_doc.getRoot();
     }
 
     public Collection asCollectionElement(RequestContext request) {
@@ -149,4 +145,8 @@ public abstract class AbstractAtompubCol
         }
         return collection;
     }
+    
+    public Predicate<RequestContext> acceptable() {
+      return ProviderHelper.isAtom();
+    }
 }

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -33,12 +33,14 @@ import org.apache.abdera2.common.http.Qu
 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.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;
@@ -55,10 +57,12 @@ import org.apache.abdera2.model.Extensib
 import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.model.Link;
 import org.apache.abdera2.model.Service;
+import org.apache.abdera2.parser.ParseException;
+import org.apache.abdera2.parser.Parser;
+import org.apache.abdera2.parser.ParserOptions;
 import org.apache.abdera2.protocol.error.Error;
 import org.apache.abdera2.protocol.server.AtompubProvider;
 import org.apache.abdera2.protocol.server.AtompubResponseContext;
-import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
 import org.apache.abdera2.protocol.server.context.FOMResponseContext;
 import org.apache.abdera2.protocol.server.context.StreamWriterResponseContext;
 import org.apache.abdera2.protocol.server.model.AtompubWorkspaceInfo;
@@ -324,12 +328,55 @@ public abstract class AbstractAtompubPro
         }
         return response;
     }
-
-    @Override
-    public ResponseContext apply(RequestContext request) {
-      return super.apply(
-        request instanceof AtompubRequestContext ? 
-          request : 
-          new AtompubRequestContext(request));
+    
+    public static <T extends Element>Document<T> getDocument(
+      RequestContext context)
+        throws ParseException, IOException {
+      return getDocument(null, null, context);
+    }
+
+    public static <T extends Element> Document<T> getDocument(
+      Parser parser, RequestContext context) 
+        throws ParseException, IOException {
+      return getDocument(parser,null,context);
+    }
+
+    public static <T extends Element> Document<T> getDocument(
+      ParserOptions options, 
+      RequestContext context) throws ParseException,
+        IOException {
+        return getDocument(null,options,context);
+    }
+
+    public static <T extends Element> Document<T> getDocument(
+      Parser parser, 
+      ParserOptions options, 
+      RequestContext context)
+        throws ParseException, IOException {
+      
+      Document<T> doc = context.getAttribute(Scope.REQUEST, Document.class.getName());
+      if (doc == null) {
+        try {
+          AtompubProvider provider = context.<AtompubProvider>getProvider();
+          Abdera abdera = provider.getAbdera();
+          log.debug(Localizer.get("PARSING.REQUEST.DOCUMENT"));
+          if (parser == null)
+              parser = abdera.getParser();
+          if (parser == null)
+              throw new IllegalArgumentException(
+                "No Parser implementation was provided");
+          if (options == null)
+            options = parser.getDefaultParserOptions();
+          doc = parser.parse(
+            context.getInputStream(), 
+            context.getResolvedUri().toString(), 
+            options);
+          context.setAttribute(Document.class.getName(), doc);
+        } catch (Throwable t) {
+          throw ExceptionHelper.propogate(t);
+        }
+      }
+      return doc;
     }
+
 }

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -25,12 +25,10 @@ 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.RequestContext;
 import org.apache.abdera2.common.protocol.RequestProcessor;
 import org.apache.abdera2.common.protocol.ResponseContext;
 import org.apache.abdera2.common.protocol.TargetType;
 import org.apache.abdera2.protocol.server.AtompubProvider;
-import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
 import org.apache.abdera2.protocol.server.model.AtompubWorkspaceManager;
 import org.apache.abdera2.protocol.server.processors.ServiceRequestProcessor;
 
@@ -87,11 +85,4 @@ public abstract class AbstractAtompubWor
     return AbstractAtompubProvider.createErrorResponse(abdera,code,message,t);
   }
   
-  @Override
-  public ResponseContext apply(RequestContext request) {
-    return super.apply(
-      request instanceof AtompubRequestContext ? 
-        request:
-        new AtompubRequestContext(request));
-  }
 }
\ No newline at end of file

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -27,6 +27,7 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.activation.MimeType;
 import javax.mail.Header;
 import javax.mail.MessagingException;
 import javax.mail.internet.InternetHeaders;
@@ -44,6 +45,7 @@ import org.apache.abdera2.common.mediaty
 import org.apache.abdera2.common.protocol.RequestContext;
 import org.apache.commons.codec.binary.Base64;
 
+import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 
 @SuppressWarnings("unchecked")
@@ -63,6 +65,17 @@ public abstract class AbstractMultipartC
 
     protected Map<String, String> accepts;
 
+    public Predicate<RequestContext> acceptable() {
+      return new Predicate<RequestContext>() {
+        public boolean apply(RequestContext input) {
+          MimeType mt = input.getContentType();
+          if (mt == null) return false;
+          return MimeTypeHelper.isMultipart(mt.toString()) ||
+                 MimeTypeHelper.isAtom(mt.toString());
+        }
+      };
+    }
+    
     public Iterable<String> getAccepts(RequestContext request) {
         Collection<String> acceptKeys = getAlternateAccepts(request).keySet();
         return Iterables.unmodifiableIterable(acceptKeys);

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -25,8 +25,6 @@ import org.apache.abdera2.Abdera;
 import org.apache.abdera2.model.Document;
 import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.model.Feed;
-import org.apache.abdera2.parser.Parser;
-import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubProvider;
 import org.apache.abdera2.protocol.server.provider.managed.FeedConfiguration;
 import org.apache.abdera2.protocol.server.provider.managed.ManagedCollectionAdapter;
@@ -104,16 +102,13 @@ public abstract class BasicAdapter exten
         return config.getFeedUri() + "/" + entryId;
     }
 
-    private <S extends ResponseContext>S createOrUpdateEntry(RequestContext context, boolean createFlag) {
+    private <S extends ResponseContext>S createOrUpdateEntry(RequestContext request, boolean createFlag) {
         try {
-            AtompubRequestContext request = (AtompubRequestContext) context;
             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);
-            Abdera abdera = request.getAbdera();
-            Parser parser = abdera.getParser();
-            Entry inputEntry = (Entry)request.getDocument(parser).getRoot();
+            Entry inputEntry = AbstractAtompubProvider.<Entry>getDocument(request).getRoot();
             Target target = request.getTarget();
             String entryId = !createFlag ? target.getParameter(BasicProvider.PARAM_ENTRY) : null;
             Entry newEntry = createFlag ? createEntry(inputEntry) : updateEntry(entryId, inputEntry);
@@ -125,7 +120,7 @@ public abstract class BasicAdapter exten
                 return (S)ProviderHelper.notfound(request);
             }
         } catch (Exception e) {
-            return (S)ProviderHelper.servererror(context, e.getMessage(), e);
+            return (S)ProviderHelper.servererror(request, e.getMessage(), e);
         }
     }
 

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -34,7 +34,6 @@ import org.apache.abdera2.model.Document
 import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.parser.ParseException;
-import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
 import org.apache.abdera2.protocol.server.context.FOMResponseContext;
 import org.apache.abdera2.protocol.server.context.StreamWriterResponseContext;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubCollectionAdapter;
@@ -141,16 +140,14 @@ public class SimpleAdapter extends Abstr
   
   private Function<RequestContext,ResponseContext> postItem() {
     return new Function<RequestContext,ResponseContext>() {
-      public ResponseContext apply(RequestContext input) {
-        AtompubRequestContext request = (AtompubRequestContext) input;
-        Abdera abdera = request.getAbdera();
+      public ResponseContext apply(RequestContext request) {
         try {
-            Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
+            Document<Entry> entry_doc = (Document<Entry>)AbstractAtompubProvider.getDocument(request).clone();
             if (entry_doc != null) {
                 Entry entry = entry_doc.getRoot();
                 if (!AbstractAtompubProvider.isValidEntry(entry))
                     return ProviderHelper.badrequest(request);
-                setEntryDetails(request, entry, abdera.getFactory().newUuidUri());
+                setEntryDetails(request, entry, Abdera.getInstance().getFactory().newUuidUri());
                 Feed feed = getFeedDocument(request).getRoot();
                 feed.insertEntry(entry);
                 feed.setUpdated(DateTime.now());
@@ -197,13 +194,11 @@ public class SimpleAdapter extends Abstr
 
   private Function<RequestContext,ResponseContext> putItem() {
     return new Function<RequestContext,ResponseContext>() {
-      public ResponseContext apply(RequestContext input) {
-        AtompubRequestContext request = (AtompubRequestContext) input;
-        Abdera abdera = request.getAbdera();
+      public ResponseContext apply(RequestContext request) {
         Entry orig_entry = getAbderaEntry(request);
         if (orig_entry != null) {
             try {
-                Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
+                Document<Entry> entry_doc = (Document<Entry>)AbstractAtompubProvider.getDocument(request).clone();
                 if (entry_doc != null) {
                     Entry entry = entry_doc.getRoot();
                     if (!entry.getId().equals(orig_entry.getId()))
@@ -250,9 +245,8 @@ public class SimpleAdapter extends Abstr
 
   private Function<RequestContext,ResponseContext> getCategories() {
     return new Function<RequestContext,ResponseContext>() {
-      public ResponseContext apply(RequestContext input) {
-        AtompubRequestContext request = (AtompubRequestContext) input;
-        return new StreamWriterResponseContext(request.getAbdera()) {
+      public ResponseContext apply(RequestContext request) {
+        return new StreamWriterResponseContext(Abdera.getInstance()) {
             protected void writeTo(StreamWriter sw) throws IOException {
                 sw.startDocument().startCategories(false).writeCategory("foo").writeCategory("bar")
                     .writeCategory("baz").endCategories().endDocument();

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -34,7 +34,6 @@ import org.apache.abdera2.model.Document
 import org.apache.abdera2.model.Entry;
 import org.apache.abdera2.model.Feed;
 import org.apache.abdera2.parser.ParseException;
-import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
 import org.apache.abdera2.protocol.server.context.FOMResponseContext;
 import org.apache.abdera2.protocol.server.context.StreamWriterResponseContext;
 import org.apache.abdera2.protocol.server.impl.AbstractAtompubCollectionAdapter;
@@ -141,16 +140,15 @@ public class SimpleAdapter extends Abstr
     
     private Function<RequestContext,ResponseContext> postItem() {
       return new Function<RequestContext,ResponseContext>() {
-        public ResponseContext apply(RequestContext input) {
-          AtompubRequestContext request = (AtompubRequestContext) input;
-          Abdera abdera = request.getAbdera();
+        public ResponseContext apply(RequestContext request) {
           try {
-              Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
+              Document<Entry> entry_doc = 
+                (Document<Entry>) AbstractAtompubProvider.<Entry>getDocument(request).clone();
               if (entry_doc != null) {
                   Entry entry = entry_doc.getRoot();
                   if (!AbstractAtompubProvider.isValidEntry(entry))
                       return ProviderHelper.badrequest(request);
-                  setEntryDetails(request, entry, abdera.getFactory().newUuidUri());
+                  setEntryDetails(request, entry, Abdera.getInstance().getFactory().newUuidUri());
                   Feed feed = getFeedDocument(request).getRoot();
                   feed.insertEntry(entry);
                   feed.setUpdated(DateTime.now());
@@ -189,13 +187,13 @@ public class SimpleAdapter extends Abstr
 
     private Function<RequestContext,ResponseContext> putItem() {
       return new Function<RequestContext,ResponseContext>() {
-        public ResponseContext apply(RequestContext input) {
-          AtompubRequestContext request = (AtompubRequestContext) input;
-          Abdera abdera = request.getAbdera();
+        public ResponseContext apply(RequestContext request) {
           Entry orig_entry = getAbderaEntry(request);
           if (orig_entry != null) {
               try {
-                  Document<Entry> entry_doc = (Document<Entry>)request.getDocument(abdera.getParser()).clone();
+                  Document<Entry> entry_doc = 
+                    (Document<Entry>)AbstractAtompubProvider
+                      .getDocument(request).clone();
                   if (entry_doc != null) {
                       Entry entry = entry_doc.getRoot();
                       if (!entry.getId().equals(orig_entry.getId()))
@@ -243,8 +241,7 @@ public class SimpleAdapter extends Abstr
     private Function<RequestContext,ResponseContext> getCategories() {
       return new Function<RequestContext,ResponseContext>() {
         public ResponseContext apply(RequestContext input) {
-          AtompubRequestContext request = (AtompubRequestContext) input;
-          return new StreamWriterResponseContext(request.getAbdera()) {
+          return new StreamWriterResponseContext(Abdera.getInstance()) {
               protected void writeTo(StreamWriter sw) throws IOException {
                   sw.startDocument().startCategories(false).writeCategory("foo").writeCategory("bar")
                       .writeCategory("baz").endCategories().endDocument();

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -34,7 +34,6 @@ import org.apache.abdera2.common.protoco
 import org.apache.abdera2.model.Content;
 import org.apache.abdera2.model.Element;
 import org.apache.abdera2.model.Person;
-import org.apache.abdera2.protocol.server.context.AtompubRequestContext;
 import org.apache.abdera2.protocol.server.impl.AbstractEntityCollectionAdapter;
 import org.joda.time.DateTime;
 
@@ -91,8 +90,7 @@ public class CustomerAdapter extends Abs
 
     @Override
     public List<Person> getAuthors(Customer entry, RequestContext context) throws ResponseContextException {
-        AtompubRequestContext request = (AtompubRequestContext) context;
-        Person author = request.getAbdera().getFactory().newAuthor();
+        Person author = Abdera.getInstance().getFactory().newAuthor();
         author.setName("Acme Industries");
         return Arrays.asList(author);
     }

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -82,5 +82,4 @@ public class MultipartRelatedAdapter 
         }
         return accepts;
     }
-
 }

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=1189582&r1=1189581&r2=1189582&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 Thu Oct 27 02:16:56 2011
@@ -40,16 +40,16 @@ public class MultipartRelatedTest {
             @Override
             protected AtompubProvider createProvider() {
                 DefaultAtompubProvider provider = new DefaultAtompubProvider("/");
-
                 Map<TargetType,Function<CollectionAdapter,? extends RequestProcessor>> map = 
                   new HashMap<TargetType,Function<CollectionAdapter,? extends RequestProcessor>>();
                 map.put(TargetType.TYPE_SERVICE, 
                   RequestProcessor.forClass(
                     MultipartRelatedServiceRequestProcessor.class, 
                     provider.getWorkspaceManager()));
+
                 provider.addRequestProcessors(map);            
-                MultipartRelatedAdapter ca = new MultipartRelatedAdapter("media");
-                
+                MultipartRelatedAdapter ca = 
+                  new MultipartRelatedAdapter("media");  
                 provider
                   .addWorkspace(
                     SimpleWorkspaceInfo
@@ -57,7 +57,6 @@ public class MultipartRelatedTest {
                       .title("multipart/related Workspace")
                       .collection(ca)
                       .get());
-
                 provider.init(null);
                 return provider;
             }



Mime
View raw message