r20364: SWAT updates, part 1
[kai/samba.git] / services / request.esp
index 1cd22a71a84af06bd456be4e8d728bee6ca190e8..970ea6b4fb759ad57c924e6109f662d401273556 100644 (file)
@@ -13,6 +13,7 @@
  * This is a simple JSON-RPC server.
  */
 
+
 /* Bring in the json format/parse functions */
 jsonrpc_include("json.esp");
 
@@ -46,7 +47,6 @@ jsonrpc.Constant.ErrorOrigin = new Object(); /* error origins */
 jsonrpc.Constant.ErrorCode = new Object();   /* server-generated error codes */
 jsonrpc.method = new Object();       /* methods available in requested class */
 
-
 /*
  * ScriptTransport constants
  */
@@ -108,14 +108,17 @@ jsonrpc.Constant.ErrorCode.ClassNotFound         = 3; // not used in this implem
  */
 jsonrpc.Constant.ErrorCode.MethodNotFound        = 4;
 
-/**
+/*
  * Error code, value 5: Parameter Mismatch
  *
  * If a method discovers that the parameters (arguments) provided to it do not
  * match the requisite types for the method's parameters, it should return
  * this error code to indicate so to the caller.
+ *
+ * This error is also used to indicate an illegal parameter value, in server
+ * scripts.
  */
-jsonrpc.Constant.ErrorCode.PaameterMismatch      = 5;
+jsonrpc.Constant.ErrorCode.ParameterMismatch     = 5;
 
 /**
  * Error code, value 6: Permission Denied
@@ -136,7 +139,13 @@ jsonrpc.Constant.ErrorCode.PermissionDenied      = 6;
  */
 jsonrpc.Constant.ErrorCode.UnexpectedOutput      = 7;
 
-
+/*
+ * Error code, value 8: Resource Error
+ *
+ * Too many resources were requested, a system limitation on the total number
+ * of resources has been reached, or a resource or resource id was misused.
+ */
+jsonrpc.Constant.ErrorCode.ResourceError         = 8;
 
 
 
@@ -328,7 +337,7 @@ var nameFirstLetter =
 if (strspn(jsonInput.method, nameChars) != strlen(jsonInput.method))
 {
     /* There's some illegal character in the service name */
-    error.setError(JsonRpcError.MethodNotFound,
+    error.setError(jsonrpc.Constant.ErrorCode.MethodNotFound,
                    "Illegal character found in method name.");
     error.Send();
     return;
@@ -355,7 +364,7 @@ if (strspn(substr(jsonInput.method, 0, 1), nameFirstLetter) != 1)
 if (strspn(jsonInput.service, "." + nameChars) != strlen(jsonInput.service))
 {
     /* There's some illegal character in the service name */
-    error.setError(JsonRpcError.IllegalService,
+    error.setError(jsonrpc.Constant.ErrorCode.IllegalService,
                    "Illegal character found in service name.");
     error.Send();
     return;
@@ -370,7 +379,7 @@ if (strspn(jsonInput.service, "." + nameChars) != strlen(jsonInput.service))
  */
 if (typeof(strstr(jsonInput.service, "..")) != "pointer")
 {
-    error.setError(JsonRpcError.IllegalService,
+    error.setError(jsonrpc.Constant.ErrorCode.IllegalService,
                    "Illegal use of two consecutive dots in service name");
     error.Send();
     return;
@@ -447,7 +456,7 @@ if (! valid)
 }
 
 /* Ensure the logged-in user is allowed to issue the requested method */
-if (! json_authenticate(serviceComponents, method))
+if (! json_authenticate(serviceComponents, jsonInput.method))
 {
     error.setError(jsonrpc.Constant.ErrorCode.PermissionDenied,
                    "Permission denied");