- Pruebas Locales invocando los 3 servicios
- Ajstes en commons plaint
This commit is contained in:
parent
797161894f
commit
8d884c1c60
5
.idea/compiler.xml
generated
5
.idea/compiler.xml
generated
@ -8,11 +8,14 @@
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="bus-update-card-status" />
|
||||
<module name="commons-bian" />
|
||||
<module name="commons" />
|
||||
<module name="rec-update-card-status" />
|
||||
<module name="prv-update-card-status" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="commons-bian" target="17" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
|
||||
2
.idea/encodings.xml
generated
2
.idea/encodings.xml
generated
@ -5,6 +5,8 @@
|
||||
<file url="file://$PROJECT_DIR$/bus-update-card-status/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/commons-bian/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/commons-bian/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/commons-plain-java/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/commons-plain-java/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/prv-update-card-status/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/prv-update-card-status/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/rec-update-card-status/src/main/java" charset="UTF-8" />
|
||||
|
||||
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -9,6 +9,7 @@
|
||||
<option value="$PROJECT_DIR$/bus-update-card-status/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/rec-update-card-status/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/prv-update-card-status/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/commons-plain-java/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/BIAN-Quarkus.iml" filepath="$PROJECT_DIR$/.idea/BIAN-Quarkus.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
1
.idea/vcs.xml
generated
1
.idea/vcs.xml
generated
@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/commons-plain-java" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@ -45,7 +45,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.banesco</groupId>
|
||||
<artifactId>commons-bian</artifactId>
|
||||
<artifactId>commons</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@ -2,7 +2,7 @@ package com.banesco.application.helper;
|
||||
|
||||
|
||||
import com.banesco.common.application.exception.BanRuntimeException;
|
||||
import com.banesco.common.domain.dto.bian.device.StringHelper;
|
||||
import com.banesco.common.infraestructure.helpers.StringHelper;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.domain.bian.request.BusUpdateCardStatusRequest;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ -3,9 +3,9 @@ package com.banesco.application.rest.controllers;
|
||||
import com.banesco.application.helper.UpdateCardStatusRequestValidator;
|
||||
import com.banesco.common.application.exception.BanBackendException;
|
||||
import com.banesco.common.application.exception.BanRuntimeException;
|
||||
import com.banesco.common.domain.dto.bian.device.JsonHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.LoggerHelper;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.common.infraestructure.helpers.JsonHelper;
|
||||
import com.banesco.common.infraestructure.helpers.LoggerHelper;
|
||||
import com.banesco.commons.config.AppConf;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.domain.bian.request.BusUpdateCardStatusRequest;
|
||||
@ -153,7 +153,6 @@ public class UpdateCardStatusController {
|
||||
BusUpdateCardStatusRequest request) {
|
||||
|
||||
|
||||
BusUpdateCardStatusResponse dataResponse = null;
|
||||
log.info("INICIO =>");
|
||||
String requestId = request.getRequestId();
|
||||
log.info(LoggerHelper.buildInfoRequest(requestId, JsonHelper.getJsonFromObject(request)));
|
||||
@ -195,9 +194,10 @@ public class UpdateCardStatusController {
|
||||
}
|
||||
|
||||
BusUpdateCardStatusResponse response = new BusUpdateCardStatusResponse();
|
||||
|
||||
response.setStatusResponse(
|
||||
new StatusResponse(
|
||||
backendCode.equals(StatusCodes.SUCCESS_OPERATION.getStatusCode()) ? "ok" : "error",
|
||||
new BianStatusResponse(
|
||||
backendDesc.equals(StatusCodes.SUCCESS_OPERATION.getStatusDesc()) ? "ok" : "error",
|
||||
backendCode,
|
||||
backendDesc,
|
||||
requestId
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package com.banesco.commons.config;
|
||||
|
||||
import com.banesco.common.application.exception.BanRuntimeException;
|
||||
import com.banesco.common.domain.dto.bian.device.DateHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.JsonHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.RequestHelper;
|
||||
import com.banesco.common.domain.model.ApiConfig;
|
||||
import com.banesco.common.infraestructure.helpers.DateHelper;
|
||||
import com.banesco.common.infraestructure.helpers.JsonHelper;
|
||||
import com.banesco.common.infraestructure.helpers.RequestHelper;
|
||||
import com.banesco.commons.exceptions.BanConfigException;
|
||||
import com.banesco.domain.models.CurrentState;
|
||||
import jakarta.inject.Singleton;
|
||||
@ -13,7 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.microprofile.config.Config;
|
||||
import org.eclipse.microprofile.config.ConfigProvider;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
|
||||
@ -86,10 +86,10 @@ public class AppConf {
|
||||
|
||||
public CurrentState getCurrentState(String requestId) {
|
||||
|
||||
LocalDateTime now = dateHelper.getCurrentDateTime();
|
||||
Map<String, String> now = (Map) dateHelper.getCurrentVenezuelanDateTime(true);
|
||||
return new CurrentState(
|
||||
dateHelper.getDate(now),
|
||||
dateHelper.getTime(now),
|
||||
now.get("date"),
|
||||
now.get("time"),
|
||||
requestId
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.banesco.commons.exceptions;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.domain.bian.response.BusUpdateCardStatusResponse;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import jakarta.inject.Inject;
|
||||
@ -29,7 +29,7 @@ public class InternalExceptionMapper {
|
||||
case "/card/status/update":
|
||||
BusUpdateCardStatusResponse response = new BusUpdateCardStatusResponse();
|
||||
response.setStatusResponse(
|
||||
new StatusResponse(
|
||||
new BianStatusResponse(
|
||||
"error",
|
||||
"CONFLICT",
|
||||
"Uso interno",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.banesco.commons.exceptions;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.domain.bian.response.BusUpdateCardStatusResponse;
|
||||
import io.vertx.core.http.HttpServerRequest;
|
||||
@ -29,12 +29,12 @@ public class MalformedPayloadExceptionMapper implements ExceptionMapper<JsonbExc
|
||||
headers.getHeader("appId"));
|
||||
|
||||
|
||||
String jsonResult = (new BusUpdateCardStatusResponse( new StatusResponse(
|
||||
String jsonResult = (new BusUpdateCardStatusResponse(new BianStatusResponse(
|
||||
"error",
|
||||
StatusCodes.INVALID_FORMAT.getStatusCode(),
|
||||
StatusCodes.INVALID_FORMAT.getStatusDesc().formatted("body"),
|
||||
null
|
||||
))).toString();
|
||||
), null)).toString();
|
||||
|
||||
log.error("[RESPONSE]: [{}]", jsonResult);
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
package com.banesco.commons.utils;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
|
||||
|
||||
public class ResponseUtil {
|
||||
|
||||
public static StatusResponse mapErrorResponse(String requestId, StatusCodes statusCodes) {
|
||||
return new StatusResponse("error", statusCodes.getStatusCode(), statusCodes.getStatusDesc(), requestId);
|
||||
public static BianStatusResponse mapErrorResponse(String requestId, StatusCodes statusCodes) {
|
||||
return new BianStatusResponse("error", statusCodes.getStatusCode(), statusCodes.getStatusDesc(), requestId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.banesco.domain.bian.request;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.customer.CustomerReference;
|
||||
import com.banesco.common.domain.dto.bian.device.Device;
|
||||
import com.banesco.common.domain.dto.bian.device.BianDevice;
|
||||
import com.banesco.domain.bian.dto.CardReference;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -15,6 +15,6 @@ public class BusUpdateCardStatusRequest {
|
||||
String requestId;
|
||||
String customerReferenceFintechId;
|
||||
CustomerReference customerReference;
|
||||
Device device;
|
||||
BianDevice device;
|
||||
CardReference cardReference;
|
||||
}
|
||||
|
||||
@ -2,21 +2,21 @@ package com.banesco.domain.bian.response;
|
||||
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.BaseResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@RegisterForReflection
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class BusUpdateCardStatusResponse extends BaseResponse {
|
||||
public class BusUpdateCardStatusResponse extends BaseResponse<BianStatusResponse, Object> {
|
||||
|
||||
public BusUpdateCardStatusResponse() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BusUpdateCardStatusResponse(StatusResponse statusResponse) {
|
||||
super(statusResponse);
|
||||
public BusUpdateCardStatusResponse(BianStatusResponse statusResponse, Object data) {
|
||||
super(statusResponse, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
package com.banesco.domain.ports.outbound;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.domain.bian.request.BusUpdateCardStatusRequest;
|
||||
|
||||
public interface PaymentCardPort {
|
||||
|
||||
StatusResponse updateCardStatus(String productAccountId, BusUpdateCardStatusRequest request);
|
||||
void updateCardStatus(String clearAccount, BusUpdateCardStatusRequest request);
|
||||
}
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
package com.banesco.domain.services;
|
||||
|
||||
import com.banesco.common.application.exception.BanBackendException;
|
||||
import com.banesco.common.application.exception.BanRuntimeException;
|
||||
import com.banesco.common.domain.dto.bian.customer.CustomerReference;
|
||||
import com.banesco.common.domain.dto.bian.device.JsonHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.StringHelper;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.model.RedisParam;
|
||||
import com.banesco.common.infraestructure.helpers.JsonHelper;
|
||||
import com.banesco.common.infraestructure.helpers.StringHelper;
|
||||
import com.banesco.commons.config.AppConf;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.domain.bian.request.BusUpdateCardStatusRequest;
|
||||
@ -24,7 +22,6 @@ public class UpdateCardStatusService implements UpdateCardStatusUseCase {
|
||||
|
||||
|
||||
private final PaymentCardPort paymentCardPort;
|
||||
private final String RESULT_OK = StatusCodes.SUCCESS_OPERATION.getStatusCode();
|
||||
|
||||
private final RedisParam redisParam;
|
||||
|
||||
@ -42,17 +39,12 @@ public class UpdateCardStatusService implements UpdateCardStatusUseCase {
|
||||
@Override
|
||||
public void execute(BusUpdateCardStatusRequest request) {
|
||||
|
||||
|
||||
CustomerProduct customerProduct = getCustomerProductByCardNumber(request.getCustomerReference(),
|
||||
request.getDevice().getDeviceSessionReference(),
|
||||
request.getCardReference().getCardNumber());
|
||||
|
||||
|
||||
StatusResponse statusResponse = paymentCardPort.updateCardStatus(customerProduct.getClearAccount(), request);
|
||||
|
||||
if (!statusResponse.statusCode().equals(RESULT_OK)) {
|
||||
throw new BanBackendException(statusResponse.statusCode(), statusResponse.message());
|
||||
}
|
||||
paymentCardPort.updateCardStatus(customerProduct.getClearAccount(), request);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@ package com.banesco.infrastructure.dtos.card;
|
||||
|
||||
|
||||
import com.banesco.common.domain.dto.bian.customer.CustomerReference;
|
||||
import com.banesco.common.domain.dto.bian.device.Device;
|
||||
import com.banesco.domain.bian.dto.CardReference;
|
||||
import com.banesco.infrastructure.dtos.osb.MsgRqHdr;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -14,9 +14,8 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdateCardStatusRequest {
|
||||
String requestId;
|
||||
String fintechId;
|
||||
CustomerReference customerReference;
|
||||
Device device;
|
||||
CardReference cardReference;
|
||||
private MsgRqHdr msgRqHdr;
|
||||
private CustomerReference customerReference;
|
||||
private CardReference cardReference;
|
||||
private String domain;
|
||||
}
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
package com.banesco.infrastructure.dtos.card;
|
||||
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.BaseResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@RegisterForReflection
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class UpdateCardStatusResponse extends BaseResponse {
|
||||
public UpdateCardStatusResponse() {
|
||||
super();
|
||||
}
|
||||
|
||||
public UpdateCardStatusResponse(StatusResponse statusResponse) {
|
||||
super(statusResponse);
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,6 @@ import com.banesco.infrastructure.dtos.osb.MsgRsHdr;
|
||||
import com.banesco.infrastructure.dtos.osb.Status;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -27,8 +26,6 @@ import java.util.List;
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public class BlockUnblockDebitCardRs {
|
||||
@ -41,10 +38,8 @@ public class BlockUnblockDebitCardRs {
|
||||
/**
|
||||
* Obtiene el valor de la propiedad msgRsHdr.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link MsgRsHdr }
|
||||
*
|
||||
* @return possible object is
|
||||
* {@link MsgRsHdr }
|
||||
*/
|
||||
public MsgRsHdr getMsgRsHdr() {
|
||||
return msgRsHdr;
|
||||
@ -53,10 +48,8 @@ public class BlockUnblockDebitCardRs {
|
||||
/**
|
||||
* Define el valor de la propiedad msgRsHdr.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link MsgRsHdr }
|
||||
*
|
||||
* @param value allowed object is
|
||||
* {@link MsgRsHdr }
|
||||
*/
|
||||
public void setMsgRsHdr(MsgRsHdr value) {
|
||||
this.msgRsHdr = value;
|
||||
@ -81,8 +74,6 @@ public class BlockUnblockDebitCardRs {
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link Status }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<Status> getStatus() {
|
||||
if (status == null) {
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package com.banesco.infrastructure.rest;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.model.ApiConfig;
|
||||
import com.banesco.commons.config.AppConf;
|
||||
import com.banesco.domain.bian.request.BusUpdateCardStatusRequest;
|
||||
import com.banesco.domain.models.CurrentState;
|
||||
import com.banesco.domain.ports.outbound.PaymentCardPort;
|
||||
import com.banesco.infrastructure.dtos.osb.ApplicantData;
|
||||
import com.banesco.infrastructure.dtos.osb.MsgRqHdr;
|
||||
import com.banesco.infrastructure.rest.mappers.PaymentCardMapper;
|
||||
import com.banesco.infrastructure.rest.mappers.SoapHeaderMapper;
|
||||
import com.banesco.infrastructure.rest.repositories.PaymentCardRepository;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
@ -20,29 +23,52 @@ public class PaymentCardAdapter implements PaymentCardPort {
|
||||
private final PaymentCardRepository paymentRepository;
|
||||
private final PaymentCardMapper paymentCardMapper;
|
||||
|
||||
private final SoapHeaderMapper soapHeaderMapper;
|
||||
|
||||
private final String OPERATION_NAME = "update-card-status";
|
||||
AppConf appConf;
|
||||
|
||||
@Inject
|
||||
public PaymentCardAdapter(AppConf appConf,
|
||||
PaymentCardMapper paymentCardMapper) {
|
||||
PaymentCardMapper paymentCardMapper,
|
||||
SoapHeaderMapper soapHeaderMapper
|
||||
) {
|
||||
|
||||
this.appConf = appConf;
|
||||
this.paymentCardMapper = paymentCardMapper;
|
||||
ApiConfig apiConfig = appConf.loadApiConfig("api.rest-client." + OPERATION_NAME);
|
||||
this.soapHeaderMapper = soapHeaderMapper;
|
||||
ApiConfig apiConfig = appConf.loadApiConfig("api.rest-client." + OPERATION_NAME + ".endpoint");
|
||||
paymentRepository = new PaymentCardRepository(apiConfig);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public StatusResponse updateCardStatus(String productAccountId, BusUpdateCardStatusRequest request) {
|
||||
public void updateCardStatus(String clearAccount, BusUpdateCardStatusRequest request) {
|
||||
|
||||
CurrentState currentState = appConf.getCurrentState(request.getRequestId());
|
||||
|
||||
MsgRqHdr msgRqHdr = soapHeaderMapper.getHeaderBySrcAppId(
|
||||
OPERATION_NAME,
|
||||
currentState
|
||||
);
|
||||
|
||||
|
||||
return paymentRepository.updateCardStatus(
|
||||
if (msgRqHdr.getApplicantData() == null) {
|
||||
msgRqHdr.setApplicantData(new ApplicantData());
|
||||
}
|
||||
|
||||
msgRqHdr.getApplicantData().setIpAddress(request.getDevice().getDeviceIp());
|
||||
|
||||
|
||||
paymentRepository.updateCardStatus(
|
||||
request.getRequestId(),
|
||||
this.paymentCardMapper.toBusinessRequest(
|
||||
appConf.getCurrentState(request.getRequestId()),
|
||||
request
|
||||
msgRqHdr,
|
||||
request,
|
||||
clearAccount,
|
||||
appConf.getSoapDomainCurrent()
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -1,73 +0,0 @@
|
||||
package com.banesco.infrastructure.rest;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.device.LoggerHelper;
|
||||
import com.banesco.common.domain.model.ApiConfig;
|
||||
import com.banesco.commons.config.AppConf;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.microprofile.rest.client.RestClientBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@ApplicationScoped
|
||||
@Slf4j
|
||||
public class RegisterSecurityAdapter implements RegisterSecurityPort {
|
||||
|
||||
private final RegisterSecurityRestClient restClient;
|
||||
|
||||
private final String registerSecuritySP;
|
||||
private final String registerSecurityEventCod;
|
||||
private final String registerSecurityBankCod;
|
||||
private final String registerSecurityCurCOd;
|
||||
|
||||
|
||||
@Inject
|
||||
public RegisterSecurityAdapter(AppConf appConf) {
|
||||
|
||||
ApiConfig apiConfig = appConf.loadApiConfig("api.rest-client.register-security");
|
||||
|
||||
restClient = RestClientBuilder.newBuilder().baseUri(
|
||||
URI.create(apiConfig.getUrl())
|
||||
).
|
||||
connectTimeout(apiConfig.getTimeout().getConnect(), TimeUnit.MILLISECONDS)
|
||||
.readTimeout(apiConfig.getTimeout().getResponse(), TimeUnit.MILLISECONDS)
|
||||
.build(RegisterSecurityRestClient.class);
|
||||
|
||||
registerSecuritySP = apiConfig.getConfig().get("sp");
|
||||
registerSecurityEventCod = apiConfig.getConfig().get("eventCod");
|
||||
registerSecurityBankCod = apiConfig.getConfig().get("bankCod");
|
||||
registerSecurityCurCOd = apiConfig.getConfig().get("curCod");
|
||||
}
|
||||
|
||||
|
||||
public void writeTrace(String requestId, RegisterSecurityRq request) {
|
||||
|
||||
request.setSp(registerSecuritySP);
|
||||
request.setCodEve(registerSecurityEventCod);
|
||||
request.setCodEve2(registerSecurityEventCod);
|
||||
request.setCodBan(registerSecurityBankCod);
|
||||
request.setCodMon(registerSecurityCurCOd);
|
||||
log.info(LoggerHelper.buildInfoPrivateRequest(requestId, "REGISTER_SECURITY", request));
|
||||
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
// Simulate some processing
|
||||
try {
|
||||
Response responseHttp = restClient.invoke(request);
|
||||
Object response = responseHttp.readEntity(Object.class);
|
||||
log.info(LoggerHelper.buildInfoPrivateResponse(requestId, "REGISTER_SECURITY", response != null ? response.toString() : "null"));
|
||||
} catch (Exception e) {
|
||||
log.error(LoggerHelper.buildError("REGISTER_SECURITY - " + requestId, "Error calling API: " + e.getMessage()));
|
||||
log.error("Error writing trace: {}", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package com.banesco.infrastructure.rest.mappers;
|
||||
|
||||
import com.banesco.domain.bian.request.BusUpdateCardStatusRequest;
|
||||
import com.banesco.domain.models.CurrentState;
|
||||
import com.banesco.infrastructure.dtos.card.UpdateCardStatusRequest;
|
||||
import com.banesco.infrastructure.dtos.osb.MsgRqHdr;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
@ -10,16 +10,18 @@ public class PaymentCardMapper {
|
||||
|
||||
|
||||
public UpdateCardStatusRequest toBusinessRequest(
|
||||
CurrentState currentState,
|
||||
BusUpdateCardStatusRequest receptionRequest
|
||||
MsgRqHdr msgRqHdr,
|
||||
BusUpdateCardStatusRequest receptionRequest,
|
||||
String clearAccount,
|
||||
String domain
|
||||
) {
|
||||
|
||||
receptionRequest.getCardReference().setCardNumber(clearAccount);
|
||||
UpdateCardStatusRequest request = new UpdateCardStatusRequest(
|
||||
currentState.requestId(),
|
||||
receptionRequest.getCustomerReferenceFintechId(),
|
||||
msgRqHdr,
|
||||
receptionRequest.getCustomerReference(),
|
||||
receptionRequest.getDevice(),
|
||||
receptionRequest.getCardReference()
|
||||
receptionRequest.getCardReference(),
|
||||
domain
|
||||
|
||||
);
|
||||
|
||||
|
||||
@ -0,0 +1,68 @@
|
||||
package com.banesco.infrastructure.rest.mappers;
|
||||
|
||||
import com.banesco.common.application.exception.BanBackendException;
|
||||
import com.banesco.common.infraestructure.helpers.JsonHelper;
|
||||
import com.banesco.commons.config.AppConf;
|
||||
import com.banesco.domain.models.CurrentState;
|
||||
import com.banesco.infrastructure.dtos.osb.MsgRqHdr;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.microprofile.config.Config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@ApplicationScoped
|
||||
@Slf4j
|
||||
public class SoapHeaderMapper {
|
||||
|
||||
public final Map<String, MsgRqHdr> SOAP_HEADERS = new HashMap<>();
|
||||
|
||||
private final Config configEnv;
|
||||
|
||||
public SoapHeaderMapper(AppConf appConf) {
|
||||
configEnv = appConf.getConfigEnv();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite obtener el Request Header de una operacion hacia servicios SOAP
|
||||
*
|
||||
* @param operationName
|
||||
* @return
|
||||
*/
|
||||
public MsgRqHdr getHeaderBySrcAppId(String operationName, CurrentState currentState) {
|
||||
|
||||
MsgRqHdr msgRqHdr = SOAP_HEADERS.get(operationName);
|
||||
String msgRqHdrEnvName = "api.rest-client." + operationName + ".msgRqHdr";
|
||||
try {
|
||||
if (msgRqHdr == null) {
|
||||
String soapHeaderStr = configEnv.getValue("api.rest-client." + operationName + ".msgRqHdr", String.class);
|
||||
msgRqHdr = JsonHelper.getObjectFromJson(
|
||||
soapHeaderStr,
|
||||
MsgRqHdr.class);
|
||||
log.info("[SOAP HEADER loaded]:{} -> {}", operationName, soapHeaderStr);
|
||||
|
||||
if (msgRqHdr == null) {
|
||||
throw new BanBackendException("CONF02", msgRqHdrEnvName + " invalid or bad configured.");
|
||||
}
|
||||
|
||||
SOAP_HEADERS.put(operationName, msgRqHdr);
|
||||
}
|
||||
|
||||
msgRqHdr = msgRqHdr.clone();
|
||||
msgRqHdr.setRequestId(currentState.requestId());
|
||||
msgRqHdr.setMessageDate(currentState.date());
|
||||
msgRqHdr.setMessageTime(currentState.time());
|
||||
msgRqHdr.getNetworkTrnInfo().get(0).setTransactionDate(currentState.date());
|
||||
msgRqHdr.getNetworkTrnInfo().get(0).setTransactionTime(currentState.time());
|
||||
|
||||
|
||||
return msgRqHdr;
|
||||
} catch (Exception e) {
|
||||
throw new BanBackendException("CONF02", msgRqHdrEnvName + " invalid or bad configured.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,13 +1,14 @@
|
||||
package com.banesco.infrastructure.rest.repositories;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.device.JsonHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.LoggerHelper;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.application.exception.BanBackendException;
|
||||
import com.banesco.common.application.exception.BanRuntimeException;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.common.domain.model.ApiConfig;
|
||||
import com.banesco.common.infraestructure.helpers.JsonHelper;
|
||||
import com.banesco.common.infraestructure.helpers.LoggerHelper;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.commons.utils.ResponseUtil;
|
||||
import com.banesco.infrastructure.dtos.card.UpdateCardStatusRequest;
|
||||
import com.banesco.infrastructure.dtos.card.UpdateCardStatusResponse;
|
||||
import com.banesco.infrastructure.dtos.card.soap.BlockUnblockDebitCardRs;
|
||||
import com.banesco.infrastructure.dtos.osb.AdditionalStatus;
|
||||
import com.banesco.infrastructure.dtos.osb.Status;
|
||||
import com.banesco.infrastructure.rest.clients.BusUpdateCardStatusRestClient;
|
||||
@ -31,7 +32,7 @@ public class PaymentCardRepository {
|
||||
|
||||
private final BusUpdateCardStatusRestClient restClient;
|
||||
|
||||
private final String OPERATION_NAME = "BUS_UPDATE_CARD_STATUS";
|
||||
private final String OPERATION_NAME = "PRV_UPDATE_CARD_STATUS";
|
||||
|
||||
|
||||
public PaymentCardRepository(ApiConfig apiConfig) {
|
||||
@ -46,37 +47,46 @@ public class PaymentCardRepository {
|
||||
}
|
||||
|
||||
|
||||
public StatusResponse updateCardStatus(UpdateCardStatusRequest request) {
|
||||
public void updateCardStatus(String requestId, UpdateCardStatusRequest request) {
|
||||
|
||||
BlockUnblockDebitCardRs response = null;
|
||||
try {
|
||||
|
||||
|
||||
log.info(LoggerHelper.buildInfoPrivateRequest(request.getRequestId(), OPERATION_NAME, JsonHelper.getJsonFromObject(request)));
|
||||
log.info(LoggerHelper.buildInfoPrivateRequest(requestId, OPERATION_NAME, JsonHelper.getJsonFromObject(request)));
|
||||
|
||||
Response responseHttp = restClient.invoke(request);
|
||||
|
||||
UpdateCardStatusResponse response = responseHttp.readEntity(UpdateCardStatusResponse.class);
|
||||
log.info(LoggerHelper.buildInfoPrivateResponse(request.getRequestId(), OPERATION_NAME, JsonHelper.getJsonFromObject(response)));
|
||||
/*
|
||||
response = responseHttp.readEntity(BlockUnblockDebitCardRs.class);
|
||||
log.info(LoggerHelper.buildInfoPrivateResponse(requestId, OPERATION_NAME, JsonHelper.getJsonFromObject(response)));
|
||||
|
||||
if (response.getStatus().getStatusCode() != null &&
|
||||
response.getStatus().getStatusCode().equals("000")) {
|
||||
return ResponseUtil.mapResponse(request.getRequestId(), StatusCodes.SUCCESS_OPERATION);
|
||||
|
||||
if (response.getMsgRsHdr() != null &&
|
||||
response.getMsgRsHdr().getFinalStatusRequest() != null &&
|
||||
response.getMsgRsHdr().getFinalStatusRequest().equals("0001")
|
||||
&& response.getMsgRsHdr().getDetailReg() != null
|
||||
&& response.getMsgRsHdr().getDetailReg().contains("con exito")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
return validateSoapResponseStatus(request.getRequestId(), response.getStatus());
|
||||
*/
|
||||
return null;
|
||||
|
||||
|
||||
} catch (ClientErrorException e) {
|
||||
log.error(LoggerHelper.buildError(OPERATION_NAME + " - " + request.getRequestId(), "Error calling API: " + e.getMessage()));
|
||||
return ResponseUtil.mapErrorResponse(request.getRequestId(), StatusCodes.FAILED_DEPENDENCY);
|
||||
log.error(LoggerHelper.buildError(OPERATION_NAME + " - " + requestId, "Error calling API: " + e.getMessage()));
|
||||
throw new BanRuntimeException(StatusCodes.FAILED_DEPENDENCY);
|
||||
} catch (Exception e) {
|
||||
log.error(LoggerHelper.buildError(OPERATION_NAME + " - " + request.getRequestId(), "Error interno callig API: " + e.getMessage()));
|
||||
return ResponseUtil.mapErrorResponse(request.getRequestId(), StatusCodes.INTERNAL_ERROR);
|
||||
log.error(LoggerHelper.buildError(OPERATION_NAME + " - " + requestId, "Error interno calling API: " + e.getMessage()));
|
||||
throw new BanRuntimeException(StatusCodes.INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
|
||||
if (response.getStatus() != null &&
|
||||
response.getStatus().get(0) != null &&
|
||||
!response.getStatus().get(0).getStatusCode().equals("000")) {
|
||||
throw new BanBackendException(response.getStatus().get(0).getStatusCode(), response.getStatus().get(0).getStatusDesc());
|
||||
}
|
||||
|
||||
validateSoapResponseStatus(response.getStatus().get(0));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +95,7 @@ public class PaymentCardRepository {
|
||||
*
|
||||
* @param status
|
||||
*/
|
||||
private StatusResponse validateSoapResponseStatus(String requestId, Status status) {
|
||||
private BianStatusResponse validateSoapResponseStatus(Status status) {
|
||||
|
||||
// Get Back Error
|
||||
Map<String, String> errors = new HashMap<>();
|
||||
@ -107,15 +117,12 @@ public class PaymentCardRepository {
|
||||
/**
|
||||
* Concat errors
|
||||
*/
|
||||
return new StatusResponse(
|
||||
"error",
|
||||
errors.values().stream().collect(Collectors.joining("-")).toString(),
|
||||
additionalStatus.getStatusDesc(),
|
||||
requestId
|
||||
);
|
||||
|
||||
throw new BanBackendException(errors.values().stream().collect(Collectors.joining("-")).toString(),
|
||||
additionalStatus.getStatusDesc());
|
||||
}
|
||||
|
||||
return ResponseUtil.mapErrorResponse(requestId, StatusCodes.INTERNAL_ERROR);
|
||||
throw new BanRuntimeException(StatusCodes.INTERNAL_ERROR);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
quarkus:
|
||||
http:
|
||||
port: 8080
|
||||
port: 8082
|
||||
idle-timeout: 30s
|
||||
thread-pool:
|
||||
max-threads: 100
|
||||
@ -11,15 +11,16 @@ quarkus:
|
||||
# 4 minutes 60*4*1000 (MS)
|
||||
timeout: 240000
|
||||
api:
|
||||
source-id: UCSS
|
||||
source-id: BUCS
|
||||
rest-client:
|
||||
update-card-status:
|
||||
endpoint: '{"url":"http://localhost:8082/card/status/update","timeout":{"connect":20000,"response":20000},"config":{}}'
|
||||
endpoint: '{"url":"http://localhost:8083/card/status/update","timeout":{"connect":20000,"response":20000},"config":{}}'
|
||||
msgRqHdr: '{"networkTrnInfo":[{"bankId":"01","transactionCode":"8741"}],"applicantData":{"application":"APIMGMT"},"vbProtocol":{"vbProtocolInd":"true","transactionInd":"false"},"operatorCode":"BAN1738A02","sourceChannelCode":"INT"}'
|
||||
redis:
|
||||
#expiration with Zero, not apply Redis
|
||||
get-evaluate-customer-product: '{"prefix":"%s%d%s","expiration":0}'
|
||||
get-evaluate-customer-product: '{"prefix":"%s%s%s","expiration":0}'
|
||||
soap:
|
||||
domain:
|
||||
current: osbp2p
|
||||
|
||||
# api.rest-client.update-card-statu
|
||||
38
commons-bian/.gitignore
vendored
38
commons-bian/.gitignore
vendored
@ -1,38 +0,0 @@
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
3
commons-bian/.idea/.gitignore
generated
vendored
3
commons-bian/.idea/.gitignore
generated
vendored
@ -1,3 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
7
commons-bian/.idea/encodings.xml
generated
7
commons-bian/.idea/encodings.xml
generated
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
14
commons-bian/.idea/misc.xml
generated
14
commons-bian/.idea/misc.xml
generated
@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
4
commons-bian/.idea/vcs.xml
generated
4
commons-bian/.idea/vcs.xml
generated
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
</project>
|
||||
@ -1,10 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
Todos los cambios notables en este proyecto se documentarán en este archivo.
|
||||
|
||||
El formato se basa en [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
y este proyecto se adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [UNRELEASE]
|
||||
|
||||
- Base inicial commons nativo (Java)
|
||||
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Banesco Banco Universal, C.A.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@ -1,10 +0,0 @@
|
||||
|
||||

|
||||
|
||||
|
||||
# Commons
|
||||
|
||||
Este proyecto utiliza Java nativo como librería commons
|
||||
|
||||
|
||||
- Banesco Banco Universal © Todos los Derechos Reservados.
|
||||
@ -1,66 +0,0 @@
|
||||
<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>
|
||||
|
||||
<groupId>com.banesco</groupId>
|
||||
<artifactId>commons-bian</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>commons-bian</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.15.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!--dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.13.0</version>
|
||||
</dependency-->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<release>17</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@ -1,8 +0,0 @@
|
||||
package com.banesco;
|
||||
|
||||
public class CommonsBian {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Commons BIAN...");
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
package com.banesco.common.application.exception;
|
||||
|
||||
public class BanBackendException extends RuntimeException {
|
||||
|
||||
protected String backendCode;
|
||||
protected String backendDesc;
|
||||
protected String target;
|
||||
|
||||
public BanBackendException(String backendCode, String backendDesc) {
|
||||
super(backendDesc);
|
||||
this.backendCode = backendCode;
|
||||
this.backendDesc = backendDesc;
|
||||
}
|
||||
|
||||
public BanBackendException(String backendCode, String backendDesc, String target) {
|
||||
super(backendDesc.formatted(target) + ", Target:" + target);
|
||||
this.backendCode = backendCode;
|
||||
this.backendDesc = backendDesc;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public String getBackendCode() {
|
||||
return backendCode;
|
||||
}
|
||||
|
||||
public String getBackendDesc() {
|
||||
return backendDesc;
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.banesco.common.application.exception;
|
||||
|
||||
import com.banesco.common.domain.interfaces.BaseStatusCodesEnum;
|
||||
|
||||
public class BanRuntimeException extends RuntimeException {
|
||||
|
||||
protected BaseStatusCodesEnum statusCode;
|
||||
protected String target;
|
||||
|
||||
public BanRuntimeException() {
|
||||
super("Internal Error");
|
||||
}
|
||||
|
||||
public BanRuntimeException(BaseStatusCodesEnum statusCode, String target) {
|
||||
super(statusCode.getStatusDesc().formatted(target) + ", Target:" + target);
|
||||
this.statusCode = statusCode;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public BanRuntimeException(BaseStatusCodesEnum statusCode) {
|
||||
super(statusCode.getStatusDesc());
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public BaseStatusCodesEnum getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
package com.banesco.common.application.helper;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.device.Device;
|
||||
import com.banesco.common.domain.dto.bian.device.DeviceTypeValues;
|
||||
import com.banesco.common.domain.dto.bian.device.StringHelper;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class DeviceHelper {
|
||||
|
||||
|
||||
private static final Logger logger = Logger.getLogger(DeviceHelper.class.getName());
|
||||
|
||||
|
||||
public static DeviceTypeValues getDeviceTypeValue(
|
||||
Device device
|
||||
) {
|
||||
var deviceTypeValue = DeviceTypeValues.Unknown;
|
||||
|
||||
if (!Objects.isNull(device) && !StringHelper.isEmpty(device.getDeviceType())) {
|
||||
try {
|
||||
deviceTypeValue = DeviceTypeValues.valueOf(device.getDeviceType());
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, "Error Mapping Device Type: %s -> %s".formatted(device.getDeviceType(), e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
return deviceTypeValue;
|
||||
}
|
||||
|
||||
public static boolean isValidDeviceType(String type) {
|
||||
|
||||
for (DeviceTypeValues deviceType : DeviceTypeValues.values()) {
|
||||
if (deviceType.name().equals(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getDeviceTypes() {
|
||||
return Stream.of(DeviceTypeValues.values()).map(Enum::name).collect(
|
||||
Collectors.joining(", ")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.banesco.common.application.helper;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.device.DeviceTypeValues;
|
||||
import com.banesco.common.domain.dto.bian.paymentCard.CardTypeValues;
|
||||
|
||||
public class PaymentCardHelper {
|
||||
|
||||
public static boolean isValidCardType(String type) {
|
||||
for (CardTypeValues cardTypeValue : CardTypeValues.values()) {
|
||||
if (cardTypeValue.name().equals(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.customer;
|
||||
|
||||
public class CustomerReference {
|
||||
String customerIdType;
|
||||
String customerId;
|
||||
|
||||
public CustomerReference() {
|
||||
}
|
||||
|
||||
public CustomerReference(String customerIdType, String customerId) {
|
||||
this.customerIdType = customerIdType;
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public String getCustomerIdType() {
|
||||
return customerIdType;
|
||||
}
|
||||
|
||||
public void setCustomerIdType(String customerIdType) {
|
||||
this.customerIdType = customerIdType;
|
||||
}
|
||||
|
||||
public String getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(String customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{\"customerIdType\":\"%s\",\"customerId\":\"%s\"}"
|
||||
.formatted(customerIdType, customerId);
|
||||
}
|
||||
}
|
||||
@ -1,21 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.device;
|
||||
|
||||
|
||||
/**
|
||||
* Clase utilitaria para operaciones relacionadas con cuentas bancarias.
|
||||
* Proporciona métodos para manipular y formatear información de cuentas.
|
||||
*/
|
||||
public class AccountHelper {
|
||||
|
||||
/**
|
||||
* Enmascara un número de cuenta, mostrando solo los primeros 4
|
||||
* y últimos 4 Los dígitos intermedios son reemplazados por asteriscos para proteger la
|
||||
* información sensible del cliente.
|
||||
*
|
||||
* @param clearAccountId El número de cuenta completo sin enmascarar
|
||||
* @return El número de cuenta enmascarado en formato "XXXX************YYYY"
|
||||
*/
|
||||
public static String getMaskedAccountId(String clearAccountId) {
|
||||
return clearAccountId.substring(0, 4) + "************" + clearAccountId.substring(clearAccountId.length() - 4);
|
||||
}
|
||||
}
|
||||
@ -1,163 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.device;
|
||||
|
||||
import java.time.DateTimeException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Clase utilitaria para operaciones relacionadas con fechas y horas.
|
||||
* Proporciona métodos para validar, comparar y calcular períodos entre fechas.
|
||||
*/
|
||||
public class DateHelper {
|
||||
|
||||
|
||||
private final Logger logger = Logger.getLogger(DateHelper.class.getName());
|
||||
private final ZoneId currentZone = ZoneId.of("America/Caracas");
|
||||
private final DateTimeFormatter DATE_YYYY_MM_DD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
private final DateTimeFormatter TIME_HH_MM_SS = DateTimeFormatter.ofPattern("HH:mm:ss");
|
||||
|
||||
private static class SingletonHelper {
|
||||
private static final DateHelper INSTANCE = new DateHelper();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructo private to no allow other Instances
|
||||
*/
|
||||
private DateHelper() {
|
||||
// not public instance
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Instance Singleton
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static DateHelper getInstance() {
|
||||
return SingletonHelper.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite obtener la Fecha Hora Actual
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public LocalDateTime getCurrentDateTime() {
|
||||
return LocalDateTime.now(currentZone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite Obtener la Hora para una FechaHora, en caso de ser null se obtiene la hora actual
|
||||
*
|
||||
* @param now Feha Hora Local
|
||||
* @return
|
||||
*/
|
||||
public String getTime(LocalDateTime now) {
|
||||
if (now == null) {
|
||||
now = LocalDateTime.now(currentZone);
|
||||
}
|
||||
return now.format(TIME_HH_MM_SS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite Obtener la Fecha para una FechaHora, en caso de ser null se obtiene la fecha actual
|
||||
*
|
||||
* @param now Feha Hora Local
|
||||
* @return
|
||||
*/
|
||||
public String getDate(LocalDateTime now) {
|
||||
if (now == null) {
|
||||
now = LocalDateTime.now(currentZone);
|
||||
}
|
||||
return now.format(DATE_YYYY_MM_DD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is Current Hour is in Hour Range passed by parameters
|
||||
* if Parameters are equal then return false
|
||||
*
|
||||
* @param rangeHourBegin Cadena de la hora de inicio del Rango
|
||||
* @param rangeHourFinish Candena de la hora de fin del Rango
|
||||
* @param hourStrToCheck Hora en cadena para evaluar si se encuentra entre el rango de parametros
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isHourInRange(String rangeHourBegin, String rangeHourFinish, String hourStrToCheck) {
|
||||
|
||||
return isHourInRange(Integer.parseInt(rangeHourBegin.replace(":", "")),
|
||||
Integer.parseInt(rangeHourFinish.replace(":", "")),
|
||||
hourStrToCheck
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check is Current Hour is in Hour Range passed by parameters
|
||||
* if Parameters are equal then return false
|
||||
*
|
||||
* @param rangeHourBegin Numero entero de la hora de inicio del Rango
|
||||
* @param rangeHourFinish Numero entero de la hora de fin del Rango
|
||||
* @param hourStrToCheck Hora en cadena para evaluar si se encuentra entre el rango de parametros
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isHourInRange(int rangeHourBegin, int rangeHourFinish, String hourStrToCheck) {
|
||||
boolean mustValidateService = false;
|
||||
|
||||
if (rangeHourBegin == rangeHourFinish) {
|
||||
return mustValidateService;
|
||||
}
|
||||
|
||||
int currentHour = Integer.parseInt(hourStrToCheck.replace(":", ""));
|
||||
|
||||
|
||||
if (rangeHourBegin > rangeHourFinish) { // hour end is less than hour start, => then validate next day
|
||||
|
||||
if (currentHour <= rangeHourFinish || currentHour >= rangeHourBegin) {
|
||||
mustValidateService = true;
|
||||
}
|
||||
} else if (currentHour >= rangeHourBegin && currentHour <= rangeHourFinish) { // Hour the same day
|
||||
mustValidateService = true;
|
||||
}
|
||||
logger.log(Level.INFO, "La hora (%s => %d) %sesta entre %d y %d ".formatted(
|
||||
hourStrToCheck,
|
||||
currentHour,
|
||||
(mustValidateService ? "" : "NO "),
|
||||
rangeHourBegin,
|
||||
rangeHourFinish));
|
||||
|
||||
return mustValidateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcula el número de días entre dos fechas.
|
||||
*
|
||||
* @param startDate Fecha de inicio en formato ISO (yyyy-MM-dd)
|
||||
* @param endDate Fecha de fin en formato ISO (yyyy-MM-dd)
|
||||
* @return El número de días entre las fechas o -1 si ocurre un error al
|
||||
* procesar las fechas
|
||||
*/
|
||||
public long daysBetweenTwoDates(String startDate, String endDate) {
|
||||
try {
|
||||
return ChronoUnit.DAYS.between(LocalDate.parse(startDate), LocalDate.parse(endDate));
|
||||
} catch (DateTimeException dte) {
|
||||
return -1L;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica si la fecha de inicio es anterior o igual a la fecha de fin.
|
||||
*
|
||||
* @param startDate Fecha de inicio en formato ISO (yyyy-MM-dd)
|
||||
* @param endDate Fecha de fin en formato ISO (yyyy-MM-dd)
|
||||
* @return true si startDate es anterior o igual a endDate, false en caso
|
||||
* contrario
|
||||
*/
|
||||
public boolean isStartDateBeforeEndDate(String startDate, String endDate) {
|
||||
return LocalDate.parse(startDate).isBefore(LocalDate.parse(endDate))
|
||||
|| LocalDate.parse(startDate).isEqual(LocalDate.parse(endDate));
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.device;
|
||||
|
||||
|
||||
|
||||
public class Device {
|
||||
String deviceType;
|
||||
String deviceDescription;
|
||||
String deviceIp;
|
||||
String deviceSessionReference;
|
||||
|
||||
public Device() {
|
||||
|
||||
}
|
||||
|
||||
public Device(String deviceType, String deviceDescription, String deviceIp, String deviceSessionReference) {
|
||||
this.deviceType = deviceType;
|
||||
this.deviceDescription = deviceDescription;
|
||||
this.deviceIp = deviceIp;
|
||||
this.deviceSessionReference = deviceSessionReference;
|
||||
}
|
||||
|
||||
public String getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(String deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public String getDeviceDescription() {
|
||||
return deviceDescription;
|
||||
}
|
||||
|
||||
public void setDeviceDescription(String deviceDescription) {
|
||||
this.deviceDescription = deviceDescription;
|
||||
}
|
||||
|
||||
public String getDeviceIp() {
|
||||
return deviceIp;
|
||||
}
|
||||
|
||||
public void setDeviceIp(String deviceIp) {
|
||||
this.deviceIp = deviceIp;
|
||||
}
|
||||
|
||||
public String getDeviceSessionReference() {
|
||||
return deviceSessionReference;
|
||||
}
|
||||
|
||||
public void setDeviceSessionReference(String deviceSessionReference) {
|
||||
this.deviceSessionReference = deviceSessionReference;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "{\"deviceType\":\"%s\",\"deviceDescription\":\"%s\",\"deviceIp\":\"%s\",\"deviceSessionReference\":\"%s\"}"
|
||||
.formatted(deviceType, deviceDescription, deviceIp, deviceSessionReference);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.device;
|
||||
|
||||
public enum DeviceTypeValues {
|
||||
Mobile,
|
||||
Tablet,
|
||||
PersonalComputer,
|
||||
SecureCardReader,
|
||||
NonSecureCardReader,
|
||||
OtherNational,
|
||||
OtherPrivate,
|
||||
Wearable,
|
||||
Vehicle,
|
||||
Embedded,
|
||||
KeyFob,
|
||||
Jewellery,
|
||||
Sticker,
|
||||
GamingDevice,
|
||||
Watch,
|
||||
Unknown
|
||||
}
|
||||
@ -1,93 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.device;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class JsonHelper {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(JsonHelper.class.getName());
|
||||
public static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
static {
|
||||
MAPPER.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Object to jsonString
|
||||
*
|
||||
* @param object El objeto a convertir en JSON.
|
||||
* @return La cadena JSON resultante o null si ocurre un error.
|
||||
*/
|
||||
public static String getJsonFromObject(Object object) {
|
||||
if (object == null) {
|
||||
return "null";
|
||||
}
|
||||
try {
|
||||
return MAPPER.writeValueAsString(object);
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.log(Level.SEVERE, "Error parsing objeto a JSON: {0}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convierte una cadena JSON en un objeto Java de la clase especificada.
|
||||
*
|
||||
* @param json La cadena JSON a convertir.
|
||||
* @param className La clase del objeto Java resultante.
|
||||
* @param <T> El tipo del objeto resultante.
|
||||
* @return El objeto Java resultante, o null si ocurre un error o la cadena
|
||||
* JSON está vacía.
|
||||
*/
|
||||
public static <T> T getObjectFromJson(String json, Class<T> className) {
|
||||
if (json == null || json.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return MAPPER.readValue(json, className);
|
||||
} catch (JsonProcessingException | IllegalArgumentException e) {
|
||||
logger.log(Level.WARNING, "Error parsing JSON a objeto: {0}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<T> getListFromJson(String json, Class<T> className) {
|
||||
if (json == null || json.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
return MAPPER.readValue(json,
|
||||
MAPPER.getTypeFactory().constructCollectionType(List.class, className)
|
||||
);
|
||||
} catch (JsonProcessingException | IllegalArgumentException e) {
|
||||
logger.log(Level.WARNING, "Error parsing JSON a List Object: {0}", e.getMessage());
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public static <T> List<T> getListFromInputStream(InputStream inputStream, Class<T> className) throws IOException {
|
||||
if (inputStream == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
try {
|
||||
return MAPPER.readValue(inputStream,
|
||||
MAPPER.getTypeFactory().constructCollectionType(List.class, className)
|
||||
);
|
||||
} catch (JsonProcessingException | IllegalArgumentException e) {
|
||||
logger.log(Level.WARNING, "Error parsing JSON a List Object: {0}", e.getMessage());
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@ -1,118 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.device;
|
||||
|
||||
/**
|
||||
* Clase utilitaria para la generación de mensajes de registro (logging).
|
||||
* Facilita la creación de cadenas formateadas para registrar información de
|
||||
* solicitudes y respuestas, tanto públicas como privadas, así como mensajes de
|
||||
* error. Utiliza un formato estandarizado para mejorar la legibilidad y
|
||||
* facilitar el análisis de los registros del sistema.
|
||||
*/
|
||||
public class LoggerHelper {
|
||||
|
||||
/**
|
||||
* Construye una cadena de información para una solicitud pública.
|
||||
*
|
||||
* @param requestId El ID de la solicitud.
|
||||
* @param request El objeto de solicitud.
|
||||
* @param <T> El tipo del objeto de solicitud.
|
||||
* @return Una cadena de información formateada.
|
||||
*/
|
||||
public static <T> String buildInfoRequest(String requestId, T request) {
|
||||
return String.format("[PUB RQ: %s] [%s]", requestId, JsonHelper.getJsonFromObject(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construye una cadena de información para una solicitud pública.
|
||||
*
|
||||
* @param requestId El ID de la solicitud.
|
||||
* @param request El request en cadena de la solicitud.
|
||||
* @return Una cadena de información formateada.
|
||||
*/
|
||||
public static <T> String buildInfoRequest(String requestId, String request) {
|
||||
return String.format("[PUB RQ: %s] [%s]", requestId, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construye una cadena de información para una respuesta pública.
|
||||
*
|
||||
* @param requestId El ID de la solicitud.
|
||||
* @param response El objeto de respuesta.
|
||||
* @param <T> El tipo del objeto de respuesta.
|
||||
* @return Una cadena de información formateada.
|
||||
*/
|
||||
public static <T> String buildInfoResponse(String requestId, T response) {
|
||||
return String.format("[PUB RS: %s] [%s]", requestId, JsonHelper.getJsonFromObject(response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construye una cadena de información para una respuesta pública.
|
||||
*
|
||||
* @param requestId El ID de la solicitud.
|
||||
* @param response El objeto en cadena de respuesta.
|
||||
* @return Una cadena de información formateada.
|
||||
*/
|
||||
public static String buildInfoResponse(String requestId, String response) {
|
||||
return String.format("[PUB RS: %s] [%s]", requestId, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construye una cadena de información para una solicitud privada.
|
||||
*
|
||||
* @param requestId El ID de la solicitud.
|
||||
* @param name El nombre de la solicitud privada.
|
||||
* @param request El objeto de solicitud.
|
||||
* @param <T> El tipo del objeto de solicitud.
|
||||
* @return Una cadena de información formateada.
|
||||
*/
|
||||
public static <T> String buildInfoPrivateRequest(String requestId, String name, T request) {
|
||||
return String.format("[PRV RQ %s: %s] [%s]", name, requestId, JsonHelper.getJsonFromObject(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construye una cadena de información para una solicitud privada.
|
||||
*
|
||||
* @param requestId El ID de la solicitud.
|
||||
* @param name El nombre de la solicitud privada.
|
||||
* @param request El objeto en cadena de la solicitud.
|
||||
* @return Una cadena de información formateada.
|
||||
*/
|
||||
public static String buildInfoPrivateRequest(String requestId, String name, String request) {
|
||||
return String.format("[PRV RQ %s: %s] [%s]", name, requestId, request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construye una cadena de información para una respuesta privada.
|
||||
*
|
||||
* @param requestId El ID de la solicitud.
|
||||
* @param name El nombre de la respuesta privada.
|
||||
* @param response El objeto de respuesta.
|
||||
* @param <T> El tipo del objeto de respuesta.
|
||||
* @return Una cadena de información formateada.
|
||||
*/
|
||||
public static <T> String buildInfoPrivateResponse(String requestId, String name, T response) {
|
||||
return String.format("[PRV RS %s: %s] [%s]", name, requestId, JsonHelper.getJsonFromObject(response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construye una cadena de información para una respuesta privada.
|
||||
*
|
||||
* @param requestId El ID de la solicitud.
|
||||
* @param name El nombre de la respuesta privada.
|
||||
* @param response El objeto en cadena de la respuesta.
|
||||
* @return Una cadena de información formateada.
|
||||
*/
|
||||
public static String buildInfoPrivateResponse(String requestId, String name, String response) {
|
||||
return String.format("[PRV RS %s: %s] [%s]", name, requestId, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construye una cadena de error.
|
||||
*
|
||||
* @param requestId El ID de la solicitud asociada al error.
|
||||
* @param out El mensaje de error.
|
||||
* @return Una cadena de error formateada.
|
||||
*/
|
||||
public static String buildError(String requestId, String out) {
|
||||
return String.format("[ERROR %s] [%s]", requestId, out);
|
||||
}
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.device;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
/**
|
||||
* Clase utilitaria para operaciones relacionadas con solicitudes HTTP y
|
||||
* generación de identificadores. Proporciona métodos para generar IDs únicos,
|
||||
* obtener información del cliente y gestionar información del dispositivo.
|
||||
*/
|
||||
public class RequestHelper {
|
||||
|
||||
private final String ALPHANUMERIC_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
private final int baseCharacterLen = ALPHANUMERIC_CHARACTERS.length();
|
||||
|
||||
|
||||
/**
|
||||
* Permite tener una cadena aleatoria de caracteres numericos
|
||||
*
|
||||
* @param len longitud de la cadena numerica a retornar
|
||||
* @return
|
||||
*/
|
||||
public String randomNumeric(int len) {
|
||||
char[] chars = new char[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
chars[i] = (char) ThreadLocalRandom.current().nextInt(48, 58); // ascii index number
|
||||
}
|
||||
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite tener una cadena aleatoria de caracteres alfa-numericos
|
||||
*
|
||||
* @param len longitud de la cadena alfa-numerica a retornar
|
||||
* @return
|
||||
*/
|
||||
public String randomAlphanumeric(int len) {
|
||||
char[] chars = new char[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
chars[i] = ALPHANUMERIC_CHARACTERS.charAt(ThreadLocalRandom.current().nextInt(baseCharacterLen));
|
||||
}
|
||||
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retorna Identificador de la Instancia del Request, usando como prefijo un valor predefinido
|
||||
* ejemplos: P2P, REM,
|
||||
* Facilita identificar el origen de los Requests
|
||||
* Deberia obtenerse una vez al inicia el Request
|
||||
*
|
||||
* @param apiSourceId
|
||||
* @return
|
||||
*/
|
||||
public String getInstanceId(String apiSourceId) {
|
||||
return (apiSourceId == null ? "INST" : apiSourceId).concat(randomAlphanumeric(10));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retorna un Identificador del Request, se sugiere usar el getInstanceId creada como prefijo.
|
||||
* Usar uno para Cada Request que implique afectacion financiera
|
||||
*
|
||||
* @param instanceId
|
||||
* @return
|
||||
*/
|
||||
public String getRequestId(String instanceId) {
|
||||
return instanceId.concat("REQ").concat(randomAlphanumeric(20));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Permite Obtener un valor Numerico de Identificador de Transaccion
|
||||
*
|
||||
* @param len
|
||||
* @return
|
||||
*/
|
||||
public String getTransactionId(int len) {
|
||||
return randomNumeric(len);
|
||||
}
|
||||
}
|
||||
@ -1,106 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.device;
|
||||
|
||||
/**
|
||||
* Clase utilitaria para operaciones con cadenas de texto (strings). Proporciona
|
||||
* métodos para validar, manipular y formatear cadenas de texto. Incluye
|
||||
* funcionalidades como verificación de tipos numéricos, validación de cadenas
|
||||
* no vacías y funciones de formato como relleno de caracteres.
|
||||
*/
|
||||
public class StringHelper {
|
||||
|
||||
/**
|
||||
* Verifica si una cadena de texto representa un número entero.
|
||||
*
|
||||
* @param value La cadena de texto a verificar.
|
||||
* @return true si la cadena es un número entero válido, false en caso
|
||||
* contrario.
|
||||
* @throws NumberFormatException Si el string no tiene el formato adeacuado
|
||||
*/
|
||||
public static boolean isNumeric(String value) {
|
||||
if (value == null || value.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Integer.parseInt(value);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifica si una cadena de texto es nula o está vacía después de
|
||||
* eliminar espacios en blanco.
|
||||
*
|
||||
* @param value La cadena de texto a verificar.
|
||||
* @return true si la cadena está vacía, false en caso contrario.
|
||||
*/
|
||||
public static boolean isEmpty(String value) {
|
||||
return value == null || value.trim().isEmpty();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rellena una cadena de texto con un carácter específico a la izquierda
|
||||
* hasta alcanzar la longitud deseada.
|
||||
*
|
||||
* @param inputStr La cadena de texto a rellenar.
|
||||
* @param strLenOut La longitud deseada de la cadena resultante.
|
||||
* @param padChar El carácter de relleno.
|
||||
* @return La cadena rellenada con el carácter especificado a la izquierda.
|
||||
*/
|
||||
public static String leftPad(String inputStr, int strLenOut, char padChar) {
|
||||
if (inputStr == null) {
|
||||
inputStr = ""; // Handle null input
|
||||
}
|
||||
int padLength = strLenOut - inputStr.length();
|
||||
if (padLength <= 0) {
|
||||
return inputStr; // No padding needed
|
||||
}
|
||||
|
||||
char[] paddedString = new char[padLength];
|
||||
for (int i = 0; i < padLength; i++) {
|
||||
paddedString[i] = padChar;
|
||||
}
|
||||
|
||||
return new String(paddedString).concat(inputStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite convertir nombre de propiedad separada con (,-) to CamelCase
|
||||
*
|
||||
* @param inputStr Cadena de texto a convertir
|
||||
* @param firstUpper Flag que indica si la primera letra es Mayuscula
|
||||
* @return
|
||||
*/
|
||||
public static String convertToCamelCase(String inputStr, boolean firstUpper) {
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean capitalizeNext = firstUpper;
|
||||
|
||||
for (char ch : inputStr.toCharArray()) {
|
||||
if (ch == '.' || ch == '-') {
|
||||
capitalizeNext = true; // Next character should be capitalized
|
||||
} else {
|
||||
if (capitalizeNext) {
|
||||
result.append(Character.toUpperCase(ch)); // Capitalize current character
|
||||
capitalizeNext = false; // Reset flag
|
||||
} else {
|
||||
result.append(Character.toLowerCase(ch)); // Append in lowercase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param inputStr Cadena de texto a convertir en UpperCamelCase
|
||||
* @return
|
||||
*/
|
||||
public static String convertToUpperCamelCase(String inputStr) {
|
||||
return convertToCamelCase(inputStr, true);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.paymentCard;
|
||||
|
||||
public enum CardTypeValues {
|
||||
DebitCard,
|
||||
CreditCard
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.response;
|
||||
|
||||
public class BaseResponse {
|
||||
protected StatusResponse statusResponse;
|
||||
|
||||
public BaseResponse() {
|
||||
}
|
||||
|
||||
public BaseResponse(StatusResponse statusResponse) {
|
||||
this.statusResponse = statusResponse;
|
||||
}
|
||||
|
||||
public StatusResponse getStatusResponse() {
|
||||
return statusResponse;
|
||||
}
|
||||
|
||||
public void setStatusResponse(StatusResponse statusResponse) {
|
||||
this.statusResponse = statusResponse;
|
||||
}
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.response;
|
||||
|
||||
public record MetadataResponse(String timestamp, String operationId) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{\"timestamp\":\"%s\",\"operationId\":\"%s\"}".formatted(timestamp, operationId);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
package com.banesco.common.domain.dto.bian.response;
|
||||
|
||||
public record StatusResponse(String status,String statusCode, String message, String traceId) {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{\"status\":\"%s\",\"statusCode\":\"%s\",\"message\":\"%s\",\"traceId\":\"%s\"}".formatted(status, statusCode, message, traceId);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
package com.banesco.common.domain.interfaces;
|
||||
|
||||
public interface BaseStatusCodesEnum {
|
||||
String getStatusCode();
|
||||
String getStatusDesc();
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
package com.banesco.common.domain.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Clase de configuración para APIs. Almacena la información necesaria para
|
||||
* conectarse a un servicio API externo, incluyendo URL, configuración de
|
||||
* timeout y parámetros adicionales. Diseñada para ser utilizada como objeto de
|
||||
* configuración en clientes de API y servicios de integración.
|
||||
*/
|
||||
public class ApiConfig {
|
||||
|
||||
String url;
|
||||
ApiTimeout timeout;
|
||||
Map<String, String> config;
|
||||
|
||||
public ApiConfig(){
|
||||
|
||||
}
|
||||
|
||||
public ApiConfig(String url,
|
||||
ApiTimeout timeout,
|
||||
Map<String, String> config) {
|
||||
|
||||
this.url = url;
|
||||
this.timeout = timeout;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public ApiTimeout getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(ApiTimeout timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public Map<String, String> getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(Map<String, String> config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
package com.banesco.common.domain.model;
|
||||
|
||||
/**
|
||||
* Clase interna que representa la configuración de tiempos de espera
|
||||
* (timeout) para conexiones a APIs. Define los tiempos máximos de espera
|
||||
* para establecer la conexión y para recibir una respuesta, especificados
|
||||
* en milisegundos.
|
||||
*/
|
||||
public class ApiTimeout{
|
||||
private int connect;
|
||||
private int response;
|
||||
|
||||
public ApiTimeout() {
|
||||
|
||||
}
|
||||
public ApiTimeout(int connect, int response) {
|
||||
this.connect = connect;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public int getConnect() {
|
||||
return connect;
|
||||
}
|
||||
|
||||
public void setConnect(int connect) {
|
||||
this.connect = connect;
|
||||
}
|
||||
|
||||
public int getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(int response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,63 +0,0 @@
|
||||
package com.banesco.common.domain.model;
|
||||
|
||||
/**
|
||||
* Clase para obtener los codigos y mensajes de salida
|
||||
*/
|
||||
public class BackResponse {
|
||||
|
||||
private String backendCode;
|
||||
private int httpCode;
|
||||
private String statusCode;
|
||||
private String description;
|
||||
|
||||
public BackResponse() {
|
||||
}
|
||||
|
||||
public BackResponse(String backendCode,
|
||||
int httpCode,
|
||||
String statusCode,
|
||||
String description) {
|
||||
this.backendCode = backendCode;
|
||||
this.httpCode = httpCode;
|
||||
this.statusCode = statusCode;
|
||||
this.description = backendCode;
|
||||
}
|
||||
|
||||
public String getBackendCode() {
|
||||
return backendCode;
|
||||
}
|
||||
|
||||
public int getHttpCode() {
|
||||
return httpCode;
|
||||
}
|
||||
|
||||
public String getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setBackendCode(String backendCode) {
|
||||
this.backendCode = backendCode;
|
||||
}
|
||||
|
||||
public void setHttpCode(int httpCode) {
|
||||
this.httpCode = httpCode;
|
||||
}
|
||||
|
||||
public void setStatusCode(String statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{\"backendCode\":\"%s\",\"httpCode\":%d,\"statusCode\":\"%s\",\"description\":\"%s\"}"
|
||||
.formatted(backendCode, httpCode, statusCode, description);
|
||||
}
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
package com.banesco.common.domain.model;
|
||||
|
||||
|
||||
public class RedisParam {
|
||||
private String prefix;
|
||||
private long expiration;
|
||||
|
||||
public RedisParam() {
|
||||
}
|
||||
|
||||
public RedisParam(String prefix, long expiration) {
|
||||
this.prefix = prefix;
|
||||
this.expiration = expiration;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public long getExpiration() {
|
||||
return expiration;
|
||||
}
|
||||
|
||||
public void setExpiration(long expiration) {
|
||||
this.expiration = expiration;
|
||||
}
|
||||
}
|
||||
@ -1,111 +0,0 @@
|
||||
package com.banesco.common.infraestructure.repository;
|
||||
|
||||
import com.banesco.common.domain.model.BackResponse;
|
||||
import com.banesco.common.domain.dto.bian.device.JsonHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.StringHelper;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MessageRepository {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MessageRepository.class.getName());
|
||||
|
||||
/**
|
||||
* Respuesta de error por defecto que se utiliza cuando no se encuentra un
|
||||
* error específico.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Mapa que almacena múltiples mapas de códigos de error, donde la clave
|
||||
* principal es el nombre del archivo de mensajes.
|
||||
*/
|
||||
public final Map<String, Map<String, BackResponse>> mapErrorsMultiple = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Carga los mensajes de error desde un InputStream y los almacena en un
|
||||
* mapa.
|
||||
*
|
||||
* @param inputStream El InputStream que contiene los datos JSON de los
|
||||
* mensajes de error.
|
||||
* @param messageFileKey La clave del archivo de mensajes, utilizada para
|
||||
* almacenar el mapa en mapErrorsMultiple.
|
||||
* @return Un mapa que contiene los códigos de error como claves y los
|
||||
* objetos BackResponse como valores.
|
||||
* @throws IOException Si ocurre un error de entrada/salida al leer el
|
||||
* InputStream.
|
||||
*/
|
||||
private Map<String, BackResponse> loadFile(InputStream inputStream, String messageFileKey) throws IOException {
|
||||
Map<String, BackResponse> mapStatusCodes = new HashMap<>();
|
||||
Arrays.stream(JsonHelper.MAPPER.readValue(inputStream, BackResponse[].class)).forEach(o -> {
|
||||
mapStatusCodes.put(o.getBackendCode(), o);
|
||||
});
|
||||
mapErrorsMultiple.put(messageFileKey, mapStatusCodes);
|
||||
return mapStatusCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Carga los mensajes de error desde una cadena JSON y los almacena en un
|
||||
* mapa.
|
||||
*
|
||||
* @param messageFileKey La clave del archivo de mensajes, utilizada para
|
||||
* almacenar el mapa en mapErrorsMultiple.
|
||||
* @param jsonString La cadena JSON que contiene los datos de los mensajes
|
||||
* de error.
|
||||
* @throws IOException Si ocurre un error al procesar la cadena JSON.
|
||||
*/
|
||||
public void loadMessagesFromString(String messageFileKey, String jsonString) throws IOException {
|
||||
Map<String, BackResponse> mapStatusCodes = new HashMap<>();
|
||||
Arrays.stream(JsonHelper.MAPPER.readValue(jsonString, BackResponse[].class)).forEach(o -> {
|
||||
mapStatusCodes.put(o.getBackendCode(), o);
|
||||
});
|
||||
mapErrorsMultiple.put(messageFileKey, mapStatusCodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el mapa de códigos de error para un archivo de respuesta
|
||||
* específico.
|
||||
*
|
||||
* @param responseFile El nombre del archivo de respuesta para el cual se
|
||||
* desea obtener el mapa de errores.
|
||||
* @return Un mapa que contiene los códigos de error como claves y los
|
||||
* objetos BackResponse como valores, o null si no se encuentra el mapa.
|
||||
*/
|
||||
public Map<String, BackResponse> getErrorMap(String responseFile, boolean insideProperties) {
|
||||
Map<String, BackResponse> errorMap = mapErrorsMultiple.get(responseFile);
|
||||
if (insideProperties || (errorMap != null && !errorMap.isEmpty())) {
|
||||
return errorMap;
|
||||
}
|
||||
|
||||
String fileName = (StringHelper.isNumeric(responseFile) ? "vb".concat(responseFile) : responseFile).concat(".json");
|
||||
|
||||
try {
|
||||
try {
|
||||
// Intenta cargar el archivo desde el directorio /config/.
|
||||
return loadFile(new FileInputStream("/config/".concat(fileName)), responseFile);
|
||||
} catch (IOException e) {
|
||||
// Si no se encuentra el archivo en /config/, intenta cargarlo desde el classpath.
|
||||
logger.log(Level.WARNING, "Path /config/" + fileName + " not found. Loading local from errors-mapping/" + fileName);
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
InputStream inputStream = classLoader.getResourceAsStream("errors-mapping/" + fileName);
|
||||
if (inputStream == null) {
|
||||
// Si no se encuentra el archivo en el classpath, registra un error y devuelve null.
|
||||
logger.log(Level.SEVERE, "Resource errors-mapping/" + fileName + " not found.");
|
||||
return null;
|
||||
}
|
||||
return loadFile(inputStream, responseFile);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Si ocurre un error al cargar el archivo desde cualquier ubicación, registra un error y devuelve null.
|
||||
logger.log(Level.SEVERE, "Error getting Service Messages to /config/".concat(fileName) + ": " + e.getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,90 +0,0 @@
|
||||
package com.banesco.common.infraestructure.repository;
|
||||
|
||||
import com.banesco.common.domain.model.ApiConfig;
|
||||
import com.banesco.common.domain.dto.bian.device.JsonHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.LoggerHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class RegisterSecurityRepository {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(RegisterSecurityRepository.class.getName());
|
||||
private final LoggerHelper loggerHelper;
|
||||
private final ApiConfig registerSecurityAPI;
|
||||
private final ExecutorService executor = Executors.newCachedThreadPool();
|
||||
|
||||
public RegisterSecurityRepository(LoggerHelper loggerHelper, ApiConfig registerSecurityAPI) {
|
||||
this.loggerHelper = loggerHelper;
|
||||
this.registerSecurityAPI = registerSecurityAPI;
|
||||
}
|
||||
|
||||
public <T> void writeTrice(String requestId, T registerSecurityRq) {
|
||||
logger.info(loggerHelper.buildInfoPrivateRequest(requestId, "RegisterSecurityRq", registerSecurityRq));
|
||||
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
URL url = new URL(registerSecurityAPI.getUrl());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setConnectTimeout(registerSecurityAPI.getTimeout().getConnect());
|
||||
connection.setReadTimeout(registerSecurityAPI.getTimeout().getResponse());
|
||||
connection.setDoOutput(true);
|
||||
|
||||
String jsonInputString = JsonHelper.getJsonFromObject(registerSecurityRq);
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
StringBuilder response = new StringBuilder();
|
||||
String responseLine;
|
||||
while ((responseLine = br.readLine()) != null) {
|
||||
response.append(responseLine.trim());
|
||||
}
|
||||
logger.info(loggerHelper.buildInfoPrivateResponse(requestId, "RegisterSecurityRs", response.toString()));
|
||||
}
|
||||
} else {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8))) {
|
||||
StringBuilder response = new StringBuilder();
|
||||
String responseLine;
|
||||
while ((responseLine = br.readLine()) != null) {
|
||||
response.append(responseLine.trim());
|
||||
}
|
||||
logger.info(loggerHelper.buildInfoPrivateResponse(requestId, "RegisterSecurityRs", response.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, String.format("Error interno writeTrice: %s", e.getMessage()));
|
||||
logger.info(loggerHelper.buildInfoPrivateResponse(requestId, "RegisterSecurityRs", e.getMessage()));
|
||||
}
|
||||
}, executor).exceptionally(ex -> {
|
||||
logger.log(Level.SEVERE, String.format("Async Error interno writeTrice: %s", ex.getMessage()));
|
||||
logger.info(loggerHelper.buildInfoPrivateResponse(requestId, "RegisterSecurityRs", ex.getMessage()));
|
||||
return null;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
@ -1,104 +0,0 @@
|
||||
package com.banesco.common.infraestructure.service;
|
||||
|
||||
import com.banesco.common.domain.model.BackResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.infraestructure.repository.MessageRepository;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MessageService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MessageService.class.getName());
|
||||
private final MessageRepository messageRepository;
|
||||
|
||||
private final String CONFLICT = "CONFLICT";
|
||||
private final BackResponse DEFAULT_ERROR = new BackResponse(
|
||||
CONFLICT,
|
||||
409,
|
||||
CONFLICT,
|
||||
CONFLICT
|
||||
);
|
||||
|
||||
private boolean messagesInsideProperties = false;
|
||||
|
||||
/**
|
||||
* Constructor de MessageService.
|
||||
*
|
||||
* @param messageRepository El repositorio de mensajes que se utilizará para
|
||||
* cargar y obtener mensajes de error.
|
||||
*/
|
||||
public MessageService(MessageRepository messageRepository) {
|
||||
this.messageRepository = messageRepository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Carga mensajes desde una cadena JSON en el repositorio de mensajes.
|
||||
*
|
||||
* @param responseFileName El nombre del archivo de respuesta asociado con
|
||||
* los mensajes.
|
||||
* @param jsonResponse La cadena JSON que contiene los mensajes.
|
||||
*/
|
||||
public void loadMessageFromJson(String responseFileName, String jsonResponse) {
|
||||
messagesInsideProperties = true;
|
||||
try {
|
||||
messageRepository.loadMessagesFromString(responseFileName, jsonResponse);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Error loading messages from JSON: %s".formatted(ex.getMessage()), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene una respuesta de estado (BackResponse) basada en el código de
|
||||
* backend y el nombre del archivo de respuesta.
|
||||
*
|
||||
* @param responseFileName El nombre del archivo de respuesta.
|
||||
* @param backendCode El código de backend para buscar la respuesta.
|
||||
* @return La respuesta de estado (BackResponse) correspondiente al código
|
||||
* de backend, la respuesta por defecto si no se encuentra, o null si hay un
|
||||
* error.
|
||||
*/
|
||||
public BackResponse geStatusResponse(String responseFileName, String backendCode) {
|
||||
logger.log(Level.INFO, "Finding backendCode: \"%s\" in File: \"%s\"".formatted(backendCode, responseFileName));
|
||||
Map<String, BackResponse> errors = messageRepository.getErrorMap(responseFileName, messagesInsideProperties);
|
||||
|
||||
if (errors == null || errors.isEmpty()) {
|
||||
logger.log(Level.WARNING, "Error map for %s is empty or null.".formatted(responseFileName));
|
||||
return DEFAULT_ERROR;
|
||||
}
|
||||
|
||||
BackResponse backResponse = null;
|
||||
try {
|
||||
backResponse = errors.get(backendCode);
|
||||
if (backResponse == null) {
|
||||
backResponse = errors.get("default");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, "Error code: %s not found in %s. Using default.".formatted(backendCode, responseFileName), e);
|
||||
try {
|
||||
backResponse = errors.get("default");
|
||||
} catch (Exception e2) {
|
||||
logger.log(Level.SEVERE, "Error getting default code.", e2);
|
||||
}
|
||||
}
|
||||
|
||||
if (backResponse == null) {
|
||||
logger.log(Level.WARNING, "Error code: %s and default not found in %s.".formatted(backendCode, responseFileName));
|
||||
return DEFAULT_ERROR;
|
||||
}
|
||||
return backResponse;
|
||||
}
|
||||
|
||||
public StatusResponse backToStatusResponse(String traceId, BackResponse backResponse, String target) {
|
||||
return new StatusResponse(
|
||||
backResponse.getHttpCode()>=200 && backResponse.getHttpCode()<300?"ok":"error",
|
||||
backResponse.getStatusCode(),
|
||||
target == null ? backResponse.getDescription() :
|
||||
backResponse.getDescription().formatted(target),
|
||||
traceId
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,90 +0,0 @@
|
||||
package com.banesco.common.infraestructure.utils;
|
||||
|
||||
import java.time.DateTimeException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* Clase para validación de fechas con configuración flexible. Permite validar
|
||||
* fechas en diferentes formatos, comprobar rangos de años y verificar la
|
||||
* correcta formación de componentes de fecha (año, mes, día). Implementa el
|
||||
* patrón Builder para facilitar la configuración personalizada de los
|
||||
* parámetros de validación.
|
||||
*/
|
||||
public class DateValidator {
|
||||
|
||||
private final DateTimeFormatter dateFormatter;
|
||||
private final PatternValidator datePattern;
|
||||
private final int minYear;
|
||||
private final int maxYear;
|
||||
|
||||
private DateValidator(Builder builder) {
|
||||
this.dateFormatter = builder.dateFormatter;
|
||||
this.datePattern = new PatternValidator(builder.dateFormatRegex);
|
||||
this.minYear = builder.minYear;
|
||||
this.maxYear = builder.maxYear;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
||||
private String dateFormatRegex = "(\\d{4})/(0[1-9]|1[0-2])/(0[1-9]|[12][0-9]|3[01])";
|
||||
private int minYear = 1900;
|
||||
private int maxYear = 2100;
|
||||
|
||||
public Builder withDateFormatter(String dateFormatterPattern) {
|
||||
this.dateFormatter = DateTimeFormatter.ofPattern(dateFormatterPattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withDateFormatRegex(String dateFormatRegex) {
|
||||
this.dateFormatRegex = dateFormatRegex;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withMinYear(int minYear) {
|
||||
this.minYear = minYear;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withMaxYear(int maxYear) {
|
||||
this.maxYear = maxYear;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DateValidator build() {
|
||||
return new DateValidator(this);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidDateFormat(String date) {
|
||||
return datePattern.isValid(date);
|
||||
}
|
||||
|
||||
public boolean isValidDate(String date) {
|
||||
if (!isValidDateFormat(date)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
LocalDate parsedDate = LocalDate.parse(date, dateFormatter);
|
||||
String formattedDate = parsedDate.format(dateFormatter);
|
||||
return date.equals(formattedDate);
|
||||
} catch (DateTimeException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValidDate(int year, int month, int day) {
|
||||
return year >= minYear && year <= maxYear && month >= 1 && month <= 12 && isValidDayOfMonth(year, month, day);
|
||||
}
|
||||
|
||||
private boolean isValidDayOfMonth(int year, int month, int day) {
|
||||
try {
|
||||
LocalDate.of(year, month, day);
|
||||
return true;
|
||||
} catch (DateTimeException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
package com.banesco.common.infraestructure.utils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Clase para validar Expresion regulares
|
||||
*/
|
||||
public class PatternValidator {
|
||||
|
||||
private final Pattern pattern;
|
||||
|
||||
public PatternValidator(String patternStr) {
|
||||
pattern = Pattern.compile(patternStr);
|
||||
}
|
||||
|
||||
public static PatternValidator withRegex(String patternStr) {
|
||||
return new PatternValidator(patternStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates is un valor tiene formato valido.
|
||||
*
|
||||
* @param value the value to check.
|
||||
* @return true if the value has format valid, false otherwise.
|
||||
*/
|
||||
public boolean isValid(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
return pattern.matcher(value).matches();
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package com.banesco;
|
||||
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest {
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
|
||||
public AppTest(String testName) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1
commons-plain-java
Submodule
1
commons-plain-java
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 3f36666c4dc33f988d1c635a9cfc1fe71fb7a59e
|
||||
@ -22,7 +22,5 @@ public class UpdateCardStatusService implements UpdateCardStatusUseCase {
|
||||
@Override
|
||||
public BlockUnblockDebitCardRs executeUpdate(UpdateCardStatusRequest request) {
|
||||
return cardPort.updateCardStatus(request);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package com.banesco.infrastructure.soap;
|
||||
import com.banesco.application.UpdateCardStatusRequest;
|
||||
import com.banesco.commons.config.AppConf;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.commons.helper.JsonHelper;
|
||||
import com.banesco.commons.helper.XMLHelper;
|
||||
import com.banesco.commons.model.SoapEndpoint;
|
||||
import com.banesco.commons.soap.client.apidebitcardoutappsvc.*;
|
||||
@ -31,7 +30,7 @@ public class CardAdapter implements CardPort {
|
||||
private Map<String, APIDebitCardOutAppSvc> SOAP_CLIENTS = new HashMap<>();
|
||||
private final AppConf appConf;
|
||||
private final DebitCardMapper debitCardMapper;
|
||||
private final SoapEndpoint paymentGenerateSOAP;
|
||||
private final SoapEndpoint blockUnblockDebitCardSOAP;
|
||||
|
||||
@ConfigProperty(name = "soap.print-xml", defaultValue = "false")
|
||||
boolean mustPrintXML;
|
||||
@ -39,7 +38,7 @@ public class CardAdapter implements CardPort {
|
||||
public CardAdapter(AppConf appConf, DebitCardMapper debitCardMapper) {
|
||||
this.appConf = appConf;
|
||||
this.debitCardMapper = debitCardMapper;
|
||||
paymentGenerateSOAP = appConf.loadSoapClientConfig("soap.service.block-unblock-debit-card");
|
||||
blockUnblockDebitCardSOAP = appConf.loadSoapClientConfig("soap.service.block-unblock-debit-card");
|
||||
}
|
||||
|
||||
|
||||
@ -52,14 +51,14 @@ public class CardAdapter implements CardPort {
|
||||
log.info("loading domainKey: {}", domainKey);
|
||||
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
|
||||
factory.setServiceClass(APIDebitCardOutAppSvc.class);
|
||||
factory.setAddress(paymentGenerateSOAP.getUrl(appConf.getDomainConfig(domainKey)));
|
||||
factory.setAddress(blockUnblockDebitCardSOAP.getUrl(appConf.getDomainConfig(domainKey)));
|
||||
|
||||
client = (APIDebitCardOutAppSvc) factory.create();
|
||||
|
||||
HTTPConduit conduit = (HTTPConduit) ClientProxy.getClient(client).getConduit();
|
||||
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
|
||||
httpClientPolicy.setConnectionTimeout(paymentGenerateSOAP.getTimeout().getConnect()); // Connection timeout in milliseconds
|
||||
httpClientPolicy.setReceiveTimeout(paymentGenerateSOAP.getTimeout().getResponse()); // Receive timeout in milliseconds
|
||||
httpClientPolicy.setConnectionTimeout(blockUnblockDebitCardSOAP.getTimeout().getConnect()); // Connection timeout in milliseconds
|
||||
httpClientPolicy.setReceiveTimeout(blockUnblockDebitCardSOAP.getTimeout().getResponse()); // Receive timeout in milliseconds
|
||||
conduit.setClient(httpClientPolicy);
|
||||
SOAP_CLIENTS.put(domainKey, client);
|
||||
}
|
||||
@ -79,28 +78,29 @@ public class CardAdapter implements CardPort {
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
return getSoapClient(requestData.getDomain()).blockUnblockDebitCard(request);
|
||||
|
||||
}catch (SocketTimeoutException e){
|
||||
log.error("SocketTimeoutException logging domain: {}, error: {}",requestData.getDomain(), e.getMessage());
|
||||
} catch (SocketTimeoutException e) {
|
||||
log.error("SocketTimeoutException logging domain: {}, error: {}", requestData.getDomain(), e.getMessage());
|
||||
return buildErrorStatusResponse(StatusCodes.TIMEOUT_DEPENDENCY, e.getMessage());
|
||||
} catch (WebServiceException e) {
|
||||
log.error("WebServiceException logging domain: {}, error: {}",requestData.getDomain(), e.getMessage());
|
||||
log.error("WebServiceException logging domain: {}, error: {}", requestData.getDomain(), e.getMessage());
|
||||
return buildErrorStatusResponse(StatusCodes.FAILED_DEPENDENCY, e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private BlockUnblockDebitCardRs buildErrorStatusResponse(StatusCodes statusCode, String message) {
|
||||
BlockUnblockDebitCardRs response = new BlockUnblockDebitCardRs();
|
||||
Status status = debitCardMapper.objectFactory.createStatus();
|
||||
status.setStatusCode(statusCode.getStatusCode());
|
||||
status.setStatusDesc(statusCode.getStatusDesc());
|
||||
|
||||
AdditionalStatus additionalStatus = debitCardMapper.objectFactory.createAdditionalStatus();
|
||||
additionalStatus.setStatusCode(statusCode.getStatusDesc());
|
||||
additionalStatus.setStatusCode(message);
|
||||
additionalStatus.setStatusCode(statusCode.getStatusCode());
|
||||
additionalStatus.setStatusDesc(message);
|
||||
status.getAdditionalStatus().add(additionalStatus);
|
||||
|
||||
response.getStatus().add(
|
||||
|
||||
@ -3,13 +3,13 @@ quarkus:
|
||||
port: 8083
|
||||
idle-timeout: 30s
|
||||
soap:
|
||||
print-xml: false
|
||||
print-xml: true
|
||||
health-check:
|
||||
enabled: false
|
||||
validation:
|
||||
domains: osbc,osbp2p
|
||||
service:
|
||||
block-unblock-debit-card: '{"path":"/APIDebitCardOutAppSvc/proxy/APIDebitCardOutAppSvc","soapAction":"","timeout":{ "connect": 20000, "response": 20000}}'
|
||||
block-unblock-debit-card: '{"path":"/APIDebitCardOutAppSvc/proxy/APIDebitCardOutAppSvc","soapAction":"","timeout":{ "connect": 10000, "response": 10000}}'
|
||||
domain:
|
||||
current: osbc
|
||||
domains:
|
||||
|
||||
@ -45,9 +45,10 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.banesco</groupId>
|
||||
<artifactId>commons-bian</artifactId>
|
||||
<artifactId>commons</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-core</artifactId>
|
||||
|
||||
@ -2,8 +2,8 @@ package com.banesco.application.helper;
|
||||
|
||||
|
||||
import com.banesco.common.application.exception.BanRuntimeException;
|
||||
import com.banesco.common.application.helper.DeviceHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.StringHelper;
|
||||
import com.banesco.common.infraestructure.helpers.DeviceHelper;
|
||||
import com.banesco.common.infraestructure.helpers.StringHelper;
|
||||
import com.banesco.common.infraestructure.utils.PatternValidator;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.domain.bian.request.RecUpdateCardStatusRequest;
|
||||
|
||||
@ -3,9 +3,9 @@ package com.banesco.application.rest.controllers;
|
||||
import com.banesco.application.helper.UpdateCardStatusRequestValidator;
|
||||
import com.banesco.common.application.exception.BanBackendException;
|
||||
import com.banesco.common.application.exception.BanRuntimeException;
|
||||
import com.banesco.common.domain.dto.bian.device.JsonHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.LoggerHelper;
|
||||
import com.banesco.common.domain.model.BackResponse;
|
||||
import com.banesco.common.infraestructure.helpers.JsonHelper;
|
||||
import com.banesco.common.infraestructure.helpers.LoggerHelper;
|
||||
import com.banesco.commons.config.AppConf;
|
||||
import com.banesco.domain.bian.request.RecUpdateCardStatusRequest;
|
||||
import com.banesco.domain.bian.response.RecUpdateCardStatusResponse;
|
||||
@ -221,7 +221,7 @@ public class UpdateCardStatusController {
|
||||
}
|
||||
|
||||
RecUpdateCardStatusResponse response = new RecUpdateCardStatusResponse();
|
||||
response.setStatusResponse(appConf.messageService.backToStatusResponse(currentState.requestId(), backResponse, target));
|
||||
response.setStatusResponse(appConf.messageService.backToBianStatusResponse(currentState.requestId(), backResponse, target));
|
||||
|
||||
String outputJson = response.toString();
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
package com.banesco.commons.config;
|
||||
|
||||
import com.banesco.common.application.exception.BanRuntimeException;
|
||||
import com.banesco.common.domain.dto.bian.device.DateHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.JsonHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.RequestHelper;
|
||||
import com.banesco.common.domain.model.ApiConfig;
|
||||
import com.banesco.common.domain.model.BackResponse;
|
||||
import com.banesco.common.infraestructure.helpers.DateHelper;
|
||||
import com.banesco.common.infraestructure.helpers.JsonHelper;
|
||||
import com.banesco.common.infraestructure.helpers.RequestHelper;
|
||||
import com.banesco.common.infraestructure.repository.MessageRepository;
|
||||
import com.banesco.common.infraestructure.service.MessageService;
|
||||
import com.banesco.commons.exceptions.BanConfigException;
|
||||
@ -36,6 +36,7 @@ public class AppConf {
|
||||
private final RequestHelper requestHelper;
|
||||
|
||||
DateHelper dateHelper = DateHelper.getInstance();
|
||||
|
||||
public static void getInstance() {
|
||||
|
||||
synchronized (AppConf.class) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.banesco.commons.exceptions;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.domain.bian.response.RecUpdateCardStatusResponse;
|
||||
import io.vertx.ext.web.RoutingContext;
|
||||
import jakarta.inject.Inject;
|
||||
@ -29,7 +29,7 @@ public class InternalExceptionMapper {
|
||||
case "/card/status/update":
|
||||
RecUpdateCardStatusResponse response = new RecUpdateCardStatusResponse();
|
||||
response.setStatusResponse(
|
||||
new StatusResponse(
|
||||
new BianStatusResponse(
|
||||
"error",
|
||||
"CONFLICT",
|
||||
"Uso interno",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package com.banesco.commons.exceptions;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.domain.bian.response.RecUpdateCardStatusResponse;
|
||||
import io.vertx.core.http.HttpServerRequest;
|
||||
@ -29,12 +29,12 @@ public class MalformedPayloadExceptionMapper implements ExceptionMapper<JsonbExc
|
||||
headers.getHeader("appId"));
|
||||
|
||||
|
||||
String jsonResult = (new RecUpdateCardStatusResponse( new StatusResponse(
|
||||
String jsonResult = (new RecUpdateCardStatusResponse(new BianStatusResponse(
|
||||
"error",
|
||||
StatusCodes.INVALID_FORMAT.getStatusCode(),
|
||||
StatusCodes.INVALID_FORMAT.getStatusDesc().formatted("body"),
|
||||
null
|
||||
))).toString();
|
||||
), null)).toString();
|
||||
|
||||
log.error("[RESPONSE]: [{}]", jsonResult);
|
||||
return Response.status(Response.Status.BAD_REQUEST)
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package com.banesco.commons.utils;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
|
||||
|
||||
public class ResponseUtil {
|
||||
|
||||
public static StatusResponse mapErrorResponse(String requestId, StatusCodes statusCodes) {
|
||||
return new StatusResponse("error", statusCodes.getStatusCode(), statusCodes.getStatusDesc(), requestId);
|
||||
public static BianStatusResponse mapErrorResponse(String requestId, StatusCodes statusCodes) {
|
||||
return new BianStatusResponse("error", statusCodes.getStatusCode(), statusCodes.getStatusDesc(), requestId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.banesco.domain.bian.request;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.customer.CustomerReference;
|
||||
import com.banesco.common.domain.dto.bian.device.Device;
|
||||
import com.banesco.common.domain.dto.bian.device.BianDevice;
|
||||
import com.banesco.domain.bian.dto.CardReference;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -13,6 +13,6 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class RecUpdateCardStatusRequest {
|
||||
CustomerReference customerReference;
|
||||
Device device;
|
||||
BianDevice device;
|
||||
CardReference cardReference;
|
||||
}
|
||||
|
||||
@ -2,21 +2,21 @@ package com.banesco.domain.bian.response;
|
||||
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.BaseResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@RegisterForReflection
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class RecUpdateCardStatusResponse extends BaseResponse {
|
||||
public class RecUpdateCardStatusResponse extends BaseResponse<BianStatusResponse, Object> {
|
||||
|
||||
public RecUpdateCardStatusResponse() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RecUpdateCardStatusResponse(StatusResponse statusResponse) {
|
||||
super(statusResponse);
|
||||
public RecUpdateCardStatusResponse(BianStatusResponse statusResponse, Object data) {
|
||||
super(statusResponse, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package com.banesco.domain.ports.outbound;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.domain.bian.request.RecUpdateCardStatusRequest;
|
||||
import com.banesco.domain.models.CurrentState;
|
||||
|
||||
public interface PaymentCardPort {
|
||||
|
||||
StatusResponse updateCardStatus(CurrentState currentState, RecUpdateCardStatusRequest request);
|
||||
BianStatusResponse updateCardStatus(CurrentState currentState, RecUpdateCardStatusRequest request);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.banesco.domain.services;
|
||||
|
||||
import com.banesco.common.application.exception.BanBackendException;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.domain.bian.request.RecUpdateCardStatusRequest;
|
||||
import com.banesco.domain.models.CurrentState;
|
||||
@ -26,9 +26,9 @@ public class UpdateCardStatusService implements UpdateCardStatusUseCase {
|
||||
|
||||
@Override
|
||||
public void execute(CurrentState currentState,
|
||||
RecUpdateCardStatusRequest request) {
|
||||
RecUpdateCardStatusRequest request) {
|
||||
|
||||
StatusResponse statusResponse = paymentCardPort.updateCardStatus(currentState, request);
|
||||
BianStatusResponse statusResponse = paymentCardPort.updateCardStatus(currentState, request);
|
||||
|
||||
if (!statusResponse.statusCode().equals(RESULT_OK)) {
|
||||
throw new BanBackendException(statusResponse.statusCode(), statusResponse.message());
|
||||
|
||||
@ -2,7 +2,7 @@ package com.banesco.infrastructure.dtos.card;
|
||||
|
||||
|
||||
import com.banesco.common.domain.dto.bian.customer.CustomerReference;
|
||||
import com.banesco.common.domain.dto.bian.device.Device;
|
||||
import com.banesco.common.domain.dto.bian.device.BianDevice;
|
||||
import com.banesco.domain.bian.dto.CardReference;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -17,6 +17,6 @@ public class BusUpdateCardStatusRequest {
|
||||
String requestId;
|
||||
String customerReferenceFintechId;
|
||||
CustomerReference customerReference;
|
||||
Device device;
|
||||
BianDevice device;
|
||||
CardReference cardReference;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ package com.banesco.infrastructure.dtos.card;
|
||||
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.BaseResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -10,13 +10,13 @@ import lombok.EqualsAndHashCode;
|
||||
@RegisterForReflection
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class BusUpdateCardStatusResponse extends BaseResponse {
|
||||
public class BusUpdateCardStatusResponse extends BaseResponse<BianStatusResponse, Object> {
|
||||
public BusUpdateCardStatusResponse() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BusUpdateCardStatusResponse(StatusResponse statusResponse) {
|
||||
super(statusResponse);
|
||||
public BusUpdateCardStatusResponse(BianStatusResponse statusResponse, Object data) {
|
||||
super(statusResponse, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
package com.banesco.infrastructure.rest;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.common.domain.model.ApiConfig;
|
||||
import com.banesco.commons.config.AppConf;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.domain.bian.request.RecUpdateCardStatusRequest;
|
||||
import com.banesco.domain.models.CurrentState;
|
||||
import com.banesco.domain.ports.outbound.PaymentCardPort;
|
||||
@ -37,20 +36,22 @@ public class PaymentCardAdapter implements PaymentCardPort {
|
||||
}
|
||||
|
||||
|
||||
public StatusResponse updateCardStatus(CurrentState currentState, RecUpdateCardStatusRequest request) {
|
||||
public BianStatusResponse updateCardStatus(CurrentState currentState, RecUpdateCardStatusRequest request) {
|
||||
|
||||
/*
|
||||
StatusResponse statusResponse = paymentRepository.updateCardStatus(
|
||||
|
||||
return paymentRepository.updateCardStatus(
|
||||
this.paymentCardMapper.toBusinessRequest(
|
||||
currentState,
|
||||
request
|
||||
)
|
||||
);*/
|
||||
);
|
||||
|
||||
StatusResponse statusResponse;
|
||||
/*
|
||||
|
||||
BianStatusResponse statusResponse;
|
||||
|
||||
if (request.getCustomerReference().getCustomerIdType().equals("J")) {
|
||||
statusResponse = new StatusResponse(
|
||||
statusResponse = new BianStatusResponse(
|
||||
"ok",
|
||||
StatusCodes.SUCCESS_OPERATION.getStatusCode(),
|
||||
|
||||
@ -58,7 +59,7 @@ public class PaymentCardAdapter implements PaymentCardPort {
|
||||
currentState.requestId()
|
||||
);
|
||||
} else {
|
||||
statusResponse = new StatusResponse(
|
||||
statusResponse = new BianStatusResponse(
|
||||
"error",
|
||||
StatusCodes.FAILED_DEPENDENCY.getStatusCode(),
|
||||
"Error al procesar la solicitud",
|
||||
@ -68,7 +69,7 @@ public class PaymentCardAdapter implements PaymentCardPort {
|
||||
|
||||
|
||||
return statusResponse;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.banesco.infrastructure.rest;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.device.LoggerHelper;
|
||||
import com.banesco.common.domain.model.ApiConfig;
|
||||
import com.banesco.common.infraestructure.helpers.LoggerHelper;
|
||||
import com.banesco.commons.config.AppConf;
|
||||
import com.banesco.domain.ports.outbound.RegisterSecurityPort;
|
||||
import com.banesco.infrastructure.dtos.RegisterSecurityRq;
|
||||
|
||||
@ -3,7 +3,7 @@ package com.banesco.infrastructure.rest.clients;
|
||||
import com.banesco.infrastructure.dtos.card.BusUpdateCardStatusRequest;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
@ -14,7 +14,7 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
|
||||
public interface BusUpdateCardStatusRestClient {
|
||||
|
||||
|
||||
@POST
|
||||
@PUT
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
Response invoke(BusUpdateCardStatusRequest request);
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package com.banesco.infrastructure.rest.repositories;
|
||||
|
||||
import com.banesco.common.domain.dto.bian.device.JsonHelper;
|
||||
import com.banesco.common.domain.dto.bian.device.LoggerHelper;
|
||||
import com.banesco.common.domain.dto.bian.response.StatusResponse;
|
||||
import com.banesco.common.domain.dto.bian.response.BianStatusResponse;
|
||||
import com.banesco.common.domain.model.ApiConfig;
|
||||
import com.banesco.common.infraestructure.helpers.JsonHelper;
|
||||
import com.banesco.common.infraestructure.helpers.LoggerHelper;
|
||||
import com.banesco.commons.config.StatusCodes;
|
||||
import com.banesco.commons.utils.ResponseUtil;
|
||||
import com.banesco.infrastructure.dtos.card.BusUpdateCardStatusRequest;
|
||||
@ -41,7 +41,7 @@ public class PaymentCardRepository {
|
||||
}
|
||||
|
||||
|
||||
public StatusResponse updateCardStatus(BusUpdateCardStatusRequest request) {
|
||||
public BianStatusResponse updateCardStatus(BusUpdateCardStatusRequest request) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
quarkus:
|
||||
http:
|
||||
port: 8080
|
||||
port: 8081
|
||||
idle-timeout: 30s
|
||||
thread-pool:
|
||||
max-threads: 100
|
||||
core-threads: 1
|
||||
api:
|
||||
source-id: UCSS
|
||||
source-id: UCS
|
||||
allowed:
|
||||
customer:
|
||||
types: J,V
|
||||
@ -22,9 +22,9 @@ api:
|
||||
recUpdateCardStatus:
|
||||
messages:
|
||||
key: 'recUpdateCardStatus'
|
||||
content: '[{"backendCode":"200","httpCode":200,"statusCode":"200","description":"Operacion exitosa"},{"backendCode":"503","httpCode":503,"statusCode":"503","description":"Uso interno"},{"backendCode":"422","httpCode":422,"statusCode":"422","description":"Uso interno"},{"backendCode":"SERVICE_UNAVAILABLE","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"}]'
|
||||
content: '[{"backendCode":"200","httpCode":200,"statusCode":"200","description":"Operacion exitosa"},{"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"}]'
|
||||
rest-client:
|
||||
bus-update-card-status: '{"url":"http://localhost:8081/card/status/update","timeout":{"connect":20000,"response":20000},"config":{}}'
|
||||
bus-update-card-status: '{"url":"http://localhost:8082/card/status/update","timeout":{"connect":20000,"response":20000},"config":{}}'
|
||||
register-security: '{"url":"http://api-register-security-route-apis-banesco-dev.apps.desplakur3.desintra.banesco.com/register-security/save","timeout":{"connect":20000,"response":20000},"config":{"sp":"spAPI_Traza","eventCod":"CANCTARJ","bankCod":"01","curCod":"BS"}}'
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user