From aa27694514363589150efe13249ce9ea39694d63 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Tue, 5 Jan 2010 10:09:07 +0000 Subject: 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. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@895970 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/server/mod-eval.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'sca-cpp/trunk/modules/server/mod-eval.cpp') diff --git a/sca-cpp/trunk/modules/server/mod-eval.cpp b/sca-cpp/trunk/modules/server/mod-eval.cpp index c5e71e108c..dbfe8b6221 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.cpp +++ b/sca-cpp/trunk/modules/server/mod-eval.cpp @@ -111,7 +111,7 @@ const failable get(request_rec* r, const lambda&)>& 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 path(httpd::pathValues(r->uri)); if (isNil(cddr(path))) { const failable val = failableResult(impl(cons("getall", list()))); @@ -120,7 +120,7 @@ const failable get(request_rec* r, const lambda&)>& 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 val = failableResult(impl(cons("get", mklist(caddr(path))))); if (!hasContent(val)) return mkfailure(reason(val)); @@ -156,7 +156,7 @@ const failable post(request_rec* r, const lambda&)> 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 @@ const failable put(request_rec* r, const lambda&)>& 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 path(httpd::pathValues(r->uri)); const value entry = atom::entryValue(content(atom::readEntry(ls))); const failable val = failableResult(impl(cons("put", mklist(caddr(path), entry)))); @@ -201,6 +201,18 @@ const failable del(request_rec* r, const lambda&)>& // Evaluate an ATOM delete request const list path(httpd::pathValues(r->uri)); + if (isNil(cddr(path))) { + + // Delete a collection of resources + const failable val = failableResult(impl(cons("deleteall", list()))); + if (!hasContent(val)) + return mkfailure(reason(val)); + if (val == value(false)) + return HTTP_NOT_FOUND; + return OK; + } + + // Delete a resource const failable val = failableResult(impl(cons("delete", mklist(caddr(path))))); if (!hasContent(val)) return mkfailure(reason(val)); -- cgit v1.2.3