mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-28 22:54:12 +01:00
Log REST/JSON calls (config: 'log_rest_service' => true ; stored as EventRestService)
SVN:trunk[3688]
This commit is contained in:
@@ -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\')',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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
|
||||
//
|
||||
|
||||
@@ -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~~',
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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~~',
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
@@ -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' => 'ログイン',
|
||||
|
||||
@@ -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~~',
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
@@ -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~~',
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
@@ -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~~',
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
@@ -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~~',
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
@@ -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~~',
|
||||
));
|
||||
|
||||
//
|
||||
|
||||
@@ -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();
|
||||
?>
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user