|
17 | 17 | package io.github.project.openubl.xsender.camel.routes;
|
18 | 18 |
|
19 | 19 | import io.github.project.openubl.xsender.Constants;
|
| 20 | +import io.github.project.openubl.xsender.models.Metadata; |
| 21 | +import io.github.project.openubl.xsender.models.Status; |
| 22 | +import io.github.project.openubl.xsender.models.SunatResponse; |
20 | 23 | import io.github.project.openubl.xsender.models.rest.ResponseAccessTokenSuccessDto;
|
21 | 24 | import io.github.project.openubl.xsender.models.rest.ResponseDocumentErrorDto;
|
22 | 25 | import io.github.project.openubl.xsender.models.rest.ResponseDocumentSuccessDto;
|
|
31 | 34 | import org.apache.camel.model.dataformat.JsonLibrary;
|
32 | 35 | import org.apache.camel.util.URISupport;
|
33 | 36 | import org.apache.cxf.binding.soap.SoapFault;
|
| 37 | +import org.apache.cxf.transport.http.HTTPException; |
34 | 38 |
|
35 | 39 | import java.net.URISyntaxException;
|
36 | 40 | import java.time.ZonedDateTime;
|
| 41 | +import java.util.Collections; |
37 | 42 | import java.util.List;
|
38 | 43 | import java.util.Map;
|
39 | 44 | import java.util.Objects;
|
@@ -68,6 +73,25 @@ public void configure() {
|
68 | 73 | .continued(true)
|
69 | 74 | .process(new SoapSunatErrorResponseProcessor())
|
70 | 75 | .end()
|
| 76 | + .onException(HTTPException.class) |
| 77 | + .continued(true) |
| 78 | + .maximumRedeliveries(1) |
| 79 | + .useOriginalMessage() |
| 80 | + .process(exchange -> { |
| 81 | + Throwable throwable = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class); |
| 82 | + |
| 83 | + SunatResponse sunatResponse = SunatResponse.builder() |
| 84 | + .status(Status.UNKNOWN) |
| 85 | + .metadata(Metadata.builder() |
| 86 | + .notes(Collections.emptyList()) |
| 87 | + .description(throwable.getMessage()) |
| 88 | + .build()) |
| 89 | + .build(); |
| 90 | + |
| 91 | + exchange.getIn().setBody(sunatResponse); |
| 92 | + }) |
| 93 | + .end() |
| 94 | + |
71 | 95 | // REST exception
|
72 | 96 | .onException(HttpOperationFailedException.class)
|
73 | 97 | .continued(exchange -> {
|
|
0 commit comments