Compare commits
No commits in common. "22c5bc1fc39128d8e71a56fd424d16e972a7b32e" and "159a18c91d0ad84b1bd2fd81af62bbe1107381e2" have entirely different histories.
22c5bc1fc3
...
159a18c91d
Binary file not shown.
@ -123,7 +123,7 @@ public class MessageHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (json == null || json.isEmpty()) {
|
if (json == null || json.isEmpty()) {
|
||||||
log.warn("No se encontro JSON de errores");
|
log.warn("No se encontró JSON de errores");
|
||||||
return createDefaultMappings();
|
return createDefaultMappings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,11 +138,11 @@ public class MessageHelper {
|
|||||||
result.put(mapping.getBackendCode(), mapping);
|
result.put(mapping.getBackendCode(), mapping);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("Ignorando mapping sin backendCode valido: {}", mapping.getDescription());
|
log.warn("Ignorando mapping sin backendCode válido: {}", mapping.getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Mappings de errores cargados exitosamente, total validos: {}", result.size());
|
log.info("Mappings de errores cargados exitosamente, total válidos: {}", result.size());
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error cargando mappings de errores: {}", e.getMessage());
|
log.error("Error cargando mappings de errores: {}", e.getMessage());
|
||||||
@ -153,7 +153,7 @@ public class MessageHelper {
|
|||||||
private String loadFromJsonFile() {
|
private String loadFromJsonFile() {
|
||||||
try (InputStream is = MessageHelper.class.getClassLoader().getResourceAsStream(ERROR_FILE_PATH)) {
|
try (InputStream is = MessageHelper.class.getClassLoader().getResourceAsStream(ERROR_FILE_PATH)) {
|
||||||
if (is == null) {
|
if (is == null) {
|
||||||
log.warn("No se encontro el archivo de errores: {}", ERROR_FILE_PATH);
|
log.warn("No se encontró el archivo de errores: {}", ERROR_FILE_PATH);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return new String(is.readAllBytes());
|
return new String(is.readAllBytes());
|
||||||
@ -184,7 +184,7 @@ public class MessageHelper {
|
|||||||
mapping.setBackendCode(SUCCESS_DEFAULT);
|
mapping.setBackendCode(SUCCESS_DEFAULT);
|
||||||
mapping.setHttpCode(200);
|
mapping.setHttpCode(200);
|
||||||
mapping.setStatusCode("200");
|
mapping.setStatusCode("200");
|
||||||
mapping.setDescription("Operacion exitosa");
|
mapping.setDescription("Operación exitosa");
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,10 @@ package com.banesco.common.application.service;
|
|||||||
import com.banesco.common.application.usecase.HttpClientUseCase;
|
import com.banesco.common.application.usecase.HttpClientUseCase;
|
||||||
import com.banesco.common.domain.exception.HttpApiResponseException;
|
import com.banesco.common.domain.exception.HttpApiResponseException;
|
||||||
import com.banesco.common.domain.exception.HttpStatusCodeException;
|
import com.banesco.common.domain.exception.HttpStatusCodeException;
|
||||||
import com.banesco.common.domain.model.*;
|
import com.banesco.common.domain.model.ApiResponse;
|
||||||
|
import com.banesco.common.domain.model.HttpRequest;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
@ -15,9 +15,6 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
import jakarta.ws.rs.core.Response;
|
import jakarta.ws.rs.core.Response;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -34,71 +31,43 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T execute(HttpRequest request) {
|
public <T> T execute(HttpRequest request) {
|
||||||
return executeInternal(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> ApiResponse<T> executeApiResponse(HttpRequest request) {
|
|
||||||
return executeInternal(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> ApiResponse<List<T>> executeApiResponseList(
|
|
||||||
HttpRequest request
|
|
||||||
) {
|
|
||||||
return executeInternal(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> ApiPrivateResponse<Either<T, ApiPrivateError>> executeApiPrivateResponse(
|
|
||||||
HttpRequest request
|
|
||||||
) {
|
|
||||||
return executeInternal(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> ApiPrivateResponse<Either<List<T>, ApiPrivateError>> executeApiPrivateResponseList(
|
|
||||||
HttpRequest request
|
|
||||||
) {
|
|
||||||
return executeInternal(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T executeInternal(HttpRequest request) {
|
|
||||||
String finalUrl = buildFinalUrl(request);
|
String finalUrl = buildFinalUrl(request);
|
||||||
|
|
||||||
if (request.isLogRequestBody()) {
|
|
||||||
log.info("URL final: {}", finalUrl);
|
log.info("URL final: {}", finalUrl);
|
||||||
|
|
||||||
if (request.getHeaders() != null && !request.getHeaders().isEmpty()) {
|
if (request.getHeaders() != null) {
|
||||||
log.info("Headers: {}", request.getHeaders());
|
log.info("Headers request: {}", request.getHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.getQueryParams() != null && !request.getQueryParams().isEmpty()) {
|
if (request.getQueryParams() != null) {
|
||||||
log.info("Query params: {}", request.getQueryParams());
|
log.info("Query params request: {}", request.getQueryParams());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.getBody() != null) {
|
if (request.getBody() != null) {
|
||||||
log.info("Body: {}", request.getBody());
|
log.info("Body request: {}", request.getBody());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try (Client client = createClient(request.getConnectTimeout(), request.getReadTimeout())) {
|
try (Client client = createClient(request.getConnectTimeout(), request.getReadTimeout())) {
|
||||||
WebTarget target = client.target(finalUrl);
|
WebTarget target = client.target(finalUrl);
|
||||||
|
|
||||||
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
|
Invocation.Builder builder = target.request(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
if (request.getHeaders() != null) {
|
if (request.getHeaders() != null && !request.getHeaders().isEmpty()) {
|
||||||
request.getHeaders().forEach(builder::header);
|
for (Map.Entry<String, String> entry : request.getHeaders().entrySet()) {
|
||||||
|
builder.header(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Response response = buildRequest(builder, request);
|
Response response = buildRequest(builder, request);
|
||||||
|
|
||||||
return handleResponse(request, response);
|
return handleResponse(request, response);
|
||||||
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
} catch (HttpStatusCodeException | HttpApiResponseException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error de conexion {}: {}", request.getMethod(), e.getMessage());
|
log.error("Error de conexión {}: {}", request.getMethod(), e.getMessage());
|
||||||
throw HttpStatusCodeException.serviceUnavailable(
|
throw HttpStatusCodeException.serviceUnavailable(
|
||||||
"503",
|
"503",
|
||||||
"Error de conexion con el servicio externo: " + e.getMessage()
|
"Error de conexión con el servicio externo: " + e.getMessage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,13 +76,18 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
String finalUrl = request.getUrl();
|
String finalUrl = request.getUrl();
|
||||||
|
|
||||||
if (request.getPathParams() != null && !request.getPathParams().isEmpty()) {
|
if (request.getPathParams() != null && !request.getPathParams().isEmpty()) {
|
||||||
|
log.debug("PathParams antes de reemplazar: {}", request.getPathParams());
|
||||||
|
log.debug("URL original: {}", finalUrl);
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : request.getPathParams().entrySet()) {
|
for (Map.Entry<String, String> entry : request.getPathParams().entrySet()) {
|
||||||
String placeholder = "{" + entry.getKey() + "}";
|
String placeholder = "{" + entry.getKey() + "}";
|
||||||
finalUrl = finalUrl.replace(placeholder, entry.getValue());
|
finalUrl = finalUrl.replace(placeholder, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return appendQueryParams(finalUrl, request.getQueryParams());
|
finalUrl = appendQueryParams(finalUrl, request.getQueryParams());
|
||||||
|
|
||||||
|
return finalUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String appendQueryParams(String url, Map<String, String> queryParams) {
|
private String appendQueryParams(String url, Map<String, String> queryParams) {
|
||||||
@ -122,6 +96,7 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder urlBuilder = new StringBuilder(url);
|
StringBuilder urlBuilder = new StringBuilder(url);
|
||||||
|
|
||||||
boolean firstParam = !url.contains("?");
|
boolean firstParam = !url.contains("?");
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : queryParams.entrySet()) {
|
for (Map.Entry<String, String> entry : queryParams.entrySet()) {
|
||||||
@ -144,7 +119,11 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
Invocation.Builder builder,
|
Invocation.Builder builder,
|
||||||
HttpRequest request
|
HttpRequest request
|
||||||
) {
|
) {
|
||||||
log.info("Metodo HTTP: {}", request.getMethod().name());
|
log.info(
|
||||||
|
"Método HTTP: {}, Headers enviados: {}",
|
||||||
|
request.getMethod().name(),
|
||||||
|
request.getHeaders()
|
||||||
|
);
|
||||||
|
|
||||||
return switch (request.getMethod()) {
|
return switch (request.getMethod()) {
|
||||||
case GET -> builder.get();
|
case GET -> builder.get();
|
||||||
@ -154,11 +133,14 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
case PATCH -> builder.method("PATCH", Entity.entity(request.getBody(), MediaType.APPLICATION_JSON));
|
case PATCH -> builder.method("PATCH", Entity.entity(request.getBody(), MediaType.APPLICATION_JSON));
|
||||||
case HEAD -> builder.head();
|
case HEAD -> builder.head();
|
||||||
case OPTIONS -> builder.options();
|
case OPTIONS -> builder.options();
|
||||||
default -> throw new IllegalArgumentException("Metodo HTTP no soportado: " + request.getMethod());
|
default -> throw new IllegalArgumentException("Método HTTP no soportado: " + request.getMethod());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Client createClient(int connectTimeout, int readTimeout) {
|
private Client createClient(
|
||||||
|
int connectTimeout,
|
||||||
|
int readTimeout
|
||||||
|
) {
|
||||||
return ClientBuilder.newBuilder()
|
return ClientBuilder.newBuilder()
|
||||||
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
|
.connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
|
||||||
.readTimeout(readTimeout, TimeUnit.MILLISECONDS)
|
.readTimeout(readTimeout, TimeUnit.MILLISECONDS)
|
||||||
@ -175,9 +157,7 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
try (response) {
|
try (response) {
|
||||||
String responseBody = response.readEntity(String.class);
|
String responseBody = response.readEntity(String.class);
|
||||||
|
|
||||||
if (request.isLogResponseBody()) {
|
|
||||||
log.info("Respuesta Cuerpo: {}", responseBody);
|
log.info("Respuesta Cuerpo: {}", responseBody);
|
||||||
}
|
|
||||||
|
|
||||||
if (statusCode >= 200 && statusCode < 300) {
|
if (statusCode >= 200 && statusCode < 300) {
|
||||||
if (request.getResponseType() == Void.class || request.getResponseType() == void.class) {
|
if (request.getResponseType() == Void.class || request.getResponseType() == void.class) {
|
||||||
@ -215,7 +195,8 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
e.getMessage()
|
e.getMessage()
|
||||||
);
|
);
|
||||||
throw HttpStatusCodeException.internalServer(
|
throw HttpStatusCodeException.internalServer(
|
||||||
"500", "Error procesando respuesta del servicio externo: " + e.getMessage()
|
"500",
|
||||||
|
"Error procesando respuesta del servicio externo: " + e.getMessage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,166 +205,26 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
HttpRequest request,
|
HttpRequest request,
|
||||||
String responseBody
|
String responseBody
|
||||||
) throws JsonProcessingException {
|
) throws JsonProcessingException {
|
||||||
if (request.isApiPrivateResponse() && request.isEitherResponse()) {
|
|
||||||
return handleApiPrivateResponseWithEither(request, responseBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
T result;
|
T result;
|
||||||
|
|
||||||
if (request.getResponseType() == ApiResponse.class) {
|
if (request.getResponseType() == ApiResponse.class) {
|
||||||
result = deserializeApiResponse(responseBody, request);
|
result = deserializeApiResponse(responseBody, request);
|
||||||
} else if (request.getComplexType() != null) {
|
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
|
||||||
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getComplexType())
|
|
||||||
);
|
|
||||||
result = objectMapper.readValue(responseBody, javaType);
|
|
||||||
} else if (request.getGenericType() != null) {
|
|
||||||
JavaType javaType = objectMapper.getTypeFactory().constructParametricType(
|
|
||||||
request.getResponseType(), objectMapper.getTypeFactory().constructType(request.getGenericType())
|
|
||||||
);
|
|
||||||
result = objectMapper.readValue(responseBody, javaType);
|
|
||||||
} else {
|
} else {
|
||||||
result = objectMapper.readValue(
|
result = (request.getGenericType() != null) ? objectMapper.readValue(
|
||||||
responseBody, objectMapper.getTypeFactory().constructType(request.getResponseType())
|
responseBody,
|
||||||
|
objectMapper.getTypeFactory().constructParametricType(
|
||||||
|
request.getResponseType(),
|
||||||
|
objectMapper.getTypeFactory().constructType(request.getGenericType())
|
||||||
|
)
|
||||||
|
) : objectMapper.readValue(
|
||||||
|
responseBody,
|
||||||
|
objectMapper.getTypeFactory().constructType(request.getResponseType())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T handleApiPrivateResponseWithEither(
|
|
||||||
HttpRequest request,
|
|
||||||
String responseBody
|
|
||||||
) throws JsonProcessingException {
|
|
||||||
JsonNode rootNode = objectMapper.readTree(responseBody);
|
|
||||||
String status = rootNode.has("estatus") ? rootNode.get("estatus").asText() : null;
|
|
||||||
String message = rootNode.has("mensaje") ? rootNode.get("mensaje").asText() : null;
|
|
||||||
JsonNode detailNode = rootNode.get("detalle");
|
|
||||||
|
|
||||||
if (request.getStatusSuccess().equals(status)) {
|
|
||||||
return handleSuccessResponse(request, status, message, detailNode);
|
|
||||||
} else {
|
|
||||||
return handleErrorResponse(status, message, detailNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T> T handleSuccessResponse(
|
|
||||||
HttpRequest request,
|
|
||||||
String status,
|
|
||||||
String message,
|
|
||||||
JsonNode detailNode
|
|
||||||
) {
|
|
||||||
Object successData;
|
|
||||||
|
|
||||||
if (request.isListResponse()) {
|
|
||||||
successData = handleListSuccess(request, detailNode);
|
|
||||||
ApiPrivateResponse<Either<List<Object>, ApiPrivateError>> response = new ApiPrivateResponse<>();
|
|
||||||
|
|
||||||
response.setEstatus(status);
|
|
||||||
response.setMensaje(message);
|
|
||||||
response.setDetalle(Either.left((List<Object>) successData));
|
|
||||||
return (T) response;
|
|
||||||
} else {
|
|
||||||
successData = handleObjectSuccess(request, detailNode);
|
|
||||||
ApiPrivateResponse<Either<Object, ApiPrivateError>> response = new ApiPrivateResponse<>();
|
|
||||||
|
|
||||||
response.setEstatus(status);
|
|
||||||
response.setMensaje(message);
|
|
||||||
response.setDetalle(Either.left(successData));
|
|
||||||
return (T) response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object handleListSuccess(
|
|
||||||
HttpRequest request,
|
|
||||||
JsonNode detailNode
|
|
||||||
) {
|
|
||||||
Class<?> elementType = getElementTypeFromRequest(request);
|
|
||||||
JavaType listType = objectMapper.getTypeFactory().constructCollectionType(List.class, elementType);
|
|
||||||
|
|
||||||
if (detailNode != null && !detailNode.isNull()) {
|
|
||||||
return objectMapper.convertValue(detailNode, listType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object handleObjectSuccess(
|
|
||||||
HttpRequest request,
|
|
||||||
JsonNode detailNode
|
|
||||||
) {
|
|
||||||
Class<?> elementType = getElementTypeFromRequest(request);
|
|
||||||
|
|
||||||
if (detailNode != null && !detailNode.isNull()) {
|
|
||||||
return objectMapper.convertValue(detailNode, elementType);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T> T handleErrorResponse(
|
|
||||||
String status,
|
|
||||||
String message,
|
|
||||||
JsonNode detailNode
|
|
||||||
) {
|
|
||||||
ApiPrivateError error = buildApiPrivateError(detailNode, message);
|
|
||||||
ApiPrivateResponse<Either<Object, ApiPrivateError>> response = new ApiPrivateResponse<>();
|
|
||||||
|
|
||||||
response.setEstatus(status);
|
|
||||||
response.setMensaje(message);
|
|
||||||
response.setDetalle(Either.right(error));
|
|
||||||
|
|
||||||
return (T) response;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ApiPrivateError buildApiPrivateError(
|
|
||||||
JsonNode detailNode,
|
|
||||||
String message
|
|
||||||
) {
|
|
||||||
if (detailNode != null && !detailNode.isNull()) {
|
|
||||||
try {
|
|
||||||
return objectMapper.convertValue(detailNode, ApiPrivateError.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("Cannot map detail to ApiPrivateError, creating default error. Detail: {}", detailNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ApiPrivateError.builder()
|
|
||||||
.codError(null)
|
|
||||||
.mensajeError(message)
|
|
||||||
.constraintName(null)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Class<?> getElementTypeFromRequest(HttpRequest request) {
|
|
||||||
if (request.getGenericType() != null) {
|
|
||||||
return request.getGenericType();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.getComplexType() instanceof ParameterizedType pt) {
|
|
||||||
Type[] typeArgs = pt.getActualTypeArguments();
|
|
||||||
|
|
||||||
if (typeArgs.length > 0) {
|
|
||||||
Type firstArg = typeArgs[0];
|
|
||||||
|
|
||||||
if (firstArg instanceof ParameterizedType innerPt) {
|
|
||||||
Type[] innerArgs = innerPt.getActualTypeArguments();
|
|
||||||
|
|
||||||
if (innerArgs.length > 0 && innerArgs[0] instanceof Class<?> innerClass) {
|
|
||||||
return innerClass;
|
|
||||||
}
|
|
||||||
} else if (firstArg instanceof Class<?> elementClass) {
|
|
||||||
return elementClass;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.warn("No se pudo determinar el elementType del request, usando Object.class");
|
|
||||||
return Object.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T deserializeApiResponse(
|
private <T> T deserializeApiResponse(
|
||||||
String responseBody,
|
String responseBody,
|
||||||
@ -402,12 +243,14 @@ public class HttpClientService implements HttpClientUseCase {
|
|||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
log.error("Error deserializando respuesta JSON: {}", e.getMessage());
|
log.error("Error deserializando respuesta JSON: {}", e.getMessage());
|
||||||
throw HttpStatusCodeException.internalServer(
|
throw HttpStatusCodeException.internalServer(
|
||||||
"500", "Error deserializando respuesta JSON: " + e.getMessage()
|
"500",
|
||||||
|
"Error deserializando respuesta JSON: " + e.getMessage()
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error desconocido al deserializar respuesta: {}", e.getMessage());
|
log.error("Error desconocido al deserializar respuesta: {}", e.getMessage());
|
||||||
throw HttpStatusCodeException.internalServer(
|
throw HttpStatusCodeException.internalServer(
|
||||||
"500", "Error desconocido al deserializar respuesta: " + e.getMessage()
|
"500",
|
||||||
|
"Error desconocido al deserializar respuesta: " + e.getMessage()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,7 @@
|
|||||||
package com.banesco.common.application.usecase;
|
package com.banesco.common.application.usecase;
|
||||||
|
|
||||||
import com.banesco.common.domain.model.*;
|
import com.banesco.common.domain.model.HttpRequest;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface HttpClientUseCase {
|
public interface HttpClientUseCase {
|
||||||
|
|
||||||
<T> T execute(HttpRequest request);
|
<T> T execute(HttpRequest request);
|
||||||
|
|
||||||
<T> ApiResponse<T> executeApiResponse(HttpRequest request);
|
|
||||||
|
|
||||||
<T> ApiResponse<List<T>> executeApiResponseList(HttpRequest request);
|
|
||||||
|
|
||||||
<T> ApiPrivateResponse<Either<T, ApiPrivateError>> executeApiPrivateResponse(HttpRequest request);
|
|
||||||
|
|
||||||
<T> ApiPrivateResponse<Either<List<T>, ApiPrivateError>> executeApiPrivateResponseList(HttpRequest request);
|
|
||||||
}
|
}
|
||||||
@ -15,6 +15,6 @@ import java.util.List;
|
|||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Agreement {
|
public class Agreement {
|
||||||
@Schema(description = "Informacion del arreglo de la cuenta")
|
@Schema(description = "Información del arreglo de la cuenta")
|
||||||
private List<Arrangement> arrangement;
|
private List<Arrangement> arrangement;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
package com.banesco.common.domain.model;
|
|
||||||
|
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@ToString
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@RegisterForReflection
|
|
||||||
public class ApiPrivateError {
|
|
||||||
private Long codError;
|
|
||||||
private String mensajeError;
|
|
||||||
private String constraintName;
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
package com.banesco.common.domain.model;
|
|
||||||
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class ApiPrivateResponse<T> {
|
|
||||||
private String estatus;
|
|
||||||
private String mensaje;
|
|
||||||
private T detalle;
|
|
||||||
private String codeline;
|
|
||||||
private String __equalsCalc;
|
|
||||||
private Boolean __hashCodeCalc;
|
|
||||||
}
|
|
||||||
@ -13,6 +13,6 @@ import org.eclipse.microprofile.openapi.annotations.media.Schema;
|
|||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Arrangement {
|
public class Arrangement {
|
||||||
@Schema(description = "Informacion del tipo de arreglo de la cuenta (Si la cuenta corriente tiene interes)")
|
@Schema(description = "Información del tipo de arreglo de la cuenta (Si la cuenta corriente tiene interés)")
|
||||||
private ArrangementType arrangementType;
|
private ArrangementType arrangementType;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,33 +0,0 @@
|
|||||||
package com.banesco.common.domain.model;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class Either<L, R> {
|
|
||||||
private final L left;
|
|
||||||
private final R right;
|
|
||||||
|
|
||||||
private final boolean leftFlag;
|
|
||||||
|
|
||||||
private Either(L left, R right, boolean leftFlag) {
|
|
||||||
this.left = left;
|
|
||||||
this.right = right;
|
|
||||||
this.leftFlag = leftFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <L, R> Either<L, R> left(L left) {
|
|
||||||
return new Either<>(left, null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <L, R> Either<L, R> right(R right) {
|
|
||||||
return new Either<>(null, right, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLeft() {
|
|
||||||
return leftFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRight() {
|
|
||||||
return !leftFlag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,7 +2,6 @@ package com.banesco.common.domain.model;
|
|||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -24,24 +23,6 @@ public class HttpRequest {
|
|||||||
|
|
||||||
private Class<?> genericType;
|
private Class<?> genericType;
|
||||||
|
|
||||||
private Type complexType;
|
|
||||||
|
|
||||||
private Class<?> errorType;
|
|
||||||
|
|
||||||
private String statusSuccess;
|
|
||||||
|
|
||||||
@Builder.Default
|
|
||||||
private boolean eitherResponse = false;
|
|
||||||
|
|
||||||
@Builder.Default
|
|
||||||
private boolean apiPrivateResponse = false;
|
|
||||||
|
|
||||||
@Builder.Default
|
|
||||||
private boolean apiResponse = false;
|
|
||||||
|
|
||||||
@Builder.Default
|
|
||||||
private boolean listResponse = false;
|
|
||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
private int connectTimeout = 5000;
|
private int connectTimeout = 5000;
|
||||||
|
|
||||||
@ -51,172 +32,6 @@ public class HttpRequest {
|
|||||||
@Builder.Default
|
@Builder.Default
|
||||||
private boolean returnFullResponse = false;
|
private boolean returnFullResponse = false;
|
||||||
|
|
||||||
@Builder.Default
|
|
||||||
private boolean logRequestBody = true;
|
|
||||||
|
|
||||||
@Builder.Default
|
|
||||||
private boolean logResponseBody = true;
|
|
||||||
|
|
||||||
public static <T> HttpRequest forApiResponse(
|
|
||||||
String url,
|
|
||||||
HttpMethod method,
|
|
||||||
Class<T> dataType
|
|
||||||
) {
|
|
||||||
return HttpRequest.builder()
|
|
||||||
.url(url)
|
|
||||||
.method(method)
|
|
||||||
.responseType(ApiResponse.class)
|
|
||||||
.genericType(dataType)
|
|
||||||
.apiResponse(true)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> HttpRequest forApiResponseList(
|
|
||||||
String url,
|
|
||||||
HttpMethod method,
|
|
||||||
Class<T> elementType
|
|
||||||
) {
|
|
||||||
return HttpRequest.builder()
|
|
||||||
.url(url)
|
|
||||||
.method(method)
|
|
||||||
.responseType(ApiResponse.class)
|
|
||||||
.complexType(TypeBuilder.listOf(elementType))
|
|
||||||
.apiResponse(true)
|
|
||||||
.listResponse(true)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> HttpRequest forApiPrivateResponse(
|
|
||||||
String url,
|
|
||||||
String statusSuccess,
|
|
||||||
HttpMethod method,
|
|
||||||
Class<T> successType
|
|
||||||
) {
|
|
||||||
return HttpRequest.builder()
|
|
||||||
.url(url)
|
|
||||||
.method(method)
|
|
||||||
.responseType(ApiPrivateResponse.class)
|
|
||||||
.complexType(TypeBuilder.parametricType(
|
|
||||||
Either.class,
|
|
||||||
successType,
|
|
||||||
ApiPrivateError.class
|
|
||||||
))
|
|
||||||
.apiPrivateResponse(true)
|
|
||||||
.eitherResponse(true)
|
|
||||||
.errorType(ApiPrivateError.class)
|
|
||||||
.statusSuccess(statusSuccess)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> HttpRequest forApiPrivateResponseList(
|
|
||||||
String url,
|
|
||||||
String statusSuccess,
|
|
||||||
HttpMethod method,
|
|
||||||
Class<T> elementType
|
|
||||||
) {
|
|
||||||
return HttpRequest.builder()
|
|
||||||
.url(url)
|
|
||||||
.method(method)
|
|
||||||
.responseType(ApiPrivateResponse.class)
|
|
||||||
.complexType(TypeBuilder.parametricType(
|
|
||||||
Either.class,
|
|
||||||
TypeBuilder.listOf(elementType),
|
|
||||||
ApiPrivateError.class
|
|
||||||
))
|
|
||||||
.apiPrivateResponse(true)
|
|
||||||
.eitherResponse(true)
|
|
||||||
.listResponse(true)
|
|
||||||
.errorType(ApiPrivateError.class)
|
|
||||||
.statusSuccess(statusSuccess)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> HttpRequest forDirectResponse(
|
|
||||||
String url,
|
|
||||||
HttpMethod method,
|
|
||||||
Class<T> responseType
|
|
||||||
) {
|
|
||||||
return HttpRequest.builder()
|
|
||||||
.url(url)
|
|
||||||
.method(method)
|
|
||||||
.responseType(responseType)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T, U> HttpRequest forGenericResponse(
|
|
||||||
String url,
|
|
||||||
HttpMethod method,
|
|
||||||
Class<T> rawType,
|
|
||||||
Class<U> genericType
|
|
||||||
) {
|
|
||||||
return HttpRequest.builder()
|
|
||||||
.url(url)
|
|
||||||
.method(method)
|
|
||||||
.responseType(rawType)
|
|
||||||
.complexType(TypeBuilder.parametricType(rawType, genericType))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpRequest withHeaders(Map<String, String> headers) {
|
|
||||||
this.headers = headers;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpRequest withQueryParams(Map<String, String> queryParams) {
|
|
||||||
this.queryParams = queryParams;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpRequest withPathParams(Map<String, String> pathParams) {
|
|
||||||
this.pathParams = pathParams;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpRequest withBody(Object body) {
|
|
||||||
this.body = body;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpRequest withTimeout(int connectTimeout, int readTimeout) {
|
|
||||||
this.connectTimeout = connectTimeout;
|
|
||||||
this.readTimeout = readTimeout;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpRequest disableRequestLogging() {
|
|
||||||
this.logRequestBody = false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpRequest disableResponseLogging() {
|
|
||||||
this.logResponseBody = false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResponseType getExpectedResponseType() {
|
|
||||||
if (apiPrivateResponse && eitherResponse) {
|
|
||||||
return listResponse ? ResponseType.API_PRIVATE_WITH_EITHER_LIST : ResponseType.API_PRIVATE_WITH_EITHER;
|
|
||||||
} else if (apiResponse) {
|
|
||||||
return listResponse ? ResponseType.API_RESPONSE_LIST : ResponseType.API_RESPONSE;
|
|
||||||
} else if (complexType != null) {
|
|
||||||
return ResponseType.COMPLEX_TYPE;
|
|
||||||
} else if (genericType != null) {
|
|
||||||
return ResponseType.GENERIC_TYPE;
|
|
||||||
} else {
|
|
||||||
return ResponseType.DIRECT_TYPE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ResponseType {
|
|
||||||
API_RESPONSE,
|
|
||||||
API_RESPONSE_LIST,
|
|
||||||
API_PRIVATE_WITH_EITHER,
|
|
||||||
API_PRIVATE_WITH_EITHER_LIST,
|
|
||||||
GENERIC_TYPE,
|
|
||||||
COMPLEX_TYPE,
|
|
||||||
DIRECT_TYPE
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum HttpMethod {
|
public enum HttpMethod {
|
||||||
GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
|
GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,67 +0,0 @@
|
|||||||
package com.banesco.common.domain.model;
|
|
||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
public class TypeBuilder {
|
|
||||||
|
|
||||||
private TypeBuilder() {}
|
|
||||||
|
|
||||||
public static Type listOf(Class<?> elementType) {
|
|
||||||
return new ParameterizedType() {
|
|
||||||
@Override
|
|
||||||
public Type[] getActualTypeArguments() {
|
|
||||||
return new Type[]{elementType};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getRawType() {
|
|
||||||
return java.util.List.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getOwnerType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type parametricType(Class<?> rawType, Type... typeArguments) {
|
|
||||||
return new ParameterizedType() {
|
|
||||||
@Override
|
|
||||||
public Type[] getActualTypeArguments() {
|
|
||||||
return typeArguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getRawType() {
|
|
||||||
return rawType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getOwnerType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type apiPrivateResponseWithEither(Class<?> successType, Class<?> errorType) {
|
|
||||||
Type eitherType = parametricType(Either.class, successType, errorType);
|
|
||||||
return parametricType(ApiPrivateResponse.class, eitherType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type apiPrivateResponseWithListEither(Class<?> successType, Class<?> errorType) {
|
|
||||||
Type listType = listOf(successType);
|
|
||||||
Type eitherType = parametricType(Either.class, listType, errorType);
|
|
||||||
return parametricType(ApiPrivateResponse.class, eitherType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type apiResponseType(Class<?> dataType) {
|
|
||||||
return parametricType(ApiResponse.class, dataType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type apiResponseListType(Class<?> elementType) {
|
|
||||||
Type listType = listOf(elementType);
|
|
||||||
return parametricType(ApiResponse.class, listType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -40,7 +40,7 @@ public class ApiAllowedConfig {
|
|||||||
log.info("Configurando {}: {}", fullConfigName, json);
|
log.info("Configurando {}: {}", fullConfigName, json);
|
||||||
|
|
||||||
if (json == null || json.trim().isEmpty()) {
|
if (json == null || json.trim().isEmpty()) {
|
||||||
throw new IllegalStateException("Configuracion no encontrada para: " + fullConfigName);
|
throw new IllegalStateException("Configuración no encontrada para: " + fullConfigName);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, Object>> configList = objectMapper.readValue(json, new TypeReference<>() {});
|
List<Map<String, Object>> configList = objectMapper.readValue(json, new TypeReference<>() {});
|
||||||
|
|||||||
@ -58,15 +58,15 @@ public class RestClientConfig {
|
|||||||
log.info("Configurando {}: {}", fullConfigName, json);
|
log.info("Configurando {}: {}", fullConfigName, json);
|
||||||
|
|
||||||
if (json == null || json.trim().isEmpty()) {
|
if (json == null || json.trim().isEmpty()) {
|
||||||
throw new IllegalStateException("Configuracion no encontrada para: " + fullConfigName);
|
throw new IllegalStateException("Configuración no encontrada para: " + fullConfigName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> configMap = objectMapper.readValue(json, new TypeReference<>() {});
|
Map<String, Object> configMap = objectMapper.readValue(json, new TypeReference<>() {});
|
||||||
return objectMapper.convertValue(configMap, configType);
|
return objectMapper.convertValue(configMap, configType);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new IllegalArgumentException("Formato JSON invalido para " + configName + ": " + e.getMessage(), e);
|
throw new IllegalArgumentException("Formato JSON inválido para " + configName + ": " + e.getMessage(), e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalStateException("Error cargando configuracion del servicio " + configName + ": " + e.getMessage(), e);
|
throw new IllegalStateException("Error cargando configuración del servicio " + configName + ": " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -18,18 +18,18 @@ import java.util.List;
|
|||||||
public class Account {
|
public class Account {
|
||||||
@Schema(description = "Estado de la cuenta")
|
@Schema(description = "Estado de la cuenta")
|
||||||
private AccountStatus accountStatus;
|
private AccountStatus accountStatus;
|
||||||
@Schema(description = "Lista de datos de identificacion de la cuenta")
|
@Schema(description = "Lista de datos de identificación de la cuenta")
|
||||||
private List<AccountIdentification> accountIdentification;
|
private List<AccountIdentification> accountIdentification;
|
||||||
@Schema(description = "Tipo de cuenta")
|
@Schema(description = "Tipo de cuenta")
|
||||||
private AccountType accountType;
|
private AccountType accountType;
|
||||||
@Schema(description = "Informacion de los tipos de balances de la cuenta")
|
@Schema(description = "Información de los tipos de balances de la cuenta")
|
||||||
private List<AccountBalance> accountBalance;
|
private List<AccountBalance> accountBalance;
|
||||||
@Schema(description = "Informacion de la moneda de la cuenta")
|
@Schema(description = "Información de la moneda de la cuenta")
|
||||||
private List<AccountCurrency> accountCurrency;
|
private List<AccountCurrency> accountCurrency;
|
||||||
@Schema(description = "Informacion complementaria de la cuenta")
|
@Schema(description = "Información complementaria de la cuenta")
|
||||||
private List<AccountInvolvement> accountInvolvement;
|
private List<AccountInvolvement> accountInvolvement;
|
||||||
@Schema(description = "Informacion relacional de la cuenta con otras o consigo misma")
|
@Schema(description = "Información relacional de la cuenta con otras o consigo misma")
|
||||||
private List<AccountRelationship> accountRelationship;
|
private List<AccountRelationship> accountRelationship;
|
||||||
@Schema(description = "Informacion del acuerdo de la cuenta")
|
@Schema(description = "Información del acuerdo de la cuenta")
|
||||||
private List<Agreement> agreement;
|
private List<Agreement> agreement;
|
||||||
}
|
}
|
||||||
@ -13,6 +13,6 @@ import org.eclipse.microprofile.openapi.annotations.media.Schema;
|
|||||||
@RegisterForReflection
|
@RegisterForReflection
|
||||||
public class AccountInvolvement {
|
public class AccountInvolvement {
|
||||||
private AccountInvolvementType accountInvolvementType;
|
private AccountInvolvementType accountInvolvementType;
|
||||||
@Schema(description = "Informacion del cliente")
|
@Schema(description = "Información del cliente")
|
||||||
private Party partyReference;
|
private Party partyReference;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class LegalCustomerProductDirectoryService implements LegalCustomerProduc
|
|||||||
public ApiResponse<LegalCustomerProductDirectoryResponse> execute(
|
public ApiResponse<LegalCustomerProductDirectoryResponse> execute(
|
||||||
LegalCustomerProductDirectoryRequest request
|
LegalCustomerProductDirectoryRequest request
|
||||||
) {
|
) {
|
||||||
log.info("Iniciando ejecucion para el cliente: {}", request.getCustomerIbsNumber());
|
log.info("Iniciando ejecución para el cliente: {}", request.getCustomerIbsNumber());
|
||||||
|
|
||||||
LegalCustomerProductDirectoryRequest requestFromAppId = getRequestFromAppId(request);
|
LegalCustomerProductDirectoryRequest requestFromAppId = getRequestFromAppId(request);
|
||||||
|
|
||||||
@ -76,10 +76,10 @@ public class LegalCustomerProductDirectoryService implements LegalCustomerProduc
|
|||||||
|
|
||||||
throw HttpStatusCodeException.serviceUnavailable("503");
|
throw HttpStatusCodeException.serviceUnavailable("503");
|
||||||
} catch (HttpStatusCodeException e) {
|
} catch (HttpStatusCodeException e) {
|
||||||
log.error("Excepcion HTTP del api de dominio: {} - {}", e.getStatusCode(), e.getErrorCode());
|
log.error("Excepción HTTP del api de dominio: {} - {}", e.getStatusCode(), e.getErrorCode());
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Excepcion generica del api de dominio: {}", e.getMessage());
|
log.error("Excepción genérica del api de dominio: {}", e.getMessage());
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
securityTrace();
|
securityTrace();
|
||||||
@ -91,7 +91,7 @@ public class LegalCustomerProductDirectoryService implements LegalCustomerProduc
|
|||||||
) {
|
) {
|
||||||
if(appIdsAllowed.isEmpty()) {
|
if(appIdsAllowed.isEmpty()) {
|
||||||
log.info(
|
log.info(
|
||||||
"Configuracion de la Lista App ID no disponible: {} -> {}",
|
"Configuración de la Lista App ID no disponible: {} -> {}",
|
||||||
request.getCustomerIbsNumber(),
|
request.getCustomerIbsNumber(),
|
||||||
request.getAppId()
|
request.getAppId()
|
||||||
);
|
);
|
||||||
@ -110,7 +110,7 @@ public class LegalCustomerProductDirectoryService implements LegalCustomerProduc
|
|||||||
AppIdConfig appIdConfig = appIdAllowed.get();
|
AppIdConfig appIdConfig = appIdAllowed.get();
|
||||||
|
|
||||||
if(!request.hasValidRequestParameters(appIdConfig)) {
|
if(!request.hasValidRequestParameters(appIdConfig)) {
|
||||||
log.info("App ID sin configuracion: {} -> {}", request.getCustomerIbsNumber(), request.getAppId());
|
log.info("App ID sin configuración: {} -> {}", request.getCustomerIbsNumber(), request.getAppId());
|
||||||
throw HttpStatusCodeException.unauthorized("401");
|
throw HttpStatusCodeException.unauthorized("401");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,16 +20,16 @@ public class LegalCustomerProductDirectoryRequest {
|
|||||||
@NonNull
|
@NonNull
|
||||||
private String appId; // Header obligatorio
|
private String appId; // Header obligatorio
|
||||||
@NonNull
|
@NonNull
|
||||||
private String customerIbsNumber; // VCUSCUN - Obligatorio (Numero de cliente IBS)
|
private String customerIbsNumber; // VCUSCUN - Obligatorio (Número de cliente IBS)
|
||||||
|
|
||||||
private String bankNumber; // VACMBNK - Numero de Banco (filtro)
|
private String bankNumber; // VACMBNK - Número de Banco (filtro)
|
||||||
private String currencyCode; // VACMCCY - Moneda (filtro)
|
private String currencyCode; // VACMCCY - Moneda (filtro)
|
||||||
private String accountStatus; // VACMAST - Estatus de Cuenta (filtro)
|
private String accountStatus; // VACMAST - Estatus de Cuenta (filtro)
|
||||||
private String productCvCode; // VACMPROCV - Codigo de Producto Cuenta Verde (filtro)
|
private String productCvCode; // VACMPROCV - Código de Producto Cuenta Verde (filtro)
|
||||||
private String productCode; // VACMPRO - Codigo de Producto (filtro)
|
private String productCode; // VACMPRO - Código de Producto (filtro)
|
||||||
private String channelCode; // VAFILICANAL - Codigo de Canal (filtro)
|
private String channelCode; // VAFILICANAL - Código de Canal (filtro)
|
||||||
private String serviceType; // VAFILICOSER - Tipo de Servicio (filtro)
|
private String serviceType; // VAFILICOSER - Tipo de Servicio (filtro)
|
||||||
private String affiliationStatus; // VAFILISTATU - Estatus de afiliacion (filtro)
|
private String affiliationStatus; // VAFILISTATU - Estatus de afiliación (filtro)
|
||||||
private String limitType; // VALIMIT - Pagador/Receptor (PAG/REC) (filtro)
|
private String limitType; // VALIMIT - Pagador/Receptor (PAG/REC) (filtro)
|
||||||
private String casheaIndicator; // VCASHEA - SI/NO (filtro)
|
private String casheaIndicator; // VCASHEA - SI/NO (filtro)
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public class DomLegalCustomerProductDirectoryClient implements DomainUseCase {
|
|||||||
) {
|
) {
|
||||||
this.httpClientUseCase = httpClientUseCase;
|
this.httpClientUseCase = httpClientUseCase;
|
||||||
this.domainConfig = restClientConfig.getDomLegalCustomerConfig();
|
this.domainConfig = restClientConfig.getDomLegalCustomerConfig();
|
||||||
log.info("Configuracion cargada para bus-legal-customer-directory: {}", domainConfig);
|
log.info("Configuración cargada para bus-legal-customer-directory: {}", domainConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,17 +37,16 @@ public class DomLegalCustomerProductDirectoryClient implements DomainUseCase {
|
|||||||
Class<T> responseType
|
Class<T> responseType
|
||||||
) {
|
) {
|
||||||
String customerIbsNumber = params.getCustomerIbsNumber();
|
String customerIbsNumber = params.getCustomerIbsNumber();
|
||||||
HttpRequest request = HttpRequest.forApiResponse(
|
HttpRequest request = HttpRequest.builder()
|
||||||
domainConfig.getUrl(),
|
.url(domainConfig.getUrl())
|
||||||
HttpRequest.HttpMethod.GET,
|
.method(HttpRequest.HttpMethod.GET)
|
||||||
responseType
|
.pathParams(Map.of("customerIbsNumber", customerIbsNumber))
|
||||||
)
|
.queryParams(params.toQueryString())
|
||||||
.withPathParams(Map.of("customerIbsNumber", customerIbsNumber))
|
.responseType(ApiResponse.class)
|
||||||
.withQueryParams(params.toQueryString())
|
.genericType(responseType)
|
||||||
.withTimeout(
|
.connectTimeout(domainConfig.getTimeout().getConnect())
|
||||||
domainConfig.getTimeout().getConnect(),
|
.readTimeout(domainConfig.getTimeout().getResponse())
|
||||||
domainConfig.getTimeout().getResponse()
|
.build();
|
||||||
);
|
|
||||||
|
|
||||||
log.debug("Request configurado: {}", request);
|
log.debug("Request configurado: {}", request);
|
||||||
|
|
||||||
|
|||||||
@ -45,12 +45,12 @@ public class LegalCustomerProductDirectoryResource {
|
|||||||
@Path("/retrieve/{customerIbsNumber : (?!retrieve$).*}")
|
@Path("/retrieve/{customerIbsNumber : (?!retrieve$).*}")
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Recuperar productos de cliente legal",
|
summary = "Recuperar productos de cliente legal",
|
||||||
description = "Consulta masiva de cuentas por numero de cliente IBS"
|
description = "Consulta masiva de cuentas por número de cliente IBS"
|
||||||
)
|
)
|
||||||
@APIResponses(value = {
|
@APIResponses(value = {
|
||||||
@APIResponse(
|
@APIResponse(
|
||||||
responseCode = "200",
|
responseCode = "200",
|
||||||
description = "Operacion exitosa",
|
description = "Operación exitosa",
|
||||||
content = @Content(
|
content = @Content(
|
||||||
mediaType = MediaType.APPLICATION_JSON,
|
mediaType = MediaType.APPLICATION_JSON,
|
||||||
schema = @Schema(
|
schema = @Schema(
|
||||||
@ -142,7 +142,7 @@ public class LegalCustomerProductDirectoryResource {
|
|||||||
"fullName": "TASCA RESTAURANT GOOD WORLD CEN, C.A."
|
"fullName": "TASCA RESTAURANT GOOD WORLD CEN, C.A."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"partyType": "ORGANIZATION",
|
"partyType": "ORGANISATION",
|
||||||
"partyIdentification": [
|
"partyIdentification": [
|
||||||
{
|
{
|
||||||
"partyIdentificationType": "TAX_IDENTIFICATION_NUMBER",
|
"partyIdentificationType": "TAX_IDENTIFICATION_NUMBER",
|
||||||
@ -186,7 +186,7 @@ public class LegalCustomerProductDirectoryResource {
|
|||||||
},
|
},
|
||||||
"statusResponse": {
|
"statusResponse": {
|
||||||
"statusCode": "200",
|
"statusCode": "200",
|
||||||
"message": "Operacion exitosa"
|
"message": "Operación exitosa"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@ -259,7 +259,7 @@ public class LegalCustomerProductDirectoryResource {
|
|||||||
),
|
),
|
||||||
examples = {
|
examples = {
|
||||||
@ExampleObject(
|
@ExampleObject(
|
||||||
name = "Error VRN08 - Identificacion del fintechId no coincide",
|
name = "Error VRN08 - Identificación del fintechId no coincide",
|
||||||
value = """
|
value = """
|
||||||
{
|
{
|
||||||
"data": null,
|
"data": null,
|
||||||
@ -299,7 +299,7 @@ public class LegalCustomerProductDirectoryResource {
|
|||||||
"data": null,
|
"data": null,
|
||||||
"statusResponse": {
|
"statusResponse": {
|
||||||
"statusCode": "VRN04",
|
"statusCode": "VRN04",
|
||||||
"message": "El servicio no esta disponible fuera del horario operativo"
|
"message": "El servicio no está disponible fuera del horario operativo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@ -311,7 +311,7 @@ public class LegalCustomerProductDirectoryResource {
|
|||||||
"data": null,
|
"data": null,
|
||||||
"statusResponse": {
|
"statusResponse": {
|
||||||
"statusCode": "VDR13",
|
"statusCode": "VDR13",
|
||||||
"message": "El servicio OSB no esta disponible en este momento"
|
"message": "El servicio OSB no está disponible en este momento"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
@ -322,11 +322,11 @@ public class LegalCustomerProductDirectoryResource {
|
|||||||
})
|
})
|
||||||
public Response retrieve(
|
public Response retrieve(
|
||||||
@PathParam("customerIbsNumber")
|
@PathParam("customerIbsNumber")
|
||||||
@Parameter(description = "Numero de cliente IBS (VCUSCUN)", example = "200053197")
|
@Parameter(description = "Número de cliente IBS (VCUSCUN)", example = "200053197")
|
||||||
String customerIbsNumber,
|
String customerIbsNumber,
|
||||||
|
|
||||||
@QueryParam("appId")
|
@QueryParam("appId")
|
||||||
@Parameter(description = "ID de la aplicacion", required = true, example = "DANIAPP")
|
@Parameter(description = "ID de la aplicación", required = true, example = "DANIAPP")
|
||||||
String appId,
|
String appId,
|
||||||
|
|
||||||
@QueryParam("customerReferenceFintechId")
|
@QueryParam("customerReferenceFintechId")
|
||||||
|
|||||||
@ -2,5 +2,5 @@ package com.banesco.module.party.domain.model;
|
|||||||
|
|
||||||
public enum PartyType {
|
public enum PartyType {
|
||||||
PERSON,
|
PERSON,
|
||||||
ORGANIZATION
|
ORGANISATION
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,22 +24,20 @@ public class SecurityTraceClient implements SecurityTraceUseCase {
|
|||||||
) {
|
) {
|
||||||
this.httpClientUseCase = httpClientUseCase;
|
this.httpClientUseCase = httpClientUseCase;
|
||||||
this.securityTraceConfig = restClientConfig.getSecurityTraceConfig();
|
this.securityTraceConfig = restClientConfig.getSecurityTraceConfig();
|
||||||
log.info("Configuracion cargada para security-trace: {}", securityTraceConfig);
|
log.info("Configuración cargada para security-trace: {}", securityTraceConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T execute(Class<T> responseType) {
|
public <T> T execute(Class<T> responseType) {
|
||||||
SecurityTraceRequest body = securityTraceConfig.getRequest();
|
SecurityTraceRequest body = securityTraceConfig.getRequest();
|
||||||
HttpRequest request = HttpRequest.forDirectResponse(
|
HttpRequest request = HttpRequest.builder()
|
||||||
securityTraceConfig.getUrl(),
|
.url(securityTraceConfig.getUrl())
|
||||||
HttpRequest.HttpMethod.POST,
|
.method(HttpRequest.HttpMethod.POST)
|
||||||
responseType
|
.body(body)
|
||||||
)
|
.responseType(responseType)
|
||||||
.withBody(body)
|
.connectTimeout(securityTraceConfig.getTimeout().getConnect())
|
||||||
.withTimeout(
|
.readTimeout(securityTraceConfig.getTimeout().getResponse())
|
||||||
securityTraceConfig.getTimeout().getConnect(),
|
.build();
|
||||||
securityTraceConfig.getTimeout().getResponse()
|
|
||||||
);
|
|
||||||
|
|
||||||
log.debug("Request configurado: {}", request);
|
log.debug("Request configurado: {}", request);
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public class ServiceStatusClient implements ServiceStatusUseCase {
|
|||||||
) {
|
) {
|
||||||
this.httpClientUseCase = httpClientUseCase;
|
this.httpClientUseCase = httpClientUseCase;
|
||||||
this.serviceStatusConfig = restClientConfig.getServiceStatusConfig();
|
this.serviceStatusConfig = restClientConfig.getServiceStatusConfig();
|
||||||
log.info("Configuracion cargada para service-status: {}", serviceStatusConfig);
|
log.info("Configuración cargada para service-status: {}", serviceStatusConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,16 +37,14 @@ public class ServiceStatusClient implements ServiceStatusUseCase {
|
|||||||
.transactionId(params.getTransactionId())
|
.transactionId(params.getTransactionId())
|
||||||
.bankService(serviceStatusConfig.getRequest().getBankService())
|
.bankService(serviceStatusConfig.getRequest().getBankService())
|
||||||
.build();
|
.build();
|
||||||
HttpRequest request = HttpRequest.forDirectResponse(
|
HttpRequest request = HttpRequest.builder()
|
||||||
serviceStatusConfig.getUrl(),
|
.url(serviceStatusConfig.getUrl())
|
||||||
HttpRequest.HttpMethod.POST,
|
.method(HttpRequest.HttpMethod.POST)
|
||||||
responseType
|
.body(body)
|
||||||
)
|
.responseType(responseType)
|
||||||
.withBody(body)
|
.connectTimeout(serviceStatusConfig.getTimeout().getConnect())
|
||||||
.withTimeout(
|
.readTimeout(serviceStatusConfig.getTimeout().getResponse())
|
||||||
serviceStatusConfig.getTimeout().getConnect(),
|
.build();
|
||||||
serviceStatusConfig.getTimeout().getResponse()
|
|
||||||
);
|
|
||||||
|
|
||||||
log.debug("Request configurado: {}", request);
|
log.debug("Request configurado: {}", request);
|
||||||
|
|
||||||
@ -61,14 +59,14 @@ public class ServiceStatusClient implements ServiceStatusUseCase {
|
|||||||
return response;
|
return response;
|
||||||
} catch (HttpStatusCodeException e) {
|
} catch (HttpStatusCodeException e) {
|
||||||
log.error(
|
log.error(
|
||||||
"Error HTTP ejecutando verificacion de estado del servicio: {} - {}",
|
"Error HTTP ejecutando verificación de estado del servicio: {} - {}",
|
||||||
e.getStatusCode(),
|
e.getStatusCode(),
|
||||||
e.getMessage()
|
e.getMessage()
|
||||||
);
|
);
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error ejecutando verificacion de estado del servicio: {}", e.getMessage());
|
log.error("Error ejecutando verificación de estado del servicio: {}", e.getMessage());
|
||||||
throw HttpStatusCodeException.serviceUnavailable("503");
|
throw HttpStatusCodeException.serviceUnavailable("503");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ api:
|
|||||||
bus-legal-customer-product-directory:
|
bus-legal-customer-product-directory:
|
||||||
messages:
|
messages:
|
||||||
key: 'bus-legal-customer-product-directory'
|
key: 'bus-legal-customer-product-directory'
|
||||||
content: '[{"backendCode":"200","httpCode":200,"statusCode":"200","description":"Operacion exitosa"},{"backendCode":"R404","httpCode":404,"statusCode":"404","description":"Datos de validacion no encontrado."},{"backendCode":"503","httpCode":503,"statusCode":"503","description":"Uso interno"},{"backendCode":"422","httpCode":422,"statusCode":"422","description":"Uso interno"},{"backendCode":"500","httpCode":500,"statusCode":"500","description":"Uso interno"},{"backendCode":"100","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-382505","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-380002","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"ERROR","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"400","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"401","httpCode":401,"statusCode":"401","description":"Uso interno"},{"backendCode":"403","httpCode":403,"statusCode":"403","description":"Uso interno"},{"backendCode":"404","httpCode":404,"statusCode":"404","description":"Uso interno"},{"backendCode":"default","httpCode":409,"statusCode":"409","description":"Conflicto"},{"backendCode":"424","httpCode":424,"statusCode":"424","description":"Error de dependencia"},{"backendCode":"VDE01","httpCode":400,"statusCode":"VDE01","description":"VDE01 - Error en dato de entrada obligatorio: %s"},{"backendCode":"VDE02","httpCode":400,"statusCode":"VDE02","description":"VDE02 - Error en valor permitido para campo: %s"},{"backendCode":"VRN04","httpCode":"503","statusCode":"VRN04","description":"Servicio en horario de mantenimiento","status":"error"},{"backendCode":"204","httpCode":"200","statusCode":"200","description":"Cliente sin productos","status":"ok"}]'
|
content: '[{"backendCode":"200","httpCode":200,"statusCode":"200","description":"Operacion exitosa"},{"backendCode":"R404","httpCode":404,"statusCode":"404","description":"Datos de validación no encontrado."},{"backendCode":"503","httpCode":503,"statusCode":"503","description":"Uso interno"},{"backendCode":"422","httpCode":422,"statusCode":"422","description":"Uso interno"},{"backendCode":"500","httpCode":500,"statusCode":"500","description":"Uso interno"},{"backendCode":"100","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-382505","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"OSB-380002","httpCode":503,"statusCode":"503","description":"VDR13 - OSB Disponible"},{"backendCode":"ERROR","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"400","httpCode":400,"statusCode":"400","description":"Uso interno"},{"backendCode":"401","httpCode":401,"statusCode":"401","description":"Uso interno"},{"backendCode":"403","httpCode":403,"statusCode":"403","description":"Uso interno"},{"backendCode":"404","httpCode":404,"statusCode":"404","description":"Uso interno"},{"backendCode":"default","httpCode":409,"statusCode":"409","description":"Conflicto"},{"backendCode":"424","httpCode":424,"statusCode":"424","description":"Error de dependencia"},{"backendCode":"VDE01","httpCode":400,"statusCode":"VDE01","description":"VDE01 - Error en dato de entrada obligatorio: %s"},{"backendCode":"VDE02","httpCode":400,"statusCode":"VDE02","description":"VDE02 - Error en valor permitido para campo: %s"},{"backendCode":"VRN04","httpCode":"503","statusCode":"VRN04","description":"Servicio en horario de mantenimiento","status":"error"},{"backendCode":"204","httpCode":"200","statusCode":"200","description":"Cliente sin productos","status":"ok"}]'
|
||||||
rest-client:
|
rest-client:
|
||||||
dom-legal-customer-product-directory: '{"url":"http://localhost:8083/dom-legal-customer-product-directory/retrieve/{customerIbsNumber}","timeout":{"connect":10000,"response":10000}}'
|
dom-legal-customer-product-directory: '{"url":"http://localhost:8083/dom-legal-customer-product-directory/retrieve/{customerIbsNumber}","timeout":{"connect":10000,"response":10000}}'
|
||||||
security-trace: '{"url":"http://api-register-security-route-apis-banesco-dev.apps.desplakur3.desintra.banesco.com/register-security/save","timeout":{"connect":10000,"response":10000},"request":{"sp":"spAPI_Traza","eventCod":"CANCTARJ","bankCod":"01","curCod":"BS"}}'
|
security-trace: '{"url":"http://api-register-security-route-apis-banesco-dev.apps.desplakur3.desintra.banesco.com/register-security/save","timeout":{"connect":10000,"response":10000},"request":{"sp":"spAPI_Traza","eventCod":"CANCTARJ","bankCod":"01","curCod":"BS"}}'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user