diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 5b27840e0..11c560e22 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -277,6 +277,14 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ), + 'log_rest_service' => array( + 'type' => 'bool', + 'description' => 'Log the usage of the REST/JSON service', + 'default' => false, + 'value' => false, + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ), 'synchro_trace' => array( 'type' => 'string', 'description' => 'Synchronization details: none, display, save (includes \'display\')', diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 2cbcbc63a..788ed15d8 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -423,6 +423,17 @@ abstract class DBObject implements iDisplay return true; } + public function SetTrim($sAttCode, $sValue) + { + $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode); + $iMaxSize = $oAttDef->GetMaxSize(); + if ($iMaxSize && (strlen($sValue) > $iMaxSize)) + { + $sValue = substr($sValue, 0, $iMaxSize); + } + $this->Set($sAttCode, $sValue); + } + public function GetLabel($sAttCode) { $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode); diff --git a/core/event.class.inc.php b/core/event.class.inc.php index 66d904418..97d7d19c9 100644 --- a/core/event.class.inc.php +++ b/core/event.class.inc.php @@ -332,6 +332,42 @@ class EventWebService extends Event } } +class EventRestService extends Event +{ + public static function Init() + { + $aParams = array + ( + "category" => "core/cmdb,view_in_gui", + "key_type" => "autoincrement", + "name_attcode" => "", + "state_attcode" => "", + "reconc_keys" => array(), + "db_table" => "priv_event_restservice", + "db_key_field" => "id", + "db_finalclass_field" => "", + "display_template" => "", + "order_by_default" => array('date' => false) + ); + MetaModel::Init_Params($aParams); + MetaModel::Init_InheritAttributes(); + MetaModel::Init_AddAttribute(new AttributeString("operation", array("allowed_values"=>null, "sql"=>"operation", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("version", array("allowed_values"=>null, "sql"=>"version", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeText("json_input", array("allowed_values"=>null, "sql"=>"json_input", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array()))); + + MetaModel::Init_AddAttribute(new AttributeInteger("code", array("allowed_values"=>null, "sql"=>"code", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeText("json_output", array("allowed_values"=>null, "sql"=>"json_output", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array()))); + MetaModel::Init_AddAttribute(new AttributeString("provider", array("allowed_values"=>null, "sql"=>"provider", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array()))); + + // Display lists + MetaModel::Init_SetZListItems('details', array('date', 'userinfo', 'operation', 'version', 'json_input', 'message', 'code', 'json_output', 'provider')); // Attributes to be displayed for the complete details + MetaModel::Init_SetZListItems('list', array('date', 'userinfo', 'operation', 'message')); // Attributes to be displayed for a list + // Search criteria +// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form +// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form + } +} + class EventLoginUsage extends Event { public static function Init() diff --git a/dictionaries/da.dictionary.itop.core.php b/dictionaries/da.dictionary.itop.core.php index 98daf39cd..027730d21 100644 --- a/dictionaries/da.dictionary.itop.core.php +++ b/dictionaries/da.dictionary.itop.core.php @@ -1255,6 +1255,20 @@ Dict::Add('DA DA', 'Danish', 'Dansk', array( 'Class:EventWebService/Attribute:log_error+' => '', 'Class:EventWebService/Attribute:data' => 'Data', 'Class:EventWebService/Attribute:data+' => '', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', 'Class:EventLoginUsage' => 'Login Usage', 'Class:EventLoginUsage+' => '', 'Class:EventLoginUsage/Attribute:user_id' => 'Login', diff --git a/dictionaries/de.dictionary.itop.core.php b/dictionaries/de.dictionary.itop.core.php index b12660f4e..64030ac2b 100644 --- a/dictionaries/de.dictionary.itop.core.php +++ b/dictionaries/de.dictionary.itop.core.php @@ -181,6 +181,20 @@ Dict::Add('DE DE', 'German', 'Deutsch', array( 'Class:EventWebService/Attribute:log_error+' => 'Ergebnis der Fehler-Protokollierung', 'Class:EventWebService/Attribute:data' => 'Daten', 'Class:EventWebService/Attribute:data+' => 'Ergebnisdaten', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', 'Class:EventLoginUsage' => 'Login Verwendung', 'Class:EventLoginUsage+' => '', 'Class:EventLoginUsage/Attribute:user_id' => 'Login', diff --git a/dictionaries/dictionary.itop.core.php b/dictionaries/dictionary.itop.core.php index cbbd27981..b5b2cf35b 100644 --- a/dictionaries/dictionary.itop.core.php +++ b/dictionaries/dictionary.itop.core.php @@ -376,6 +376,23 @@ Dict::Add('EN US', 'English', 'English', array( 'Class:EventWebService/Attribute:data+' => 'Result data', )); +Dict::Add('EN US', 'English', 'English', array( + 'Class:EventRestService' => 'REST/JSON call', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call', + 'Class:EventRestService/Attribute:operation' => 'Operation', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'', + 'Class:EventRestService/Attribute:version' => 'Version', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'', + 'Class:EventRestService/Attribute:json_input' => 'Input', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'', + 'Class:EventRestService/Attribute:code' => 'Code', + 'Class:EventRestService/Attribute:code+' => 'Result code', + 'Class:EventRestService/Attribute:json_output' => 'Response', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)', + 'Class:EventRestService/Attribute:provider' => 'Provider', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation', +)); + // // Class: EventLoginUsage // diff --git a/dictionaries/es_cr.dictionary.itop.core.php b/dictionaries/es_cr.dictionary.itop.core.php index fd72113f9..7d5466498 100644 --- a/dictionaries/es_cr.dictionary.itop.core.php +++ b/dictionaries/es_cr.dictionary.itop.core.php @@ -355,7 +355,7 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array( )); // -// Class: EventWebService +// Classes: EventWebService and EventRestService // Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array( @@ -373,6 +373,20 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array( 'Class:EventWebService/Attribute:log_error+' => 'Bitácora de Error de Resultado', 'Class:EventWebService/Attribute:data' => 'Datos', 'Class:EventWebService/Attribute:data+' => 'Datos de Resultado', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', )); // diff --git a/dictionaries/fr.dictionary.itop.core.php b/dictionaries/fr.dictionary.itop.core.php index 61bf731b9..cbacfb53f 100644 --- a/dictionaries/fr.dictionary.itop.core.php +++ b/dictionaries/fr.dictionary.itop.core.php @@ -201,6 +201,20 @@ Dict::Add('FR FR', 'French', 'Français', array( 'Class:EventWebService/Attribute:log_error+' => '', 'Class:EventWebService/Attribute:data' => 'Données', 'Class:EventWebService/Attribute:data+' => '', + 'Class:EventRestService' => 'Appel REST/JSON', + 'Class:EventRestService+' => 'Trace de l\'appel au service REST/JSON (rest.php)', + 'Class:EventRestService/Attribute:operation' => 'Opération', + 'Class:EventRestService/Attribute:operation+' => 'Paramètre \'opération\'', + 'Class:EventRestService/Attribute:version' => 'Version', + 'Class:EventRestService/Attribute:version+' => 'Paramètre \'version\'', + 'Class:EventRestService/Attribute:json_input' => 'Données d\'entrée', + 'Class:EventRestService/Attribute:json_input+' => 'Paramètre \'json_data\'', + 'Class:EventRestService/Attribute:code' => 'Code', + 'Class:EventRestService/Attribute:code+' => 'Code de retour', + 'Class:EventRestService/Attribute:json_output' => 'Réponse', + 'Class:EventRestService/Attribute:json_output+' => 'Réponse HTTP (structure json)', + 'Class:EventRestService/Attribute:provider' => 'Fournisseur', + 'Class:EventRestService/Attribute:provider+' => 'Classe PHP qui a pris en charge l\'opération demandée', 'Class:EventLoginUsage' => 'Utilisation de l\'application', 'Class:EventLoginUsage+' => '', 'Class:EventLoginUsage/Attribute:user_id' => 'Login', diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index 8061995b7..73ea15e49 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -359,7 +359,7 @@ Dict::Add('FR FR', 'French', 'Français', array( 'UI:Login:PasswordPrompt' => 'Mot de passe', 'UI:Login:ForgotPwd' => 'Mot de passe oublié ?', 'UI:Login:ForgotPwdForm' => 'Mot de passe oublié', - 'UI:Login:ForgotPwdForm+' => 'Vous pouvez demander à saisir d\'un nouveau mot de passe. Vous allez recevoir un email et vous pourrez suivre les instructions.', + 'UI:Login:ForgotPwdForm+' => 'Vous pouvez demander à saisir un nouveau mot de passe. Vous allez recevoir un email et vous pourrez suivre les instructions.', 'UI:Login:ResetPassword' => 'Envoyer le message', 'UI:Login:ResetPwdFailed' => 'Impossible de vous faire parvenir le message: %1$s', diff --git a/dictionaries/hu.dictionary.itop.core.php b/dictionaries/hu.dictionary.itop.core.php index 065258be8..5fc3c4128 100755 --- a/dictionaries/hu.dictionary.itop.core.php +++ b/dictionaries/hu.dictionary.itop.core.php @@ -173,6 +173,20 @@ Dict::Add('HU HU', 'Hungarian', 'Magyar', array( 'Class:EventWebService/Attribute:log_error+' => '', 'Class:EventWebService/Attribute:data' => 'Adat', 'Class:EventWebService/Attribute:data+' => '', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', 'Class:EventLoginUsage' => 'Belépés esemény', 'Class:EventLoginUsage+' => '', 'Class:EventLoginUsage/Attribute:user_id' => 'Felhasználó név', diff --git a/dictionaries/it.dictionary.itop.core.php b/dictionaries/it.dictionary.itop.core.php index b0c922d1c..2f13578f1 100644 --- a/dictionaries/it.dictionary.itop.core.php +++ b/dictionaries/it.dictionary.itop.core.php @@ -342,7 +342,7 @@ Dict::Add('IT IT', 'Italian', 'Italiano', array( )); // -// Class: EventWebService +// Classes: EventWebService and EventWebService // Dict::Add('IT IT', 'Italian', 'Italiano', array( @@ -360,6 +360,20 @@ Dict::Add('IT IT', 'Italian', 'Italiano', array( 'Class:EventWebService/Attribute:log_error+' => 'Risultati error log', 'Class:EventWebService/Attribute:data' => 'Dati', 'Class:EventWebService/Attribute:data+' => 'Risultati dei dati', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', )); // diff --git a/dictionaries/ja.dictionary.itop.core.php b/dictionaries/ja.dictionary.itop.core.php index abbbce5c8..601223198 100644 --- a/dictionaries/ja.dictionary.itop.core.php +++ b/dictionaries/ja.dictionary.itop.core.php @@ -183,6 +183,20 @@ Dict::Add('JA JP', 'Japanese', '日本語', array( 'Class:EventWebService/Attribute:log_error+' => 'エラーログ結果', 'Class:EventWebService/Attribute:data' => 'データ', 'Class:EventWebService/Attribute:data+' => '結果データ', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', 'Class:EventLoginUsage' => 'ログイン方法', 'Class:EventLoginUsage+' => 'アプリケーションへ接続します。', 'Class:EventLoginUsage/Attribute:user_id' => 'ログイン', diff --git a/dictionaries/nl.dictionary.itop.core.php b/dictionaries/nl.dictionary.itop.core.php index 08dfeb1b4..41cc79453 100644 --- a/dictionaries/nl.dictionary.itop.core.php +++ b/dictionaries/nl.dictionary.itop.core.php @@ -362,7 +362,7 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', array( )); // -// Class: EventWebService +// Classes: EventWebService and EventRestService // Dict::Add('NL NL', 'Dutch', 'Nederlands', array( @@ -380,6 +380,20 @@ Dict::Add('NL NL', 'Dutch', 'Nederlands', array( 'Class:EventWebService/Attribute:log_error+' => 'Resultaat errorlog', 'Class:EventWebService/Attribute:data' => 'Data', 'Class:EventWebService/Attribute:data+' => 'Result data', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', )); // diff --git a/dictionaries/pt_br.dictionary.itop.core.php b/dictionaries/pt_br.dictionary.itop.core.php index 9b5bedcc7..28554c32c 100644 --- a/dictionaries/pt_br.dictionary.itop.core.php +++ b/dictionaries/pt_br.dictionary.itop.core.php @@ -356,7 +356,7 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', array( )); // -// Class: EventWebService +// Classes: EventWebService and EventRestService // Dict::Add('PT BR', 'Brazilian', 'Brazilian', array( @@ -374,6 +374,20 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', array( 'Class:EventWebService/Attribute:log_error+' => 'Resultado log de erro', 'Class:EventWebService/Attribute:data' => 'Dado', 'Class:EventWebService/Attribute:data+' => 'Resultado dado', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', )); // diff --git a/dictionaries/ru.dictionary.itop.core.php b/dictionaries/ru.dictionary.itop.core.php index af52b2356..8d9a4a020 100644 --- a/dictionaries/ru.dictionary.itop.core.php +++ b/dictionaries/ru.dictionary.itop.core.php @@ -351,7 +351,7 @@ Dict::Add('RU RU', 'Russian', 'Русский', array( )); // -// Class: EventWebService +// Classes: EventWebService and EventRestService // Dict::Add('RU RU', 'Russian', 'Русский', array( @@ -369,6 +369,20 @@ Dict::Add('RU RU', 'Russian', 'Русский', array( 'Class:EventWebService/Attribute:log_error+' => 'Результаты логов ошибок', 'Class:EventWebService/Attribute:data' => 'Данные', 'Class:EventWebService/Attribute:data+' => 'Результаты данных', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', )); // diff --git a/dictionaries/tr.dictionary.itop.core.php b/dictionaries/tr.dictionary.itop.core.php index 0d4a65ea4..ce8bc059f 100644 --- a/dictionaries/tr.dictionary.itop.core.php +++ b/dictionaries/tr.dictionary.itop.core.php @@ -217,7 +217,7 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', array( )); // -// Class: EventWebService +// Classes: EventWebService and EventRestService // Dict::Add('TR TR', 'Turkish', 'Türkçe', array( @@ -235,6 +235,20 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', array( 'Class:EventWebService/Attribute:log_error+' => 'Sonuç hata kaydı', 'Class:EventWebService/Attribute:data' => 'Veri', 'Class:EventWebService/Attribute:data+' => 'Sonuç veri', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', )); // diff --git a/dictionaries/zh.dictionary.itop.core.php b/dictionaries/zh.dictionary.itop.core.php index e0ae453f8..d07e4a21f 100644 --- a/dictionaries/zh.dictionary.itop.core.php +++ b/dictionaries/zh.dictionary.itop.core.php @@ -216,7 +216,7 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', array( )); // -// Class: EventWebService +// Classes: EventWebService and EventRestService // Dict::Add('ZH CN', 'Chinese', '简体中文', array( @@ -234,6 +234,20 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', array( 'Class:EventWebService/Attribute:log_error+' => '结果错误记录', 'Class:EventWebService/Attribute:data' => '数据', 'Class:EventWebService/Attribute:data+' => '结果数据', + 'Class:EventRestService' => 'REST/JSON call~~', + 'Class:EventRestService+' => 'Trace of a REST/JSON service call~~', + 'Class:EventRestService/Attribute:operation' => 'Operation~~', + 'Class:EventRestService/Attribute:operation+' => 'Argument \'operation\'~~', + 'Class:EventRestService/Attribute:version' => 'Version~~', + 'Class:EventRestService/Attribute:version+' => 'Argument \'version\'~~', + 'Class:EventRestService/Attribute:json_input' => 'Input~~', + 'Class:EventRestService/Attribute:json_input+' => 'Argument \'json_data\'~~', + 'Class:EventRestService/Attribute:code' => 'Code~~', + 'Class:EventRestService/Attribute:code+' => 'Result code~~', + 'Class:EventRestService/Attribute:json_output' => 'Response~~', + 'Class:EventRestService/Attribute:json_output+' => 'HTTP response (json)~~', + 'Class:EventRestService/Attribute:provider' => 'Provider~~', + 'Class:EventRestService/Attribute:provider+' => 'PHP class implementing the expected operation~~', )); // diff --git a/webservices/rest.php b/webservices/rest.php index b6b688c24..649b2972a 100644 --- a/webservices/rest.php +++ b/webservices/rest.php @@ -92,6 +92,10 @@ class RestResultListOperations extends RestResult // $oP = new ajax_page('rest'); +$sVersion = utils::ReadParam('version', null, false, 'raw_data'); +$sOperation = utils::ReadParam('operation', null); +$sJsonString = utils::ReadParam('json_data', null, false, 'raw_data'); +$sProvider = ''; try { utils::UseParamFile(); @@ -122,13 +126,11 @@ try } } - $sVersion = utils::ReadParam('version', null, false, 'raw_data'); if ($sVersion == null) { throw new Exception("Missing parameter 'version' (e.g. '1.0')", RestResult::MISSING_VERSION); } - $sJsonString = utils::ReadParam('json_data', null, false, 'raw_data'); if ($sJsonString == null) { throw new Exception("Missing parameter 'json_data", RestResult::MISSING_JSON); @@ -188,6 +190,7 @@ try throw new Exception("Unknown verb '$sOperation' in version '$sVersion'", RestResult::UNKNOWN_OPERATION); } $oRS = $aOpToRestService[$sOperation]['service_provider']; + $sProvider = get_class($oRS); CMDBObject::SetTrackOrigin('webservice-rest'); $oResult = $oRS->ExecOperation($sVersion, $sOperation, $aJsonData); @@ -209,18 +212,42 @@ catch(Exception $e) // Output the results // +$sResponse = json_encode($oResult); + $oP->add_header('Access-Control-Allow-Origin: *'); $sCallback = utils::ReadParam('callback', null); if ($sCallback == null) { $oP->SetContentType('application/json'); - $oP->add(json_encode($oResult)); + $oP->add($sResponse); } else { $oP->SetContentType('application/javascript'); - $oP->add($sCallback.'('.json_encode($oResult).')'); + $oP->add($sCallback.'('.$sResponse.')'); } $oP->Output(); -?> \ No newline at end of file + +// Log usage +// +if (MetaModel::GetConfig()->Get('log_rest_service')) +{ + $oLog = new EventRestService(); + $oLog->SetTrim('userinfo', UserRights::GetUser()); + $oLog->Set('version', $sVersion); + $oLog->Set('operation', $sOperation); + $oLog->SetTrim('json_input', $sJsonString); + + $oLog->Set('provider', $sProvider); + $sMessage = $oResult->message; + if (empty($oResult->message)) + { + $sMessage = 'Ok'; + } + $oLog->SetTrim('message', $sMessage); + $oLog->Set('code', $oResult->code); + $oLog->SetTrim('json_output', $sResponse); + + $oLog->DBInsertNoReload(); +}