From d9d43afc9e8a2412597c07d7899e15b51d4a1b2d Mon Sep 17 00:00:00 2001 From: Pawel Sosnowski Date: Wed, 6 Dec 2023 11:34:04 +0100 Subject: [PATCH] feat(irs-api):[#256] spotbug fix --- .../EndpointDataReferenceCacheService.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheService.java index 4f742bd666..604e422bd5 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/util/EndpointDataReferenceCacheService.java @@ -59,18 +59,21 @@ public EndpointDataReferenceStatus getEndpointDataReference(final String assetId final Optional endpointDataReferenceOptional = retrieveEndpointEndpointReferenceByAssetId( assetId); - if (endpointDataReferenceOptional.isPresent() && endpointDataReferenceOptional.get().getAuthCode() != null) { - final EndpointDataReference endpointDataReference = endpointDataReferenceOptional.get(); - if (isTokenExpired(endpointDataReferenceOptional.get().getAuthCode())) { - log.info("Endpoint data reference with expired token and id: {} for assetId: {} found in storage.", - endpointDataReference.getId(), assetId); - return new EndpointDataReferenceStatus(endpointDataReference, - EndpointDataReferenceStatus.TokenStatus.EXPIRED); - } else { - log.info("Endpoint data reference with id: {} for assetId: {} found in storage.", - endpointDataReference.getId(), assetId); - return new EndpointDataReferenceStatus(endpointDataReference, - EndpointDataReferenceStatus.TokenStatus.VALID); + if (endpointDataReferenceOptional.isPresent()) { + final String authCode = endpointDataReferenceOptional.get().getAuthCode(); + if (authCode != null) { + final EndpointDataReference endpointDataReference = endpointDataReferenceOptional.get(); + if (isTokenExpired(authCode)) { + log.info("Endpoint data reference with expired token and id: {} for assetId: {} found in storage.", + endpointDataReference.getId(), assetId); + return new EndpointDataReferenceStatus(endpointDataReference, + EndpointDataReferenceStatus.TokenStatus.EXPIRED); + } else { + log.info("Endpoint data reference with id: {} for assetId: {} found in storage.", + endpointDataReference.getId(), assetId); + return new EndpointDataReferenceStatus(endpointDataReference, + EndpointDataReferenceStatus.TokenStatus.VALID); + } } }