aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/main')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/ErrorCode.java50
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboadingJobStatus.java63
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingJob.java49
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingJobDescriptor.java74
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingRequest.java54
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogServiceProvider.java112
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiResourcePackageProcessor.java175
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/HttpRestServiceProviderConfiguration.java55
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/JobStatus.java60
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SdcBasicHttpConfigurationProvider.java60
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SdcResourceProvider.java96
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SslBasedHttpClientConfiguration.java93
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/EtsiCatalogManagerRequestFailureException.java40
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/SOL004ResourcePackageFailureException.java40
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/SOL004ResourcePackageProcessingException.java34
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java11
16 files changed, 1063 insertions, 3 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/ErrorCode.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/ErrorCode.java
new file mode 100644
index 0000000000..1714e24a27
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/ErrorCode.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum ErrorCode {
+
+ NORMAL("0"), PACKAGE_EXIST("1"), CATALOG_EXCEPTION("2"), SYSTEM_ERROR("3"), UNKNOWN("-1");
+
+ private String code;
+
+ private ErrorCode(final String code) {
+ this.code = code;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public static ErrorCode getErrorCode(final String code) {
+ for (final ErrorCode errorCode : ErrorCode.values()) {
+ if (errorCode.getCode().equalsIgnoreCase(code)) {
+ return errorCode;
+ }
+
+ }
+ return UNKNOWN;
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboadingJobStatus.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboadingJobStatus.java
new file mode 100644
index 0000000000..772f81a7fe
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboadingJobStatus.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import java.io.Serializable;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class EtsiCatalogPackageOnboadingJobStatus implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "jobId")
+ private String jobId;
+
+ @XmlElement(name = "responseDescriptor")
+ private EtsiCatalogPackageOnboardingJobDescriptor responseDescriptor;
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(final String jobId) {
+ this.jobId = jobId;
+ }
+
+ public EtsiCatalogPackageOnboardingJobDescriptor getResponseDescriptor() {
+ return responseDescriptor;
+ }
+
+ public void setResponseDescriptor(final EtsiCatalogPackageOnboardingJobDescriptor responseDescriptor) {
+ this.responseDescriptor = responseDescriptor;
+ }
+
+ @Override
+ public String toString() {
+ return "EtsiCatalogPackageOnboadingJobStatus [jobId=" + jobId + ", responseDescriptor=" + responseDescriptor
+ + "]";
+ }
+
+
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingJob.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingJob.java
new file mode 100644
index 0000000000..0c7bba6751
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingJob.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import java.io.Serializable;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class EtsiCatalogPackageOnboardingJob implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "jobId")
+ private String jobId;
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(final String jobId) {
+ this.jobId = jobId;
+ }
+
+ @Override
+ public String toString() {
+ return "EtsiCatalogPackageOnboardingJob [jobId=" + jobId + "]";
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingJobDescriptor.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingJobDescriptor.java
new file mode 100644
index 0000000000..b0c07d6f24
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingJobDescriptor.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import java.io.Serializable;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class EtsiCatalogPackageOnboardingJobDescriptor implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "status")
+ private String status;
+
+ @XmlElement(name = "statusDescription")
+ private String statusDescription;
+
+ @XmlElement(name = "errorCode")
+ private String errorCode;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(final String status) {
+ this.status = status;
+ }
+
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ public void setStatusDescription(final String statusDescription) {
+ this.statusDescription = statusDescription;
+ }
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(final String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ @Override
+ public String toString() {
+ return "EtsiCatalogPackageOnboardingJobDescriptor [status=" + status + ", statusDescription="
+ + statusDescription + ", errorCode=" + errorCode + "]";
+ }
+
+
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingRequest.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingRequest.java
new file mode 100644
index 0000000000..79fd1398a0
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogPackageOnboardingRequest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import java.io.Serializable;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class EtsiCatalogPackageOnboardingRequest implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "csarId")
+ private String csarId;
+
+ public EtsiCatalogPackageOnboardingRequest csarId(final String csarId) {
+ this.csarId = csarId;
+ return this;
+ }
+
+ public String getCsarId() {
+ return csarId;
+ }
+
+ public void setCsarId(final String csarId) {
+ this.csarId = csarId;
+ }
+
+ @Override
+ public String toString() {
+ return "EtsiCatalogPackageOnboardingRequest [csarId=" + csarId + "]";
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogServiceProvider.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogServiceProvider.java
new file mode 100644
index 0000000000..f6a303291f
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiCatalogServiceProvider.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import static org.onap.so.asdc.etsi.pkg.processor.HttpRestServiceProviderConfiguration.ETSI_CATALOG_HTTP_REST_SERVICE_PROVIDER_BEAN;
+import org.onap.so.asdc.etsi.pkg.processor.exceptions.EtsiCatalogManagerRequestFailureException;
+import org.onap.so.rest.exceptions.InvalidRestRequestException;
+import org.onap.so.rest.exceptions.RestProcessingException;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Service
+public class EtsiCatalogServiceProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(EtsiCatalogServiceProvider.class);
+
+ private final HttpRestServiceProvider httpServiceProvider;
+
+ @Value("${etsi-catalog-manager.endpoint:http://modeling-etsicatalog.onap:8806/api/catalog/v1}")
+ private String etsiCatalogManagerEndpoint;
+
+ @Autowired
+ public EtsiCatalogServiceProvider(
+ @Qualifier(ETSI_CATALOG_HTTP_REST_SERVICE_PROVIDER_BEAN) final HttpRestServiceProvider httpServiceProvider) {
+ this.httpServiceProvider = httpServiceProvider;
+ }
+
+ public EtsiCatalogPackageOnboardingJob onBoardResource(
+ final EtsiCatalogPackageOnboardingRequest packageOnboardingRequest) {
+ try {
+ final String url = etsiCatalogManagerEndpoint + "/vnfpackages";
+ final ResponseEntity<EtsiCatalogPackageOnboardingJob> responseEntity = httpServiceProvider.postHttpRequest(
+ packageOnboardingRequest, url, getHeaders(), EtsiCatalogPackageOnboardingJob.class);
+
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
+ if (responseEntity.hasBody()) {
+ return responseEntity.getBody();
+ }
+ LOGGER.error("Received response without body");
+ }
+ final String message = "Unexpected status code received " + responseEntity.getStatusCode();
+ LOGGER.error(message);
+ throw new EtsiCatalogManagerRequestFailureException(message);
+
+ } catch (final InvalidRestRequestException | RestProcessingException exception) {
+ final String message = "Unable to process onboarding request";
+ LOGGER.error(message, exception);
+ throw new EtsiCatalogManagerRequestFailureException(message);
+ }
+
+ }
+
+ public EtsiCatalogPackageOnboadingJobStatus getJobStatus(final String jobId) {
+ try {
+ final String url = etsiCatalogManagerEndpoint + "/jobs/" + jobId;
+
+ final ResponseEntity<EtsiCatalogPackageOnboadingJobStatus> responseEntity =
+ httpServiceProvider.getHttpResponse(url, getHeaders(), EtsiCatalogPackageOnboadingJobStatus.class);
+
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
+ if (responseEntity.hasBody()) {
+ return responseEntity.getBody();
+ }
+ LOGGER.error("Received response without body");
+ }
+ final String message =
+ "Unexpected status code received while getting job status " + responseEntity.getStatusCode();
+ LOGGER.error(message);
+ throw new EtsiCatalogManagerRequestFailureException(message);
+ } catch (final InvalidRestRequestException | RestProcessingException exception) {
+ final String message = "Unable to get job status";
+ LOGGER.error(message, exception);
+ throw new EtsiCatalogManagerRequestFailureException(message);
+ }
+
+ }
+
+ private HttpHeaders getHeaders() {
+ final HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ return headers;
+ }
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiResourcePackageProcessor.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiResourcePackageProcessor.java
new file mode 100644
index 0000000000..bb7197b7a4
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/EtsiResourcePackageProcessor.java
@@ -0,0 +1,175 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.time.Instant;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import org.onap.so.asdc.etsi.pkg.processor.exceptions.SOL004ResourcePackageFailureException;
+import org.onap.so.asdc.etsi.pkg.processor.exceptions.SOL004ResourcePackageProcessingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import com.google.common.collect.ImmutableSet;
+
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Service
+public class EtsiResourcePackageProcessor {
+
+ private final static Logger LOGGER = LoggerFactory.getLogger(EtsiResourcePackageProcessor.class);
+ private static final String ONBOARDED_PACKAGE_DIR_PATH = "Artifacts/Deployment/ONBOARDED_PACKAGE";
+ private final SdcResourceProvider sdcResourceProvider;
+ private final EtsiCatalogServiceProvider catalogServiceProvider;
+ private static final int SLEEP_TIME_IN_SECONDS = 5;
+
+ private static final ImmutableSet<JobStatus> JOB_FINISHED_STATES =
+ ImmutableSet.of(JobStatus.FINISHED, JobStatus.ERROR, JobStatus.TIMEOUT);
+
+ @Value("${etsi-catalog-manager.rest.timeoutInSeconds:300}")
+ private int timeOutInSeconds;
+
+ @Autowired
+ public EtsiResourcePackageProcessor(final SdcResourceProvider sdcResourceProvider,
+ final EtsiCatalogServiceProvider catalogServiceProvider) {
+ this.sdcResourceProvider = sdcResourceProvider;
+ this.catalogServiceProvider = catalogServiceProvider;
+ }
+
+ public void processPackageIfExists(final String vnfUuid) {
+ LOGGER.debug("Processing vnf with UUID: {} ", vnfUuid);
+ try {
+ final Optional<byte[]> optional = sdcResourceProvider.getVnfResource(vnfUuid);
+ if (optional.isPresent()) {
+ final byte[] resourceContent = optional.get();
+
+ if (containsOnBoardedSol004Package(resourceContent)) {
+ final EtsiCatalogPackageOnboardingJob onboardingJob = catalogServiceProvider
+ .onBoardResource(new EtsiCatalogPackageOnboardingRequest().csarId(vnfUuid));
+ LOGGER.debug("Successfully created job with id: {} to onboard vnf with UUID: {}",
+ onboardingJob.getJobId(), vnfUuid);
+
+ if (onboardingJob.getJobId() == null) {
+ throw new SOL004ResourcePackageFailureException(
+ "Received invalid jobId " + onboardingJob.getJobId());
+ }
+
+ final Optional<EtsiCatalogPackageOnboadingJobStatus> jobStatusOptional =
+ waitForJobToFinish(onboardingJob);
+
+ if (!jobStatusOptional.isPresent()) {
+ final String message = "Job status timeout reached failed to onboard vnf with UUID: " + vnfUuid;
+ LOGGER.debug(message, vnfUuid);
+ throw new SOL004ResourcePackageFailureException(message);
+ }
+
+ final EtsiCatalogPackageOnboadingJobStatus onboadingJobStatus = jobStatusOptional.get();
+ final JobStatus jobStatus = getJobStatus(onboadingJobStatus);
+ final ErrorCode errorCode = getErrorCode(onboadingJobStatus);
+
+ LOGGER.debug("Final job status: {}, error code: {}", jobStatus, errorCode);
+ if (!JobStatus.FINISHED.equals(jobStatus) && !ErrorCode.PACKAGE_EXIST.equals(errorCode)) {
+ final String message = "Failed to onboard vnf with UUID: " + vnfUuid + " job status: "
+ + jobStatus + " errorCode: " + errorCode;
+ LOGGER.debug(message, vnfUuid);
+ throw new SOL004ResourcePackageFailureException(message);
+ }
+ LOGGER.debug("Successfully onboarded package in ETSI catalog .. ");
+ }
+
+ }
+ } catch (final Exception exception) {
+ final String message = "Unable to process resource received from SDC";
+ LOGGER.error(message, exception);
+ throw new SOL004ResourcePackageProcessingException(message, exception);
+ }
+
+ }
+
+ private Optional<EtsiCatalogPackageOnboadingJobStatus> waitForJobToFinish(
+ final EtsiCatalogPackageOnboardingJob onboardingJob) throws InterruptedException {
+ JobStatus currentJobStatus = null;
+ final long startTimeInMillis = System.currentTimeMillis();
+ final long timeOutTime = startTimeInMillis + TimeUnit.SECONDS.toMillis(timeOutInSeconds);
+
+ LOGGER.debug("Will wait till {} for {} job to finish", Instant.ofEpochMilli(timeOutTime).toString(),
+ onboardingJob.getJobId());
+
+ while (timeOutTime > System.currentTimeMillis()) {
+
+ final EtsiCatalogPackageOnboadingJobStatus onboadingJobStatus =
+ catalogServiceProvider.getJobStatus(onboardingJob.getJobId());
+ LOGGER.debug("Current job status {} ", onboadingJobStatus);
+
+ currentJobStatus = getJobStatus(onboadingJobStatus);
+ if (JOB_FINISHED_STATES.contains(currentJobStatus)) {
+ return Optional.of(onboadingJobStatus);
+ }
+
+ LOGGER.debug("Onboarding not finished yet, will try again in {} seconds", SLEEP_TIME_IN_SECONDS);
+ TimeUnit.SECONDS.sleep(SLEEP_TIME_IN_SECONDS);
+
+ }
+ LOGGER.warn("Timeout current job status: {}", currentJobStatus);
+ return Optional.empty();
+ }
+
+ private boolean containsOnBoardedSol004Package(final byte[] resourceContent) throws IOException {
+ try (final ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(resourceContent))) {
+ ZipEntry entry;
+ while ((entry = zipStream.getNextEntry()) != null) {
+ if (entry.getName() != null && entry.getName().contains(ONBOARDED_PACKAGE_DIR_PATH)) {
+ LOGGER.debug("Found entry: {} that contains {} in name", entry.getName(),
+ ONBOARDED_PACKAGE_DIR_PATH);
+ return true;
+ }
+ }
+
+ }
+ LOGGER.debug("Unable to find {} dir in downloaded package", ONBOARDED_PACKAGE_DIR_PATH);
+ return false;
+ }
+
+ private JobStatus getJobStatus(final EtsiCatalogPackageOnboadingJobStatus onboadingJobStatus) {
+ if (onboadingJobStatus.getResponseDescriptor() != null) {
+ return JobStatus.getJobStatus(onboadingJobStatus.getResponseDescriptor().getStatus());
+ }
+ LOGGER.warn("Found null ResponseDescriptor {}", onboadingJobStatus);
+ return JobStatus.UNKNOWN;
+ }
+
+ private ErrorCode getErrorCode(final EtsiCatalogPackageOnboadingJobStatus onboadingJobStatus) {
+ if (onboadingJobStatus.getResponseDescriptor() != null) {
+ return ErrorCode.getErrorCode(onboadingJobStatus.getResponseDescriptor().getErrorCode());
+ }
+ LOGGER.warn("Found null ResponseDescriptor {}", onboadingJobStatus);
+ return ErrorCode.UNKNOWN;
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/HttpRestServiceProviderConfiguration.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/HttpRestServiceProviderConfiguration.java
new file mode 100644
index 0000000000..1afda0d29f
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/HttpRestServiceProviderConfiguration.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import static org.onap.so.asdc.etsi.pkg.processor.SslBasedHttpClientConfiguration.SSL_BASED_CONFIGURABLE_REST_TEMPLATE;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.onap.so.rest.service.HttpRestServiceProviderImpl;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Configuration
+public class HttpRestServiceProviderConfiguration {
+
+ public static final String ETSI_CATALOG_HTTP_REST_SERVICE_PROVIDER_BEAN = "etsiCatalogHttpRestServiceProviderBean";
+ public static final String SDC_HTTP_REST_SERVICE_PROVIDER_BEAN = "sdcHttpRestServiceProviderBean";
+
+ @Bean
+ @Qualifier(ETSI_CATALOG_HTTP_REST_SERVICE_PROVIDER_BEAN)
+ public HttpRestServiceProvider etsiCataloghttpRestServiceProvider(
+ @Qualifier(CONFIGURABLE_REST_TEMPLATE) final RestTemplate restTemplate) {
+ return new HttpRestServiceProviderImpl(restTemplate);
+ }
+
+ @Bean
+ @Qualifier(SDC_HTTP_REST_SERVICE_PROVIDER_BEAN)
+ public HttpRestServiceProvider sdchttpRestServiceProvider(
+ @Qualifier(SSL_BASED_CONFIGURABLE_REST_TEMPLATE) final RestTemplate restTemplate) {
+ return new HttpRestServiceProviderImpl(restTemplate);
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/JobStatus.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/JobStatus.java
new file mode 100644
index 0000000000..cf09b15539
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/JobStatus.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum JobStatus {
+
+ STARTED("started"),
+ TIMEOUT("timeout"),
+ FINISHED("finished"),
+ PARTLY_FINISHED("partly_finished"),
+ PROCESSING("processing"),
+ ERROR("error"),
+ UNKNOWN("unknown");
+
+ private String value;
+
+ private JobStatus(final String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+ public static JobStatus getJobStatus(final String jobStatus) {
+ for (final JobStatus status : JobStatus.values()) {
+ if (status.getValue().equalsIgnoreCase(jobStatus)) {
+ return status;
+ }
+ }
+ return JobStatus.UNKNOWN;
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SdcBasicHttpConfigurationProvider.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SdcBasicHttpConfigurationProvider.java
new file mode 100644
index 0000000000..19375e265f
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SdcBasicHttpConfigurationProvider.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import java.nio.charset.StandardCharsets;
+import java.security.GeneralSecurityException;
+import org.apache.commons.codec.binary.Base64;
+import org.onap.so.utils.CryptoUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Configuration
+public class SdcBasicHttpConfigurationProvider {
+
+ @Value("${sdc.endpoint:https://sdc-be.onap:8443}")
+ private String endPoint;
+
+ @Value("${sdc.username:mso}")
+ private String username;
+
+ @Value(value = "${sdc.password:76966BDD3C7414A03F7037264FF2E6C8EEC6C28F2B67F2840A1ED857C0260FEE731D73F47F828E5527125D29FD25D3E0DE39EE44C058906BF1657DE77BF897EECA93BDC07FA64F}")
+ private String password;
+
+ @Value(value = "${sdc.key:566B754875657232314F5548556D3665}")
+ private String key;
+
+
+ public String getBasicAuthorization() throws GeneralSecurityException {
+ final String auth = username + ":" + CryptoUtils.decrypt(password, key);
+ final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
+ return "Basic " + new String(encodedAuth);
+ }
+
+ public String getEndPoint() {
+ return endPoint;
+ }
+
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SdcResourceProvider.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SdcResourceProvider.java
new file mode 100644
index 0000000000..0cd0aba9c3
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SdcResourceProvider.java
@@ -0,0 +1,96 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import static org.onap.so.asdc.etsi.pkg.processor.HttpRestServiceProviderConfiguration.SDC_HTTP_REST_SERVICE_PROVIDER_BEAN;
+import static org.springframework.http.HttpHeaders.ACCEPT;
+import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
+import java.security.GeneralSecurityException;
+import java.util.Optional;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Service
+public class SdcResourceProvider {
+ private final static Logger LOGGER = LoggerFactory.getLogger(SdcResourceProvider.class);
+
+ private static final String SERVICE_NAME = "SO-SDC-CONTROLLER";
+
+ private final HttpRestServiceProvider httpRestServiceProvider;
+
+ private final SdcBasicHttpConfigurationProvider sdcBasicHttpConfigurationProvider;
+
+ @Autowired
+ public SdcResourceProvider(
+ @Qualifier(SDC_HTTP_REST_SERVICE_PROVIDER_BEAN) final HttpRestServiceProvider httpRestServiceProvider,
+ final SdcBasicHttpConfigurationProvider sdcBasicHttpConfigurationProvider) {
+ this.httpRestServiceProvider = httpRestServiceProvider;
+ this.sdcBasicHttpConfigurationProvider = sdcBasicHttpConfigurationProvider;
+ }
+
+ public Optional<byte[]> getVnfResource(final String resourceId) {
+ LOGGER.debug("Will get resource from SDC using resource id: {}", resourceId);
+ try {
+ final HttpHeaders headers = getHttpHeaders();
+ headers.add(ACCEPT, APPLICATION_OCTET_STREAM_VALUE);
+ final String url = getSdcResourceEndPoint(resourceId);
+ LOGGER.debug("will invoke url: {} to get resource ", url);
+ final ResponseEntity<byte[]> responseEntity =
+ httpRestServiceProvider.getHttpResponse(url, headers, byte[].class);
+
+ if (responseEntity.getStatusCode().is2xxSuccessful()) {
+ if (responseEntity.hasBody()) {
+ return Optional.of(responseEntity.getBody());
+ }
+ LOGGER.error("Received response without body");
+ }
+ LOGGER.error("Unexpected Status code received : {}", responseEntity.getStatusCode());
+ return Optional.empty();
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to get {} resource from SDC", resourceId, exception);
+ return Optional.empty();
+ }
+ }
+
+ private String getSdcResourceEndPoint(final String resourceId) {
+ return sdcBasicHttpConfigurationProvider.getEndPoint() + "/sdc/v1/catalog/resources/" + resourceId
+ + "/toscaModel";
+ }
+
+
+ private HttpHeaders getHttpHeaders() throws GeneralSecurityException {
+ final HttpHeaders headers = new HttpHeaders();
+ headers.add(HttpHeaders.AUTHORIZATION, sdcBasicHttpConfigurationProvider.getBasicAuthorization());
+ headers.add("X-ECOMP-InstanceID", SERVICE_NAME);
+ headers.add("X-FromAppId", SERVICE_NAME);
+ return headers;
+ }
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SslBasedHttpClientConfiguration.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SslBasedHttpClientConfiguration.java
new file mode 100644
index 0000000000..88c21524e9
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/SslBasedHttpClientConfiguration.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor;
+
+import java.security.NoSuchAlgorithmException;
+import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
+import org.onap.so.configuration.rest.HttpClientConnectionConfiguration;
+import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.client.BufferingClientHttpRequestFactory;
+import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Configuration
+public class SslBasedHttpClientConfiguration {
+ private final static Logger LOGGER = LoggerFactory.getLogger(EtsiResourcePackageProcessor.class);
+
+
+ public static final String SSL_BASED_CONFIGURABLE_REST_TEMPLATE = "sslBasedConfigurableRestTemplate";
+ private final HttpClientConnectionConfiguration clientConnectionConfiguration;
+
+ @Autowired
+ public SslBasedHttpClientConfiguration(final HttpClientConnectionConfiguration clientConnectionConfiguration) {
+ this.clientConnectionConfiguration = clientConnectionConfiguration;
+ }
+
+ @Bean
+ @Qualifier(SSL_BASED_CONFIGURABLE_REST_TEMPLATE)
+ public RestTemplate sslBasedConfigurableRestTemplate() {
+ final RestTemplate restTemplate =
+ new RestTemplate(new BufferingClientHttpRequestFactory(httpComponentsClientHttpRequestFactory()));
+ restTemplate.getInterceptors().add(new SOSpringClientFilter());
+ restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
+ return restTemplate;
+ }
+
+ private HttpComponentsClientHttpRequestFactory httpComponentsClientHttpRequestFactory() {
+ try {
+ LOGGER.debug("Setting up HttpComponentsClientHttpRequestFactory with default SSL Context");
+ return new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create()
+ .setConnectionManager(getConnectionManager())
+ .setMaxConnPerRoute(clientConnectionConfiguration.getMaxConnectionsPerRoute())
+ .setMaxConnTotal(clientConnectionConfiguration.getMaxConnections())
+ .setDefaultRequestConfig(getRequestConfig()).setSSLContext(SSLContext.getDefault()).build());
+
+ } catch (final NoSuchAlgorithmException exception) {
+ LOGGER.error("Failed to create HttpComponentsClientHttpRequestFactory with default SSL Context", exception);
+ throw new RuntimeException(exception);
+ }
+ }
+
+ private PoolingHttpClientConnectionManager getConnectionManager() {
+ return new PoolingHttpClientConnectionManager(clientConnectionConfiguration.getTimeToLiveInMins(),
+ TimeUnit.MINUTES);
+ }
+
+ private RequestConfig getRequestConfig() {
+ return RequestConfig.custom().setSocketTimeout(clientConnectionConfiguration.getSocketTimeOutInMiliSeconds())
+ .setConnectTimeout(clientConnectionConfiguration.getConnectionTimeOutInMilliSeconds()).build();
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/EtsiCatalogManagerRequestFailureException.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/EtsiCatalogManagerRequestFailureException.java
new file mode 100644
index 0000000000..4f2e5039d7
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/EtsiCatalogManagerRequestFailureException.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor.exceptions;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class EtsiCatalogManagerRequestFailureException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public EtsiCatalogManagerRequestFailureException(final String message) {
+ super(message);
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/SOL004ResourcePackageFailureException.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/SOL004ResourcePackageFailureException.java
new file mode 100644
index 0000000000..8e05a50f32
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/SOL004ResourcePackageFailureException.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor.exceptions;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class SOL004ResourcePackageFailureException extends RuntimeException {
+
+ private static final long serialVersionUID = 5834657185124807797L;
+
+ public SOL004ResourcePackageFailureException(final String message) {
+ super(message);
+
+ }
+
+ @Override
+ public synchronized Throwable fillInStackTrace() {
+ return this;
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/SOL004ResourcePackageProcessingException.java b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/SOL004ResourcePackageProcessingException.java
new file mode 100644
index 0000000000..0e9f1ea9dc
--- /dev/null
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/etsi/pkg/processor/exceptions/SOL004ResourcePackageProcessingException.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.asdc.etsi.pkg.processor.exceptions;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class SOL004ResourcePackageProcessingException extends RuntimeException {
+
+ private static final long serialVersionUID = 4860501744379116092L;
+
+ public SOL004ResourcePackageProcessingException(final String message, final Throwable cause) {
+ super(message, cause);
+
+ }
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 240bb83862..263118d1b3 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -39,7 +39,6 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import org.onap.so.logger.LoggingAnchor;
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockAcquisitionException;
import org.onap.sdc.api.notification.IArtifactInfo;
@@ -63,6 +62,7 @@ import org.onap.sdc.toscaparser.api.parameters.Input;
import org.onap.sdc.utils.DistributionStatusEnum;
import org.onap.so.asdc.client.ASDCConfiguration;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
+import org.onap.so.asdc.etsi.pkg.processor.EtsiResourcePackageProcessor;
import org.onap.so.asdc.installer.ASDCElementInfo;
import org.onap.so.asdc.installer.BigDecimalVersion;
import org.onap.so.asdc.installer.IVfModuleData;
@@ -113,7 +113,6 @@ import org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRep
import org.onap.so.db.catalog.data.repository.CollectionResourceRepository;
import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository;
-import org.onap.so.db.catalog.data.repository.CvnfcConfigurationCustomizationRepository;
import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository;
import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository;
import org.onap.so.db.catalog.data.repository.HeatEnvironmentRepository;
@@ -140,6 +139,7 @@ import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatu
import org.onap.so.db.request.data.repository.WatchdogDistributionStatusRepository;
import org.onap.so.db.request.data.repository.WatchdogServiceModVerIdLookupRepository;
import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -147,9 +147,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.springframework.util.CollectionUtils;
@Component
public class ToscaResourceInstaller {
@@ -273,6 +273,9 @@ public class ToscaResourceInstaller {
@Autowired
protected WorkflowResource workflowResource;
+ @Autowired
+ protected EtsiResourcePackageProcessor etsiResourcePackageProcessor;
+
protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
public boolean isCsarAlreadyDeployed(ToscaResourceStructure toscaResourceStructure)
@@ -456,6 +459,8 @@ public class ToscaResourceInstaller {
if (ALLOTTED_RESOURCE.equalsIgnoreCase(category)) {
arEntityDetails.add(vfEntityDetails);
}
+ final String vnfUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+ etsiResourcePackageProcessor.processPackageIfExists(vnfUuid);
processVfModules(vfEntityDetails, toscaResourceStruct, vfResourceStructure, service, metadata);
}