From: hickert Date: Fri, 28 May 2010 15:27:35 +0000 (+0000) Subject: Added error handling to rpc class X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ab8f38ea4462ffd85252ccb17f47a12da6e780a8;p=gosa.git Added error handling to rpc class git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18794 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_core.inc b/gosa-core/include/class_core.inc index ed8df7830..48bce63ac 100644 --- a/gosa-core/include/class_core.inc +++ b/gosa-core/include/class_core.inc @@ -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", diff --git a/gosa-core/include/class_jsonRPC.inc b/gosa-core/include/class_jsonRPC.inc index eae33f9bd..5058c59a7 100644 --- a/gosa-core/include/class_jsonRPC.inc +++ b/gosa-core/include/class_jsonRPC.inc @@ -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']); } diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 53bdee5f7..198d3ddea 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -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") != ""){ diff --git a/gosa-core/include/utils/class_msgPool.inc b/gosa-core/include/utils/class_msgPool.inc index 559c7156b..efd47aa0b 100644 --- a/gosa-core/include/utils/class_msgPool.inc +++ b/gosa-core/include/utils/class_msgPool.inc @@ -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"), "

".$error); + } + + public static function stillInUse($type, $objects= array()) { if (!is_array($objects)){