From f3677532d3fff9391501124fb9a99c9cbbb692c6 Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Sat, 25 May 2024 01:03:16 +0530 Subject: [PATCH] fix code ql issues --- .../GlobalDefaultExceptionHandler.java | 2 +- .../manager/ConnectorRegistrationManager.java | 2 +- .../manager/PortalIntegrationManager.java | 33 +++++++++---------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java index 0767be6e..96ebc112 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java @@ -69,7 +69,7 @@ public ResponseEntity handleValidationException(ValidationException ex, } @ExceptionHandler(FeignException.class) - public ResponseEntity> handleFeignException(FeignException ex, WebRequest request) { + public ResponseEntity> handleFeignException(FeignException ex) { log.error("FeignException: " + ex.getMessage()); log.error("FeignException RequestBody: " + ex.request()); log.error("FeignException ResponseBody: " + ex.contentUTF8()); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java index 87b28565..38b85d9f 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java @@ -178,7 +178,7 @@ private String checkSubcriptionHaveConnectorRegister(Map header, String remoteSubscriptionId = "";//JsonObjectProcessingUtility.getValueFromJsonNode(jsonNode, //SUBSCRIPTION_ID); - if (subscriptionId.equalsIgnoreCase(remoteSubscriptionId)) { + if (subscriptionId.equalsIgnoreCase(remoteSubscriptionId) && jsonNode!=null) { JsonNode connectorIds = null;//JsonObjectProcessingUtility.getArrayNodeFromJsonNode(jsonNode, //"connectorIds"); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java index b73c5e57..34ca7769 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java @@ -211,7 +211,7 @@ private ServiceInstanceResultResponse processAppServiceGetResponse(String subscr String appServiceURIPath) { ServiceInstanceResultResponse serviceInstanceResultResponse = verifyIsAlreadySubcribedActivatedAndGetDetails( - subscriptionId, offerId, header, serviceInstanceResultRequest, appServiceURIPath); + subscriptionId, offerId, header, appServiceURIPath); if (serviceInstanceResultResponse == null) { @@ -221,7 +221,7 @@ private ServiceInstanceResultResponse processAppServiceGetResponse(String subscr log.info("Post App/Service instanceURL, going to read credentials asynchronously"); serviceInstanceResultResponse = verifyIsAlreadySubcribedActivatedAndGetDetails(subscriptionId, offerId, - header, serviceInstanceResultRequest, appServiceURIPath); + header, appServiceURIPath); } @@ -229,15 +229,14 @@ private ServiceInstanceResultResponse processAppServiceGetResponse(String subscr throw new ServiceException("Unable to read technical user detials from portal auto setup"); } - readTechnicalUserDetails(subscriptionId, header, serviceInstanceResultResponse); + readTechnicalUserDetails(header, serviceInstanceResultResponse); return serviceInstanceResultResponse; } @SneakyThrows private ServiceInstanceResultResponse verifyIsAlreadySubcribedActivatedAndGetDetails(String subscriptionId, - String offerId, Map header, ServiceInstanceResultRequest serviceInstanceResultRequest, - String appServiceURIPath) { + String offerId, Map header, String appServiceURIPath) { int retry = 5; int counter = 1; @@ -256,28 +255,28 @@ private ServiceInstanceResultResponse verifyIsAlreadySubcribedActivatedAndGetDet offerSubscriptionStatus = serviceInstanceResultResponse.getOfferSubscriptionStatus(); - log.info("VerifyIsAlreadySubcribedActivatedAndGetDetails: The subscription details found for " + offerId + log.info(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails: The subscription details found for " + offerId + ", " + subscriptionId + ", status is " + offerSubscriptionStatus + ", result is " - + serviceInstanceResultResponse.toJsonString()); + + serviceInstanceResultResponse.toJsonString())); } catch (FeignException e) { - log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException request: " + e.request()); - log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException response Body: " - + e.responseBody()); + log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException request: " + e.request())); + log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException response Body: " + + e.responseBody())); String error = e.contentUTF8(); error = StringUtils.isAllEmpty(error) ? error : e.getMessage(); if (e.status() == 404) { - log.warn("VerifyIsAlreadySubcribedActivatedAndGetDetails: The no app or subscription found for " - + offerId + ", " + subscriptionId + ", result is " + error); + log.warn(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails: The no app or subscription found for " + + offerId + ", " + subscriptionId + ", result is " + error)); } else { - log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException Exception response: " - + error); + log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails FeignException Exception response: " + + error)); } } catch (Exception e) { - log.error("VerifyIsAlreadySubcribedActivatedAndGetDetails Exception processing portal call " - + e.getMessage()); + log.error(LogUtil.encode("VerifyIsAlreadySubcribedActivatedAndGetDetails Exception processing portal call " + + e.getMessage())); } counter++; @@ -287,7 +286,7 @@ private ServiceInstanceResultResponse verifyIsAlreadySubcribedActivatedAndGetDet } @SneakyThrows - private void readTechnicalUserDetails(String subscriptionId, Map header, + private void readTechnicalUserDetails(Map header, ServiceInstanceResultResponse serviceInstanceResultResponse) { if (serviceInstanceResultResponse.getTechnicalUserData() != null) {