You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-08-10 22:41:43 +02:00
Main build (Jenkins)
This commit is contained in:
13112
service/dictionaries/en.json
vendored
13112
service/dictionaries/en.json
vendored
File diff suppressed because it is too large
Load Diff
@@ -53,19 +53,25 @@ Var OPIObject Export;
|
||||
Procedure MainHandler(Context, NexHandler) Export
|
||||
|
||||
Try
|
||||
ProcessRequest(Context);
|
||||
Result = ProcessRequest(Context);
|
||||
Except
|
||||
|
||||
Error = ErrorDescription();
|
||||
Error = BriefErrorDescription(ErrorInfo());
|
||||
|
||||
Context.Response.StatusCode = 500;
|
||||
Context.Response.WriteAsJson(New Structure("result,error", False, "OneScript exception: " + Error));
|
||||
|
||||
EndTry
|
||||
Result = New Structure("result,error", False, "OneScript exception: " + Error);
|
||||
|
||||
EndTry;
|
||||
|
||||
JSON = OPI_Tools.JSONString(Result);
|
||||
|
||||
Context.Response.ContentType = "application/json;charset=UTF8";
|
||||
Context.Response.Write(JSON);
|
||||
|
||||
EndProcedure
|
||||
|
||||
Procedure ProcessRequest(Context)
|
||||
Function ProcessRequest(Context)
|
||||
|
||||
Path = Context.Request.Path;
|
||||
|
||||
@@ -79,36 +85,39 @@ Procedure ProcessRequest(Context)
|
||||
Handler = HandlerDescription["data"];
|
||||
Handler = ?(TypeOf(Handler) = Type("Array"), Handler[0], Handler);
|
||||
|
||||
ExecuteProcessing(Context, Handler);
|
||||
Result = ExecuteProcessing(Context, Handler);
|
||||
|
||||
Else
|
||||
ProcessingError(Context, 404, "Handler not found!");
|
||||
Result = ProcessingError(Context, 404, "Handler not found!");
|
||||
EndIf;
|
||||
|
||||
EndProcedure
|
||||
Return Result;
|
||||
|
||||
EndFunction
|
||||
|
||||
#EndRegion
|
||||
|
||||
#Region Private
|
||||
|
||||
Procedure ExecuteProcessing(Context, Handler)
|
||||
Function ExecuteProcessing(Context, Handler)
|
||||
|
||||
Method = Upper(Context.Request.Method);
|
||||
|
||||
If Not Method = Upper(Handler["method"]) Then
|
||||
ProcessingError(Context, 405, "Method not allowed for this handler");
|
||||
Return;
|
||||
Return ProcessingError(Context, 405, "Method not allowed for this handler");
|
||||
EndIf;
|
||||
|
||||
If Method = "GET" Then
|
||||
ExecuteProcessingGet(Context, Handler);
|
||||
Result = ExecuteProcessingGet(Context, Handler);
|
||||
Else
|
||||
ProcessingError(Context, 405, "Method not allowed for this handler");
|
||||
Result = ProcessingError(Context, 405, "Method not allowed for this handler");
|
||||
EndIf;
|
||||
|
||||
EndProcedure
|
||||
Return Result;
|
||||
|
||||
Procedure ExecuteProcessingGet(Context, Handler)
|
||||
EndFunction
|
||||
|
||||
Function ExecuteProcessingGet(Context, Handler)
|
||||
|
||||
Request = Context.Request;
|
||||
Parameters = Request.Parameters;
|
||||
@@ -148,14 +157,14 @@ Procedure ExecuteProcessingGet(Context, Handler)
|
||||
ParametersBoiler.Insert(Argument.Key, Argument.Value);
|
||||
EndDo;
|
||||
|
||||
ExecuteUniversalProcessing(Context
|
||||
Return ExecuteUniversalProcessing(Context
|
||||
, Handler["library"]
|
||||
, Handler["function"]
|
||||
, ParametersBoiler);
|
||||
|
||||
EndProcedure
|
||||
EndFunction
|
||||
|
||||
Procedure ExecuteUniversalProcessing(Context, Command, Method, Parameters)
|
||||
Function ExecuteUniversalProcessing(Context, Command, Method, Parameters)
|
||||
|
||||
ExecutionStructure = OPIObject.FormMethodCallString(Parameters, Command, Method);
|
||||
|
||||
@@ -174,15 +183,16 @@ Procedure ExecuteUniversalProcessing(Context, Command, Method, Parameters)
|
||||
|
||||
EndIf;
|
||||
|
||||
Context.Response.WriteAsJson(Response);
|
||||
Return Response;
|
||||
|
||||
EndProcedure
|
||||
EndFunction
|
||||
|
||||
Procedure ProcessingError(Context, Code, Text)
|
||||
Function ProcessingError(Context, Code, Text)
|
||||
|
||||
Context.Response.StatusCode = Code;
|
||||
Context.Response.WriteAsJson(New Structure("result,error", False, Text));
|
||||
|
||||
EndProcedure
|
||||
Return New Structure("result,error", False, Text);
|
||||
|
||||
EndFunction
|
||||
|
||||
#EndRegion
|
||||
|
@@ -53,19 +53,25 @@ Var OPIObject Export;
|
||||
Procedure MainHandler(Context, NexHandler) Export
|
||||
|
||||
Try
|
||||
ProcessRequest(Context);
|
||||
Result = ProcessRequest(Context);
|
||||
Except
|
||||
|
||||
Error = ErrorDescription();
|
||||
Error = BriefErrorDescription(ErrorInfo());
|
||||
|
||||
Context.Response.StatusCode = 500;
|
||||
Context.Response.WriteAsJson(New Structure("result,error", False, "OneScript exception: " + Error));
|
||||
|
||||
EndTry
|
||||
Result = New Structure("result,error", False, "OneScript exception: " + Error);
|
||||
|
||||
EndTry;
|
||||
|
||||
JSON = OPI_Tools.JSONString(Result);
|
||||
|
||||
Context.Response.ContentType = "application/json;charset=UTF8";
|
||||
Context.Response.Write(JSON);
|
||||
|
||||
EndProcedure
|
||||
|
||||
Procedure ProcessRequest(Context)
|
||||
Function ProcessRequest(Context)
|
||||
|
||||
Path = Context.Request.Path;
|
||||
|
||||
@@ -79,36 +85,39 @@ Procedure ProcessRequest(Context)
|
||||
Handler = HandlerDescription["data"];
|
||||
Handler = ?(TypeOf(Handler) = Type("Array"), Handler[0], Handler);
|
||||
|
||||
ExecuteProcessing(Context, Handler);
|
||||
Result = ExecuteProcessing(Context, Handler);
|
||||
|
||||
Else
|
||||
ProcessingError(Context, 404, "Handler not found!");
|
||||
Result = ProcessingError(Context, 404, "Handler not found!");
|
||||
EndIf;
|
||||
|
||||
EndProcedure
|
||||
Return Result;
|
||||
|
||||
EndFunction
|
||||
|
||||
#EndRegion
|
||||
|
||||
#Region Private
|
||||
|
||||
Procedure ExecuteProcessing(Context, Handler)
|
||||
Function ExecuteProcessing(Context, Handler)
|
||||
|
||||
Method = Upper(Context.Request.Method);
|
||||
|
||||
If Not Method = Upper(Handler["method"]) Then
|
||||
ProcessingError(Context, 405, "Method not allowed for this handler");
|
||||
Return;
|
||||
Return ProcessingError(Context, 405, "Method not allowed for this handler");
|
||||
EndIf;
|
||||
|
||||
If Method = "GET" Then
|
||||
ExecuteProcessingGet(Context, Handler);
|
||||
Result = ExecuteProcessingGet(Context, Handler);
|
||||
Else
|
||||
ProcessingError(Context, 405, "Method not allowed for this handler");
|
||||
Result = ProcessingError(Context, 405, "Method not allowed for this handler");
|
||||
EndIf;
|
||||
|
||||
EndProcedure
|
||||
Return Result;
|
||||
|
||||
Procedure ExecuteProcessingGet(Context, Handler)
|
||||
EndFunction
|
||||
|
||||
Function ExecuteProcessingGet(Context, Handler)
|
||||
|
||||
Request = Context.Request;
|
||||
Parameters = Request.Parameters;
|
||||
@@ -148,14 +157,14 @@ Procedure ExecuteProcessingGet(Context, Handler)
|
||||
ParametersBoiler.Insert(Argument.Key, Argument.Value);
|
||||
EndDo;
|
||||
|
||||
ExecuteUniversalProcessing(Context
|
||||
Return ExecuteUniversalProcessing(Context
|
||||
, Handler["library"]
|
||||
, Handler["function"]
|
||||
, ParametersBoiler);
|
||||
|
||||
EndProcedure
|
||||
EndFunction
|
||||
|
||||
Procedure ExecuteUniversalProcessing(Context, Command, Method, Parameters)
|
||||
Function ExecuteUniversalProcessing(Context, Command, Method, Parameters)
|
||||
|
||||
ExecutionStructure = OPIObject.FormMethodCallString(Parameters, Command, Method);
|
||||
|
||||
@@ -174,15 +183,16 @@ Procedure ExecuteUniversalProcessing(Context, Command, Method, Parameters)
|
||||
|
||||
EndIf;
|
||||
|
||||
Context.Response.WriteAsJson(Response);
|
||||
Return Response;
|
||||
|
||||
EndProcedure
|
||||
EndFunction
|
||||
|
||||
Procedure ProcessingError(Context, Code, Text)
|
||||
Function ProcessingError(Context, Code, Text)
|
||||
|
||||
Context.Response.StatusCode = Code;
|
||||
Context.Response.WriteAsJson(New Structure("result,error", False, Text));
|
||||
|
||||
EndProcedure
|
||||
Return New Structure("result,error", False, Text);
|
||||
|
||||
EndFunction
|
||||
|
||||
#EndRegion
|
||||
|
@@ -53,19 +53,25 @@
|
||||
Процедура ОсновнаяОбработка(Контекст, СледующийОбработчик) Экспорт
|
||||
|
||||
Попытка
|
||||
ОбработатьЗапрос(Контекст);
|
||||
Результат = ОбработатьЗапрос(Контекст);
|
||||
Исключение
|
||||
|
||||
Ошибка = ОписаниеОшибки();
|
||||
Ошибка = КраткоеПредставлениеОшибки(ИнформацияОбОшибке());
|
||||
|
||||
Контекст.Ответ.КодСостояния = 500;
|
||||
Контекст.Ответ.ЗаписатьКакJson(Новый Структура("result,error", Ложь, "OneScript exception: " + Ошибка));
|
||||
|
||||
КонецПопытки
|
||||
Результат = Новый Структура("result,error", Ложь, "OneScript exception: " + Ошибка);
|
||||
|
||||
КонецПопытки;
|
||||
|
||||
JSON = OPI_Инструменты.JSONСтрокой(Результат);
|
||||
|
||||
Контекст.Ответ.ТипКонтента = "application/json;charset=UTF8";
|
||||
Контекст.Ответ.Записать(JSON);
|
||||
|
||||
КонецПроцедуры
|
||||
|
||||
Процедура ОбработатьЗапрос(Контекст)
|
||||
Функция ОбработатьЗапрос(Контекст)
|
||||
|
||||
Путь = Контекст.Запрос.Путь;
|
||||
|
||||
@@ -79,36 +85,39 @@
|
||||
Обработчик = ОписаниеОбработчика["data"];
|
||||
Обработчик = ?(ТипЗнч(Обработчик) = Тип("Массив"), Обработчик[0], Обработчик);
|
||||
|
||||
ВыполнитьОбработку(Контекст, Обработчик);
|
||||
Результат = ВыполнитьОбработку(Контекст, Обработчик);
|
||||
|
||||
Иначе
|
||||
ОшибкаОбработки(Контекст, 404, "Handler not found!");
|
||||
Результат = ОшибкаОбработки(Контекст, 404, "Handler not found!");
|
||||
КонецЕсли;
|
||||
|
||||
КонецПроцедуры
|
||||
Возврат Результат;
|
||||
|
||||
КонецФункции
|
||||
|
||||
#КонецОбласти
|
||||
|
||||
#Область СлужебныеПроцедурыИФункции
|
||||
|
||||
Процедура ВыполнитьОбработку(Контекст, Обработчик)
|
||||
Функция ВыполнитьОбработку(Контекст, Обработчик)
|
||||
|
||||
Метод = вРег(Контекст.Запрос.Метод);
|
||||
|
||||
Если Не Метод = вРег(Обработчик["method"]) Тогда
|
||||
ОшибкаОбработки(Контекст, 405, "Method not allowed for this handler");
|
||||
Возврат;
|
||||
Возврат ОшибкаОбработки(Контекст, 405, "Method not allowed for this handler");
|
||||
КонецЕсли;
|
||||
|
||||
Если Метод = "GET" Тогда
|
||||
ВыполнитьОбработкуGet(Контекст, Обработчик);
|
||||
Результат = ВыполнитьОбработкуGet(Контекст, Обработчик);
|
||||
Иначе
|
||||
ОшибкаОбработки(Контекст, 405, "Method not allowed for this handler");
|
||||
Результат = ОшибкаОбработки(Контекст, 405, "Method not allowed for this handler");
|
||||
КонецЕсли;
|
||||
|
||||
КонецПроцедуры
|
||||
Возврат Результат;
|
||||
|
||||
Процедура ВыполнитьОбработкуGet(Контекст, Обработчик)
|
||||
КонецФункции
|
||||
|
||||
Функция ВыполнитьОбработкуGet(Контекст, Обработчик)
|
||||
|
||||
Запрос = Контекст.Запрос;
|
||||
Параметры = Запрос.Параметры;
|
||||
@@ -148,14 +157,14 @@
|
||||
КотелПараметров.Вставить(Аргумент.Ключ, Аргумент.Значение);
|
||||
КонецЦикла;
|
||||
|
||||
ВыполнитьУниверсальнуюОбработку(Контекст
|
||||
Возврат ВыполнитьУниверсальнуюОбработку(Контекст
|
||||
, Обработчик["library"]
|
||||
, Обработчик["function"]
|
||||
, КотелПараметров);
|
||||
|
||||
КонецПроцедуры
|
||||
КонецФункции
|
||||
|
||||
Процедура ВыполнитьУниверсальнуюОбработку(Контекст, Команда, Метод, Параметры)
|
||||
Функция ВыполнитьУниверсальнуюОбработку(Контекст, Команда, Метод, Параметры)
|
||||
|
||||
СтруктураВыполнения = ОбъектОПИ.СформироватьСтрокуВызоваМетода(Параметры, Команда, Метод);
|
||||
|
||||
@@ -174,15 +183,16 @@
|
||||
|
||||
КонецЕсли;
|
||||
|
||||
Контекст.Ответ.ЗаписатьКакJson(Ответ);
|
||||
Возврат Ответ;
|
||||
|
||||
КонецПроцедуры
|
||||
КонецФункции
|
||||
|
||||
Процедура ОшибкаОбработки(Контекст, Код, Текст)
|
||||
Функция ОшибкаОбработки(Контекст, Код, Текст)
|
||||
|
||||
Контекст.Ответ.КодСостояния = Код;
|
||||
Контекст.Ответ.ЗаписатьКакJson(Новый Структура("result,error", Ложь, Текст));
|
||||
|
||||
КонецПроцедуры
|
||||
Возврат Новый Структура("result,error", Ложь, Текст);
|
||||
|
||||
КонецФункции
|
||||
|
||||
#КонецОбласти
|
||||
|
Reference in New Issue
Block a user