diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2019-10-24 17:18:41 +0200 |
---|---|---|
committer | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2019-10-28 09:18:28 +0000 |
commit | 0f4c9ea387e1ac8e815b3ecd324e464a06d07791 (patch) | |
tree | 600c76e6f2676a75bc9e6fa8de48ba8869350d9f /adapters/mso-vnfm-adapter | |
parent | 17caf5e4b1792d592ba9ce3ca8f3115c76b78919 (diff) |
blocker sonar fix
Change-Id: I500447927dc2497c9d630bc3217f03cd5d4f2b98
Issue-ID: SO-2187
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'adapters/mso-vnfm-adapter')
-rw-r--r-- | adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java index 3bdba368b2..d898de3ad0 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java @@ -136,15 +136,9 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { logger.error(errorMessage, exception); throw new VnfmRequestFailureException(errorMessage, exception); } - if (response.getStatusCode() != HttpStatus.ACCEPTED) { - final String errorMessage = "Terminate request to " + vnfSelfLink + " returned status code: " - + response.getStatusCode() + ", request: " + terminateVnfRequest; - logger.error(errorMessage); - throw new VnfmRequestFailureException(errorMessage); - } + checkIfResponseIsAcceptable(response, vnfSelfLink, terminateVnfRequest); final String locationHeader = response.getHeaders().get("Location").iterator().next(); return locationHeader.substring(locationHeader.lastIndexOf("/") + 1); - } @Override @@ -177,6 +171,22 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { } } + private void checkIfResponseIsAcceptable(ResponseEntity<Void> response, String vnfSelfLink, + TerminateVnfRequest terminateVnfRequest) { + if (response == null) { + final String errorMessage = + "Terminate request to " + vnfSelfLink + ", response is null, " + "request: " + terminateVnfRequest; + logger.error(errorMessage); + throw new VnfmRequestFailureException(errorMessage); + } + if (response.getStatusCode() != HttpStatus.ACCEPTED) { + final String errorMessage = "Terminate request to " + vnfSelfLink + ", returned status code: " + + response.getStatusCode() + ", request: " + terminateVnfRequest; + logger.error(errorMessage); + throw new VnfmRequestFailureException(errorMessage); + } + } + private HttpRestServiceProvider getHttpServiceProvider(final EsrVnfm vnfm) { return vnfmServiceProviderConfiguration.getHttpRestServiceProvider(vnfm); } |