Code

Added error handling to rpc class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 May 2010 15:27:35 +0000 (15:27 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 May 2010 15:27:35 +0000 (15:27 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18794 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_core.inc
gosa-core/include/class_jsonRPC.inc
gosa-core/include/functions.inc
gosa-core/include/utils/class_msgPool.inc

index ed8df7830981ece3efe8c4fb379e4f526e43091c..48bce63ac931e88b35dae4981eb9421cb9738d99 100644 (file)
@@ -570,8 +570,8 @@ DEBUG_SI      = 256"),
                         array(
                                 "name"          => "gosaRpcServer",
                                 "type"          => "string",
-                                "default"       => "http://localhost:8080/rpc",
-                                "description"   => "Ther server to use for RPC connections! Future GOsa-ng service!",
+                                "default"       => "",
+                                "description"   => "The server to use for RPC connections! (http://localhost:8080/rpc), Future GOsa-ng service! If this value is set and not empty GOsa will try to establish a connection!",
                                 "check"         => "",
                                 "migrate"       => "",
                                 "group"         => "rpc",
index eae33f9bd4ff6553f7b0157e18d1b68f598fa385..5058c59a723aa46f05bbdf227d52314ce135b763 100644 (file)
@@ -23,6 +23,16 @@ class jsonRPC {
         curl_setopt($this->curlHandler, CURLOPT_HTTPHEADER , array('Content-Type: application/json'));
     }
 
+    public function get_error()
+    {
+        return(curl_error($this->curlHandler));
+    }
+
+    public function success()
+    {
+        return(curl_errno($this->curlHandler) == 0);
+    }
+
     public function __destruct()
     {
         curl_close($this->curlHandler);
@@ -30,7 +40,6 @@ class jsonRPC {
 
     public function __call($method,$params) 
     {
-
         if (!is_scalar($method))  trigger_error('jsonRPC::__call requires a scalar value as first parameter!');
 
         if (is_array($params)) {
@@ -50,8 +59,8 @@ class jsonRPC {
 
         // Check responce id
         if ($response['id'] != $this->id){
-            trigger_error('jsonPRC returned incorrect response '.
-                    'id (request id: '.$this->id.', response id: '.$response['id'].')');
+            #trigger_error('jsonPRC returned incorrect response '.
+            #        'id (request id: '.$this->id.', response id: '.$response['id'].')');
         }
         return($response['result']);
     }
index 53bdee5f7a321fd3f110fdf0690c71a6d120d516..198d3ddea026f1a131bf152dcd9e74ced67dd9ef 100644 (file)
@@ -3041,6 +3041,10 @@ function generate_smb_nt_hash($password)
 
     $rpc = $config->getRpcHandle();
     $hash = $rpc->mksmbhash($password);
+    if(!$rpc->success()){
+        msg_dialog::display(_("Error"),msgPool::rpcError($rpc->get_error()),ERROR_DIALOG);
+        return("");
+    }
 
   }elseif ($config->get_cfg_value("core","gosaSupportURI") != ""){
 
index 559c7156b7bc3162b21025c2b1ef558e7c914ef9..efd47aa0bc63c90ec9a69afa2feba0f2b025f825 100644 (file)
@@ -481,6 +481,15 @@ class msgPool
   }
 
 
+  public static function rpcError($error= "")
+  {
+    if ($error == ""){
+      return _("Communication failure with the GOSA-NG service!");
+    }
+    return sprintf(_("Communication failure with the GOSA-NG service: %s"), "<br><br>".$error);
+  }
+
+
   public static function stillInUse($type, $objects= array())
   {
     if (!is_array($objects)){