aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2019-12-20 14:58:57 +0000
committerwaqas.ikram <waqas.ikram@est.tech>2019-12-20 15:01:26 +0000
commit0a9a368db26919b3134a6a785df9cf4777bf4420 (patch)
treebdb3c731d798a8b7d82f5d51cc33ea9fcff0fc34 /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main
parent6a407a9d3c3b6b2e02c1dcfa6219df31ecece013 (diff)
SOL003 Adapter Package Management - Fetch VNF Package Artifacts
Change-Id: Ibb7d3ff392b42f8e98ce45d45cfc54caad66bdcb Issue-ID: SO-2416 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main')
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java12
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java30
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java12
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java43
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java (renamed from adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Sol003PackageManagementControllerExceptionHandler.java)2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java2
7 files changed, 79 insertions, 24 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
index a73958e544..d4063951bd 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
@@ -20,8 +20,8 @@
package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
import java.util.Optional;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
/**
* Provides methods for invoking REST calls to the ETSI Catalog Manager.
@@ -53,4 +53,14 @@ public interface EtsiCatalogServiceProvider {
*/
Optional<InlineResponse2001> getVnfPackage(final String vnfPkgId);
+ /**
+ * GET Package Artifact, from VNF Package.
+ *
+ * @param vnfPkgId The ID of the VNF Package from which the artifact will be retrieved.
+ * @param artifactPath Sequence of one or more path segments representing the path of the artifact within the VNF
+ * Package, e.g., foo/bar/run.sh
+ * @return The Package Artifact of a VNF Package ("vnfPkgId", "artifactPath").
+ */
+ Optional<byte[]> getVnfPackageArtifact(final String vnfPkgId, final String artifactPath);
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
index 96b01f04e4..11a59c2ec8 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java
@@ -23,10 +23,7 @@ package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
import java.util.Optional;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.EtsiCatalogManagerRequestFailureException;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgBadRequestException;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgConflictException;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgNotFoundException;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.*;
import org.onap.so.rest.exceptions.HttpResouceNotFoundException;
import org.onap.so.rest.exceptions.InvalidRestRequestException;
import org.onap.so.rest.exceptions.RestProcessingException;
@@ -88,6 +85,31 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide
}
@Override
+ public Optional<byte[]> getVnfPackageArtifact(final String vnfPkgId, final String artifactPath) {
+ try {
+ final ResponseEntity<byte[]> response = httpServiceProvider.getHttpResponse(
+ etsiCatalogUrlProvider.getVnfPackageArtifactUrl(vnfPkgId, artifactPath), byte[].class);
+ logger.info("getVnfPackageArtifact Request to ETSI Catalog Manager Status Code: {}",
+ response.getStatusCodeValue());
+ if (response.getStatusCode() == HttpStatus.OK) {
+ return Optional.ofNullable(response.getBody());
+ }
+ } catch (final HttpResouceNotFoundException httpResouceNotFoundException) {
+ logger.error("Caught HttpResouceNotFoundException", httpResouceNotFoundException);
+ throw new VnfPkgNotFoundException("No Vnf Package Artifact found with vnfPkgId: \"" + vnfPkgId
+ + "\" and artifactPath: \"" + artifactPath + "\".");
+ } catch (final RestProcessingException restProcessingException) {
+ logger.error("Caught RestProcessingException with Status Code: {}", restProcessingException.getStatusCode(),
+ restProcessingException);
+ if (restProcessingException.getStatusCode() == HttpStatus.CONFLICT.value()) {
+ throw new VnfPkgConflictException("A conflict occurred with the state of the resource,\n"
+ + "due to the attribute: onboardingState not being set to ONBOARDED.");
+ }
+ }
+ throw new EtsiCatalogManagerRequestFailureException("Internal Server Error Occurred.");
+ }
+
+ @Override
public Optional<InlineResponse2001[]> getVnfPackages() {
try {
final ResponseEntity<VnfPkgInfo[]> response =
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java
index d233c3f0fd..cc2c7a62a4 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java
@@ -79,4 +79,16 @@ public class EtsiCatalogUrlProvider {
return url;
}
+ /**
+ * Get the URL for retrieving VNF Package Artifacts
+ *
+ * @param vnfPkgId The ID of the VNF Package
+ * @param artifactPath The path to the Artifact
+ * @return the URL for the GET operation
+ */
+ public String getVnfPackageArtifactUrl(final String vnfPkgId, final String artifactPath) {
+ final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/artifacts/" + artifactPath;
+ logger.info("getVnfPackageArtifactUrl: {}", url);
+ return url;
+ }
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
index 76ec492bd4..3f975fbc9c 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
@@ -49,7 +49,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
public class Sol003PackageManagementController {
private final EtsiCatalogServiceProvider etsiCatalogServiceProvider;
- private static final String LOG_REQUEST_RECEIVED = "VNF PackageManagement Controller: {} {} {}";
+ private static final String LOG_REQUEST_RECEIVED = "VNF PackageManagement Controller: {} {} {} {}";
private static final Logger logger = getLogger(Sol003PackageManagementController.class);
@Autowired
@@ -64,18 +64,18 @@ public class Sol003PackageManagementController {
* @return An Array of all VNF packages. Object: InlineResponse2001[] Response Code: 200 OK
*/
@GetMapping(value = "/vnf_packages", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity getVnfPackages() {
+ public ResponseEntity<?> getVnfPackages() {
logger.info(LOG_REQUEST_RECEIVED, "getVnfPackages.");
final Optional<InlineResponse2001[]> response = etsiCatalogServiceProvider.getVnfPackages();
if (response.isPresent()) {
logger.info(LOG_REQUEST_RECEIVED, "getVnfPackages Response: ", HttpStatus.OK);
- return new ResponseEntity(response.get(), HttpStatus.OK);
+ return ResponseEntity.ok().body(response.get());
}
final String errorMessage = "An error occurred, a null response was received by the\n"
+ " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnf_packages\" \n"
+ "endpoint.";
logger.error(errorMessage);
- return new ResponseEntity(buildProblemDetails(errorMessage), HttpStatus.INTERNAL_SERVER_ERROR);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage));
}
/**
@@ -86,18 +86,18 @@ public class Sol003PackageManagementController {
* @return A VNF package based on vnfPkgId. Object: VnfPkgInfo Response Code: 200 OK
*/
@GetMapping(value = "/vnf_packages/{vnfPkgId}", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public ResponseEntity getVnfPackage(@PathVariable("vnfPkgId") final String vnfPkgId) {
+ public ResponseEntity<?> getVnfPackage(@PathVariable("vnfPkgId") final String vnfPkgId) {
logger.info(LOG_REQUEST_RECEIVED, "getVnfPackage: ", vnfPkgId);
final Optional<InlineResponse2001> response = etsiCatalogServiceProvider.getVnfPackage(vnfPkgId);
if (response.isPresent()) {
logger.info(LOG_REQUEST_RECEIVED, "getVnfPackage Response: ", HttpStatus.OK);
- return new ResponseEntity(response.get(), HttpStatus.OK);
+ return ResponseEntity.ok().body(response.get());
}
final String errorMessage = "An error occurred, a null response was received by the\n"
+ " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"vnf_packages\" by vnfPkgId: \""
+ vnfPkgId + "\" \n" + "endpoint.";
logger.error(errorMessage);
- return new ResponseEntity(buildProblemDetails(errorMessage), HttpStatus.INTERNAL_SERVER_ERROR);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage));
}
/**
@@ -109,7 +109,7 @@ public class Sol003PackageManagementController {
*/
@GetMapping(value = "/vnf_packages/{vnfPkgId}/vnfd",
produces = {MediaType.TEXT_PLAIN, APPLICATION_ZIP, MediaType.APPLICATION_JSON})
- public ResponseEntity<byte[]> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) {
+ public ResponseEntity<?> getVnfPackageVnfd(@PathVariable("vnfPkgId") final String vnfPkgId) {
logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageVnfd: ", vnfPkgId);
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@@ -123,17 +123,18 @@ public class Sol003PackageManagementController {
*/
@GetMapping(value = "/vnf_packages/{vnfPkgId}/package_content",
produces = {MediaType.APPLICATION_JSON, APPLICATION_ZIP, MediaType.APPLICATION_OCTET_STREAM})
- public ResponseEntity getVnfPackageContent(@PathVariable("vnfPkgId") final String vnfPkgId) {
+ public ResponseEntity<?> getVnfPackageContent(@PathVariable("vnfPkgId") final String vnfPkgId) {
logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageContent Endpoint Invoked with VNF Package ID: ", vnfPkgId);
final Optional<byte[]> response = etsiCatalogServiceProvider.getVnfPackageContent(vnfPkgId);
if (response.isPresent()) {
logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageContent Response: ", HttpStatus.OK);
- return new ResponseEntity(response.get(), HttpStatus.OK);
+ return ResponseEntity.ok().body(response.get());
}
- logger.error("Null response was received from the EtsiCatalogManager using the GET \"package_content\"");
- return new ResponseEntity(buildProblemDetails("An error occurred, a null response was received by the\n"
+ final String errorMessage = "An error occurred, a null response was received by the\n"
+ " Sol003PackageManagementController from the EtsiCatalogManager using the GET \"package_content\" \n"
- + "endpoint."), HttpStatus.INTERNAL_SERVER_ERROR);
+ + "endpoint.";
+ logger.error(errorMessage);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage));
}
/**
@@ -146,10 +147,20 @@ public class Sol003PackageManagementController {
*/
@GetMapping(value = "/vnf_packages/{vnfPkgId}/artifacts/{artifactPath}",
produces = {MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
- public ResponseEntity<byte[]> getVnfPackageArtifact(@PathVariable("vnfPkgId") final String vnfPkgId,
+ public ResponseEntity<?> getVnfPackageArtifact(@PathVariable("vnfPkgId") final String vnfPkgId,
@PathVariable("artifactPath") final String artifactPath) {
- logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageArtifact: vnfPkgId=", vnfPkgId, " artifactPath=", artifactPath);
- return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
+ logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageArtifact: vnfPkgId= ", vnfPkgId, " artifactPath=",
+ artifactPath);
+ final Optional<byte[]> response = etsiCatalogServiceProvider.getVnfPackageArtifact(vnfPkgId, artifactPath);
+ if (response.isPresent()) {
+ logger.info(LOG_REQUEST_RECEIVED, "getVnfPackageArtifact Response: ", HttpStatus.OK);
+ return ResponseEntity.ok().body(response.get());
+ }
+ final String errorMessage = "An error occurred, a null response was received by the\n"
+ + " Sol003PackageManagementController from the EtsiCatalogManager using the\n GET \"vnf_packages\" by vnfPkgId: \""
+ + vnfPkgId + "\" for artifactPath: \"" + artifactPath + "\"\n" + "endpoint.";
+ logger.error(errorMessage);
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(buildProblemDetails(errorMessage));
}
/**
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Sol003PackageManagementControllerExceptionHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java
index 2a97bb47e4..a49063a72f 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Sol003PackageManagementControllerExceptionHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.vnfmadapter;
+package org.onap.so.adapters.vnfmadapter.rest.exceptions;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails;
import org.onap.so.adapters.vnfmadapter.rest.Sol003PackageManagementController;
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java
index 0cc9c5bd7e..f9aa2a0e21 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java
@@ -23,7 +23,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
/**
- * Exception for a Vnfpkg Conflict failure, due to state of resource.
+ * Exception for a VnfPkg Conflict failures, due to state of resource.
*
* @author gareth.roper@est.tech
*/
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java
index 0f9f214643..c15e7052ab 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java
@@ -23,7 +23,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
/**
- * Exception for a Vnfpkg Not Found Failure
+ * Exception for VnfPkg Not Found Failures
*
* @author gareth.roper@est.tech
*/