Author: keith
Date: Mon Dec 10 02:33:57 2007
New Revision: 10818
Log:
Adding restsample
Added:
trunk/mashup/java/modules/samples/RESTSample/
trunk/mashup/java/modules/samples/RESTSample/RESTSample.js
Added: trunk/mashup/java/modules/samples/RESTSample/RESTSample.js
==============================================================================
--- (empty file)
+++ trunk/mashup/java/modules/samples/RESTSample/RESTSample.js Mon Dec 10
02:33:57 2007
@@ -0,0 +1,53 @@
+this.scope="application";
+
+getWeather.httpMethod = "GET";
+getWeather.httpLocation = "weather/{city}";
+getWeather.inputTypes = "string";
+getWeather.outputType = "string";
+function getWeather(city){
+var details = session.get(city);
+if (details == null) {
+ throw ("Cannot find weather details of city " + city + ".")
+}
+return details;
+}
+
+POSTWeather.httpMethod = "POST";
+POSTWeather.httpLocation = "weather/{city}";
+POSTWeather.inputTypes = {"city" : "string",
+"weatherDetails" : "string"};
+POSTWeather.outputType = "string";
+function POSTWeather(city, weatherDetails){
+var details = session.get(city);
+if (details != null) {
+ throw ("Weather details of city " + city + " already exists.")
+}
+session.put(city ,weatherDetails);
+return city;
+}
+
+DeleteWeather.httpMethod = "DELETE";
+DeleteWeather.httpLocation = "weather/{city}";
+DeleteWeather.inputTypes = "string";
+DeleteWeather.outputType = "string";
+function DeleteWeather(city){
+if (details == null) {
+ throw ("Cannot find weather details of city " + city + " to update.")
+}
+session.put(city ,"removed");
+return city;
+}
+
+PUTWeather.httpMethod = "GET";
+PUTWeather.httpLocation = "weather/{city}";
+PUTWeather.inputTypes = {"city" : "string",
+"weatherDetails" : "string"};
+PUTWeather.outputType = "string";
+function PUTWeather(city, weatherDetails){
+var details = session.get(city);
+if (details == null) {
+ throw ("Cannot find weather details of city " + city + " to update.")
+}
+session.put(city ,weatherDetails);
+return city;
+}
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev