You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by da...@apache.org on 2008/01/31 21:18:47 UTC

svn commit: r617211 - in /incubator/abdera/java/trunk/server/src: main/java/org/apache/abdera/protocol/server/impl/ test/java/org/apache/abdera/protocol/server/test/customer/

Author: dandiep
Date: Thu Jan 31 12:18:41 2008
New Revision: 617211

URL: http://svn.apache.org/viewvc?rev=617211&view=rev
Log:
Apply ABDERA-95. Small AbstractEntityCollectionAdapter cleanup.

Modified:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
    incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java?rev=617211&r1=617210&r2=617211&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractCollectionAdapter.java Thu Jan 31 12:18:41 2008
@@ -58,7 +58,11 @@
   }
   
   public String getHref(RequestContext request) {
-    return request.urlFor("feed", hrefParams);
+    String href = request.urlFor("feed", hrefParams);
+    
+    System.out.println("CA HREF " + href);
+    
+    return href;
   }
   
   public void compensate(RequestContext request, Throwable t) {

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java?rev=617211&r1=617210&r2=617211&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractEntityCollectionAdapter.java Thu Jan 31 12:18:41 2008
@@ -173,8 +173,7 @@
 
   public ResponseContext getEntry(RequestContext request) {
     try {
-      Entry entry = getEntryFromCollectionProvider(new IRI(getHref(request)),
-                                                   request);
+      Entry entry = getEntryFromCollectionProvider(request);
       if (entry != null) {
         return buildGetEntryResponse(request, entry);
       } else {
@@ -429,7 +428,7 @@
     }
   }
 
-  protected Entry getEntryFromCollectionProvider(IRI feedIri, RequestContext request) throws ResponseContextException {
+  protected Entry getEntryFromCollectionProvider(RequestContext request) throws ResponseContextException {
     String id = getEntryID(request);
     T entryObj = getEntry(id, request);
 
@@ -437,6 +436,7 @@
       return null;
     }
 
+    IRI feedIri = new IRI(getFeedIriForEntry(entryObj, request));
     return getEntryFromCollectionProvider(entryObj, feedIri, request);
   }
 

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java?rev=617211&r1=617210&r2=617211&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RouteManager.java Thu Jan 31 12:18:41 2008
@@ -121,17 +121,31 @@
       return new RouteTarget(type, context, route, uri);
   }
   
+  @SuppressWarnings("unchecked")
   public String urlFor(
     RequestContext context, 
     Object key, 
     Object param) {
       Route route = routes.get(key);
-//      return route != null ?
-//        route.expand(TemplateTargetBuilder.getContext(context,param)) :
-//        null;
-      return route != null ?
-        route.expand(getContext(param)) :
-        null;
+    // return route != null ?
+    // route.expand(TemplateTargetBuilder.getContext(context,param)) :
+    // null;
+    if (route != null) {
+      if (param instanceof Map) {
+        Map<String, Object> map = (Map<String, Object>)param;
+        for (String var : route.getVariables()) {
+          Object value = context.getTarget().getParameter(var);
+          if (!map.containsKey(var) && value != null) {
+            map.put(var, value);
+          }
+        }
+        return route.expand(getContext(map));
+      } else {
+        return route.expand(getContext(param));
+      }
+    } else {
+      return null;
+    }
   }
   
   @SuppressWarnings("unchecked")

Modified: incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java?rev=617211&r1=617210&r2=617211&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java (original)
+++ incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/protocol/server/test/customer/CustomerAdapterTest.java Thu Jan 31 12:18:41 2008
@@ -58,7 +58,7 @@
   
   @Test
   public void testCustomerProviderWithDifferentBase() throws Exception {
-    setupAbdera("/base/");
+    setupAbdera("/:base/");
     
     runTests("/base/");
   }