tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r895970 - in /tuscany/sca-cpp/trunk: modules/server/mod-eval.cpp test/store-script/shopping-cart.scm test/store-script/store-script-test.cpp test/store-script/store-script-test.scm test/store-script/store-script.scm test/store-script/store.scm
Date Tue, 05 Jan 2010 10:09:28 GMT
Author: jsdelfino
Date: Tue Jan  5 10:09:07 2010
New Revision: 895970

URL: http://svn.apache.org/viewvc?rev=895970&view=rev
Log:
Fixed shopping cart delete function. Map HTTP delete with no path info to a deleteall function,
to distinguish delete of a resource and delete of the whole collection of resources.

Added:
    tuscany/sca-cpp/trunk/test/store-script/store-script-test.scm
      - copied, changed from r895959, tuscany/sca-cpp/trunk/test/store-script/store-script.scm
Removed:
    tuscany/sca-cpp/trunk/test/store-script/store-script.scm
Modified:
    tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp
    tuscany/sca-cpp/trunk/test/store-script/shopping-cart.scm
    tuscany/sca-cpp/trunk/test/store-script/store-script-test.cpp
    tuscany/sca-cpp/trunk/test/store-script/store.scm

Modified: tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp?rev=895970&r1=895969&r2=895970&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/mod-eval.cpp Tue Jan  5 10:09:07 2010
@@ -111,7 +111,7 @@
         return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc",
r);
     }
 
-    // Evaluate an ATOM GET request and return an ATOM feed
+    // Evaluate an ATOM GET request and return an ATOM feed representing a collection of
resources
     const list<value> path(httpd::pathValues(r->uri));
     if (isNil(cddr(path))) {
         const failable<value> val = failableResult(impl(cons<value>("getall",
list<value>())));
@@ -120,7 +120,7 @@
         return httpd::writeResult(atom::writeATOMFeed(atom::feedValuesToElements(content(val))),
"application/atom+xml;type=feed", r);
     }
 
-    // Evaluate an ATOM GET and return an ATOM entry
+    // Evaluate an ATOM GET and return an ATOM entry representing a resource
     const failable<value> val = failableResult(impl(cons<value>("get", mklist<value>(caddr(path)))));
     if (!hasContent(val))
         return mkfailure<int>(reason(val));
@@ -156,7 +156,7 @@
         return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc",
r);
     }
 
-    // Evaluate an ATOM POST request and return the created resource location
+    // Evaluate an ATOM POST request and return the location of the corresponding created
resource
     if (contains(ct, "application/atom+xml")) {
 
         // Evaluate the request expression
@@ -182,7 +182,7 @@
     debug(r->uri, "modeval::put::url");
     debug(ls, "modeval::put::input");
 
-    // Evaluate an ATOM PUT request
+    // Evaluate an ATOM PUT request and update the corresponding resource
     const list<value> path(httpd::pathValues(r->uri));
     const value entry = atom::entryValue(content(atom::readEntry(ls)));
     const failable<value> val = failableResult(impl(cons<value>("put", mklist<value>(caddr(path),
entry))));
@@ -201,6 +201,18 @@
 
     // Evaluate an ATOM delete request
     const list<value> path(httpd::pathValues(r->uri));
+    if (isNil(cddr(path))) {
+
+        // Delete a collection of resources
+        const failable<value> val = failableResult(impl(cons<value>("deleteall",
list<value>())));
+        if (!hasContent(val))
+            return mkfailure<int>(reason(val));
+        if (val == value(false))
+            return HTTP_NOT_FOUND;
+        return OK;
+    }
+
+    // Delete a resource
     const failable<value> val = failableResult(impl(cons<value>("delete", mklist<value>(caddr(path)))));
     if (!hasContent(val))
         return mkfailure<int>(reason(val));

Modified: tuscany/sca-cpp/trunk/test/store-script/shopping-cart.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/test/store-script/shopping-cart.scm?rev=895970&r1=895969&r2=895970&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/test/store-script/shopping-cart.scm (original)
+++ tuscany/sca-cpp/trunk/test/store-script/shopping-cart.scm Tue Jan  5 10:09:07 2010
@@ -39,11 +39,16 @@
   (find id (getcart cartId cache))
 )
 
-; Delete the cart
-(define (delete id cache)
+; Delete the whole cart
+(define (deleteall cache)
   (cache "delete" cartId)
 )
 
+; Delete an item from the  cart
+(define (delete id cache)
+  true
+)
+
 ; Return the price of an item
 (define (price item)
   (cadr (assoc 'price (caddr item)))

Modified: tuscany/sca-cpp/trunk/test/store-script/store-script-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/test/store-script/store-script-test.cpp?rev=895970&r1=895969&r2=895970&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/test/store-script/store-script-test.cpp (original)
+++ tuscany/sca-cpp/trunk/test/store-script/store-script-test.cpp Tue Jan  5 10:09:07 2010
@@ -39,7 +39,7 @@
 bool testScript() {
     gc_scoped_pool pool;
 
-    ifstream is("store-script.scm");
+    ifstream is("store-script-test.scm");
     ostringstream os;
     scheme::evalDriverRun(is, os, pool);
     assert(contains(str(os), "(\"Sample Feed\" \""));
@@ -52,7 +52,7 @@
 bool testEval() {
     {
         gc_scoped_pool pool;
-        ifstream is("store-script.scm");
+        ifstream is("store-script-test.scm");
         ostringstream os;
         scheme::setupDisplay(os);
         scheme::Env globalEnv = scheme::setupEnvironment(pool);
@@ -66,7 +66,7 @@
 
     {
         gc_scoped_pool pool;
-        ifstream is("store-script.scm");
+        ifstream is("store-script-test.scm");
         ostringstream os;
         scheme::setupDisplay(os);
 

Copied: tuscany/sca-cpp/trunk/test/store-script/store-script-test.scm (from r895959, tuscany/sca-cpp/trunk/test/store-script/store-script.scm)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/test/store-script/store-script-test.scm?p2=tuscany/sca-cpp/trunk/test/store-script/store-script-test.scm&p1=tuscany/sca-cpp/trunk/test/store-script/store-script.scm&r1=895959&r2=895970&rev=895970&view=diff
==============================================================================
    (empty)

Modified: tuscany/sca-cpp/trunk/test/store-script/store.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/test/store-script/store.scm?rev=895970&r1=895969&r2=895970&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/test/store-script/store.scm (original)
+++ tuscany/sca-cpp/trunk/test/store-script/store.scm Tue Jan  5 10:09:07 2010
@@ -20,6 +20,10 @@
   (shoppingCart "gettotal")
 )
 
+(define (deleteall catalog shoppingCart shoppingTotal)
+  (shoppingCart "deleteall")
+)
+
 (define (delete id catalog shoppingCart shoppingTotal)
   (shoppingCart "delete" id)
 )



Mime
View raw message