summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-11-04 14:49:27 +0000
committerGerrit Code Review <gerrit@onap.org>2019-11-04 14:49:27 +0000
commit4ec5384dc1fac74d0fde85a4c941fe7aba233069 (patch)
tree4bafbe8edc0bd2358492f592cb02bfa0ad786f7d
parent14951284d76e23ea621add2d7e8bae00b84f8195 (diff)
parent0f4c9ea387e1ac8e815b3ecd324e464a06d07791 (diff)
Merge "blocker sonar fix"
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java24
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);
}