initial public commit
This commit is contained in:
201
system/core/error-handler/LICENSE.txt
Normal file
201
system/core/error-handler/LICENSE.txt
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
116
system/core/error-handler/README.md
Normal file
116
system/core/error-handler/README.md
Normal file
@ -0,0 +1,116 @@
|
||||
# SYSTEM :: ENTAXY :: CORE :: COMMON ERROR HANDLER
|
||||
|
||||
Централизованный обработчик ошибок для формирования кодов ошибок, их синхронного возврата клиенту и для асинхронного дублирования более подробного описания ошибки (для клиента и для Центральной Базы Интеграции).
|
||||
|
||||
## Установка и настройка
|
||||
Установка модуля происходит через фичу:
|
||||
```
|
||||
feature:install error-handler
|
||||
```
|
||||
Фича включена в общий установочный скрипт и будет устанавливаться вместе с остальными модулями.
|
||||
Во время установки фичи в караф копируются файлы конфигурации:
|
||||
```
|
||||
ru.entaxy.esb.error.cfg (основная конфигурация)
|
||||
ru.entaxy.esb.error.code.cfg (справочник исключений с маппингом на коды ошибок)
|
||||
ru.entaxy.esb.error.text.cfg (справочник кодов ошибок с маппингом на текстовые сообщения)
|
||||
```
|
||||
Есть возможность настройки маппинга уровней журналирования через файл конфигурации `ru.entaxy.esb.error.severity.cfg`.
|
||||
### ru.entaxy.esb.error.cfg (основная конфигурация)
|
||||
```
|
||||
# асинхронный пакет с ошибкой отправляется от имени:
|
||||
# false - системы, вызвавшей ошибку в шине
|
||||
# true - шины (система с идентификатором "-1")
|
||||
error.bus.always_at_source=false
|
||||
|
||||
# асинхронный пакет с ошибкой в поле description содержит:
|
||||
# false - сообщение из маппинга в файле ru.entaxy.esb.error.text.cfg
|
||||
# true - содержит сообщение, сохранённое в исключении
|
||||
error.description.exception_message=true
|
||||
|
||||
# имя очереди для отправки пакета с ошибкой при недоступности системы, указанной в свойстве error.system.name
|
||||
error.queue.name=error
|
||||
|
||||
# имя системы для отправки пакета с ошибкой, подразумевается система ЦБИ
|
||||
error.system.name=error
|
||||
|
||||
# true - включает в пакет с ошибкой весь stacktrace исключения
|
||||
error.stacktrace.show=true
|
||||
|
||||
# свойство автоматического запуска тестового маршрута, который при старте модуля бросает исключение java.lang.IllegalArgumentException: Test exception thrown
|
||||
error.test-route.startup=false
|
||||
```
|
||||
### ru.entaxy.esb.error.code.cfg (справочник исключений с маппингом на коды ошибок)
|
||||
Справочник содержит соответствие имён классов исключений и http кодов ошибок. И будет наполняться по мере использования шины в разных ситуациях. Для исключения, имя которого ещё не указано в этом файле, будет возвращаться http код `520` (Unknown Error).
|
||||
```
|
||||
DefaultException=520
|
||||
com.ctc.wstx.exc.WstxParsingException=400
|
||||
java.security.AccessControlException=403
|
||||
javax.ws.rs.ForbiddenException=403
|
||||
ConnectorNotFound=424
|
||||
ru.entaxy.esb.system.common.exception.DefaultException=520
|
||||
ProfileNotFound=424
|
||||
# и т.д.
|
||||
```
|
||||
### ru.entaxy.esb.error.text.cfg (справочник кодов ошибок с маппингом на текстовые сообщения)
|
||||
Если в основной конфигурации свойство `error.description.exception_message` установлено в `false`, то описание ошибки отправляется из этого файла в соответствие с кодом http ошибки.
|
||||
```
|
||||
# 1xx: Informational
|
||||
# 2xx: Success
|
||||
200=OK
|
||||
|
||||
# 3xx: Redirection
|
||||
# 4xx: Client Error
|
||||
400=Bad Request
|
||||
403=Forbidden
|
||||
424=Failed Dependency
|
||||
|
||||
# 5xx: Server Error
|
||||
520=Unknown Error
|
||||
# и т.д.
|
||||
```
|
||||
## Подключение обработчика ошибок
|
||||
Для подключения обработчика ошибок к маршрутам какого-либо модуля необходимо выполнить следующие шаги:
|
||||
1. Добавить в модуль обработки ошибок в директорию `src/main/resources/xslt/operation` новый xslt для формирования ответа с ошибкой. Файл должен называться по имени операции, для которой будет формироваться ответ. Например `sendToJMS.xsl`.
|
||||
1. Добавить в `camelContext` аттрибут `errorHandlerRef="commonErrorHandler"` и внутри зарегистрировать обработчик и политику повторной доставки:
|
||||
```xml
|
||||
<camelContext id="soap-service-endpoints-camel-context"
|
||||
xmlns="http://camel.apache.org/schema/blueprint"
|
||||
errorHandlerRef="commonErrorHandler" handleFault="true">
|
||||
|
||||
<errorHandler id="commonErrorHandler" redeliveryPolicyRef="noRedelivery"
|
||||
type="DeadLetterChannel" deadLetterUri="direct-vm:commonErrorEndpoint"/>
|
||||
<redeliveryPolicyProfile id="noRedelivery" disableRedelivery="true" />
|
||||
<!-- any content -->
|
||||
</camelContext>
|
||||
```
|
||||
Для контекстов, содержащих конечные точки cxf, необходимо:
|
||||
- через `pom.xml` импортировать интерцептор для перехвата ошибок (SoapFault)
|
||||
```xml
|
||||
<bundle.osgi.import.pkg>
|
||||
ru.entaxy.esb.system.core.common.error.handler.interceptor,
|
||||
...
|
||||
</bundle.osgi.import.pkg>
|
||||
```
|
||||
- добавить интерцептор в `cxfEndpoint` и bean с указанием в первом аргументе идентификатора `camelContext`
|
||||
```xml
|
||||
<camelcxf:cxfEndpoint id="soap-proxy" .../>
|
||||
<!-- any properties and interceptors -->
|
||||
<camelcxf:outFaultInterceptors>
|
||||
<ref component-id="handleOutFaultInterceptor"/>
|
||||
</camelcxf:outFaultInterceptors>
|
||||
</camelcxf:cxfEndpoint>
|
||||
|
||||
<bean id="handleOutFaultInterceptor" class="ru.entaxy.esb.system.core.common.error.handler.interceptor.HandleOutFaultInterceptor">
|
||||
<argument ref="soap-service-endpoints-camel-context"/>
|
||||
<argument value="direct:error_from_cxf"/>
|
||||
</bean>
|
||||
```
|
||||
- в `camelContext` добавить маршрут
|
||||
```xml
|
||||
<route id="error_from_cxf">
|
||||
<from uri="direct:error_from_cxf"/>
|
||||
<log message="cxf message: ${body}" loggingLevel="DEBUG"/>
|
||||
<log message="headers: ${headers}\n" loggingLevel="DEBUG"/>
|
||||
<to uri="direct-vm:cxfErrorEndpoint"/>
|
||||
</route>
|
||||
```
|
46
system/core/error-handler/pom.xml
Normal file
46
system/core/error-handler/pom.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>ru.entaxy.esb.system.core</groupId>
|
||||
<artifactId>system-core</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>error-handler</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<name>SYSTEM :: ENTAXY :: CORE :: COMMON ERROR HANDLER</name>
|
||||
<description>SYSTEM :: ENTAXY :: CORE :: COMMON ERROR HANDLER</description>
|
||||
|
||||
<properties>
|
||||
<bundle.osgi.export.pkg>
|
||||
ru.entaxy.esb.system.core.common.error.handler.interceptor
|
||||
</bundle.osgi.export.pkg>
|
||||
<bundle.osgi.import.pkg>
|
||||
*
|
||||
</bundle.osgi.import.pkg>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ru.entaxy.esb.system.commons</groupId>
|
||||
<artifactId>system-commons</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-cxf</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,148 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* error-handler
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.core.common.error.handler.interceptor;
|
||||
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
import org.apache.camel.component.cxf.common.message.CxfConstants;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.cxf.binding.soap.SoapMessage;
|
||||
import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
|
||||
import org.apache.cxf.endpoint.Endpoint;
|
||||
import org.apache.cxf.interceptor.Fault;
|
||||
import org.apache.cxf.message.Exchange;
|
||||
import org.apache.cxf.message.Message;
|
||||
import org.apache.cxf.phase.Phase;
|
||||
import org.apache.cxf.transport.Conduit;
|
||||
import org.apache.cxf.transport.http.Headers;
|
||||
import ru.entaxy.esb.system.common.util.SystemHeadersConstants;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class HandleOutFaultInterceptor extends AbstractSoapInterceptor {
|
||||
private static final Log LOG = LogFactory.getLog(HandleOutFaultInterceptor.class);
|
||||
|
||||
private final ProducerTemplate template;
|
||||
private final String endpointUri;
|
||||
|
||||
public HandleOutFaultInterceptor(CamelContext camelContext, String endpointUri) {
|
||||
super(Phase.POST_PROTOCOL);
|
||||
this.template = camelContext.createProducerTemplate();
|
||||
this.endpointUri = endpointUri;
|
||||
}
|
||||
|
||||
|
||||
public void handleMessage(SoapMessage message) {
|
||||
LOG.debug("HandleOutFaultInterceptor.handleMessage invocation");
|
||||
// String inMEssage = message.getExchange().getInMessage().getContent(String.class);
|
||||
// Fault fault = (Fault) message.getContent(Exception.class);
|
||||
Map headers = prepareHeaders(message);
|
||||
String response = template.requestBodyAndHeaders(this.endpointUri, "", headers, String.class);
|
||||
LOG.debug("HandleOutFaultInterceptor.handleMessage result from camel: \n" + response);
|
||||
sendErrorResponse(message, 200, response);
|
||||
}
|
||||
|
||||
private Map prepareHeaders(SoapMessage message) {
|
||||
Fault fault = (Fault) message.getContent(Exception.class);
|
||||
Map headers = new HashMap();
|
||||
headers.put("NTX_ERROR_HANDLER_SoapFault", fault);
|
||||
// headers.put("ERROR_HANDLER_EXCEPTION", fault.getCause());
|
||||
// headers.put("NTX_ERROR_HANDLER_ExceptionClass", fault.getCause().getClass().getName());
|
||||
// headers.put("NTX_ERROR_HANDLER_ExceptionMessage", fault.getCause().getMessage());
|
||||
headers.put(CxfConstants.OPERATION_NAME, getOperationName(message));
|
||||
try {
|
||||
addSystemHeaders(message, headers);
|
||||
} catch (Exception e) {
|
||||
LOG.info("Unable to add source system information to headers in HandleOutFaultInterceptor");
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
private void addSystemHeaders(SoapMessage message, Map headers) {
|
||||
Message inMessage = message.getExchange().getInMessage();
|
||||
Map<String, List<String>> inHeaders = Headers.getSetProtocolHeaders(inMessage);
|
||||
headers.put(SystemHeadersConstants.HEADER_SYSTEM_NAME,
|
||||
inHeaders.get(SystemHeadersConstants.HEADER_SYSTEM_NAME).get(0));
|
||||
headers.put(SystemHeadersConstants.HEADER_SYSTEM_ID,
|
||||
inHeaders.get(SystemHeadersConstants.HEADER_SYSTEM_ID).get(0));
|
||||
}
|
||||
|
||||
private String getOperationName(SoapMessage message) {
|
||||
String operation = "";
|
||||
try {
|
||||
operation = message.getExchange().getBindingOperationInfo().getOperationInfo().getName().getLocalPart();
|
||||
} catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
LOG.debug("operation name: " + operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
private void sendErrorResponse(Message message, int responseCode, String ret) {
|
||||
Message outMessage = getOutMessage(message);
|
||||
outMessage.put(Message.RESPONSE_CODE, responseCode);
|
||||
// Set the response headers
|
||||
Map responseHeaders = (Map) outMessage.get(Message.PROTOCOL_HEADERS);
|
||||
if (responseHeaders != null) {
|
||||
responseHeaders.clear();
|
||||
responseHeaders.put("CAMEL_ERROR", Arrays.asList(ret));
|
||||
}
|
||||
message.getInterceptorChain().abort();
|
||||
try {
|
||||
getConduit(message).prepare(outMessage);
|
||||
write(outMessage, ret);
|
||||
} catch (IOException e) {
|
||||
LOG.warn(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private Message getOutMessage(Message inMessage) {
|
||||
Exchange exchange = inMessage.getExchange();
|
||||
Message outMessage = exchange.getOutMessage();
|
||||
if (outMessage == null) {
|
||||
Endpoint endpoint = exchange.get(Endpoint.class);
|
||||
outMessage = endpoint.getBinding().createMessage();
|
||||
exchange.setOutMessage(outMessage);
|
||||
}
|
||||
outMessage.putAll(inMessage);
|
||||
return outMessage;
|
||||
}
|
||||
|
||||
private Conduit getConduit(Message inMessage) throws IOException {
|
||||
Exchange exchange = inMessage.getExchange();
|
||||
Conduit conduit = exchange.getDestination().getBackChannel(inMessage);
|
||||
exchange.setConduit(conduit);
|
||||
return conduit;
|
||||
}
|
||||
|
||||
private void write(Message outMessage, String ret) throws IOException {
|
||||
OutputStream os = outMessage.getContent(OutputStream.class);
|
||||
os.write(ret.getBytes(StandardCharsets.UTF_8));
|
||||
os.flush();
|
||||
os.close();
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* error-handler
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.core.common.error.handler.processor;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.Processor;
|
||||
import org.apache.camel.ProducerTemplate;
|
||||
|
||||
public class ErrorProcessor implements Processor {
|
||||
|
||||
@Override
|
||||
public void process(Exchange exchange) throws Exception {
|
||||
|
||||
String body = exchange.getIn().getBody(String.class);
|
||||
Exception cause = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
|
||||
exchange.getIn().setBody("ErrorProcessor: \n" + cause.getMessage());
|
||||
|
||||
ProducerTemplate template = exchange.getContext().createProducerTemplate();
|
||||
// template.send("xslt:xslt/CreateUniversalErrorPacket.xsl", exchange);
|
||||
template.send("direct-vm:commonErrorEndpoint", exchange);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* error-handler
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2021 EmDev LLC
|
||||
* ==========
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.esb.system.core.common.error.handler.util;
|
||||
|
||||
public class Timestamp {
|
||||
public String currentTimeMillis(String body) {
|
||||
return String.valueOf(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public String unixTime(String body) {
|
||||
return String.valueOf(System.currentTimeMillis() / 1000L);
|
||||
}
|
||||
}
|
@ -0,0 +1,410 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
|
||||
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
|
||||
xsi:schemaLocation="
|
||||
http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
|
||||
">
|
||||
|
||||
<cm:property-placeholder persistent-id="ru.entaxy.esb.error" update-strategy="reload">
|
||||
<cm:default-properties>
|
||||
<cm:property name="error.bus.system.id" value="-1"/>
|
||||
<cm:property name="error.bus.system.name" value="esb"/>
|
||||
<cm:property name="error.bus.always_at_source" value="false"/>
|
||||
<cm:property name="error.description.exception_message" value="true"/>
|
||||
<cm:property name="error.queue.name" value="error"/>
|
||||
<cm:property name="error.system.name" value="error"/>
|
||||
<cm:property name="error.stacktrace.show" value="true"/>
|
||||
<cm:property name="error.test-route.startup" value="false"/>
|
||||
</cm:default-properties>
|
||||
</cm:property-placeholder>
|
||||
|
||||
<cm:property-placeholder persistent-id="ru.entaxy.esb.error.code" update-strategy="reload"
|
||||
placeholder-prefix="$errorCode{">
|
||||
<cm:default-properties>
|
||||
<cm:property name="ru.entaxy.esb.system.common.exception.DefaultException" value="520"/>
|
||||
</cm:default-properties>
|
||||
</cm:property-placeholder>
|
||||
|
||||
<cm:property-placeholder persistent-id="ru.entaxy.esb.error.text" update-strategy="reload"
|
||||
placeholder-prefix="$errorText{">
|
||||
<cm:default-properties>
|
||||
<cm:property name="http-520" value="Unknown Error"/>
|
||||
</cm:default-properties>
|
||||
</cm:property-placeholder>
|
||||
|
||||
<cm:property-placeholder persistent-id="ru.entaxy.esb.error.severity" update-strategy="reload"
|
||||
placeholder-prefix="$errorSeverity{">
|
||||
<cm:default-properties>
|
||||
<cm:property name="FATAL" value="1"/>
|
||||
<cm:property name="ERROR" value="2"/>
|
||||
<cm:property name="WARN" value="3"/>
|
||||
<cm:property name="INFO" value="4"/>
|
||||
</cm:default-properties>
|
||||
</cm:property-placeholder>
|
||||
|
||||
<bean id="uuidGenerator" class="java.util.UUID" scope="prototype" factory-method="randomUUID"/>
|
||||
<bean id="timestamp" class="ru.entaxy.esb.system.core.common.error.handler.util.Timestamp"/>
|
||||
|
||||
<reference id="pooledConnectionFactory" interface="javax.jms.ConnectionFactory"/>
|
||||
|
||||
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
|
||||
<property name="connectionFactory" ref="pooledConnectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<!-- <bean id="errorProcessor" class="ErrorProcessor"/>-->
|
||||
|
||||
<camelContext id="common-error-handler-context" errorHandlerRef="errorHandlerFailed"
|
||||
xmlns="http://camel.apache.org/schema/blueprint">
|
||||
|
||||
<!-- <errorHandler id="synchronousErrorHandler" redeliveryPolicyRef="noRedelivery"-->
|
||||
<!-- onPrepareFailureRef="errorProcessor"-->
|
||||
<!-- type="DeadLetterChannel" deadLetterUri="direct:syncErrorHandlerEndpoint" />-->
|
||||
<errorHandler id="commonErrorHandler" redeliveryPolicyRef="noRedelivery"
|
||||
type="DeadLetterChannel" deadLetterUri="direct-vm:commonErrorEndpoint"/>
|
||||
<errorHandler id="errorHandlerFailed" redeliveryPolicyRef="noRedelivery"
|
||||
type="DeadLetterChannel" deadLetterUri="direct:errorHandlerFailedEndpoint"/>
|
||||
<errorHandler id="loggingErrorHandler" redeliveryPolicyRef="noRedelivery"/>
|
||||
<!-- type="LoggingErrorHandler" logName="errorHandlerCrash"/>-->
|
||||
<redeliveryPolicyProfile id="noRedelivery" disableRedelivery="true"/>
|
||||
|
||||
<route id="error-handler-test-route" errorHandlerRef="commonErrorHandler"
|
||||
autoStartup="{{error.test-route.startup}}">
|
||||
<from uri="timer:test-route?repeatCount=1"/>
|
||||
<log message="error handler test route started successfully\n\n" loggingLevel="INFO"/>
|
||||
|
||||
<setBody>
|
||||
<simple>
|
||||
<![CDATA[<packet xmlns="http://www.entaxy.ru/ExchangeTypes/1.0"><content>Oops... some test error occurred</content></packet>]]>
|
||||
</simple>
|
||||
</setBody>
|
||||
|
||||
<throwException exceptionType="java.lang.IllegalArgumentException" message="Test exception thrown"/>
|
||||
</route>
|
||||
|
||||
<!-- the route is designed to handle errors that occurred in other routes of this context -->
|
||||
<route id="error-handler-failed-route" errorHandlerRef="loggingErrorHandler">
|
||||
<from uri="direct:errorHandlerFailedEndpoint"/>
|
||||
<log message="Exception handled by ${routeId}: ${exception}
|
||||
${messageHistory}${exception.stacktrace}" loggingLevel="ERROR"/>
|
||||
<!-- TODO connect to alarm or monitoring system (send email, sms, etc) -->
|
||||
</route>
|
||||
|
||||
<route id="cxf-error-handler-route">
|
||||
<from uri="direct-vm:cxfErrorEndpoint"/>
|
||||
<log message="Exception handled by ${routeId}: ${header.NTX_ERROR_HANDLER_SoapFault}" loggingLevel="ERROR"/>
|
||||
<doTry>
|
||||
<to uri="direct-vm:commonErrorEndpoint"/>
|
||||
<doFinally>
|
||||
<to uri="xslt:xslt/WrapSoapEnvelope.xsl"/>
|
||||
</doFinally>
|
||||
</doTry>
|
||||
</route>
|
||||
|
||||
<route id="common-error-handler-route">
|
||||
<from uri="direct-vm:commonErrorEndpoint"/>
|
||||
<log message="Exception handled by ${routeId}: ${exception}
|
||||
on message ${headers.ENTAXY_MessageUUID}
|
||||
${messageHistory}${exception.stacktrace}" loggingLevel="ERROR"/>
|
||||
|
||||
<setBody>
|
||||
<constant><![CDATA[<empty/>]]></constant>
|
||||
</setBody>
|
||||
<to uri="xslt:xslt/DefaultResponse.xsl"/>
|
||||
<to uri="direct:prepareResponseCodeAndTextEndpoint"/>
|
||||
|
||||
<wireTap uri="direct:asynchronousErrorEndpoint"/>
|
||||
<to uri="direct:synchronousErrorEndpoint"/>
|
||||
|
||||
<!-- Remove headers before response -->
|
||||
<removeHeaders pattern="*"/>
|
||||
</route>
|
||||
|
||||
<route id="prepare-response-code-and-text-route">
|
||||
<from uri="direct:prepareResponseCodeAndTextEndpoint"/>
|
||||
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${exception} != null</simple>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ExceptionClass">
|
||||
<simple resultType="String">${exception.class.name}</simple>
|
||||
</setHeader>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ExceptionMessage">
|
||||
<simple resultType="String">${exception.message}</simple>
|
||||
</setHeader>
|
||||
</when>
|
||||
<when>
|
||||
<simple>${header.NTX_ERROR_HANDLER_SoapFault} != null</simple>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ExceptionClass">
|
||||
<simple resultType="String">${header.NTX_ERROR_HANDLER_SoapFault.cause.class.name}</simple>
|
||||
</setHeader>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ExceptionMessage">
|
||||
<simple resultType="String">${header.NTX_ERROR_HANDLER_SoapFault.cause.message}</simple>
|
||||
</setHeader>
|
||||
</when>
|
||||
<otherwise>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ExceptionClass">
|
||||
<simple resultType="String">ru.entaxy.esb.system.common.exception.DefaultException</simple>
|
||||
</setHeader>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ExceptionMessage">
|
||||
<simple resultType="String">Something wrong</simple>
|
||||
</setHeader>
|
||||
</otherwise>
|
||||
</choice>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${header.NTX_ERROR_HANDLER_ExceptionClass}</simple>
|
||||
<doTry>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ResponseCode">
|
||||
<simple>${properties:${header.NTX_ERROR_HANDLER_ExceptionClass}}</simple>
|
||||
</setHeader>
|
||||
<doCatch>
|
||||
<exception>java.lang.Exception</exception>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ResponseCode">
|
||||
<simple>${properties:ru.entaxy.esb.system.common.exception.DefaultException}</simple>
|
||||
</setHeader>
|
||||
</doCatch>
|
||||
</doTry>
|
||||
</when>
|
||||
</choice>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${properties:error.description.exception_message} == "true"</simple>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ResponseText">
|
||||
<simple>${header.NTX_ERROR_HANDLER_ExceptionMessage}</simple>
|
||||
</setHeader>
|
||||
</when>
|
||||
<otherwise>
|
||||
<setHeader name="NTX_ERROR_HANDLER_ResponseText">
|
||||
<simple>${properties:${header.NTX_ERROR_HANDLER_ResponseCode}}</simple>
|
||||
</setHeader>
|
||||
</otherwise>
|
||||
</choice>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>
|
||||
${properties:error.stacktrace.show} == "true"
|
||||
&& ${exception.stacktrace} != null
|
||||
</simple>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Stacktrace">
|
||||
<simple>${exception.stacktrace}</simple>
|
||||
</setHeader>
|
||||
</when>
|
||||
</choice>
|
||||
|
||||
<log message="${exchangeProperty.CamelExceptionCaught}\n" loggingLevel="DEBUG"/>
|
||||
<log message="${routeId}: \n
|
||||
${header.NTX_ERROR_HANDLER_ExceptionClass} \n
|
||||
${header.NTX_ERROR_HANDLER_ResponseCode} ${header.NTX_ERROR_HANDLER_ResponseText}"
|
||||
loggingLevel="INFO"/>
|
||||
</route>
|
||||
|
||||
<route id="asynchronous-error-handler-route">
|
||||
<from uri="direct:asynchronousErrorEndpoint"/>
|
||||
<log message="${routeId}" loggingLevel="DEBUG"/>
|
||||
|
||||
<to uri="direct:prepareErrorPacketEndpoint"/>
|
||||
<removeHeaders pattern="NTX_ERROR_HANDLER_.+"/>
|
||||
|
||||
<!-- Send error packet to central error handling system -->
|
||||
<doTry>
|
||||
<toD uri="system:${properties:error.system.name}?exchangePattern=InOnly"/>
|
||||
<doCatch>
|
||||
<exception>java.lang.Exception</exception>
|
||||
<log message="${exception.message}" loggingLevel="ERROR"/>
|
||||
<log message="${exception.stacktrace}" loggingLevel="DEBUG"/>
|
||||
<toD uri="jms:queue:entaxy.${properties:error.queue.name}?exchangePattern=InOnly"/>
|
||||
</doCatch>
|
||||
</doTry>
|
||||
|
||||
<!-- Send error packet back to the calling system -->
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${headers.X-SystemName} != "esb"</simple>
|
||||
<doTry>
|
||||
<toD uri="system:${headers.X-SystemName}?exchangePattern=InOnly"/>
|
||||
<doCatch>
|
||||
<exception>java.lang.Exception</exception>
|
||||
<log message="Can't deliver error packet to system: ${headers.X-SystemName}"
|
||||
loggingLevel="ERROR"/>
|
||||
<log message="${exception.message}" loggingLevel="ERROR"/>
|
||||
<log message="${exception.stacktrace}" loggingLevel="DEBUG"/>
|
||||
</doCatch>
|
||||
</doTry>
|
||||
</when>
|
||||
</choice>
|
||||
</route>
|
||||
|
||||
<route id="prepare-error-packet-route">
|
||||
<from uri="direct:prepareErrorPacketEndpoint"/>
|
||||
<log message="${routeId}" loggingLevel="DEBUG"/>
|
||||
<to uri="direct:prepareErrorPacketHeadersEndpoint"/>
|
||||
|
||||
<setHeader name="ENTAXY_Source">
|
||||
<constant>esb</constant>
|
||||
</setHeader>
|
||||
|
||||
<log message="Before transformation \n${body}" loggingLevel="DEBUG"/>
|
||||
<to uri="xslt:xslt/UniversalErrorPacket.xsl"/>
|
||||
<log message="After transformation \n${body}" loggingLevel="DEBUG"/>
|
||||
|
||||
<setHeader name="ENTAXY_MessageUUID">
|
||||
<simple>${bean:uuidGenerator.toString}</simple>
|
||||
</setHeader>
|
||||
<setHeader name="ENTAXY_MessageType">
|
||||
<constant>ВыгрузкаДанныхКаноническийФормат</constant>
|
||||
</setHeader>
|
||||
<setHeader name="ENTAXY_ContentType">
|
||||
<constant>application/xml</constant>
|
||||
</setHeader>
|
||||
<setHeader name="CamelJms_IntMessageType">
|
||||
<constant>String</constant>
|
||||
</setHeader>
|
||||
<setHeader name="CamelJms_IntContentXsiType">
|
||||
<constant>xs:string</constant>
|
||||
</setHeader>
|
||||
</route>
|
||||
|
||||
<route id="prepare-error-packet-headers-route">
|
||||
<from uri="direct:prepareErrorPacketHeadersEndpoint"/>
|
||||
|
||||
<setHeader name="NTX_ERROR_HANDLER_CentralIntegrationDB">
|
||||
<simple>${properties:error.system.name}</simple>
|
||||
</setHeader>
|
||||
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${headers.ENTAXY_Source} != null && ${headers.ENTAXY_Source} != ""
|
||||
</simple>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Source">
|
||||
<simple>${headers.ENTAXY_Source}</simple>
|
||||
</setHeader>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Destination">
|
||||
<simple>${headers.ENTAXY_Source}</simple>
|
||||
</setHeader>
|
||||
</when>
|
||||
<when>
|
||||
<simple>${headers.NTX_SystemId} != null && ${headers.NTX_SystemId} != ""</simple>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Source">
|
||||
<simple>${headers.NTX_SystemId}</simple>
|
||||
</setHeader>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Destination">
|
||||
<simple>${headers.NTX_SystemId}</simple>
|
||||
</setHeader>
|
||||
</when>
|
||||
<when>
|
||||
<simple>${headers.X-SystemName} != null && ${headers.X-SystemName} != ""</simple>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Source">
|
||||
<simple>${headers.X-SystemName}</simple>
|
||||
</setHeader>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Destination">
|
||||
<simple>${headers.X-SystemName}</simple>
|
||||
</setHeader>
|
||||
</when>
|
||||
<otherwise>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Source">
|
||||
<constant>esb</constant>
|
||||
</setHeader>
|
||||
<setHeader name="X-SystemName">
|
||||
<constant>esb</constant>
|
||||
</setHeader>
|
||||
</otherwise>
|
||||
</choice>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${headers.X-SystemName} == null || ${headers.X-SystemName} == ""</simple>
|
||||
<setHeader name="X-SystemName">
|
||||
<constant>esb</constant>
|
||||
</setHeader>
|
||||
</when>
|
||||
</choice>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${headers.X-SystemId} == null || ${headers.X-SystemId} == ""</simple>
|
||||
<setHeader name="X-SystemId">
|
||||
<constant>-1</constant>
|
||||
</setHeader>
|
||||
</when>
|
||||
</choice>
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${properties:error.bus.always_at_source} == "true"</simple>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Source">
|
||||
<constant>esb</constant>
|
||||
</setHeader>
|
||||
<setHeader name="X-SystemName">
|
||||
<constant>esb</constant>
|
||||
</setHeader>
|
||||
<setHeader name="X-SystemId">
|
||||
<constant>-1</constant>
|
||||
</setHeader>
|
||||
</when>
|
||||
</choice>
|
||||
|
||||
<setHeader name="NTX_ERROR_HANDLER_ErrorUUID">
|
||||
<simple>${bean:uuidGenerator.toString}</simple>
|
||||
</setHeader>
|
||||
<log message="Prepare error packet with eventUUID: ${headers.NTX_ERROR_HANDLER_ErrorUUID}"
|
||||
loggingLevel="ERROR"/>
|
||||
<setHeader name="NTX_ERROR_HANDLER_Timestamp">
|
||||
<simple>${bean:timestamp?method=currentTimeMillis}</simple>
|
||||
</setHeader>
|
||||
<when>
|
||||
<simple>${headers.NTX_ERROR_HANDLER_SeverityLevel} == null</simple>
|
||||
<setHeader name="NTX_ERROR_HANDLER_SeverityLevel">
|
||||
<constant>ERROR</constant>
|
||||
</setHeader>
|
||||
</when>
|
||||
</route>
|
||||
|
||||
<route id="synchronous-error-handler-route">
|
||||
<from uri="direct:synchronousErrorEndpoint"/>
|
||||
<setBody>
|
||||
<constant><![CDATA[<root/>]]></constant>
|
||||
</setBody>
|
||||
|
||||
<choice>
|
||||
<when>
|
||||
<simple>${headers.NTX_ERROR_HANDLER_GenerateResponseEndpoint} != null</simple>
|
||||
<toD uri="direct-vm:${headers.NTX_ERROR_HANDLER_GenerateResponseEndpoint}"/>
|
||||
</when>
|
||||
<when>
|
||||
<simple>${headers.operationName}</simple>
|
||||
<doTry>
|
||||
<toD uri="xslt:xslt/operation/${header.operationName}.xsl"/>
|
||||
<doCatch>
|
||||
<exception>java.lang.Exception</exception>
|
||||
<log message="${exception}" loggingLevel="ERROR"/>
|
||||
<to uri="xslt:xslt/DefaultResponse.xsl"/>
|
||||
</doCatch>
|
||||
</doTry>
|
||||
</when>
|
||||
<otherwise>
|
||||
<to uri="xslt:xslt/DefaultResponse.xsl"/>
|
||||
</otherwise>
|
||||
</choice>
|
||||
</route>
|
||||
|
||||
</camelContext>
|
||||
|
||||
</blueprint>
|
@ -0,0 +1,30 @@
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
<xsl:stylesheet version="2.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns="http://www.entaxy.ru/ExchangeTypes/1.0"
|
||||
>
|
||||
<xsl:import href="operation/type/response.xsl"/>
|
||||
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:call-template name="response"/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
@ -0,0 +1,103 @@
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
<xsl:stylesheet version="2.0"
|
||||
xmlns="http://www.entaxy.ru/ServiceInterface/1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
>
|
||||
|
||||
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
||||
|
||||
<xsl:param name="NTX_ERROR_HANDLER_CentralIntegrationDB"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_Destination"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_Source"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_ErrorUUID"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_Timestamp"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_ResponseCode"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_ResponseText"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_SeverityLevel"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_ExceptionClass"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_Stacktrace"/>
|
||||
<xsl:param name="NTX_ERROR_HANDLER_EventName"/>
|
||||
<xsl:param name="ENTAXY_MessageUUID"/>
|
||||
<xsl:param name="ENTAXY_Source"/>
|
||||
<xsl:param name="ENTAXY_AcknowledgeMsgID"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<Message>
|
||||
<Header xmlns="http://www.entaxy.ru/ServiceInterface/1.0">
|
||||
<Format>http://www.entaxy.ru/ServiceInterface/1.0</Format>
|
||||
<CreationDate>2020-05-20T07:19:59</CreationDate>
|
||||
<AvailableVersion>1</AvailableVersion>
|
||||
</Header>
|
||||
<Body xmlns="http://www.entaxy.ru/ServiceInterface/1.0">
|
||||
<Справочник.События>
|
||||
<КлючевыеСвойства>
|
||||
<Ссылка>
|
||||
<xsl:value-of select="$NTX_ERROR_HANDLER_ErrorUUID"/>
|
||||
</Ссылка>
|
||||
</КлючевыеСвойства>
|
||||
<Description>
|
||||
<xsl:value-of select="$NTX_ERROR_HANDLER_ResponseText"/>
|
||||
</Description>
|
||||
<xsl:if test="$ENTAXY_MessageUUID">
|
||||
<MessageUUID>
|
||||
<xsl:value-of select="$ENTAXY_MessageUUID"/>
|
||||
</MessageUUID>
|
||||
</xsl:if>
|
||||
<xsl:if test="$ENTAXY_AcknowledgeMsgID">
|
||||
<TransportUUID>
|
||||
<xsl:value-of select="$ENTAXY_AcknowledgeMsgID"/>
|
||||
</TransportUUID>
|
||||
</xsl:if>
|
||||
<SeverityLevel>
|
||||
<xsl:value-of select="$NTX_ERROR_HANDLER_SeverityLevel"/>
|
||||
</SeverityLevel>
|
||||
<EventName>Packet.Validation</EventName>
|
||||
<Timestamp>
|
||||
<xsl:value-of select="$NTX_ERROR_HANDLER_Timestamp"/>
|
||||
</Timestamp>
|
||||
<ErrorCode>
|
||||
<xsl:value-of select="$NTX_ERROR_HANDLER_ResponseCode"/>
|
||||
</ErrorCode>
|
||||
<xsl:if test="$NTX_ERROR_HANDLER_ExceptionClass">
|
||||
<ErrorClass>
|
||||
<xsl:value-of select="$NTX_ERROR_HANDLER_ExceptionClass"/>
|
||||
</ErrorClass>
|
||||
</xsl:if>
|
||||
<xsl:if test="$NTX_ERROR_HANDLER_Stacktrace">
|
||||
<Context>
|
||||
<xsl:value-of select="$NTX_ERROR_HANDLER_Stacktrace"/>
|
||||
</Context>
|
||||
</xsl:if>
|
||||
<xsl:if test="$NTX_ERROR_HANDLER_Source">
|
||||
<MessageSource>
|
||||
<xsl:value-of select="$NTX_ERROR_HANDLER_Source"/>
|
||||
</MessageSource>
|
||||
</xsl:if>
|
||||
<xsl:if test="$ENTAXY_Source">
|
||||
<Source>
|
||||
<xsl:value-of select="$ENTAXY_Source"/>
|
||||
</Source>
|
||||
</xsl:if>
|
||||
</Справочник.События>
|
||||
</Body>
|
||||
</Message>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
||||
<xsl:template match="/">
|
||||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<xsl:copy-of select="."/>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
@ -0,0 +1,30 @@
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
<xsl:stylesheet version="2.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns="http://www.entaxy.ru/ExchangeTypes/1.0"
|
||||
>
|
||||
<xsl:import href="type/response.xsl"/>
|
||||
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:call-template name="response"/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
@ -0,0 +1,30 @@
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
<xsl:stylesheet version="2.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns="http://www.entaxy.ru/ExchangeTypes/1.0"
|
||||
>
|
||||
<xsl:import href="type/response.xsl"/>
|
||||
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:call-template name="response"/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
@ -0,0 +1,30 @@
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
<xsl:stylesheet version="2.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns="http://www.entaxy.ru/ExchangeTypes/1.0"
|
||||
>
|
||||
<xsl:import href="type/response.xsl"/>
|
||||
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:call-template name="response"/>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:import href="../DefaultResponse.xsl"/>
|
||||
</xsl:stylesheet>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:import href="../DefaultResponse.xsl"/>
|
||||
</xsl:stylesheet>
|
@ -0,0 +1,35 @@
|
||||
<!--
|
||||
~~~~~~licensing~~~~~~
|
||||
error-handler
|
||||
==========
|
||||
Copyright (C) 2020 - 2021 EmDev LLC
|
||||
==========
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
~~~~~~/licensing~~~~~~
|
||||
-->
|
||||
<xsl:stylesheet version="2.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns="http://www.entaxy.ru/ExchangeTypes/1.0"
|
||||
>
|
||||
<xsl:output omit-xml-declaration="yes" indent="yes"/>
|
||||
|
||||
<xsl:param name="NTX_ERROR_HANDLER_ResponseCode" select="'520'"/>
|
||||
|
||||
<xsl:template name="response">
|
||||
<response>
|
||||
<status>
|
||||
<xsl:value-of select="$NTX_ERROR_HANDLER_ResponseCode"/>
|
||||
</status>
|
||||
</response>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
Reference in New Issue
Block a user