aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
diff options
context:
space:
mode:
authorAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
committerAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
commitb8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch)
treef78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
parent75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff)
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535 Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java34
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java34
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManager.java)13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManagerFactory.java)7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java21
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java18
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java95
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java52
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java22
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java59
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MibUploadErrorBuilder.java)16
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java46
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java76
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java46
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java164
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java503
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java31
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java396
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java24
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java359
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java117
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImpl.java226
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerFactoryImpl.java)14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java269
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java111
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java186
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java339
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java24
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java25
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java44
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MibUploadStatus.java)20
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ManualVspDataCollectionService.java418
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java41
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json7
49 files changed, 3639 insertions, 422 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
new file mode 100644
index 0000000000..65bceb9864
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
@@ -0,0 +1,34 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public interface ComputeManager {
+
+ Collection<ListComputeResponse> listCompute(String vspId, Version version, String
+ componentId, String user);
+
+ ComputeEntity createCompute(ComputeEntity compute, String user);
+
+ CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version, String
+ componentId, String computeFlavorId, String user);
+
+ QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String
+ componentId, String computeFlavorId, String user);
+
+ void updateComputeQuestionnaire(String vspId, Version version, String componentId, String
+ computeId, String
+ questionnaireData, String user);
+
+ CompositionEntityValidationData updateCompute(ComputeEntity compute, String user);
+
+ void deleteCompute(String vspId, Version version,String componentId, String computeFlavorId,
+ String user);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java
new file mode 100644
index 0000000000..26b5bdad17
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManagerFactory.java
@@ -0,0 +1,11 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ComputeManagerFactory extends AbstractComponentFactory<ComputeManager> {
+
+ public static ComputeManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ComputeManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
new file mode 100644
index 0000000000..51ba2f4d40
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
@@ -0,0 +1,34 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public interface DeploymentFlavorManager {
+
+
+ DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity,
+ String user);
+
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version,
+ String user);
+
+ CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId, Version version,
+ String deploymentFlavorId,
+ String user);
+
+ CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId, Version
+ version, String user);
+
+ void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId, String
+ user);
+
+ CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity
+ deploymentFlavorEntity, String user);
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java
new file mode 100644
index 0000000000..a367057b63
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManagerFactory.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class DeploymentFlavorManagerFactory extends
+ AbstractComponentFactory<DeploymentFlavorManager> {
+
+ public static DeploymentFlavorManagerFactory getInstance() {
+ return AbstractFactory.getInstance(DeploymentFlavorManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
new file mode 100644
index 0000000000..6bbfc0b69a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
@@ -0,0 +1,33 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public interface ImageManager {
+ ImageEntity createImage(ImageEntity imageEntity, String user);
+
+ CompositionEntityResponse<Image> getImageSchema(String vspId, String user);
+
+ Collection<ImageEntity> listImages(String vspId, Version version, String componentId,
+ String user);
+
+ CompositionEntityResponse<Image> getImage(String vspId, Version version, String componentId,
+ String imageId, String user);
+
+ QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String
+ componentId, String imageId, String user);
+
+ void deleteImage(String vspId, Version version, String componentId, String imageId, String user);
+
+ CompositionEntityValidationData updateImage(ImageEntity imageEntity, String user);
+
+ void updateImageQuestionnaire(String vspId, Version version, String componentId, String imageId,
+ String
+ questionnaireData, String user);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java
new file mode 100644
index 0000000000..f844186a03
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManagerFactory.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ImageManagerFactory extends AbstractComponentFactory<ImageManager> {
+
+ public static ImageManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ImageManagerFactory.class);
+ }
+}
+
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
new file mode 100644
index 0000000000..c9a5206383
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public interface ManualVspToscaManager {
+
+ public VspModelInfo gatherVspInformation(String vspId, Version version, String user);
+
+ public ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
index 7d2db68c1d..f5e34a01be 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
@@ -20,18 +20,19 @@
package org.openecomp.sdc.vendorsoftwareproduct;
-import org.openecomp.core.enrichment.types.ArtifactType;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus;
+import org.openecomp.core.enrichment.types.MonitoringUploadType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.InputStream;
-public interface MibManager {
+public interface MonitoringUploadsManager {
void delete(String vspId, Version version, String componentId,
- ArtifactType artifactType, String user);
+ MonitoringUploadType monitoringUploadType, String user);
void upload(InputStream object, String filename, String vspId, Version version,
- String componentId, ArtifactType artifactType, String user);
+ String componentId, MonitoringUploadType monitoringUploadType, String user);
- MibUploadStatus listFilenames(String vspId, Version version, String componentId, String user);
+ MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId,
+ String user);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java
index f25658bf0f..eb4271be16 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManagerFactory.java
@@ -23,9 +23,10 @@ package org.openecomp.sdc.vendorsoftwareproduct;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class MibManagerFactory extends AbstractComponentFactory<MibManager> {
+public abstract class MonitoringUploadsManagerFactory
+ extends AbstractComponentFactory<MonitoringUploadsManager> {
- public static MibManagerFactory getInstance() {
- return AbstractFactory.getInstance(MibManagerFactory.class);
+ public static MonitoringUploadsManagerFactory getInstance() {
+ return AbstractFactory.getInstance(MonitoringUploadsManagerFactory.class);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
index 7e9a002ad1..738e267ca0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.vendorsoftwareproduct;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
@@ -30,6 +31,7 @@ import org.openecomp.sdc.versioning.types.VersionInfo;
import java.io.File;
import java.io.IOException;
+import java.util.Collection;
import java.util.List;
public interface VendorSoftwareProductManager {
@@ -73,6 +75,7 @@ public interface VendorSoftwareProductManager {
File getInformationArtifact(String vspId, Version version, String user);
-
String fetchValidationVsp(String user);
+
+ Collection<ComputeEntity> getComputeByVsp(String vspId, Version version, String user);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java
new file mode 100644
index 0000000000..78d2ef866a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilder.java
@@ -0,0 +1,21 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+
+public class ComponentErrorBuilder {
+
+ private static final String VFC_INVALID_MISSING_IMAGE_MSG =
+ "All VFC need to have atleast a single Image specified. Please fix the VFC Images and re-submit the VSP";
+
+
+ public static ErrorCode VfcMissingImageErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.VFC_INVALID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder
+ .withMessage(String.format(VFC_INVALID_MISSING_IMAGE_MSG));
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java
new file mode 100644
index 0000000000..3ecf6f1a2e
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeleteNicErrorBuilder.java
@@ -0,0 +1,18 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class DeleteNicErrorBuilder {
+ private static final String DELETE_NIC_NOT_ALLOWED_MSG =
+ "NIC cannot be deleted for VSPs onboarded with HEAT.";
+
+ public static ErrorCode getDeleteNicForHeatOnboardedVspErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.DELETE_NIC_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DELETE_NIC_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
new file mode 100644
index 0000000000..63d716504b
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
@@ -0,0 +1,95 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public class DeploymentFlavorErrorBuilder {
+ private static final String CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG=
+ "Deployment Flavor cannot be added for VSPs onboarded with HEAT.";
+ private static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG=
+ "Invalid request,Feature Group with Id %s does not exist for Vsp with Id %s and version " +
+ "%s.";
+ private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG
+ ="Invalid request,for valid association please provide ComponentId for Compute Flavor";
+ private static final String SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG=
+ "Invalid Request,Same Vfc cannot be associated more than once.";
+ private static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG =
+ "Invalid request, Deployment Flavor with model %s already exists for Vsp with Id %s.";
+ private static final String INVALID_COMPUTE_FLAVOR_ID_MSG =
+ "Invalid request, Compute Flavor with Id %s does not exist for VFC with Id %s.";
+ private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG="VSP cannot be " +
+ "submitted with an invalid Deployment Flavor. All Deployment Flavor should have atleast a VFC included with it's required Compute needs. Please fix the Deployment Flavor and re-submit the VSP.";
+
+ private static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG = "VSP cannot be " +
+ "submitted with an invalid Deployment Flavor. All Deployment Flavor should have " +
+ "FeatureGroup. Please fix the Deployment Flavor and re-submit the VSP.";
+
+ public static ErrorCode getAddDeploymentNotSupportedHeatOnboardErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getFeatureGroupNotexistErrorBuilder( String featureGroupId, String
+ VspId, Version activeVersion){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG,featureGroupId,
+ VspId,activeVersion.toString()));
+ return builder.build();
+ }
+
+ public static ErrorCode getDuplicateVfcAssociationErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getInvalidAssociationErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getDuplicateDeploymentFlavorModelErrorBuilder(String name, String vspId){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG,name,vspId));
+ return builder.build();
+ }
+ public static ErrorCode getInvalidComputeIdErrorBuilder( String computeFlavorId, String
+ vfcId){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_COMPUTE_FLAVOR_ID_MSG,computeFlavorId,
+ vfcId));
+ return builder.build();
+ }
+
+ public static ErrorCode getInvalidComponentComputeAssociationErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getFeatureGroupMandatoryErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG));
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
new file mode 100644
index 0000000000..b242b7169c
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
@@ -0,0 +1,52 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED;
+
+
+public class DuplicateComputeInComponentErrorBuilder {
+
+ private static final String DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG =
+ "Invalid request, Compute with name %s already exists for component with ID %s.";
+ private static final String COMPUTE_HEAT_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
+ + "for VSP onboarded via HEAT.";
+ private static final String COMPUTE_MANUAL_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
+ + "for VSP onboarded manually.";
+
+
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public DuplicateComputeInComponentErrorBuilder(String computeName, String componentId ){
+ builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG,computeName,
+ componentId));
+ }
+
+ /**
+ * Gets duplicate compute name error builder.
+ *
+ * @return the duplicate compute name error builder
+ */
+ public static ErrorCode getDuplicateComputeNameErrorBuilder(String computeName, String componenetId) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG, computeName, componenetId ));
+ return builder.build();
+ }
+
+ public static ErrorCode getComputeHeatReadOnlyErrorBuilder(String name) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(UPDATE_COMPUTE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(COMPUTE_HEAT_READONLY_ATTR_MSG, name));
+ return builder.build();
+ }
+
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java
new file mode 100644
index 0000000000..741dddb4f5
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateNicInComponentErrorBuilder.java
@@ -0,0 +1,22 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class DuplicateNicInComponentErrorBuilder {
+
+ private static final String DUPLICATE_NIC_NAME_NOT_ALLOWED_MSG =
+ "Invalid request, NIC with name %s already exist for component with ID %s.";
+
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public DuplicateNicInComponentErrorBuilder(String nicName, String componentId ){
+ builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_NIC_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DUPLICATE_NIC_NAME_NOT_ALLOWED_MSG,nicName,componentId));
+ }
+ public ErrorCode build() {
+ return builder.build();
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
new file mode 100644
index 0000000000..95bff60479
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
@@ -0,0 +1,59 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_NAME_NOT_ALLOWED;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VFC_IMAGE_INVALID_FORMAT;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+/**
+ * The Image error builder.
+ */
+public class ImageErrorBuilder {
+
+ private static final String VFC_IMAGE_DUPLICATE_NAME_MSG = "Invalid request, Image with name %s"
+ + " already exists for component with ID %s.";
+
+ private static final String IMAGE_INVALID_FORMAT_MSG = "The format value doesn't meet the "
+ + "expected attribute value.";
+
+ private static final String IMAGE_HEAT_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
+ + "for VSP onboarded via HEAT.";
+
+
+ /**
+ * Gets duplicate image name error builder.
+ *
+ * @return the duplicate image name error builder
+ */
+ public static ErrorCode getDuplicateImageNameErrorBuilder(String imageName, String componenetId) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DUPLICATE_IMAGE_NAME_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VFC_IMAGE_DUPLICATE_NAME_MSG, imageName, componenetId ));
+ return builder.build();
+ }
+
+ /**
+ * Gets invalid image format error builder.
+ *
+ * @return the invalid image format error builder
+ */
+ public static ErrorCode getInvalidImageFormatErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VFC_IMAGE_INVALID_FORMAT);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(IMAGE_INVALID_FORMAT_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getImageHeatReadOnlyErrorBuilder(String name) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(UPDATE_IMAGE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(IMAGE_HEAT_READONLY_ATTR_MSG, name));
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MibUploadErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
index bffe805618..5fc29d5a4f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MibUploadErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
@@ -24,11 +24,12 @@ import org.openecomp.sdc.common.errors.BaseErrorBuilder;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.versioning.dao.types.Version;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.MIB_UPLOAD_INVALID;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.MONITORING_UPLOAD_INVALID;
-public class MibUploadErrorBuilder extends BaseErrorBuilder {
+public class MonitoringUploadErrorBuilder extends BaseErrorBuilder {
private static final String UPLOAD_INVALID_DETAILED_MSG =
- "MIB uploaded for vendor software product with Id %s and version %s is invalid: %s";
+ "Monitoring file uploaded for vendor software product with Id %s and version %s is invalid:" +
+ " %s";
/**
@@ -38,8 +39,9 @@ public class MibUploadErrorBuilder extends BaseErrorBuilder {
* @param version the version
* @param error the error
*/
- public MibUploadErrorBuilder(String vendorSoftwareProductId, Version version, String error) {
- getErrorCodeBuilder().withId(MIB_UPLOAD_INVALID);
+ public MonitoringUploadErrorBuilder(String vendorSoftwareProductId, Version version,
+ String error) {
+ getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(String.format(UPLOAD_INVALID_DETAILED_MSG,
vendorSoftwareProductId, version == null ? null : version.toString(), error));
@@ -50,8 +52,8 @@ public class MibUploadErrorBuilder extends BaseErrorBuilder {
*
* @param errorMessage the error message
*/
- public MibUploadErrorBuilder(String errorMessage) {
- getErrorCodeBuilder().withId(MIB_UPLOAD_INVALID);
+ public MonitoringUploadErrorBuilder(String errorMessage) {
+ getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(errorMessage);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
new file mode 100644
index 0000000000..0850d2e704
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
@@ -0,0 +1,46 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_TYPE_UPDATE_NOT_ALLOWED;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class NicInternalNetworkErrorBuilder {
+ private static final String NULL_NETWORKID_NOT_ALLOWED_MSG =
+ "Internal Networks are currently not supported for VSP created Manually, so please fix all the NIC to be of Type External and re-submit the VSP.";
+
+ private static final String NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK_MSG =
+ "Invalid request, Network Description not allowed for Internal Networks";
+ private static final String NETWORK_TYPE_UPDATE_NOT_ALLOWED_MSG =
+ "Invalid request, Network Type Update not allowed for a Nic";
+
+
+ public static ErrorCode getNicNullNetworkIdInternalNetworkIdErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.NULL_NETWORKID_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NULL_NETWORKID_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+
+ public static ErrorCode getNetworkDescriptionInternalNetworkErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK_MSG));
+ return builder.build();
+ }
+
+
+ public static ErrorCode getNetworkTypeErrorBuilder(){
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(NETWORK_TYPE_UPDATE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NETWORK_TYPE_UPDATE_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java
new file mode 100644
index 0000000000..2d75f81fcd
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicNetworkIdNotAllowedExternalNetworkErrorBuilder.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class NicNetworkIdNotAllowedExternalNetworkErrorBuilder {
+ private static final String NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK_MSG =
+ "Invalid request,NetworkId not allowed for External Networks";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ public NicNetworkIdNotAllowedExternalNetworkErrorBuilder(){
+ builder.withId(VendorSoftwareProductErrorCodes.NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK_MSG));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
new file mode 100644
index 0000000000..7801df8fd7
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
@@ -0,0 +1,76 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class NotSupportedHeatOnboardMethodErrorBuilder {
+ private static final String ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
+ "NIC cannot be added for VSPs onboarded with HEAT.";
+ private static final String ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
+ "Compute flavor cannot be added for VSPs onboarded with HEAT.";
+ private static final String IMAGE_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
+ "Image cannot be added for VSPs onboarded with HEAT.";
+ private static final String DELETE_IMAGE_NOT_ALLOWED_MSG =
+ "Image cannot be deleted for VSPs onboarded with HEAT.";
+ private static final String DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG =
+ "Deployment Flavor cannot be deleted for VSPs onboarded with HEAT.";
+ private static final String EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG =
+ "Deployment Flavor cannot be edited for VSPs onboarded with HEAT.";
+
+
+ public static ErrorCode getAddNicNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getAddComputeNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getAddImageNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(IMAGE_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getDelImageNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DELETE_IMAGE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DELETE_IMAGE_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getDelDeploymentFlavorNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getUpdateDfNotSupportedHeatOnboardMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
new file mode 100644
index 0000000000..8aad900102
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
@@ -0,0 +1,46 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
+ .VSP_INVALID_ONBOARDING_METHOD;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
+ .VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+/**
+ * The type Onboarding method error builder.
+ */
+public class OnboardingMethodErrorBuilder {
+
+ private static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED_MSG =
+ "onboardingMethod update is not allowed.";
+ private static final String VSP_INVALID_ONBOARDING_METHOD_MSG =
+ "The onboardingMethod value doesn't meet the expected attribute value.";
+
+ /**
+ * Gets onboarding update error.
+ *
+ * @return the onboarding update error
+ */
+ public static ErrorCode getOnboardingUpdateError() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED_MSG));
+ return builder.build();
+ }
+
+ /**
+ * Get invalid onboarding method error builder error code.
+ *
+ * @return the error code
+ */
+ public static ErrorCode getInvalidOnboardingMethodErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VSP_INVALID_ONBOARDING_METHOD);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(VSP_INVALID_ONBOARDING_METHOD_MSG));
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
index 8fe2bfc396..4a84c83338 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
@@ -28,6 +28,8 @@ public class VendorSoftwareProductInvalidErrorBuilder {
private static final String VSP_INVALID_MSG =
"Vendor software product with Id %s and version %s is invalid - does not contain "
+ "service model.";
+ private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG ="VSP has to have a " +
+ "minimum of one Deployment Flavor defined for being able to be instantiated.Please add a Deployment Flavor and re-submit the VSP.";
private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
/**
@@ -36,14 +38,27 @@ public class VendorSoftwareProductInvalidErrorBuilder {
* @param vendorSoftwareProductId the vendor software product id
* @param version the version
*/
- public VendorSoftwareProductInvalidErrorBuilder(String vendorSoftwareProductId, Version version) {
+ public static ErrorCode VendorSoftwareProductMissingServiceModelErrorBuilder(String
+ vendorSoftwareProductId,
+ Version version) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
builder.withCategory(ErrorCategory.APPLICATION);
builder
.withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.toString()));
+ return builder.build();
}
- public ErrorCode build() {
+ /**
+ * Instantiates a new Vendor software product invalid error builder.
+ */
+ public static ErrorCode VspMissingDeploymentFlavorErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder
+ .withMessage(String.format(VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG));
return builder.build();
}
+
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
index a2aaf2f8f5..05a088f76a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
@@ -24,6 +24,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
public class ComponentManagerFactoryImpl extends ComponentManagerFactory {
@@ -31,7 +33,8 @@ public class ComponentManagerFactoryImpl extends ComponentManagerFactory {
new ComponentManagerImpl(
ComponentDaoFactory.getInstance().createInterface(),
CompositionEntityDataManagerFactory.getInstance().createInterface(),
- NicManagerFactory.getInstance().createInterface()
+ NicManagerFactory.getInstance().createInterface(),
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface()
);
@Override
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
index 75a5377ec3..42c8d12b3a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
@@ -20,9 +20,13 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.VFC_NODE_TYPE_PREFIX;
+
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
@@ -32,9 +36,11 @@ import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.CompositionEditNotAllowedErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
@@ -46,6 +52,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentCo
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQuestionnaireSchemaInput;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -59,14 +66,16 @@ public class ComponentManagerImpl implements ComponentManager {
private ComponentDao componentDao;
private CompositionEntityDataManager compositionEntityDataManager;
private NicManager nicManager;
+ private VendorSoftwareProductInfoDao vspInfoDao;
public ComponentManagerImpl(
ComponentDao componentDao,
CompositionEntityDataManager compositionEntityDataManager,
- NicManager nicManager) {
+ NicManager nicManager, VendorSoftwareProductInfoDao vspInfoDao) {
this.componentDao = componentDao;
this.compositionEntityDataManager = compositionEntityDataManager;
this.nicManager = nicManager;
+ this.vspInfoDao = vspInfoDao;
}
@Override
@@ -79,7 +88,7 @@ public class ComponentManagerImpl implements ComponentManager {
@Override
public void deleteComponents(String vspId, Version version, String user) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- if (!isManual(vspId, version)) {
+ if (!vspInfoDao.isManual(vspId, version)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_COMPONENT, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete component");
@@ -91,7 +100,7 @@ public class ComponentManagerImpl implements ComponentManager {
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
}
- @Override
+ /*@Override
public ComponentEntity createComponent(ComponentEntity component, String user) {
mdcDataDebugMessage.debugEntryMessage("VSP id", component.getId());
@@ -107,6 +116,91 @@ public class ComponentManagerImpl implements ComponentManager {
//componentDao.updateVspLatestModificationTime(component.getVspId(), component.getVersion());
mdcDataDebugMessage.debugExitMessage("VSP id", component.getId());
return null;
+ }*/
+
+ @Override
+ public ComponentEntity createComponent(ComponentEntity component, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", component.getId());
+ /*Version activeVersion =
+ getVersionInfo(component.getVspId(), VersionableEntityAction.Write, user)
+ .getActiveVersion();
+ component.setVersion(activeVersion);*/
+
+ final String VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
+ "VFCs cannot be added for VSPs onboarded with HEAT.";
+
+ ComponentEntity createdComponent = null;
+
+ if (!vspInfoDao.isManual(component.getVspId(), component.getVersion())) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create component");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING)
+ .withMessage(VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG).build());
+ } else {
+ validateComponentManual(component);
+ updateComponentName(component);
+ createdComponent = createComponent(component);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", component.getId());
+
+ return createdComponent;
+ }
+
+ private ComponentEntity createComponent(ComponentEntity component) {
+ return compositionEntityDataManager.createComponent(component);
+ }
+
+ private void updateComponentName(ComponentEntity component) {
+ final String NAME_PREFIX = VFC_NODE_TYPE_PREFIX + "heat.";
+ ComponentData data = component.getComponentCompositionData();
+ data.setName(NAME_PREFIX + data.getDisplayName());
+ component.setComponentCompositionData(data);
+ }
+
+ private void validateComponentManual(ComponentEntity component) {
+ final String VSP_VFC_COUNT_EXCEED_MSG = "Creation of only one VFC per "
+ + "VSP allowed.";
+
+ final String VSP_VFC_DUPLICATE_NAME_MSG = "VFC with specified name "
+ + "already present in given VSP.";
+
+ Collection<ComponentEntity> vspComponentList = listComponents(component.getVspId()
+ , component.getVersion(), null);
+ if (vspComponentList.size() >= 1) //1707 release only supports 1 VFC in VSP (manual creation)
+ {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create component: "
+ + "vsp component count exceed");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VSP_VFC_COUNT_EXCEED)
+ .withMessage(VSP_VFC_COUNT_EXCEED_MSG).build());
+ }
+ if (!isVfcNameUnique(vspComponentList,
+ component.getComponentCompositionData().getDisplayName())) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create component: "
+ + "vsp component duplicate name");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME)
+ .withMessage(VSP_VFC_DUPLICATE_NAME_MSG).build());
+ }
+ }
+
+ private boolean isVfcNameUnique(Collection<ComponentEntity> component, String displayName) {
+ for (ComponentEntity comp : component) {
+ if (comp.getComponentCompositionData().getDisplayName().equalsIgnoreCase(displayName)) {
+ return false;
+ }
+ }
+ return true;
}
@Override
@@ -116,13 +210,19 @@ public class ComponentManagerImpl implements ComponentManager {
ComponentEntity retrieved =
getComponent(component.getVspId(), component.getVersion(), component.getId());
+ if (vspInfoDao.isManual(component.getVspId(), component.getVersion())) {
+ validateComponentUpdateManual(component, retrieved, user);
+ }
+
+
ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(isManual(component.getVspId(), component.getVersion()));
+ schemaInput.setManual(vspInfoDao.isManual(component.getVspId(), component.getVersion()));
schemaInput.setComponent(retrieved.getComponentCompositionData());
CompositionEntityValidationData validationData = compositionEntityDataManager
.validateEntity(component, SchemaTemplateContext.composition, schemaInput);
if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ updateComponentName(component);
componentDao.update(component);
//componentDao.updateVspLatestModificationTime(component.getVspId(), component.getVersion());
}
@@ -132,6 +232,54 @@ public class ComponentManagerImpl implements ComponentManager {
return validationData;
}
+ private void validateComponentUpdateManual(ComponentEntity component, ComponentEntity
+ retrieved, String user) {
+ Collection<ComponentEntity> vspComponentList = listComponents(component.getVspId()
+ , component.getVersion(), user);
+ //Removing check from name as we will ignore passed value
+ // and re-genarate new name from displayName
+ // List<String> invalidParameters = new LinkedList<>();
+ // if (!component.getComponentCompositionData().getName().equals(retrieved
+ // .getComponentCompositionData().getName())) {
+ // invalidParameters.add(NAME);
+ // }
+ // if (!invalidParameters.isEmpty()) {
+ // String msg = String.format(VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED_MSG, StringUtils
+ // .join(invalidParameters, ", "));
+ // MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ // LoggerTragetServiceName.UPDATE_COMPONENT, ErrorLevel.ERROR.name(),
+ // LoggerErrorCode.DATA_ERROR.getErrorCode(), msg);
+ //
+ // throw new CoreException(
+ // new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ // .withId(VendorSoftwareProductErrorCodes.VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED)
+ // .withMessage(msg).build());
+ // }
+
+ //VFC name should be unique within VSP
+ //Removing VFC with same ID from list to avoid self compare
+ for(ComponentEntity ce : vspComponentList) {
+ if (ce.getId().equals(component.getId())) {
+ vspComponentList.remove(ce);
+ break;
+ }
+ }
+ if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData()
+ .getDisplayName())) {
+ final String VSP_VFC_DUPLICATE_NAME_MSG = "VFC with specified name "
+ + "already present in given VSP.";
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Component with same name already " +
+ "exists for specified VSP");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME)
+ .withMessage(VSP_VFC_DUPLICATE_NAME_MSG).build());
+
+ }
+ }
+
public CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
String componentId, String user) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
@@ -139,7 +287,7 @@ public class ComponentManagerImpl implements ComponentManager {
ComponentData component = componentEntity.getComponentCompositionData();
ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(isManual(vspId, version));
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
schemaInput.setComponent(component);
CompositionEntityResponse<ComponentData> response = new CompositionEntityResponse<>();
@@ -155,7 +303,7 @@ public class ComponentManagerImpl implements ComponentManager {
public void deleteComponent(String vspId, Version version, String componentId, String user) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- if (!isManual(vspId, version)) {
+ if (!vspInfoDao.isManual(vspId, version)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_COMPONENT, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete component");
@@ -228,7 +376,7 @@ public class ComponentManagerImpl implements ComponentManager {
schemaInput);
}
- private boolean isManual(String vspId, Version version) {
+ /*private boolean isManual(String vspId, Version version) {
return false;
- }
+ }*/
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
new file mode 100644
index 0000000000..71985fa83e
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
+
+public class ComputeManagerFactoryImpl extends ComputeManagerFactory {
+
+ private static final ComputeManager INSTANCE =
+ new ComputeManagerImpl(
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ ComputeDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ DeploymentFlavorDaoFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface()
+
+ );
+
+ @Override
+ public ComputeManager createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
new file mode 100644
index 0000000000..a2d1d708c1
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
@@ -0,0 +1,503 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DuplicateComputeInComponentErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComputeCompositionSchemaInput;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
+import org.openecomp.sdc.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class ComputeManagerImpl implements ComputeManager {
+
+ private static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private ComputeDao computeDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private ComponentDao componentDao;
+ private static final String MANUAL = "Manual";
+
+ public ComputeManagerImpl(
+ VendorSoftwareProductInfoDao vspInfoDao,
+ ComputeDao computeDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ DeploymentFlavorDao deploymentFlavorDao,
+ ComponentDao componentDao
+ ) {
+ this.computeDao = computeDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.vspInfoDao = vspInfoDao;
+ this.deploymentFlavorDao = deploymentFlavorDao;
+ this.componentDao = componentDao;
+ }
+
+ @Override
+ public ComputeEntity createCompute(ComputeEntity compute, String user) {
+ ComputeEntity createdCompute = null;
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", compute.getVspId(),
+ compute.getComponentId());
+
+ /*Version activeVersion =
+ getVersionInfo(compute.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
+ compute.setVersion(activeVersion);*/
+ //if (!isManual(compute.getVspId(), activeVersion)) {
+ if (!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
+ ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
+ .getAddComputeNotSupportedHeatOnboardMethodErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ onboardingMethodUpdateErrorCode.message());
+ throw new CoreException(onboardingMethodUpdateErrorCode);
+ } else {
+ //validateComponentId(compute.getVspId(),compute.getVersion(),compute.getComponentId());
+ validateCompute(compute);
+ createdCompute = createCompute(compute);
+ }
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId());
+
+ return createdCompute;
+ }
+
+ private ComputeEntity createCompute(ComputeEntity compute) {
+
+ return compositionEntityDataManager.createCompute(compute);
+ }
+
+ private void validateCompute(ComputeEntity compute) {
+ Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
+ (),compute.getComponentId());
+
+ if (!isComputeNameUnique(vfcComputeList,compute.getComputeCompositionData().getName())) {
+ final ErrorCode duplicateComputeInComponentErrorBuilder =
+ new DuplicateComputeInComponentErrorBuilder(compute.getComputeCompositionData().getName(),
+ compute.getComponentId()).build();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateComputeInComponentErrorBuilder.message());
+ throw new CoreException(duplicateComputeInComponentErrorBuilder);
+ }
+
+ }
+
+ private void validateComputeUpdate(ComputeEntity compute) {
+ Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
+ (),compute.getComponentId());
+
+ for (ComputeEntity ce : vfcComputeList) {
+ if (ce.getId().equals(compute.getId())) {
+ vfcComputeList.remove(ce);
+ break;
+ }
+ }
+
+ if (!isComputeNameUnique(vfcComputeList,compute.getComputeCompositionData().getName())) {
+ final ErrorCode duplicateComputeInComponentErrorBuilder =
+ new DuplicateComputeInComponentErrorBuilder(compute.getComputeCompositionData().getName(),
+ compute.getComponentId()).build();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateComputeInComponentErrorBuilder.message());
+ throw new CoreException(duplicateComputeInComponentErrorBuilder);
+ }
+
+ }
+
+ @Override
+ public Collection<ListComputeResponse> listCompute(String vspId, Version version,
+ String componentId, String user) {
+
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ //validateComponentId(vspId, version, componentId);
+ ComputeEntity entity = new ComputeEntity(vspId, version, componentId, null);
+ Collection<ComputeEntity> computes = computeDao.list(entity);
+
+ Collection<ListComputeResponse> computeResponse =
+ getListComputeResponse(vspId, version, user, computes);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ return computeResponse;
+ }
+
+ private Collection<ListComputeResponse> getListComputeResponse(String vspId, Version version,
+ String user,
+ Collection<ComputeEntity> computes) {
+ Set<String> vspComputes = getComputeAssociatedWithDepFlavors(vspId, version, user);
+ Collection<ListComputeResponse> computeResponse = new ArrayList<ListComputeResponse>();
+ for(ComputeEntity computeEntity : computes) {
+ ListComputeResponse response = new ListComputeResponse();
+ response.setComputeEntity(computeEntity);
+ if(vspComputes.contains(computeEntity.getId())) {
+ response.setAssociatedWithDeploymentFlavor(true);
+ } else {
+ response.setAssociatedWithDeploymentFlavor(false);
+ }
+ computeResponse.add(response);
+ }
+ return computeResponse;
+ }
+
+ private Set<String> getComputeAssociatedWithDepFlavors(String vspId, Version version,
+ String user) {
+ final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
+ Set<String> vspComputes = new HashSet<String>();
+ for(DeploymentFlavorEntity entity : deploymentFlavorEntities) {
+ final List<ComponentComputeAssociation> componentComputeAssociations =
+ entity.getDeploymentFlavorCompositionData().getComponentComputeAssociations();
+ if(componentComputeAssociations != null && !componentComputeAssociations.isEmpty()) {
+ for(ComponentComputeAssociation association : componentComputeAssociations) {
+ vspComputes.add(association.getComputeFlavorId());
+ }
+ }
+ }
+ return vspComputes;
+ }
+
+ private boolean isComputeNameUnique(Collection<ComputeEntity> vfcComputeList, String name) {
+ for (ComputeEntity compute : vfcComputeList) {
+ if (compute.getComputeCompositionData().getName().equalsIgnoreCase(name)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private Collection<ComputeEntity> listCompute(String vspId, Version version,String componentId) {
+ Collection<ComputeEntity> computeEntities =
+ computeDao.list(new ComputeEntity(vspId, version, componentId, null));
+
+ return computeEntities;
+ }
+
+ @Override
+ public CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version,
+ String componentId,
+ String computeFlavorId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
+ componentId, computeFlavorId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+ ComputeEntity computeEntity = getCompute(vspId, version, componentId, computeFlavorId);
+ ComputeData compute = computeEntity.getComputeCompositionData();
+
+ ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ schemaInput.setCompute(compute);
+
+ CompositionEntityResponse<ComputeData> response = new CompositionEntityResponse<>();
+ response.setId(computeFlavorId);
+ response.setData(compute);
+ response.setSchema(getComputeCompositionSchema(schemaInput));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
+ componentId, computeFlavorId);
+
+ return response;
+ }
+
+ private ComputeEntity getCompute(String vspId, Version version, String componentId, String
+ computeFlavorId) {
+ //validateComponentId(vspId,version,componentId);
+ ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId,
+ computeFlavorId));
+ VersioningUtil
+ .validateEntityExistence(retrieved, new ComputeEntity(vspId, version, componentId,
+ computeFlavorId), VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ /*private void validateComponentId(String vspId, Version version, String componentId) {
+ ComponentEntity retrivedComponent = componentDao.get(new ComponentEntity(vspId, version,
+ componentId));
+ VersioningUtil
+ .validateEntityExistence(retrivedComponent, new ComponentEntity(vspId, version,
+ componentId),VspDetails.ENTITY_TYPE);
+ }*/
+
+ @Override
+ public QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String
+ componentId, String computeId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, componentId", vspId, componentId, computeId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+ //validateComponentId(vspId,version,componentId);
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ //validateComponentId(vspId,version,componentId);
+ ComputeEntity computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId, computeId);
+ VersioningUtil
+ .validateEntityExistence(computeQuestionnaire, new ComputeEntity(vspId, version, componentId,
+ computeId), VspDetails.ENTITY_TYPE);
+ questionnaireResponse.setData(computeQuestionnaire.getQuestionnaireData());
+ questionnaireResponse.setSchema(getComputeQuestionnaireSchema(null));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId,
+ componentId, computeId);
+
+ return questionnaireResponse;
+ }
+
+
+ protected String getComputeQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute,
+ schemaInput);
+ }
+
+
+ @Override
+ public void updateComputeQuestionnaire(String vspId, Version version, String componentId, String
+ computeId,
+ String questionnaireData, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
+ componentId, computeId);
+
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
+ getComponent(vspId, activeVersion, componentId);*/
+ ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId,version,componentId,
+ computeId));
+ VersioningUtil.validateEntityExistence(retrieved, new ComputeEntity(vspId, version,
+ componentId, computeId), VspDetails.ENTITY_TYPE);
+
+ computeDao.updateQuestionnaireData(vspId, version, componentId, computeId, questionnaireData);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
+ componentId, computeId);
+ }
+
+ @Override
+ public CompositionEntityValidationData updateCompute(ComputeEntity compute, String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
+ compute.getId());
+
+ /*Version activeVersion =
+ getVersionInfo(image.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
+ image.setVersion(activeVersion);*/
+
+ ComputeEntity retrieved = getComputeEntity(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ compute.getId());
+
+ if(!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
+ final ComputeData computeCompositionData = compute.getComputeCompositionData();
+ final String name = computeCompositionData.getName();
+ //final String format = computeCompositionData.getFormat();
+ validateHeatVspComputeUpdate("Name", name, retrieved.getComputeCompositionData()
+ .getName());
+ /*validateHeatVspComputeUpdate("format", format, retrieved.getComputeCompositionData()
+ .getFormat());*/
+ }
+
+ Collection<ComputeEntity> vfcComputeList = listComputes(compute.getVspId() ,
+ compute.getVersion(), compute.getComponentId());
+
+ //Set to null so that retrieved object is equal to one in list and gets removed.
+ retrieved.setQuestionnaireData(null);
+ vfcComputeList.remove(retrieved);
+ if(vspInfoDao.isManual(compute.getVspId(), compute.getVersion()))
+ validateVfcCompute(compute, vfcComputeList);
+
+ //Set format to default value in order to handle FTL validation when compute format is null
+ /*if(compute.getComputeCompositionData().getFormat() == null)
+ compute.getComputeCompositionData().setFormat(ComputeFormat.qcow2.name());*/
+
+ ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
+ schemaInput.setCompute(compute.getComputeCompositionData());
+
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(compute, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ computeDao.update(compute);
+ }
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
+ compute.getId());
+
+ return validationData;
+ }
+
+ private void validateHeatVspComputeUpdate(String name, String value, String retrivedValue) {
+
+ if(value != null && !value.equals(retrivedValue)) {
+
+ final ErrorCode updateHeatComputeErrorBuilder =
+ DuplicateComputeInComponentErrorBuilder.getComputeHeatReadOnlyErrorBuilder(name);
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateHeatComputeErrorBuilder.message());
+ throw new CoreException(updateHeatComputeErrorBuilder);
+ }
+ }
+
+ private void validateVfcCompute(ComputeEntity compute, Collection<ComputeEntity> vfcComputeList) {
+ if (isComputeNameDuplicate(vfcComputeList,compute.getComputeCompositionData().getName(), compute.getId())) {
+ ErrorCode errorCode = DuplicateComputeInComponentErrorBuilder.getDuplicateComputeNameErrorBuilder(compute
+ .getComputeCompositionData().getName(), compute.getComponentId());
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
+ }
+
+ private boolean isComputeNameDuplicate(Collection<ComputeEntity> computes, String name, String computeId) {
+ for (ComputeEntity compute : computes) {
+ if (compute.getComputeCompositionData().getName().equals(name) && !compute.getId().equals(computeId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ private ComputeEntity getComputeEntity(String vspId, Version version, String componentId,
+ String computeId) {
+ //validateComponentId(vspId,version,componentId);
+ ComputeEntity computeEntity = computeDao.get(new ComputeEntity(vspId, version, componentId, computeId));
+ VersioningUtil.validateEntityExistence(computeEntity, new ComputeEntity(vspId, version, componentId,
+ computeId), VspDetails.ENTITY_TYPE);
+ return computeEntity;
+ }
+
+ private Collection<ComputeEntity> listComputes(String vspId, Version version, String componentId) {
+ return computeDao.list(new ComputeEntity(vspId, version, componentId, null));
+ }
+
+ @Override
+ public void deleteCompute(String vspId, Version version, String componentId, String
+ computeFlavorId, String user) {
+ final String VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG =
+ "Composition entities may not be created / deleted for Vendor Software Product "
+ + "whose entities were uploaded";
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
+ componentId, computeFlavorId);
+
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();*/
+ if (!vspInfoDao.isManual(vspId, version)) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete compute");
+ throw new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
+ .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
+ .withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
+ }
+ ComputeEntity retrived = getCompute(vspId,version,componentId,computeFlavorId);
+ if (retrived != null){
+ deleteComputeFromDeploymentFlavors(vspId,version,computeFlavorId);
+ computeDao.delete(new ComputeEntity(vspId, version, componentId, computeFlavorId));
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
+ componentId, computeFlavorId);
+ }
+
+ private void deleteComputeFromDeploymentFlavors(String vspId, Version activeVersion,
+ String computeFlavorId) {
+ //Collection<DeploymentFlavorEntity> listDF = listDeploymentFlavors(vspId, activeVersion);
+ Collection<DeploymentFlavorEntity> listDF = deploymentFlavorDao.list(new DeploymentFlavorEntity
+ (vspId, activeVersion, null));
+ for(DeploymentFlavorEntity df : listDF) {
+ DeploymentFlavorEntity deploymentFlavorEntity=removeComputeFromDF(df, computeFlavorId);
+ if(deploymentFlavorEntity!=null)
+ deploymentFlavorDao.update(deploymentFlavorEntity);
+ }
+ }
+
+ private DeploymentFlavorEntity removeComputeFromDF(DeploymentFlavorEntity df, String
+ computeFlavorId) {
+ DeploymentFlavor flavor = df.getDeploymentFlavorCompositionData();
+ List<ComponentComputeAssociation> associations = flavor.getComponentComputeAssociations();
+ if (associations != null) {
+ List<ComponentComputeAssociation> updatedAssociations = new ArrayList<>();
+ for (ComponentComputeAssociation ca : associations) {
+ if (ca.getComputeFlavorId() != null && ca.getComputeFlavorId().equals(computeFlavorId)) {
+ ComponentComputeAssociation updateCaremoveCompute = new ComponentComputeAssociation();
+ updateCaremoveCompute.setComponentId(ca.getComponentId());
+ updatedAssociations.add(updateCaremoveCompute);
+ } else {
+ updatedAssociations.add(ca);
+ }
+ }
+ flavor.setComponentComputeAssociations(updatedAssociations);
+ df.setDeploymentFlavorCompositionData(flavor);
+ return df;
+ }
+ return null;
+ }
+
+ protected String getComputeCompositionSchema(SchemaTemplateInput schemaInput){
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.compute, schemaInput);
+ }
+
+ /*boolean isManual(String vspId, Version version) {
+
+ VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
+ String onboardingMethod = vsp.getOnboardingMethod();
+ if (MANUAL.equals(onboardingMethod)) {
+ return true;
+ }
+ return false;
+ }*/
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
new file mode 100644
index 0000000000..aef8be1fef
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
@@ -0,0 +1,31 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager;
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+
+public class DeploymentFlavorManagerFactoryImpl extends DeploymentFlavorManagerFactory {
+
+ private static final DeploymentFlavorManager INSTANCE = new DeploymentFlavorManagerImpl(
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ DeploymentFlavorDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface(),
+ ComputeDaoFactory.getInstance().createInterface()
+ );
+
+ @Override
+ public DeploymentFlavorManager createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
new file mode 100644
index 0000000000..7069d778a7
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
@@ -0,0 +1,396 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DeploymentFlavorErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.DeploymentFlavorCompositionSchemaInput;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
+import org.openecomp.sdc.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
+
+ private static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+ private ComponentDao componentDao;
+ private ComputeDao computeDao;
+
+ public DeploymentFlavorManagerImpl(
+ VendorSoftwareProductInfoDao vspInfoDao,
+ DeploymentFlavorDao deploymentFlavorDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ ComponentDao componentDao,
+ ComputeDao computeDao
+
+ ) {
+
+ this.vspInfoDao = vspInfoDao;
+ this.deploymentFlavorDao = deploymentFlavorDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.componentDao = componentDao;
+ this.computeDao = computeDao;
+
+ }
+
+ @Override
+ public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return listDeploymentFlavors(vspId, version);
+ }
+
+ private Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
+ return deploymentFlavorEntities;
+ }
+
+ @Override
+ public DeploymentFlavorEntity createDeploymentFlavor(
+ DeploymentFlavorEntity deploymentFlavorEntity, String user) {
+ DeploymentFlavorEntity createDeploymentFlavor = null;
+ mdcDataDebugMessage.debugEntryMessage("VSP id ", deploymentFlavorEntity.getVspId());
+ /*Version activeVersion =
+ getVersionInfo(deploymentFlavorEntity.getVspId(), VersionableEntityAction.Write, user)
+ .getActiveVersion();
+ deploymentFlavorEntity.setVersion(activeVersion);*/
+
+ if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
+ deploymentFlavorEntity.getVersion())) {
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getAddDeploymentNotSupportedHeatOnboardErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), deploymentFlavorErrorBuilder.message());
+ throw new CoreException(deploymentFlavorErrorBuilder);
+ } else {
+ validateDeploymentFlavor(deploymentFlavorEntity, user, deploymentFlavorEntity.getVersion());
+ createDeploymentFlavor =
+ compositionEntityDataManager.createDeploymentFlavor(deploymentFlavorEntity);
+ }
+ return createDeploymentFlavor;
+ }
+
+ private void validateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity, String
+ user, Version activeVersion) {
+ //Validation for unique model.
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors =
+ listDeploymentFlavors(deploymentFlavorEntity.getVspId(),
+ activeVersion);
+ isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
+
+ List<String> featureGroups =
+ getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), user, activeVersion);
+ String featureGroup = deploymentFlavorEntity.getDeploymentFlavorCompositionData()
+ .getFeatureGroupId();
+ if (featureGroup != null && featureGroup.trim().length()>0) {
+ if (isEmpty(featureGroups) || (!(validFeatureGroup(featureGroups, featureGroup)))) {
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getFeatureGroupNotexistErrorBuilder(featureGroup, deploymentFlavorEntity.getVspId(),
+ activeVersion);
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), deploymentFlavorErrorBuilder.message());
+ throw new CoreException(deploymentFlavorErrorBuilder);
+ }
+ }
+
+ validateComponentComputeAssociation(deploymentFlavorEntity, activeVersion);
+ }
+
+ private void isDeploymentFlavorModelDuplicate(DeploymentFlavorEntity deploymentFlavorEntity,
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors) {
+ listDeploymentFlavors.forEach(deploymentFlavor -> {
+ if (deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel().equalsIgnoreCase(
+ deploymentFlavor.getDeploymentFlavorCompositionData().getModel())) {
+ ErrorCode deploymentFlavorModelErrorBuilder = DeploymentFlavorErrorBuilder
+ .getDuplicateDeploymentFlavorModelErrorBuilder(
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel(),
+ deploymentFlavorEntity.getVspId());
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), deploymentFlavorModelErrorBuilder.message());
+ throw new CoreException(deploymentFlavorModelErrorBuilder);
+ }
+ });
+ }
+
+ private List<String> getFeatureGroupListForVsp(String vspId,
+ String user, Version activeVersion) {
+ /*VersionedVendorSoftwareProductInfo versionedVendorSoftwareProductInfo = getVspDetails(
+ vspId,activeVersion, user);
+ return versionedVendorSoftwareProductInfo.getVspDetails()
+ .getFeatureGroups();*/
+
+ final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, activeVersion));
+ return vspDetails.getFeatureGroups();
+ }
+
+ private boolean isEmpty(Collection coll) {
+ return (coll == null || coll.isEmpty());
+ }
+
+ private boolean validFeatureGroup(List<String> featureGroups, String featureGroupId) {
+ Iterator<String> iterator = featureGroups.iterator();
+ boolean valid = false;
+ while (iterator.hasNext()) {
+ String fgId = iterator.next().trim();
+ if (fgId.equals(featureGroupId)) {
+ valid = true;
+ break;
+ } else {
+ valid = false;
+ }
+ }
+ return valid;
+ }
+
+ private void validateComponentComputeAssociation(DeploymentFlavorEntity deploymentFlavorEntity,
+ Version activeVersion) {
+ List<ComponentComputeAssociation> componentComputeAssociationList = deploymentFlavorEntity
+ .getDeploymentFlavorCompositionData().getComponentComputeAssociations();
+ List<String> vfcList = new ArrayList<>();
+ if (!isEmpty(componentComputeAssociationList)) {
+ componentComputeAssociationList.forEach(componentComputeAssociation -> {
+ if ((componentComputeAssociation.getComponentId() == null || componentComputeAssociation
+ .getComponentId().trim().length() == 0) &&
+ (componentComputeAssociation
+ .getComputeFlavorId() != null && componentComputeAssociation
+ .getComputeFlavorId().trim().length() > 0)) {
+ ErrorCode invalidAssociationErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidAssociationErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), invalidAssociationErrorBuilder.message());
+ throw new CoreException(invalidAssociationErrorBuilder);
+ } else if (componentComputeAssociation.getComponentId() != null &&
+ componentComputeAssociation.getComponentId().trim().length() > 0 ) {
+ ComponentEntity component = getComponent(deploymentFlavorEntity.getVspId(), activeVersion,
+ componentComputeAssociation.getComponentId());
+ if (componentComputeAssociation
+ .getComputeFlavorId() != null && componentComputeAssociation
+ .getComputeFlavorId().trim().length() > 0 ) {
+ ComputeEntity computeFlavor = computeDao.get(new ComputeEntity(deploymentFlavorEntity
+ .getVspId(), activeVersion, componentComputeAssociation.getComponentId(),
+ componentComputeAssociation.getComputeFlavorId()));
+ if (computeFlavor == null) {
+ ErrorCode invalidComputeIdErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidComputeIdErrorBuilder(componentComputeAssociation.getComputeFlavorId(),
+ componentComputeAssociation.getComponentId());
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ invalidComputeIdErrorBuilder.message());
+ throw new CoreException(invalidComputeIdErrorBuilder);
+ }
+ }
+ vfcList.add(componentComputeAssociation.getComponentId());
+ }
+ });
+ Map<String, Integer> frequencyMapping = CollectionUtils.getCardinalityMap(vfcList);
+
+ for (Integer vfcCount : frequencyMapping.values()) {
+ if (vfcCount != 1) {
+ ErrorCode duplicateVfcAssociationErrorBuilder = DeploymentFlavorErrorBuilder
+ .getDuplicateVfcAssociationErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateVfcAssociationErrorBuilder.message());
+ throw new CoreException(duplicateVfcAssociationErrorBuilder);
+ }
+ }
+ }
+ }
+
+ private ComponentEntity getComponent(String vspId, Version version, String componentId) {
+ ComponentEntity retrieved = componentDao.get(new ComponentEntity(vspId, version, componentId));
+ VersioningUtil
+ .validateEntityExistence(retrieved, new ComponentEntity(vspId, version, componentId),
+ VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ @Override
+ public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId,
+ Version version,
+ String deploymentFlavorId,
+ String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+ DeploymentFlavorEntity deploymentFlavorEntity = getDeploymentFlavor(vspId,version,
+ deploymentFlavorId);
+ DeploymentFlavor deploymentFlavor = deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+ DeploymentFlavorCompositionSchemaInput schemaInput = new
+ DeploymentFlavorCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ schemaInput.setDeploymentFlavor(deploymentFlavor);
+ List<String> featureGroups =
+ getFeatureGroupListForVsp(vspId, user, version);
+ schemaInput.setFeatureGroupIds(featureGroups);
+ CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
+ response.setId(deploymentFlavorId);
+ response.setSchema((SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.deployment,
+ schemaInput)));
+ response.setData(deploymentFlavor);
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, deployment flavor id ", vspId, deploymentFlavorId);
+
+ return response;
+ }
+
+ private DeploymentFlavorEntity getDeploymentFlavor(String vspId, Version version, String
+ deploymentFlavorId) {
+ DeploymentFlavorEntity retrieved = deploymentFlavorDao.get(new DeploymentFlavorEntity(vspId,
+ version, deploymentFlavorId));
+ VersioningUtil
+ .validateEntityExistence(retrieved, new DeploymentFlavorEntity(vspId, version,
+ deploymentFlavorId ), VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ @Override
+ public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId,
+ Version version,
+ String user) {
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+ DeploymentFlavorCompositionSchemaInput schemaInput= new
+ DeploymentFlavorCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
+ List<String> featureGroups =
+ getFeatureGroupListForVsp(vspId, user, version);
+ schemaInput.setFeatureGroupIds(featureGroups);
+ CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
+ response.setSchema((SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.deployment,
+ schemaInput)));
+ return response;
+ }
+
+ @Override
+ public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId,
+ String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();*/
+ DeploymentFlavorEntity deploymentFlavorEntity = getDeploymentFlavor(vspId,version,
+ deploymentFlavorId);
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final ErrorCode deleteDeploymentFlavorErrorBuilder =
+ NotSupportedHeatOnboardMethodErrorBuilder
+ .getDelDeploymentFlavorNotSupportedHeatOnboardMethodErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ deleteDeploymentFlavorErrorBuilder.message());
+ throw new CoreException(deleteDeploymentFlavorErrorBuilder);
+ }
+ if(deploymentFlavorEntity != null) {
+ deploymentFlavorDao.delete(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
+
+ }
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
+ }
+
+ public CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity
+ deploymentFlavorEntity, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, deploymentFlavor id", deploymentFlavorEntity
+ .getVspId(), deploymentFlavorEntity.getId());
+ /*Version activeVersion =
+ getVersionInfo(deploymentFlavorEntity.getVspId(), VersionableEntityAction.Write, user)
+ .getActiveVersion();*/
+
+ if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
+ deploymentFlavorEntity.getVersion())) {
+ final ErrorCode updateDeploymentFlavorErrorBuilder =
+ NotSupportedHeatOnboardMethodErrorBuilder
+ .getUpdateDfNotSupportedHeatOnboardMethodErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateDeploymentFlavorErrorBuilder.message());
+ throw new CoreException(updateDeploymentFlavorErrorBuilder);
+ }
+ //deploymentFlavorEntity.setVersion(activeVersion);
+ DeploymentFlavorEntity retrieved =
+ getDeploymentFlavor(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion(),
+ deploymentFlavorEntity.getId());
+
+
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors = listDeploymentFlavors
+ (deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion());
+ listDeploymentFlavors.remove(retrieved);
+ isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
+
+ //validateComponentComputeAssociation(deploymentFlavorEntity, activeVersion);
+ validateComponentComputeAssociation(deploymentFlavorEntity, deploymentFlavorEntity.getVersion());
+
+ DeploymentFlavorCompositionSchemaInput schemaInput = new
+ DeploymentFlavorCompositionSchemaInput();
+ schemaInput.setManual(vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
+ deploymentFlavorEntity.getVersion()));
+ schemaInput.setDeploymentFlavor(retrieved.getDeploymentFlavorCompositionData());
+
+ List<String> featureGroups =
+ getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), user,
+ deploymentFlavorEntity.getVersion());
+ schemaInput.setFeatureGroupIds(featureGroups);
+
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(deploymentFlavorEntity, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ deploymentFlavorDao.update(deploymentFlavorEntity);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, deploymentFlavor id",
+ deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getId());
+ return validationData;
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java
new file mode 100644
index 0000000000..9689615c70
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerFactoryImpl.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
+
+public class ImageManagerFactoryImpl extends ImageManagerFactory {
+
+ private static final ImageManager INSTANCE =
+ new ImageManagerImpl(
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ ImageDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface()
+ );
+
+ @Override
+ public ImageManager createInterface() {
+ return INSTANCE;
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
new file mode 100644
index 0000000000..e180138119
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
@@ -0,0 +1,359 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.ImageErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageFormat;
+import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.image.ImageDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ImageCompositionSchemaInput;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
+import org.openecomp.sdc.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+
+import java.util.Collection;
+
+public class ImageManagerImpl implements ImageManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private ImageDao imageDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+
+ public ImageManagerImpl(
+ VendorSoftwareProductInfoDao vspInfoDao,
+ ImageDao imageDao,
+ CompositionEntityDataManager compositionEntityDataManager
+
+ ) {
+
+ this.vspInfoDao = vspInfoDao;
+ this.imageDao = imageDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+
+ }
+
+ @Override
+ public ImageEntity createImage(ImageEntity imageEntity, String user) {
+ /*Version activeVersion = getVersionInfo(imageEntity.getVspId(),
+ VersionableEntityAction.Write, user).getActiveVersion();
+
+ imageEntity.setVersion(activeVersion);*/
+ if (!vspInfoDao.isManual(imageEntity.getVspId(), imageEntity.getVersion())) {
+
+ ErrorCode errorCode = NotSupportedHeatOnboardMethodErrorBuilder
+ .getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
+
+ Collection<ImageEntity> vfcImageList = listImages(imageEntity.getVspId() ,
+ imageEntity.getVersion(), imageEntity.getComponentId());
+ validateVfcImage(imageEntity, vfcImageList);
+ compositionEntityDataManager.createImage(imageEntity);
+ return imageEntity;
+ }
+
+ @Override
+ public Collection<ImageEntity> listImages(String vspId, Version version, String componentId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ Collection<ImageEntity> imageEntities = listImages(vspId, version, componentId);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
+ return imageEntities;
+ }
+
+ private Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
+ return imageDao.list(new ImageEntity(vspId, version, componentId, null));
+ }
+
+ @Override
+ public CompositionEntityResponse getImageSchema(String vspId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, image id", vspId);
+
+ CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
+ ImageCompositionSchemaInput inputSchema = new ImageCompositionSchemaInput();
+ Image image = new Image();
+ //image.setFormat(ImageFormat.qcow2.name());
+ inputSchema.setImage(image);
+ response.setSchema(getImageCompositionSchema(inputSchema));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, image id", vspId);
+ return response;
+ }
+
+ @Override
+ public CompositionEntityResponse<Image> getImage(String vspId, Version version, String
+ componentId, String imageId, String user) {
+
+ mdcDataDebugMessage.debugEntryMessage("VSP id, componentId, image id", vspId, componentId,
+ imageId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
+
+ ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
+
+ Image image = imageEntity.getImageCompositionData();
+ //Set format to default value in order to handle FTL validation when image format is null
+ /*if(image.getFormat() == null)
+ image.setFormat(ImageFormat.qcow2.name());*/
+
+ ImageCompositionSchemaInput schemaInput = new ImageCompositionSchemaInput();
+ schemaInput.setImage(image);
+
+ CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
+ response.setId(imageId);
+ response.setData(image);
+ response.setSchema(getImageCompositionSchema(schemaInput));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, componentId, image id", vspId, componentId,
+ imageId);
+
+ return response;
+ }
+
+ @Override
+ public QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String
+ componentId, String imageId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ /*version = VersioningUtil
+ .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
+ validateComponentId(vspId,version,componentId);*/
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ //validateComponentId(vspId,version,componentId);
+
+ ImageEntity retrieved = imageDao.getQuestionnaireData(vspId, version, componentId, imageId);
+ VersioningUtil.validateEntityExistence(retrieved, new ImageEntity(vspId, version, componentId,
+ imageId), ComponentEntity.ENTITY_TYPE);
+ questionnaireResponse.setData(retrieved.getQuestionnaireData());
+ questionnaireResponse.setSchema(getImageQuestionnaireSchema(null));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
+ return questionnaireResponse;
+ }
+
+ @Override
+ public void deleteImage(String vspId, Version version, String componentId, String imageId, String
+ user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", vspId, componentId, imageId);
+
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
+ ComponentEntity component = getComponent(vspId, activeVersion, componentId);*/
+ ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final ErrorCode deleteImageErrorBuilder =
+ NotSupportedHeatOnboardMethodErrorBuilder
+ .getDelImageNotSupportedHeatOnboardMethodErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_IMAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ deleteImageErrorBuilder.message());
+ throw new CoreException(deleteImageErrorBuilder);
+ }
+ if (imageEntity != null) {
+ imageDao.delete(new ImageEntity(vspId, version, componentId, imageId));
+ }
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", vspId, componentId, imageId);
+ }
+
+ private void validateHeatVspImageUpdate(String name, String value, String retrivedValue) {
+
+ if(value != null && !value.equals(retrivedValue)) {
+
+ final ErrorCode updateHeatImageErrorBuilder =
+ ImageErrorBuilder.getImageHeatReadOnlyErrorBuilder(name);
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateHeatImageErrorBuilder.message());
+ throw new CoreException(updateHeatImageErrorBuilder);
+ }
+ }
+
+ @Override
+ public CompositionEntityValidationData updateImage(ImageEntity image, String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
+ image.getId());
+
+ /*Version activeVersion =
+ getVersionInfo(image.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
+ image.setVersion(activeVersion);*/
+
+ ImageEntity retrieved = getImageEntity(image.getVspId(), image.getVersion(), image.getComponentId(),
+ image.getId());
+
+ if(!vspInfoDao.isManual(image.getVspId(), image.getVersion())) {
+ final Image imageCompositionData = image.getImageCompositionData();
+ final String fileName = imageCompositionData.getFileName();
+ //final String format = imageCompositionData.getFormat();
+ validateHeatVspImageUpdate("fileName", fileName, retrieved.getImageCompositionData()
+ .getFileName());
+ /*validateHeatVspImageUpdate("format", format, retrieved.getImageCompositionData()
+ .getFormat());*/
+ }
+
+ Collection<ImageEntity> vfcImageList = listImages(image.getVspId() ,
+ image.getVersion(), image.getComponentId());
+
+ //Set to null so that retrieved object is equal to one in list and gets removed.
+ retrieved.setQuestionnaireData(null);
+ vfcImageList.remove(retrieved);
+ validateVfcImage(image, vfcImageList);
+
+ //Set format to default value in order to handle FTL validation when image format is null
+ /*if(image.getImageCompositionData().getFormat() == null)
+ image.getImageCompositionData().setFormat(ImageFormat.qcow2.name());*/
+
+ ImageCompositionSchemaInput schemaInput = new ImageCompositionSchemaInput();
+ schemaInput.setImage(image.getImageCompositionData());
+
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(image, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ imageDao.update(image);
+ }
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
+ image.getId());
+
+ return validationData;
+ }
+
+ @Override
+ public void updateImageQuestionnaire(String vspId, Version version, String componentId, String
+ imageId, String questionnaireData, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, imageId", vspId, componentId,
+ imageId);
+
+ getImageEntity(vspId, version, componentId, imageId);
+
+ /*Version activeVersion =
+ getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
+
+ getComponent(vspId, activeVersion, componentId);*/
+
+ final ImageDetails image = JsonUtil.json2Object(questionnaireData, ImageDetails.class);
+ final String format = image.getFormat();
+ try {
+ if (format != null) {
+ final ImageFormat imageFormat = ImageFormat.valueOf(format);
+ }
+ } catch (IllegalArgumentException exception) {
+ ErrorCode errorCode = ImageErrorBuilder.getInvalidImageFormatErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message() );
+ throw new CoreException(errorCode);
+ }
+
+ //Validate Format is read only for HEAT Onboarding
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version,
+ componentId, imageId, user);
+ final String data = imageQuestionnaire.getData();
+ if (data != null) {
+ String retrivedFormat = JsonUtil.json2Object(data, ImageDetails.class).getFormat();
+ validateHeatVspImageUpdate("format", format, retrivedFormat);
+ }
+ }
+
+ imageDao.updateQuestionnaireData(vspId, version, componentId, imageId, questionnaireData);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, imageId", vspId, componentId,
+ imageId);
+ }
+
+ private ImageEntity getImageEntity(String vspId, Version version, String componentId,
+ String imageId) {
+ //validateComponentId(vspId,version,componentId);
+
+ ImageEntity imageEntity = imageDao.get(new ImageEntity(vspId, version, componentId, imageId));
+
+ VersioningUtil.validateEntityExistence(imageEntity, new ImageEntity(vspId, version, componentId,
+ imageId), VspDetails.ENTITY_TYPE);
+ return imageEntity;
+ }
+
+
+ private boolean isImageNameDuplicate(Collection<ImageEntity> images, String fileName) {
+ for (ImageEntity image : images) {
+ if (image.getImageCompositionData().getFileName().equalsIgnoreCase(fileName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void validateVfcImage(ImageEntity image, Collection<ImageEntity> vfcImageList) {
+ if (isImageNameDuplicate(vfcImageList,image.getImageCompositionData().getFileName())) {
+ ErrorCode errorCode = ImageErrorBuilder.getDuplicateImageNameErrorBuilder(image
+ .getImageCompositionData().getFileName(), image.getComponentId());
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
+ errorCode.id(),errorCode.message());
+
+ throw new CoreException(errorCode);
+ }
+ }
+
+ protected String getImageCompositionSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.image,
+ schemaInput);
+ }
+
+ protected String getImageQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image,
+ schemaInput);
+ }
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
new file mode 100644
index 0000000000..ef33812ddc
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
@@ -0,0 +1,117 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.generator.core.services.ManualVspToscaGenerationService;
+import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
+import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
+import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.ManualVspDataCollectionService;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ @Override
+ public VspModelInfo gatherVspInformation(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ ManualVspDataCollectionService
+ manualVspDataCollectionService = new ManualVspDataCollectionService();
+ VspModelInfo vspModelInfo = new VspModelInfo();
+ //Get Release Vendor Name
+ Optional<String> releaseVendor;
+ try {
+ releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version, user);
+ } catch (Exception ex) {
+ releaseVendor = Optional.empty();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Release Vendor not found");
+ }
+ releaseVendor.ifPresent(vspModelInfo::setReleaseVendor);
+
+ //Get Allowed Deployment flavors information
+ Map<String, DeploymentFlavorModel> allowedFlavors;
+ try {
+ allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version, user);
+ } catch (Exception ex) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect allowed flavors");
+ allowedFlavors = null;
+ }
+ if (MapUtils.isNotEmpty(allowedFlavors)) {
+ vspModelInfo.setAllowedFlavors(allowedFlavors);
+ }
+
+ //Get VFC Image information
+ Map<String, List<MultiFlavorVfcImage>> vspComponentImages;
+ try {
+ vspComponentImages =
+ manualVspDataCollectionService.getVspComponentImages(vspId, version, user);
+ } catch (Exception ex) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component images");
+ vspComponentImages = null;
+ }
+ if (MapUtils.isNotEmpty(vspComponentImages)) {
+ vspModelInfo.setMultiFlavorVfcImages(vspComponentImages);
+ }
+
+ //Get VFC component information
+ Map<String, String> vspComponents;
+ try {
+ vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version, user);
+ } catch (Exception ex) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp components");
+ vspComponents = null;
+ }
+ if (MapUtils.isNotEmpty(vspComponents)) {
+ vspModelInfo.setComponents(vspComponents);
+ }
+
+ //Get VSP component nic information
+ Map<String, List<Nic>> vspComponentNics;
+ try {
+ vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version, user);
+ } catch (Exception ex) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component nics");
+ vspComponentNics = null;
+ }
+ if (MapUtils.isNotEmpty(vspComponentNics)) {
+ vspModelInfo.setNics(vspComponentNics);
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return vspModelInfo;
+ }
+
+ @Override
+ public ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo) {
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+ ManualVspToscaGenerationService vspToscaGenerator = new ManualVspToscaGenerationService();
+ ToscaServiceModel manualVspToscaServiceModel =
+ vspToscaGenerator.createManualVspToscaServiceModel(vspModelInfo);
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return manualVspToscaServiceModel;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImpl.java
deleted file mode 100644
index 185cfa091b..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImpl.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorsoftwareproduct.impl;
-
-import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.enrichment.types.ArtifactType;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.core.utilities.file.FileContentHandler;
-import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.Messages;
-import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
-import org.openecomp.sdc.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
-import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
-import org.openecomp.sdc.vendorsoftwareproduct.MibManager;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.MibUploadErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus;
-import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-public class MibManagerImpl implements MibManager {
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private ActivityLogManager activityLogManager;
- private MibDao mibDao;
-
- public MibManagerImpl(MibDao mibDao,
- ActivityLogManager activityLogManager) {
- this.mibDao = mibDao;
-
- this.activityLogManager = activityLogManager;
- mibDao.registerVersioning(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
- }
-
- @Override
- public void delete(String vspId, Version version, String componentId,
- ArtifactType artifactType, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
-
- MibEntity mibEntity =
- setValuesForComponentArtifactEntityUpload(vspId, version, null, componentId, null,
- artifactType, null);
- Optional<MibEntity> retrieved = mibDao.getByType(mibEntity);
-
- if (!retrieved.isPresent()) {
- throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
- mibEntity.getEntityType(),
- artifactType.name(),
- VspDetails.ENTITY_TYPE,
- mibEntity.getFirstClassCitizenId(),
- version).build());
- }
-
- mibDao.delete(retrieved.get());
-
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
- }
-
- @Override
- public void upload(InputStream object, String filename, String vspId,
- Version version, String componentId, ArtifactType artifactType,
- String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
-
- if (object == null) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPLOAD_MIB, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid MIB zip file");
- throw new CoreException(new MibUploadErrorBuilder(
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()).build());
- } else {
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- try {
- byte[] uploadedFileData = FileUtils.toByteArray(object);
- validateMibZipContent(vspId, version, uploadedFileData, errors);
- if (MapUtils.isNotEmpty(errors)) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPLOAD_MIB, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid MIB zip file");
- throw new CoreException(
- new MibUploadErrorBuilder(errors.values().iterator().next().get(0).getMessage())
- .build());
- }
-
- createArtifactInDatabase(vspId, version, filename, componentId, artifactType,
- uploadedFileData);
-
- } catch (Exception exception) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPLOAD_MIB, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid MIB zip file");
- throw new CoreException(new MibUploadErrorBuilder(exception.getMessage()).build());
- }
- }
-
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
- ActivityType.UPLOAD_ARTIFACT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
-
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
- }
-
- private void createArtifactInDatabase(String vspId, Version version, String filename,
- String componentId, ArtifactType artifactType,
- byte[] uploadedFileData) {
- String artifactId = CommonMethods.nextUuId();
- MibEntity mibEntity =
- setValuesForComponentArtifactEntityUpload(vspId, version, filename, componentId,
- artifactId, artifactType, uploadedFileData);
- mibDao.create(mibEntity);
- }
-
- @Override
- public MibUploadStatus listFilenames(String vspId, Version version, String componentId,
- String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
-
- MibEntity current =
- new MibEntity(vspId, version, componentId, null);
-
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
-
- return setMibUploadStatusValues(current);
- }
-
-
- private MibUploadStatus setMibUploadStatusValues(
- MibEntity mibEntity) {
- MibUploadStatus mibUploadStatus = new MibUploadStatus();
-
- Collection<MibEntity> artifactNames =
- mibDao.list(mibEntity);
- Map<ArtifactType, String> artifactTypeToFilename =
- VendorSoftwareProductUtils.filterNonTrapOrPollArtifacts(artifactNames);
-
- if (MapUtils.isNotEmpty(artifactTypeToFilename)) {
- if (artifactTypeToFilename.containsKey(ArtifactType.SNMP_TRAP)) {
- mibUploadStatus.setSnmpTrap(artifactTypeToFilename.get(ArtifactType.SNMP_TRAP));
- }
- if (artifactTypeToFilename.containsKey(ArtifactType.SNMP_POLL)) {
- mibUploadStatus.setSnmpPoll(artifactTypeToFilename.get(ArtifactType.SNMP_POLL));
- }
- }
-
- return mibUploadStatus;
- }
-
- private MibEntity setValuesForComponentArtifactEntityUpload(
- String vspId, Version version, String filename, String componentId, String artifactId,
- ArtifactType artifactType, byte[] uploadedFileData) {
-
- MibEntity mibEntity = new MibEntity();
-
- mibEntity.setVspId(vspId);
- mibEntity.setVersion(version);
- mibEntity.setComponentId(componentId);
- mibEntity.setId(artifactId);
- mibEntity.setType(artifactType);
- mibEntity.setArtifactName(filename);
-
- if (Objects.nonNull(uploadedFileData)) {
- mibEntity.setArtifact(ByteBuffer.wrap(uploadedFileData));
- }
-
- return mibEntity;
- }
-
- private void validateMibZipContent(String vspId, Version version, byte[] uploadedFileData,
- Map<String, List<ErrorMessage>> errors) {
- FileContentHandler contentMap;
- try {
- contentMap = CommonUtil.loadUploadFileContent(uploadedFileData);
- VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
- } catch (IOException exception) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_MIB, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid MIB zip file");
- throw new CoreException(
- new MibUploadErrorBuilder(vspId, version, Messages.INVALID_ZIP_FILE.getErrorMessage())
- .build());
- }
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
index 8c887e0140..6569312f02 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
@@ -21,17 +21,17 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.MibManager;
-import org.openecomp.sdc.vendorsoftwareproduct.MibManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
+import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
-public class MibManagerFactoryImpl extends MibManagerFactory {
- private static final MibManager INSTANCE =
- new MibManagerImpl(MibDaoFactory.getInstance().createInterface(),
+public class MonitoringUploadsManagerFactoryImpl extends MonitoringUploadsManagerFactory {
+ private static final MonitoringUploadsManager INSTANCE =
+ new MonitoringUploadsManagerImpl(MonitoringUploadDaoFactory.getInstance().createInterface(),
ActivityLogManagerFactory.getInstance().createInterface());
@Override
- public MibManager createInterface() {
+ public MonitoringUploadsManager createInterface() {
return INSTANCE;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
new file mode 100644
index 0000000000..73558b465a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
@@ -0,0 +1,269 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.core.enrichment.types.MonitoringUploadType;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.activityLog.ActivityLogManager;
+import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.utils.CommonUtil;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.MonitoringUploadErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
+import org.openecomp.sdcrests.activitylog.types.ActivityType;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private ActivityLogManager activityLogManager;
+ private ComponentArtifactDao componentArtifactDao;
+ private static final Logger logger =
+ LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
+
+ MonitoringUploadsManagerImpl(ComponentArtifactDao componentArtifactDao,
+ ActivityLogManager activityLogManager) {
+ this.componentArtifactDao = componentArtifactDao;
+
+ this.activityLogManager = activityLogManager;
+ componentArtifactDao.registerVersioning(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ }
+
+ @Override
+ public void delete(String vspId, Version version, String componentId,
+ MonitoringUploadType monitoringUploadType, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity =
+ setValuesForComponentArtifactEntityUpload(vspId, version, null, componentId, null,
+ monitoringUploadType, null);
+ Optional<ComponentMonitoringUploadEntity> retrieved = componentArtifactDao.getByType(
+ componentMonitoringUploadEntity);
+
+ if (!retrieved.isPresent()) {
+ throw new CoreException(new VersionableSubEntityNotFoundErrorBuilder(
+ componentMonitoringUploadEntity.getEntityType(),
+ monitoringUploadType.name(),
+ VspDetails.ENTITY_TYPE,
+ componentMonitoringUploadEntity.getFirstClassCitizenId(),
+ version).build());
+ }
+
+ componentArtifactDao.delete(retrieved.get());
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ @Override
+ public void upload(InputStream object, String filename, String vspId,
+ Version version, String componentId,
+ MonitoringUploadType type,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ if (object == null) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPLOAD_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid " + type
+ .toString() + " zip file");
+ throw new CoreException(new MonitoringUploadErrorBuilder(
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()).build());
+ } else {
+ Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ try {
+ byte[] uploadedFileData = FileUtils.toByteArray(object);
+ final FileContentHandler upload =
+ validateZip(vspId, version, uploadedFileData, errors);
+ if (type.equals(MonitoringUploadType.VES_EVENTS)) {
+ validateVesEventUpload(upload, errors, vspId, version);
+ }
+ if (MapUtils.isNotEmpty(errors)) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPLOAD_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid " + type
+ .toString() + " zip file");
+ throw new CoreException(
+ new MonitoringUploadErrorBuilder(
+ errors.values().iterator().next().get(0).getMessage())
+ .build());
+ }
+
+ createArtifactInDatabase(vspId, version, filename, componentId, type,
+ uploadedFileData);
+
+ } catch (Exception exception) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPLOAD_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid " + type.toString() + "zip file");
+ throw new CoreException(new MonitoringUploadErrorBuilder(exception.getMessage()).build());
+ }
+ }
+
+ ActivityLogEntity activityLogEntity =
+ new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
+ ActivityType.UPLOAD_MONITORING_FILE.toString(), user, true, "", "");
+ activityLogManager.addActionLog(activityLogEntity, user);
+ logger.audit("Uploaded Monitoring File for component id:" + componentId + " ,vspId:" + vspId);
+
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ private void validateVesEventUpload(FileContentHandler upload,
+ Map<String, List<ErrorMessage>> errors, String vspId,
+ Version version) {
+ if (!CommonUtil.validateAllFilesYml(upload)) {
+ ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR,
+ Messages.VES_ZIP_SHOULD_CONTAIN_YML_ONLY.getErrorMessage()));
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.VALIDATE_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VES_FILE);
+ throw new CoreException(
+ new MonitoringUploadErrorBuilder(
+ Messages.VES_ZIP_SHOULD_CONTAIN_YML_ONLY.getErrorMessage())
+ .build());
+ }
+ }
+
+ private void createArtifactInDatabase(String vspId, Version version, String filename,
+ String componentId,
+ MonitoringUploadType type,
+ byte[] uploadedFileData) {
+ String artifactId = CommonMethods.nextUuId();
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity =
+ setValuesForComponentArtifactEntityUpload(vspId, version, filename, componentId,
+ artifactId, type, uploadedFileData);
+ componentArtifactDao.create(componentMonitoringUploadEntity);
+ }
+
+ @Override
+ public MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ComponentMonitoringUploadEntity current =
+ new ComponentMonitoringUploadEntity(vspId, version, componentId, null);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ return setMonitoringUploadStatusValues(current);
+ }
+
+
+ private MonitoringUploadStatus setMonitoringUploadStatusValues(
+ ComponentMonitoringUploadEntity componentMonitoringUploadEntity) {
+ MonitoringUploadStatus monitoringUploadStatus = new MonitoringUploadStatus();
+
+ Collection<ComponentMonitoringUploadEntity> artifactNames =
+ componentArtifactDao.list(componentMonitoringUploadEntity);
+ Map<MonitoringUploadType, String> artifactTypeToFilename =
+ VendorSoftwareProductUtils.mapArtifactsByType(artifactNames);
+
+ if (MapUtils.isNotEmpty(artifactTypeToFilename)) {
+ if (artifactTypeToFilename.containsKey(MonitoringUploadType.SNMP_TRAP)) {
+ monitoringUploadStatus
+ .setSnmpTrap(artifactTypeToFilename.get(MonitoringUploadType.SNMP_TRAP));
+ }
+ if (artifactTypeToFilename.containsKey(MonitoringUploadType.SNMP_POLL)) {
+ monitoringUploadStatus
+ .setSnmpPoll(artifactTypeToFilename.get(MonitoringUploadType.SNMP_POLL));
+ }
+ if (artifactTypeToFilename.containsKey(MonitoringUploadType.VES_EVENTS)) {
+ monitoringUploadStatus
+ .setVesEvent(artifactTypeToFilename.get(MonitoringUploadType.VES_EVENTS));
+ }
+ }
+
+ return monitoringUploadStatus;
+ }
+
+ private ComponentMonitoringUploadEntity setValuesForComponentArtifactEntityUpload(
+ String vspId, Version version, String filename, String componentId, String artifactId,
+ MonitoringUploadType monitoringUploadType, byte[] uploadedFileData) {
+
+ ComponentMonitoringUploadEntity
+ entity = new ComponentMonitoringUploadEntity();
+
+ entity.setVspId(vspId);
+ entity.setVersion(version);
+ entity.setComponentId(componentId);
+ entity.setId(artifactId);
+ entity.setType(monitoringUploadType);
+ entity.setArtifactName(filename);
+
+ if (Objects.nonNull(uploadedFileData)) {
+ entity.setArtifact(ByteBuffer.wrap(uploadedFileData));
+ }
+
+ return entity;
+ }
+
+ private FileContentHandler validateZip(String vspId, Version version, byte[] uploadedFileData,
+ Map<String, List<ErrorMessage>> errors) {
+ FileContentHandler contentMap;
+ try {
+ contentMap = CommonUtil.validateAndUploadFileContent(uploadedFileData);
+ VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
+ } catch (IOException exception) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.VALIDATE_MONITORING_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid Monitoring zip file");
+ throw new CoreException(
+ new MonitoringUploadErrorBuilder(vspId, version,
+ Messages.INVALID_ZIP_FILE.getErrorMessage())
+ .build());
+ }
+ return contentMap;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
index 1d911701f9..6110519d81 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
@@ -24,6 +24,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.NetworkManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
import org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
public class NicManagerFactoryImpl extends NicManagerFactory {
@@ -31,7 +32,8 @@ public class NicManagerFactoryImpl extends NicManagerFactory {
new NicManagerImpl(
NicDaoFactory.getInstance().createInterface(),
CompositionEntityDataManagerFactory.getInstance().createInterface(),
- NetworkManagerFactory.getInstance().createInterface());
+ NetworkManagerFactory.getInstance().createInterface(),
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface());
@Override
public NicManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
index d73e0f5def..b196b3f54c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
@@ -22,6 +22,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
@@ -31,20 +32,30 @@ import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.CompositionEditNotAllowedErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DeleteNicErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DuplicateNicInComponentErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicNetworkIdNotAllowedExternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.NicCompositionSchemaInput;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -58,13 +69,16 @@ public class NicManagerImpl implements NicManager {
private NicDao nicDao;
private CompositionEntityDataManager compositionEntityDataManager;
private NetworkManager networkManager;
+ private VendorSoftwareProductInfoDao vspInfoDao;
public NicManagerImpl(NicDao nicDao,
CompositionEntityDataManager compositionEntityDataManager,
- NetworkManager networkManager) {
+ NetworkManager networkManager,
+ VendorSoftwareProductInfoDao vspInfoDao) {
this.nicDao = nicDao;
this.compositionEntityDataManager = compositionEntityDataManager;
this.networkManager = networkManager;
+ this.vspInfoDao = vspInfoDao;
}
@Override
@@ -96,15 +110,21 @@ public class NicManagerImpl implements NicManager {
@Override
public NicEntity createNic(NicEntity nic, String user) {
+ NicEntity createdNic = null;
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", nic.getVspId(),
nic.getComponentId());
- if (!isManual(nic.getVspId(), nic.getVersion())) {
+ if (!vspInfoDao.isManual(nic.getVspId(), nic.getVersion())) {
+ ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
+ .getAddNicNotSupportedHeatOnboardMethodErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create nic");
- throw new CoreException(
- new CompositionEditNotAllowedErrorBuilder(nic.getVspId(), nic.getVersion()).build());
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ onboardingMethodUpdateErrorCode.message());
+ throw new CoreException(onboardingMethodUpdateErrorCode);
+ } else {
+ validateNic(nic, user);
+ createdNic = createNic(nic);
}
//nicDao.updateVspLatestModificationTime(nic.getVspId(), nic.getVersion());
@@ -112,7 +132,63 @@ public class NicManagerImpl implements NicManager {
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", nic.getVspId(), nic.getComponentId());
- return null;
+ return createdNic;
+ }
+
+ private NicEntity createNic(NicEntity nic) {
+ return compositionEntityDataManager.createNic(nic);
+ }
+
+ private void validateNic(NicEntity nic, String user) {
+ Collection<NicEntity> listNics = listNics(nic.getVspId(), nic.getVersion(), nic
+ .getComponentId(), user);
+ String networkId = nic.getNicCompositionData().getNetworkId();
+ NetworkType networkType = nic.getNicCompositionData().getNetworkType();
+ String networkDescription = nic.getNicCompositionData().getNetworkDescription();
+ listNics.forEach(nicEntity -> {
+ Nic nicdata = nicEntity.getNicCompositionData();
+ if (nic.getNicCompositionData().getName().equalsIgnoreCase(nicdata.getName())) {
+ final ErrorCode duplicateNicInComponentErrorBuilder =
+ new DuplicateNicInComponentErrorBuilder(nic.getNicCompositionData().getName(),
+ nic.getComponentId()).build();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateNicInComponentErrorBuilder.message());
+ throw new CoreException(duplicateNicInComponentErrorBuilder);
+ }
+
+ });
+
+ if (networkType.equals(NetworkType.Internal)) {
+ if (!(networkId == null || networkId.equals(""))) {
+ //NetworkEntity ne = getNetwork(nic.getVspId(), activeVersion, networkId);
+ final CompositionEntityResponse<Network> network =
+ networkManager.getNetwork(nic.getVspId(), nic.getVersion(), networkId,
+ user);
+ }
+
+ if (!(networkDescription == null || networkDescription.equals(""))) {
+ final ErrorCode nicNetworkDescriptionErrorBuilder =
+ new NicInternalNetworkErrorBuilder()
+ .getNetworkDescriptionInternalNetworkErrorBuilder();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), nicNetworkDescriptionErrorBuilder.message());
+ throw new CoreException(nicNetworkDescriptionErrorBuilder);
+ }
+
+ } else if (networkType.equals(NetworkType.External)) {
+ if (!(networkId == null || networkId.equals(""))) {
+ final ErrorCode nicNetworkIdNotAllowedExternalNetworkErrorBuilder =
+ new NicNetworkIdNotAllowedExternalNetworkErrorBuilder().build();
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ nicNetworkIdNotAllowedExternalNetworkErrorBuilder.message());
+ throw new CoreException(nicNetworkIdNotAllowedExternalNetworkErrorBuilder);
+ }
+ }
}
@Override
@@ -125,7 +201,7 @@ public class NicManagerImpl implements NicManager {
Nic nic = nicEntity.getNicCompositionData();
NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
- schemaInput.setManual(isManual(vspId, version));
+ schemaInput.setManual(vspInfoDao.isManual(vspId, version));
schemaInput.setNic(nic);
Map<String, String> networksNameById = listNetworksNameById(vspId, version, user);
nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
@@ -157,15 +233,20 @@ public class NicManagerImpl implements NicManager {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
- if (!isManual(vspId, version)) {
+ if (!vspInfoDao.isManual(vspId, version)) {
+ final ErrorCode deleteNicErrorBuilder =
+ new DeleteNicErrorBuilder().getDeleteNicForHeatOnboardedVspErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_NIC, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete nic");
- throw new CoreException(
- new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ deleteNicErrorBuilder.message());
+ throw new CoreException(deleteNicErrorBuilder);
}
- //nicDao.updateVspLatestModificationTime(vspId, version);
+ NicEntity nicEntity = getNic(vspId, version, componentId, nicId);
+ if (nicEntity != null) {
+ nicDao.delete(nicEntity);
+ }
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", vspId, componentId, nicId);
@@ -181,7 +262,7 @@ public class NicManagerImpl implements NicManager {
getNic(nic.getVspId(), nic.getVersion(), nic.getComponentId(), nic.getId());
NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
- schemaInput.setManual(isManual(nic.getVspId(), nic.getVersion()));
+ schemaInput.setManual(vspInfoDao.isManual(nic.getVspId(), nic.getVersion()));
schemaInput.setNic(retrieved.getNicCompositionData());
CompositionEntityValidationData validationData = compositionEntityDataManager
@@ -244,7 +325,7 @@ public class NicManagerImpl implements NicManager {
}
// todo *************************** move to reusable place! *************************
- private boolean isManual(String vspId, Version version) {
+ /*private boolean isManual(String vspId, Version version) {
return false;
- }
+ }*/
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
index 77d496f0c8..b5464e5708 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
@@ -22,12 +22,11 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
-import org.openecomp.sdc.activitylog.dao.ActivityLogDaoFactory;
import org.openecomp.sdc.healing.factory.HealingManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
@@ -51,7 +50,7 @@ public class OrchestrationTemplateCandidateManagerFactoryImpl extends
CompositionEntityDataManagerFactory.getInstance().createInterface(),
NicDaoFactory.getInstance().createInterface(),
ComponentDaoFactory.getInstance().createInterface(),
- MibDaoFactory.getInstance().createInterface(),
+ MonitoringUploadDaoFactory.getInstance().createInterface(),
ProcessDaoFactory.getInstance().createInterface(),
ActivityLogManagerFactory.getInstance().createInterface());
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
index 99a438f3a8..959cf15789 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
@@ -19,14 +19,12 @@
*/
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues
- .PROCESS_NAME;
+
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.apache.xalan.xslt.Process;
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.types.ServiceElement;
+import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
@@ -55,14 +53,16 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
@@ -79,24 +79,25 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStru
import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdcrests.activitylog.types.ActivityType;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Collection;
+
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME;
public class OrchestrationTemplateCandidateManagerImpl
implements OrchestrationTemplateCandidateManager {
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static final Logger logger =
LoggerFactory.getLogger(OrchestrationTemplateCandidateManagerImpl.class);
-
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private VendorSoftwareProductDao vendorSoftwareProductDao;
private VendorSoftwareProductInfoDao vspInfoDao;
private OrchestrationTemplateDao orchestrationTemplateDataDao;
@@ -107,10 +108,27 @@ public class OrchestrationTemplateCandidateManagerImpl
private CompositionEntityDataManager compositionEntityDataManager;
private NicDao nicDao;
private ComponentDao componentDao;
- private MibDao mibDao;
+ private ComponentArtifactDao componentArtifactDao;
private ActivityLogManager activityLogManager;
private ProcessDao processDao;
+ /**
+ * Instantiates a new Orchestration template candidate manager.
+ *
+ * @param vendorSoftwareProductDao the vendor software product dao
+ * @param vspInfoDao the vsp info dao
+ * @param orchestrationTemplateDataDao the orchestration template data dao
+ * @param candidateService the candidate service
+ * @param healingManager the healing manager
+ * @param compositionDataExtractor the composition data extractor
+ * @param serviceModelDao the service model dao
+ * @param compositionEntityDataManager the composition entity data manager
+ * @param nicDao the nic dao
+ * @param componentDao the component dao
+ * @param componentArtifactDao the mib dao
+ * @param processDao the process dao
+ * @param activityLogManager the activity log manager
+ */
public OrchestrationTemplateCandidateManagerImpl(
VendorSoftwareProductDao vendorSoftwareProductDao, VendorSoftwareProductInfoDao
vspInfoDao,
@@ -121,7 +139,7 @@ public class OrchestrationTemplateCandidateManagerImpl
CompositionEntityDataManager compositionEntityDataManager,
NicDao nicDao,
ComponentDao componentDao,
- MibDao mibDao,
+ ComponentArtifactDao componentArtifactDao,
ProcessDao processDao,
ActivityLogManager activityLogManager) {
this.vendorSoftwareProductDao = vendorSoftwareProductDao;
@@ -134,7 +152,7 @@ public class OrchestrationTemplateCandidateManagerImpl
this.compositionEntityDataManager = compositionEntityDataManager;
this.nicDao = nicDao;
this.componentDao = componentDao;
- this.mibDao = mibDao;
+ this.componentArtifactDao = componentArtifactDao;
this.processDao = processDao;
this.activityLogManager = activityLogManager;
}
@@ -237,38 +255,43 @@ public class OrchestrationTemplateCandidateManagerImpl
String manifest = candidateService.createManifest(vspDetails, structure);
fileContentMap.addFile(SdcCommon.MANIFEST_NAME, manifest.getBytes());
- HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap);
-
Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
.fetchZipFileByteArrayInputStream(vspId, candidateDataEntity, manifest, uploadErrors);
if (!zipByteArrayInputStream.isPresent()) {
return response;
}
- Map<String,String> componentsQustanniare = new HashMap<>();
- Map<String, Map<String, String>> componentNicsQustanniare = new HashMap<>();
- Map<String, Collection<MibEntity>> componentMIBList = new HashMap<>();
+
+ HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap);
+
+ Map<String, String> componentsQuestionnaire = new HashMap<>();
+ Map<String, Map<String, String>> componentNicsQuestionnaire = new HashMap<>();
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList = new HashMap<>();
Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
Map<String, ProcessEntity> processArtifact = new HashMap<>();
- backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQustanniare,
- componentNicsQustanniare, componentMIBList, processes, processArtifact);
+ backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQuestionnaire,
+ componentNicsQuestionnaire, componentMibList, processes, processArtifact);
deleteUploadDataAndContent(vspId, version);
saveHotData(vspId, version, zipByteArrayInputStream.get(), fileContentMap, tree);
- ToscaServiceModel toscaServiceModel =
- HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap)
- .getToscaServiceModel();
+ TranslatorOutput translatorOutput =
+ HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap);
+ ToscaServiceModel toscaServiceModel = translatorOutput.getToscaServiceModel();
if (toscaServiceModel != null) {
serviceModelDao.storeServiceModel(vspId, version, toscaServiceModel);
+ //Extracting the compostion data from the output service model of the first phase of
+ // translation
compositionEntityDataManager.saveCompositionData(vspId, version,
- compositionDataExtractor.extractServiceCompositionData(toscaServiceModel));
- retainComponentQuestionnaireData(vspId, version, componentsQustanniare,
- componentNicsQustanniare, componentMIBList, processes, processArtifact);
+ compositionDataExtractor.extractServiceCompositionData(translatorOutput
+ .getNonUnifiedToscaServiceModel()));
+ retainComponentQuestionnaireData(vspId, version, componentsQuestionnaire,
+ componentNicsQuestionnaire, componentMibList, processes, processArtifact);
}
uploadFileResponse.addStructureErrors(uploadErrors);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspId, String.valueOf(version.getMajor()+1),
+ ActivityLogEntity activityLogEntity =
+ new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
ActivityType.UPLOAD_HEAT.toString(), user, true, "", "");
activityLogManager.addActionLog(activityLogEntity, user);
@@ -367,9 +390,10 @@ public class OrchestrationTemplateCandidateManagerImpl
private void retainComponentQuestionnaireData(String vspId, Version activeVersion,
Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>> componentNicsQustanniare,
- Map<String, Collection<MibEntity>> componentMIBList,
- Map<String,Collection<ProcessEntity>> processes,
+ Map<String, Map<String, String>>
+ componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
+ Map<String, Collection<ProcessEntity>> processes,
Map<String, ProcessEntity> processArtifact) {
//VSP processes
restoreProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID, processes,
@@ -378,27 +402,31 @@ public class OrchestrationTemplateCandidateManagerImpl
components = vendorSoftwareProductDao.listComponents(vspId, activeVersion);
components.forEach(componentEntity -> {
String componentName = componentEntity.getComponentCompositionData().getName();
- if( componentsQustanniare.containsKey(componentName) ){
+ if (componentsQustanniare.containsKey(componentName)) {
componentDao.updateQuestionnaireData(vspId, activeVersion,
- componentEntity.getId(),componentsQustanniare.get(componentEntity.getComponentCompositionData()
+ componentEntity.getId(),
+ componentsQustanniare.get(componentEntity.getComponentCompositionData()
.getName()));
- if( componentNicsQustanniare.containsKey(componentName) ){
- Map<String, String> nicsQustanniare=componentNicsQustanniare.get(componentName);
+ if (componentNicsQustanniare.containsKey(componentName)) {
+ Map<String, String> nicsQustanniare = componentNicsQustanniare.get(componentName);
Collection<NicEntity>
- nics=nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
- nics.forEach(nicEntity -> {
- if(nicsQustanniare.containsKey(nicEntity.getNicCompositionData().getName())){
- nicDao.updateQuestionnaireData(vspId, activeVersion,componentEntity.getId
- (),nicEntity.getId(),nicsQustanniare.get(nicEntity.getNicCompositionData().getName()));
+ nics =
+ nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
+ nics.forEach(nicEntity -> {
+ if (nicsQustanniare.containsKey(nicEntity.getNicCompositionData().getName())) {
+ nicDao.updateQuestionnaireData(vspId, activeVersion,
+ componentEntity.getId(), nicEntity.getId(),
+ nicsQustanniare.get(nicEntity.getNicCompositionData().getName()));
}
});
}
- //MIB
- if(componentMIBList.containsKey(componentName)) {
- Collection<MibEntity> mibList = componentMIBList.get(componentName);
+ //MIB //todo add for VES_EVENTS
+ if (componentMibList.containsKey(componentName)) {
+ Collection<ComponentMonitoringUploadEntity> mibList =
+ componentMibList.get(componentName);
mibList.forEach(mib -> {
mib.setComponentId(componentEntity.getId());
- mibDao.create(mib);
+ componentArtifactDao.create(mib);
});
}
//VFC processes
@@ -411,43 +439,47 @@ public class OrchestrationTemplateCandidateManagerImpl
private void backupComponentsQuestionnaireBeforeDelete(String vspId, Version activeVersion,
Map<String, String> componentsQustanniare,
Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<MibEntity>>
- componentMIBList,
- Map<String, Collection<ProcessEntity>> componentProcesses,
+ componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>>
+ componentMibList,
+ Map<String, Collection<ProcessEntity>>
+ componentProcesses,
Map<String, ProcessEntity> processArtifact) {
//backup VSP processes
backupProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID,
- componentProcesses,processArtifact);
- Collection<ComponentEntity> componentsCompositionAndQuestionnaire= vendorSoftwareProductDao
+ componentProcesses, processArtifact);
+ Collection<ComponentEntity> componentsCompositionAndQuestionnaire = vendorSoftwareProductDao
.listComponentsCompositionAndQuestionnaire(vspId,
activeVersion);
- componentsCompositionAndQuestionnaire.forEach(componentEntity ->{
- String componentName=componentEntity.getComponentCompositionData().getName();
- componentsQustanniare.put(componentName,componentEntity
+ componentsCompositionAndQuestionnaire.forEach(componentEntity -> {
+ String componentName = componentEntity.getComponentCompositionData().getName();
+ componentsQustanniare.put(componentName, componentEntity
.getQuestionnaireData());
Collection<NicEntity>
- nics=nicDao.list(new NicEntity(vspId, activeVersion,componentEntity.getId(),null));
+ nics = nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
//backup mib
- Collection<MibEntity> componentMIB = mibDao.listArtifacts(new
- MibEntity(vspId, activeVersion, componentEntity.getId(), null));
- if(CollectionUtils.isNotEmpty(componentMIB)){
- componentMIBList.put(componentName,componentMIB);
+ Collection<ComponentMonitoringUploadEntity> componentMib =
+ componentArtifactDao.listArtifacts(new
+ ComponentMonitoringUploadEntity(vspId, activeVersion, componentEntity.getId(),
+ null));
+ if(CollectionUtils.isNotEmpty(componentMib)){
+ componentMibList.put(componentName,componentMib);
}
//backup component processes
backupProcess(vspId, activeVersion, componentEntity.getId(), componentName,
- componentProcesses,processArtifact);
- if(CollectionUtils.isNotEmpty(nics)) {
+ componentProcesses, processArtifact);
+ if (CollectionUtils.isNotEmpty(nics)) {
Map<String, String> nicsQustanniare = new HashMap<>();
nics.forEach(nicEntity -> {
- NicEntity nic = nicDao.get(new NicEntity(vspId, activeVersion, componentEntity.getId(),
- nicEntity.getId()));
- NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId,activeVersion,
- componentEntity.getId(),nicEntity.getId());
+ NicEntity nic = nicDao.get(new NicEntity(vspId, activeVersion, componentEntity.getId(),
+ nicEntity.getId()));
+ NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, activeVersion,
+ componentEntity.getId(), nicEntity.getId());
nicsQustanniare
- .put(nicEntity.getNicCompositionData().getName(), nicQuestionnaire.getQuestionnaireData());
+ .put(nicEntity.getNicCompositionData().getName(),
+ nicQuestionnaire.getQuestionnaireData());
});
componentNicsQustanniare.put(componentName, nicsQustanniare);
}
@@ -456,17 +488,18 @@ public class OrchestrationTemplateCandidateManagerImpl
private void backupProcess(String vspId, Version activeVersion, String componentId,
String componentName, Map<String,
- Collection<ProcessEntity>> processes,
- Map<String,ProcessEntity> processArtifact){
+ Collection<ProcessEntity>> processes,
+ Map<String, ProcessEntity> processArtifact) {
Collection<ProcessEntity> processList = vendorSoftwareProductDao.listProcesses(vspId,
activeVersion, componentId);
- if(!processList.isEmpty()){
- processes.put(componentName,processList);
+ if (!processList.isEmpty()) {
+ processes.put(componentName, processList);
processList.forEach(process -> {
//ProcessArtifactEntity artifact = vendorSoftwareProductDao.getProcessArtifact(vspId,
// activeVersion, componentId, process.getId());
- ProcessEntity artifact = processDao.get(new ProcessEntity(vspId,activeVersion,componentId,process.getId()));
- if(artifact.getArtifact()!=null) {
+ ProcessEntity artifact =
+ processDao.get(new ProcessEntity(vspId, activeVersion, componentId, process.getId()));
+ if (artifact.getArtifact() != null) {
processArtifact.put(process.getId(), artifact);
}
});
@@ -474,9 +507,10 @@ public class OrchestrationTemplateCandidateManagerImpl
}
private void restoreProcess(String vspId, Version activeVersion, String componentId,
- String componentName, Map<String, Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact){
- if(processes.containsKey(componentName)) {
+ String componentName,
+ Map<String, Collection<ProcessEntity>> processes,
+ Map<String, ProcessEntity> processArtifact) {
+ if (processes.containsKey(componentName)) {
Collection<ProcessEntity> processList = processes.get(componentName);
processList.forEach(process -> {
//Reatin VFC process
@@ -550,7 +584,7 @@ public class OrchestrationTemplateCandidateManagerImpl
byte[] uploadedFileData) {
FileContentHandler contentMap = null;
try {
- contentMap = CommonUtil.loadUploadFileContent(uploadedFileData);
+ contentMap = CommonUtil.validateAndUploadFileContent(uploadedFileData);
} catch (IOException exception) {
uploadFileResponse.addStructureError(
SdcCommon.UPLOAD_FILE,
@@ -574,7 +608,7 @@ public class OrchestrationTemplateCandidateManagerImpl
return healingParams;
}
- public VspDetails getVspDetails(String vspId, Version version) {
+ private VspDetails getVspDetails(String vspId, Version version) {
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
vspDetails.setValidationData(orchestrationTemplateDataDao.getValidationData(vspId, version));
return vspDetails;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
index 4fa67ff2d3..339e05c16f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
@@ -225,7 +225,7 @@ public class ProcessManagerImpl implements ProcessManager {
vendorSoftwareProductDao.uploadProcessArtifact(vspId, version, componentId, processId, artifact,
artifactFileName);
ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspId, String.valueOf(version.getMajor()+1),
- ActivityType.UPLOAD_ARTIFACT.toString(), user, true, "", "");
+ ActivityType.UPLOAD_MONITORING_FILE.toString(), user, true, "", "");
activityLogManager.addActionLog(activityLogEntity, user);
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 995044588c..0b48c334c6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -42,6 +42,7 @@ import org.openecomp.sdc.common.utils.CommonUtil;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -56,8 +57,11 @@ import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
+import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
@@ -65,15 +69,22 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.CreatePackageForNonFinalVendorSoftwareProductErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DeploymentFlavorErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.FileCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.InformationArtifactCreationErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.OnboardingMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageInvalidErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
@@ -82,12 +93,18 @@ import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataMana
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ComponentValidationResult;
+import org.openecomp.sdc.vendorsoftwareproduct.types.DeploymentFlavorValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQuestionnaireSchemaInput;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
@@ -115,8 +132,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -141,8 +160,29 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private InformationArtifactGenerator informationArtifactGenerator;
private PackageInfoDao packageInfoDao;
private ActivityLogManager activityLogManager;
-
-
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private NicDao nicDao;
+ private ManualVspToscaManager manualVspToscaManager;
+
+ /**
+ * Instantiates a new Vendor software product manager.
+ *
+ * @param versioningManager the versioning manager
+ * @param vendorSoftwareProductDao the vendor software product dao
+ * @param orchestrationTemplateDataDao the orchestration template data dao
+ * @param vspInfoDao the vsp info dao
+ * @param vendorLicenseFacade the vendor license facade
+ * @param serviceModelDao the service model dao
+ * @param enrichedServiceModelDao the enriched service model dao
+ * @param healingManager the healing manager
+ * @param licenseArtifactsService the license artifacts service
+ * @param compositionEntityDataManager the composition entity data manager
+ * @param informationArtifactGenerator the information artifact generator
+ * @param packageInfoDao the package info dao
+ * @param activityLogManager the activity log manager
+ * @param deploymentFlavorDao the deployment flavor dao
+ * @param nicDao the nic dao
+ */
public VendorSoftwareProductManagerImpl(
VersioningManager versioningManager,
VendorSoftwareProductDao vendorSoftwareProductDao,
@@ -155,7 +195,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
VendorLicenseArtifactsService licenseArtifactsService,
InformationArtifactGenerator informationArtifactGenerator,
PackageInfoDao packageInfoDao,
- ActivityLogManager activityLogManager) {
+ ActivityLogManager activityLogManager,
+ DeploymentFlavorDao deploymentFlavorDao,
+ NicDao nicDao,
+ ManualVspToscaManager manualVspToscaManager) {
this.versioningManager = versioningManager;
this.vendorSoftwareProductDao = vendorSoftwareProductDao;
this.orchestrationTemplateDao = orchestrationTemplateDataDao;
@@ -168,6 +211,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
this.informationArtifactGenerator = informationArtifactGenerator;
this.packageInfoDao = packageInfoDao;
this.activityLogManager = activityLogManager;
+ this.deploymentFlavorDao = deploymentFlavorDao;
+ this.nicDao = nicDao;
+ this.manualVspToscaManager = manualVspToscaManager;
registerToVersioning();
}
@@ -276,8 +322,20 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
validationResponse
.setUploadDataErrors(validateUploadData(uploadData), LoggerServiceName.Submit_VSP,
LoggerTragetServiceName.SUBMIT_VSP);
+
validationResponse.setQuestionnaireValidationResult(
- validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion()));
+ validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(), vspDetails
+ .getOnboardingMethod()));
+
+ if (vspDetails.getOnboardingMethod().equals("Manual")) {
+ validationResponse.setDeploymentFlavorValidationResult(
+ deploymentFlavorValidation(vspDetails.getId(), vspDetails.getVersion()));
+ validationResponse.setComponentValidationResult(
+ componentValidation(vspDetails.getId(), vspDetails.getVersion()));
+ //Generate Tosca service model for Manual Onboarding flow
+ VspModelInfo vspModelInfo = manualVspToscaManager.gatherVspInformation(vspId, version, user);
+ serviceModel = manualVspToscaManager.generateToscaModel(vspModelInfo);
+ }
validationResponse.setCompilationErrors(
compile(vspId, vspDetails.getVersion(), serviceModel),
@@ -294,7 +352,6 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
-
return validationResponse;
}
@@ -310,43 +367,199 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return dependencyTracker.isCyclicDependencyPresent();
}
- private static List<ErrorCode> validateCompletedVendorSoftwareProduct(
+ private DeploymentFlavorValidationResult deploymentFlavorValidation(String vspId,
+ Version version) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ Set<CompositionEntityValidationData> validationData = new HashSet<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavors =
+ vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
+ if (!CollectionUtils.isEmpty(deploymentFlavors)) {
+ deploymentFlavors.forEach(deploymentFlavor -> {
+ DeploymentFlavorEntity deployment = vendorSoftwareProductDao.getDeploymentFlavor(vspId,
+ version, deploymentFlavor.getId());
+ DeploymentFlavor deploymentlocalFlavor = deployment.getDeploymentFlavorCompositionData();
+ if (deploymentlocalFlavor != null) {
+ if (deploymentlocalFlavor.getFeatureGroupId() == null ) {
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder.
+ getFeatureGroupMandatoryErrorBuilder();
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(CompositionEntityType.deployment,
+ deploymentFlavor.getId());
+ compositionEntityValidationData.setEntityName(deploymentlocalFlavor.getModel());
+ List<String> errors = new ArrayList<>();
+ errors.add(deploymentFlavorErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
+ List<ComponentComputeAssociation> componetComputeAssociations = new ArrayList<>();
+ componetComputeAssociations = deploymentlocalFlavor.getComponentComputeAssociations();
+ if (CollectionUtils.isEmpty(componetComputeAssociations)) {
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(CompositionEntityType.deployment,deploymentFlavor
+ .getId());
+ compositionEntityValidationData.setEntityName(deployment
+ .getDeploymentFlavorCompositionData().getModel());
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidComponentComputeAssociationErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(deploymentFlavorErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ } else {
+ componetComputeAssociations.forEach(componetComputeAssociation -> {
+ if (componetComputeAssociation == null
+ || !(componetComputeAssociation.getComponentId() != null
+ && componetComputeAssociation.getComputeFlavorId() != null)) {
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(CompositionEntityType.deployment,
+ deploymentFlavor.getId());
+ compositionEntityValidationData.setEntityName(deployment
+ .getDeploymentFlavorCompositionData().getModel());
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidComponentComputeAssociationErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(deploymentFlavorErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
+ });
+ }
+ }
+ });
+ }
+ if (CollectionUtils.isEmpty(validationData)) {
+ return null;
+ }
+ DeploymentFlavorValidationResult deploymentFlavorValidationResult = new
+ DeploymentFlavorValidationResult(validationData);
+ return deploymentFlavorValidationResult;
+
+ }
+
+ private ComponentValidationResult componentValidation(String vspId, Version version) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ Set<CompositionEntityValidationData> validationData = new HashSet<>();
+ Collection<ComponentEntity> components = vendorSoftwareProductDao.listComponents(vspId,version);
+ if (!CollectionUtils.isEmpty(components)) {
+ components.forEach(component -> {
+ validateImage(vspId, version, validationData, component);
+ validateNic(vspId, version, validationData, component);
+
+ });
+ }
+ if (CollectionUtils.isEmpty(validationData)) {
+ return null;
+ }
+ ComponentValidationResult componentValidationResult =
+ new ComponentValidationResult(validationData);
+ return componentValidationResult;
+ }
+
+ private void validateNic(String vspId, Version version,
+ Set<CompositionEntityValidationData> validationData,
+ ComponentEntity component) {
+ Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId,version, component.getId(),null));
+ if (CollectionUtils.isNotEmpty(nics)) {
+ nics.forEach(nicEntity -> {
+ NicEntity nic = nicDao.get(new NicEntity(vspId, version, component.getId(),
+ nicEntity.getId()));
+ NetworkType networkType = nic.getNicCompositionData().getNetworkType();
+ String networkId = nic.getNicCompositionData().getNetworkId();
+ if (networkType.equals(NetworkType.Internal) && networkId == null) {
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(CompositionEntityType.nic, nic.getId());
+ compositionEntityValidationData.setEntityName(nic.getNicCompositionData().getName());
+ ErrorCode nicInternalNetworkErrorBuilder = NicInternalNetworkErrorBuilder
+ .getNicNullNetworkIdInternalNetworkIdErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(nicInternalNetworkErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
+ });
+ }
+ }
+
+ private void validateImage(String vspId, Version version,
+ Set<CompositionEntityValidationData> validationData,
+ ComponentEntity component) {
+ Collection<ImageEntity> images = vendorSoftwareProductDao.listImages(vspId,version,
+ component.getId());
+ if (CollectionUtils.isEmpty(images)) {
+ CompositionEntityValidationData compositionEntityValidationData = new
+ CompositionEntityValidationData(component.getType(),component.getId());
+ compositionEntityValidationData.setEntityName(component.getComponentCompositionData()
+ .getDisplayName());
+ ErrorCode vfcMissingImageErrorBuilder =
+ ComponentErrorBuilder.VfcMissingImageErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(vfcMissingImageErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
+ }
+
+
+
+ private List<ErrorCode> validateCompletedVendorSoftwareProduct(
VspDetails vspDetails, UploadDataEntity uploadData, Object serviceModel) {
- List<ErrorCode> errros = new ArrayList<>();
+ List<ErrorCode> errors = new ArrayList<>();
if (vspDetails.getName() == null) {
- errros.add(createMissingMandatoryFieldError("name"));
+ errors.add(createMissingMandatoryFieldError("name"));
}
if (vspDetails.getDescription() == null) {
- errros.add(createMissingMandatoryFieldError("description"));
+ errors.add(createMissingMandatoryFieldError("description"));
}
if (vspDetails.getVendorId() == null) {
- errros.add(createMissingMandatoryFieldError("vendor Id"));
- }
- if (vspDetails.getVlmVersion() == null) {
- errros.add(createMissingMandatoryFieldError(
- "licensing version (in the format of: {integer}.{integer})"));
+ errors.add(createMissingMandatoryFieldError("vendor Id"));
}
if (vspDetails.getCategory() == null) {
- errros.add(createMissingMandatoryFieldError("category"));
+ errors.add(createMissingMandatoryFieldError("category"));
}
if (vspDetails.getSubCategory() == null) {
- errros.add(createMissingMandatoryFieldError("sub category"));
+ errors.add(createMissingMandatoryFieldError("sub category"));
+ }
+ if (vspDetails.getOnboardingMethod().equals("Manual")) {
+ //Manual Onboarding specific validations
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities = vendorSoftwareProductDao
+ .listDeploymentFlavors(vspDetails.getId(), vspDetails.getVersion());
+ if (CollectionUtils.isEmpty(deploymentFlavorEntities) ) {
+ ErrorCode vspMissingDeploymentFlavorErrorBuilder =
+ VendorSoftwareProductInvalidErrorBuilder.VspMissingDeploymentFlavorErrorBuilder();
+ errors.add(vspMissingDeploymentFlavorErrorBuilder);
+ }
+ errors.addAll(validateMandatoryLicenseFields(vspDetails));
+ } else {
+ //Heat flow specific VSP validations
+ if (uploadData == null || uploadData.getContentData() == null || serviceModel == null) {
+ errors.add(VendorSoftwareProductInvalidErrorBuilder
+ .VendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
+ vspDetails.getVersion()));
+ }
+ if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
+ || vspDetails.getFeatureGroups() != null) {
+ errors.addAll(validateMandatoryLicenseFields(vspDetails));
+ }
+ }
+ return errors.isEmpty() ? null : errors;
+ }
+
+ private List<ErrorCode> validateMandatoryLicenseFields(VspDetails vspDetails) {
+ List<ErrorCode> errors = new ArrayList<>();
+ if (vspDetails.getVlmVersion() == null) {
+ errors.add(createMissingMandatoryFieldError(
+ "licensing version (in the format of: {integer}.{integer})"));
}
if (vspDetails.getLicenseAgreement() == null) {
- errros.add(createMissingMandatoryFieldError("license agreement"));
+ errors.add(createMissingMandatoryFieldError("license agreement"));
}
if (CollectionUtils.isEmpty(vspDetails.getFeatureGroups())) {
- errros.add(createMissingMandatoryFieldError("feature groups"));
- }
- if (uploadData == null || uploadData.getContentData() == null || serviceModel == null) {
- errros.add(
- new VendorSoftwareProductInvalidErrorBuilder(vspDetails.getId(), vspDetails.getVersion())
- .build());
+ errors.add(createMissingMandatoryFieldError("feature groups"));
}
-
- return errros.isEmpty() ? null : errros;
+ return errors;
}
private static ErrorCode createMissingMandatoryFieldError(String fieldName) {
@@ -498,6 +711,20 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
mdcDataDebugMessage.debugEntryMessage("VSP id", vspDetails.getId());
VspDetails retrieved = vspInfoDao.get(vspDetails);
+ if (!retrieved.getOnboardingMethod().equals(vspDetails.getOnboardingMethod())) {
+ final ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
+ .getOnboardingUpdateError();
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPDATE_VSP, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), onboardingMethodUpdateErrorCode.message());
+
+ throw new CoreException(onboardingMethodUpdateErrorCode);
+ }
+
+ //If any existing feature group is removed from VSP which is also associated in DF then
+ //update DF to remove feature group associations.
+ updateDeploymentFlavor(vspDetails, user);
updateUniqueName(retrieved.getName(), vspDetails.getName());
vspDetails.setOldVersion(retrieved.getOldVersion());
@@ -508,6 +735,28 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
}
+ private void updateDeploymentFlavor(VspDetails vspDetails, String user) {
+ final List<String> featureGroups = vspDetails.getFeatureGroups();
+ if (featureGroups != null && !featureGroups.isEmpty() ) {
+ /*final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ listDeploymentFlavors(vspDetails.getId(), vspDetails.getVersion(), user);*/
+
+ final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao
+ .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails
+ .getVersion(), null));
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ final String featureGroupId =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData().getFeatureGroupId();
+ if ( !featureGroups.contains(featureGroupId)) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+ deploymentFlavorCompositionData.setFeatureGroupId(null);
+ vendorSoftwareProductDao.updateDeploymentFlavor(deploymentFlavorEntity);
+ }
+ }
+ }
+ }
+
@Override
public VspDetails getVsp(String vspId, Version version, String user) {
@@ -554,9 +803,12 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
Version finalVersion = checkinFinalVersion.calculateNextFinal();
createPackage(vspId, finalVersion, user);
return finalVersion;
- } catch (IOException e) {
- throw new Exception(e.getMessage());
+ } catch (IOException ex) {
+ throw new Exception(ex.getMessage());
}
+ default:
+ //do nothing
+ break;
}
return versionInfo.getActiveVersion();
}
@@ -798,15 +1050,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return null;
}
- FileContentHandler fileContentMap = new FileContentHandler();
-
- try {
- fileContentMap =
- CommonUtil.loadUploadFileContent(uploadData.getContentData().array());
- } catch (Exception e){
- ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, e.getMessage());
- validationErrors.put("Upload file", Arrays.asList(errorMessage));
- }
+ FileContentHandler fileContentMap =
+ CommonUtil.validateAndUploadFileContent(uploadData.getContentData().array());
+ //todo - check
ValidationManager validationManager =
ValidationManagerUtil.initValidationManager(fileContentMap);
validationErrors.putAll(validationManager.validate());
@@ -824,7 +1070,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
- private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version) {
+ private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version,
+ String onboardingMethod) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
// The apis of CompositionEntityDataManager used here are stateful!
@@ -854,6 +1101,14 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
JsonUtil.json2Object(component.getQuestionnaireData(), Map.class))));
+ Collection<ComputeEntity> computes = vendorSoftwareProductDao.listComputesByVsp(vspId, version);
+ computes.forEach(compute -> compositionEntityDataManager.addEntity(compute, null));
+
+ if ("Manual".equals(onboardingMethod) ) {
+ Collection<ImageEntity> images = vendorSoftwareProductDao.listImagesByVsp(vspId, version);
+ images.forEach(image -> compositionEntityDataManager.addEntity(image, null));
+ }
+
Map<CompositionEntityId, Collection<String>> errorsByEntityId =
compositionEntityDataManager.validateEntitiesQuestionnaire();
if (MapUtils.isNotEmpty(errorsByEntityId)) {
@@ -894,8 +1149,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
OutputStream out = new BufferedOutputStream(new FileOutputStream(infoArtifactFile));
out.write(infoArtifactAsByteBuffer.array());
out.close();
- } catch (IOException e) {
- throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), e);
+ } catch (IOException ex) {
+ throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), ex);
}
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
@@ -917,4 +1172,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
oldVspName, newVspName);
}
+
+ @Override
+ public Collection<ComputeEntity> getComputeByVsp(String vspId, Version version,
+ String user) {
+ return vendorSoftwareProductDao.listComputesByVsp(vspId, version);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
index 3751195d6c..44c9d155c6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
@@ -28,11 +28,15 @@ import org.openecomp.sdc.vendorlicense.VendorLicenseArtifactServiceFactory;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
public class VspManagerFactoryImpl extends VspManagerFactory {
@@ -49,7 +53,10 @@ public class VspManagerFactoryImpl extends VspManagerFactory {
VendorLicenseArtifactServiceFactory.getInstance().createInterface(),
InformationArtifactGeneratorFactory.getInstance().createInterface(),
PackageInfoDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface());
+ ActivityLogManagerFactory.getInstance().createInterface(),
+ DeploymentFlavorDaoFactory.getInstance().createInterface(),
+ NicDaoFactory.getInstance().createInterface(),
+ new ManualVspToscaManagerImpl());
@Override
public VendorSoftwareProductManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java
new file mode 100644
index 0000000000..8fa655138e
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResult.java
@@ -0,0 +1,24 @@
+package org.openecomp.sdc.vendorsoftwareproduct.types;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+
+import java.util.Set;
+
+public class ComponentValidationResult {
+ private boolean valid;
+ private Set<CompositionEntityValidationData> validationData;
+
+ public ComponentValidationResult(Set<CompositionEntityValidationData> validationData) {
+ this.validationData = validationData;
+ valid = validationData == null;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public Set<CompositionEntityValidationData> getValidationData() {
+ return validationData;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java
new file mode 100644
index 0000000000..6f02c98012
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResult.java
@@ -0,0 +1,25 @@
+package org.openecomp.sdc.vendorsoftwareproduct.types;
+
+
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+
+import java.util.Set;
+
+public class DeploymentFlavorValidationResult {
+ private boolean valid;
+ private Set<CompositionEntityValidationData> validationData;
+
+ public DeploymentFlavorValidationResult(Set<CompositionEntityValidationData> validationData){
+ this.validationData = validationData;
+ valid = validationData == null;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public Set<CompositionEntityValidationData> getValidationData() {
+ return validationData;
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java
new file mode 100644
index 0000000000..7306fe948f
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ListComputeResponse.java
@@ -0,0 +1,28 @@
+package org.openecomp.sdc.vendorsoftwareproduct.types;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+
+public class ListComputeResponse {
+
+ private ComputeEntity computeEntity;
+ private boolean associatedWithDeploymentFlavor;
+
+ public boolean isAssociatedWithDeploymentFlavor() {
+ return associatedWithDeploymentFlavor;
+ }
+
+ public void setAssociatedWithDeploymentFlavor(boolean associatedWithDeploymentFlavor) {
+ this.associatedWithDeploymentFlavor = associatedWithDeploymentFlavor;
+ }
+
+ public ComputeEntity getComputeEntity() {
+ return computeEntity;
+ }
+
+ public void setComputeEntity(
+ ComputeEntity computeEntity) {
+ this.computeEntity = computeEntity;
+ }
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
index eb03ba62b4..ea5bef13dc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java
@@ -22,10 +22,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.types;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.types.LoggerServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
@@ -41,6 +41,9 @@ public class ValidationResponse {
private Map<String, List<ErrorMessage>> uploadDataErrors;
private Map<String, List<ErrorMessage>> compilationErrors;
private QuestionnaireValidationResult questionnaireValidationResult;
+ private ComponentValidationResult componentValidationResult;
+ private DeploymentFlavorValidationResult deploymentFlavorValidationResult;
+
public boolean isValid() {
return valid;
@@ -67,6 +70,7 @@ public class ValidationResponse {
VendorSoftwareProductUtils.setErrorsIntoLogger(vspErrors, serviceName, targetServiceName);
}
+
public Collection<ErrorCode> getLicensingDataErrors() {
return licensingDataErrors;
}
@@ -145,4 +149,40 @@ public class ValidationResponse {
}
+ public ComponentValidationResult getComponentValidationResult() {
+ return componentValidationResult;
+ }
+
+ /**
+ * Sets Component validation result.
+ *
+ * @param componentValidationResult the Component validation result
+ */
+ public void setComponentValidationResult(
+ ComponentValidationResult componentValidationResult) {
+ this.componentValidationResult = componentValidationResult;
+ if (componentValidationResult != null && !componentValidationResult.isValid()) {
+ valid = false;
+ }
+ }
+
+
+ public DeploymentFlavorValidationResult getDeploymentFlavorValidationResult() {
+ return deploymentFlavorValidationResult;
+ }
+
+ /**
+ * Sets Deployment validation result.
+ *
+ * @param deploymentFlavorValidationResult the Deployment validation result
+ */
+ public void setDeploymentFlavorValidationResult(
+ DeploymentFlavorValidationResult deploymentFlavorValidationResult) {
+ this.deploymentFlavorValidationResult = deploymentFlavorValidationResult;
+ if (deploymentFlavorValidationResult != null && !deploymentFlavorValidationResult.isValid()) {
+ valid = false;
+ }
+ }
+
+
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MibUploadStatus.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java
index 046d53054e..ad604e822e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MibUploadStatus.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/MonitoringUploadStatus.java
@@ -20,17 +20,21 @@
package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
-public class MibUploadStatus {
+public class MonitoringUploadStatus {
private String snmpTrap;
private String snmpPoll;
+ private String vesEvent;
- public MibUploadStatus(String snmpTrap, String snmpPoll) {
+ //todo 1802 tech debt story : refactor this to be a map of type-filename
+
+
+ public MonitoringUploadStatus(String snmpTrap, String snmpPoll) {
this.snmpTrap = snmpTrap;
this.snmpPoll = snmpPoll;
}
- public MibUploadStatus() {
+ public MonitoringUploadStatus() {
}
public String getSnmpTrap() {
@@ -45,7 +49,17 @@ public class MibUploadStatus {
return snmpPoll;
}
+ public String getVesEvent() {
+ return vesEvent;
+ }
+
+ public void setVesEvent(String vesEvent) {
+ this.vesEvent = vesEvent;
+ }
+
public void setSnmpPoll(String snmpPoll) {
this.snmpPoll = snmpPoll;
+
+
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ManualVspDataCollectionService.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ManualVspDataCollectionService.java
new file mode 100644
index 0000000000..981bfe941a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ManualVspDataCollectionService.java
@@ -0,0 +1,418 @@
+package org.openecomp.sdc.vendorsoftwareproduct.utils;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.generator.datatypes.tosca.ComputeFlavor;
+import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
+import org.openecomp.sdc.generator.datatypes.tosca.LicenseFlavor;
+import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
+import org.openecomp.sdc.generator.datatypes.tosca.VendorInfo;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComputeManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager;
+import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ImageManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
+import org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
+import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.compute.Compute;
+import org.openecomp.sdc.vendorsoftwareproduct.types.questionnaire.component.image.ImageDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+
+public class ManualVspDataCollectionService {
+
+ private static final DeploymentFlavorManager deploymentFlavorManager =
+ DeploymentFlavorManagerFactory.getInstance().createInterface();
+ private static final ComputeManager computeManager =
+ ComputeManagerFactory.getInstance().createInterface();
+ private static final ImageManager imageManager =
+ ImageManagerFactory.getInstance().createInterface();
+ private static final ComponentManager componentManager =
+ ComponentManagerFactory.getInstance().createInterface();
+ private static final VendorSoftwareProductManager vendorSoftwareProductManager =
+ VspManagerFactory.getInstance().createInterface();
+ private static final NicManager nicManager =
+ NicManagerFactory.getInstance().createInterface();
+ private static final VendorLicenseFacade vendorLicenseFacade =
+ VendorLicenseFacadeFactory.getInstance().createInterface();
+
+
+ /**
+ * Gets vendor name for the vsp.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the release vendor name
+ */
+ public Optional<String> getReleaseVendor(String vspId, Version version, String user) {
+ String vendorName = null;
+ VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version, user);
+ if (Objects.nonNull(vspDetails)) {
+ vendorName = vspDetails.getVendorName();
+ }
+ return Optional.ofNullable(vendorName);
+ }
+
+ /**
+ * Gets the deployment flavor data for manually onboarded VSPs.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the allowed flavors
+ */
+ public Map<String, DeploymentFlavorModel> getAllowedFlavors(String vspId, Version version,
+ String user) {
+ Map<String, DeploymentFlavorModel> allowedFlavors = new HashMap<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) {
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+
+ VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version, user);
+ String vspVlmId;
+ Version vlmVersion;
+ if (Objects.nonNull(vspDetails)) {
+ vspVlmId = vspDetails.getVendorId();
+ vlmVersion = vspDetails.getVlmVersion();
+ if (StringUtils.isNotEmpty(vspVlmId)) {
+ DeploymentFlavorModel deploymentFlavorModel = new DeploymentFlavorModel();
+ String featureGroupId = deploymentFlavorCompositionData.getFeatureGroupId();
+ if (Objects.isNull(featureGroupId)) {
+ //No feature group associated with deployment flavor. So excluding this deployment
+ // flavor for Tosca model
+ continue;
+ }
+ //Gather and set License flavor info
+ LicenseFlavor licenseFlavor = getLicenseFlavor(featureGroupId);
+ deploymentFlavorModel.setLicense_flavor(licenseFlavor);
+ //Get sp_part_number
+ Optional<String> partNumber = getPartNumber(vspVlmId, vlmVersion, featureGroupId,
+ user);
+ partNumber.ifPresent(deploymentFlavorModel::setSp_part_number);
+ //Gather and set Vendor Info
+ Optional<VendorInfo> vendorInfo = getVendorInfo(vspVlmId, vlmVersion, featureGroupId,
+ user);
+ vendorInfo.ifPresent(deploymentFlavorModel::setVendor_info);
+ //Gather and set Compute info
+ List<ComponentComputeAssociation> componentComputeAssociations =
+ deploymentFlavorCompositionData.getComponentComputeAssociations();
+ if (CollectionUtils.isNotEmpty(componentComputeAssociations)) {
+ for (ComponentComputeAssociation componentComputeAssociation :
+ componentComputeAssociations) {
+ String componentId = componentComputeAssociation.getComponentId();
+ String computeFlavorId = componentComputeAssociation.getComputeFlavorId();
+ Optional<ComputeFlavor> computeFlavor =
+ getComputeFlavor(vspId, version, componentId, computeFlavorId, user);
+ computeFlavor.ifPresent(deploymentFlavorModel::setCompute_flavor);
+ }
+ }
+ partNumber.ifPresent(spPartNumber -> allowedFlavors.put(spPartNumber,
+ deploymentFlavorModel));
+ }
+ }
+ }
+ }
+ return allowedFlavors;
+ }
+
+ /**
+ * Gets the component image data for manually onboarded VSPs.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the vsp component images
+ */
+ public Map<String, List<MultiFlavorVfcImage>> getVspComponentImages(String vspId,
+ Version version,
+ String user) {
+ Map<String, List<MultiFlavorVfcImage>> vspComponentImages = new HashMap<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+
+ List<ComponentComputeAssociation> componentComputeAssociations =
+ deploymentFlavorCompositionData.getComponentComputeAssociations();
+ if (CollectionUtils.isNotEmpty(componentComputeAssociations)) {
+ for (ComponentComputeAssociation componentComputeAssociation :
+ componentComputeAssociations) {
+ String componentId = componentComputeAssociation.getComponentId();
+ List<MultiFlavorVfcImage> componentImages =
+ getComponentImages(vspId, version, componentId, user);
+ if (CollectionUtils.isNotEmpty(componentImages)) {
+ vspComponentImages.put(componentId, componentImages);
+ }
+ }
+ }
+ }
+ return vspComponentImages;
+ }
+
+ /**
+ * Gets the component data for manually onboarded VSPs.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the vsp components
+ */
+ public Map<String, String> getVspComponents(String vspId, Version version, String user) {
+ Map<String, String> componentIdNameMap = new HashMap<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+
+ List<ComponentComputeAssociation> componentComputeAssociations =
+ deploymentFlavorCompositionData.getComponentComputeAssociations();
+ if (CollectionUtils.isNotEmpty(componentComputeAssociations)) {
+ for (ComponentComputeAssociation componentComputeAssociation :
+ componentComputeAssociations) {
+ String componentId = componentComputeAssociation.getComponentId();
+ Optional<String> componentName = getComponentName(vspId, version, componentId, user);
+ componentName.ifPresent(name -> componentIdNameMap.put(componentId, name));
+ }
+ }
+ }
+ return componentIdNameMap;
+ }
+
+ /**
+ * Gets the NIC data for manually onboarded VSPs.
+ *
+ * @param vspId the vsp id
+ * @param version the version
+ * @param user the user
+ * @return the vsp component nics
+ */
+ public Map<String, List<Nic>> getVspComponentNics(String vspId, Version version, String user) {
+ Map<String, List<Nic>> vspComponentNics = new HashMap<>();
+ Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
+ deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
+ if (CollectionUtils.isNotEmpty(deploymentFlavorEntities)) {
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ DeploymentFlavor deploymentFlavorCompositionData =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+ if (Objects.nonNull(deploymentFlavorCompositionData)) {
+ List<ComponentComputeAssociation> componentComputeAssociations =
+ deploymentFlavorCompositionData.getComponentComputeAssociations();
+ if (CollectionUtils.isNotEmpty(componentComputeAssociations)) {
+ for (ComponentComputeAssociation componentComputeAssociation :
+ componentComputeAssociations) {
+ String componentId = componentComputeAssociation.getComponentId();
+ List<Nic> componentNics = getComponentNics(vspId, version, componentId, user);
+ if (CollectionUtils.isNotEmpty(componentNics)) {
+ vspComponentNics.put(componentId, componentNics);
+ }
+ }
+ }
+ }
+ }
+ }
+ return vspComponentNics;
+ }
+
+ private List<Nic> getComponentNics(String vspId, Version version, String componentId,
+ String user) {
+ List<Nic> componentNics = new ArrayList<>();
+ Collection<NicEntity> nics = nicManager.listNics(vspId, version, componentId, user);
+ if (Objects.nonNull(nics)) {
+ for (NicEntity nicEntity : nics) {
+ String nicId = nicEntity.getId();
+ CompositionEntityResponse<Nic> nicCompositionEntityResponse =
+ nicManager.getNic(vspId, version, componentId, nicId, user);
+ if (Objects.nonNull(nicCompositionEntityResponse)
+ && Objects.nonNull(nicCompositionEntityResponse.getData())) {
+ componentNics.add(nicCompositionEntityResponse.getData());
+ }
+ }
+ }
+ return componentNics;
+ }
+
+ private LicenseFlavor getLicenseFlavor(String featureGroupId) {
+ LicenseFlavor licenseFlavor = new LicenseFlavor();
+ licenseFlavor.setFeature_group_uuid(featureGroupId);
+ return licenseFlavor;
+ }
+
+ private Optional<String> getPartNumber(String vlmId, Version version,
+ String featureGroupId, String user) {
+ FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user);
+ if (Objects.nonNull(featureGroup)) {
+ return Optional.ofNullable(featureGroup.getFeatureGroup().getPartNumber());
+ }
+ return Optional.empty();
+ }
+
+ private Optional<VendorInfo> getVendorInfo(String vlmId, Version version,
+ String featureGroupId, String user) {
+ VendorInfo vendorInfo = null;
+ FeatureGroupModel featureGroup = getFeatureGroup(vlmId, version, featureGroupId, user);
+ if (Objects.nonNull(featureGroup)) {
+ //Process Feature group to get Manufacturer ref no.
+ String manufacturerReferenceNumber = featureGroup.getEntityManufacturerReferenceNumber();
+ vendorInfo = new VendorInfo();
+ vendorInfo.setVendor_model(vlmId);
+ if (Objects.nonNull(manufacturerReferenceNumber)) {
+ vendorInfo.setManufacturer_reference_number(manufacturerReferenceNumber);
+ }
+ }
+ return Optional.ofNullable(vendorInfo);
+ }
+
+ private Optional<ComputeFlavor> getComputeFlavor(String vspId, Version version,
+ String componentId, String computeFlavorId,
+ String user) {
+ ComputeFlavor computeFlavor = null;
+ QuestionnaireResponse computeQuestionnaire;
+ try {
+ computeQuestionnaire = computeManager.getComputeQuestionnaire(vspId, version, componentId,
+ computeFlavorId, user);
+ } catch (Exception ex) {
+ computeQuestionnaire = null;
+ }
+ if (Objects.nonNull(computeQuestionnaire)) {
+ String computeQuestionnaireData = computeQuestionnaire.getData();
+ if (Objects.nonNull(computeQuestionnaireData)) {
+ Compute compute;
+ try {
+ compute = JsonUtil.json2Object(computeQuestionnaireData, Compute.class);
+ } catch (Exception ex) {
+ compute = null;
+ }
+ if (Objects.nonNull(compute.getVmSizing())) {
+ computeFlavor = new ComputeFlavor();
+ if (Objects.nonNull(compute.getVmSizing().getNumOfCPUs())) {
+ computeFlavor.setNum_cpus(compute.getVmSizing().getNumOfCPUs());
+ }
+ if (Objects.nonNull(compute.getVmSizing().getFileSystemSizeGB())) {
+ computeFlavor.setDisk_size(compute.getVmSizing().getFileSystemSizeGB() + "GB");
+ }
+ if (Objects.nonNull(compute.getVmSizing().getMemoryRAM())) {
+ computeFlavor.setMem_size(compute.getVmSizing().getMemoryRAM() + "GB");
+ }
+ }
+ }
+ }
+ return Optional.ofNullable(computeFlavor);
+ }
+
+ private FeatureGroupModel getFeatureGroup(String vlmId, Version version, String featureGroupId,
+ String user) {
+ FeatureGroupEntity fgInput = new FeatureGroupEntity();
+ fgInput.setVendorLicenseModelId(vlmId);
+ fgInput.setVersion(version);
+ fgInput.setId(featureGroupId);
+ return vendorLicenseFacade.getFeatureGroupModel(fgInput, user);
+ }
+
+ private Optional<String> getComponentName(String vspId, Version version, String componentId,
+ String user) {
+ CompositionEntityResponse<ComponentData> component =
+ componentManager.getComponent(vspId, version, componentId, user);
+ if (Objects.nonNull(component.getData())) {
+ return Optional.ofNullable(component.getData().getDisplayName());
+ }
+ return Optional.empty();
+ }
+
+ private List<MultiFlavorVfcImage> getComponentImages(String vspId, Version version,
+ String componentId, String user) {
+ List<MultiFlavorVfcImage> componentImages = new ArrayList<>();
+ MultiFlavorVfcImage multiFlavorVfcImage = null;
+ Collection<ImageEntity> imageEntities =
+ imageManager.listImages(vspId, version, componentId, user);
+ if (Objects.nonNull(imageEntities)) {
+ for (ImageEntity imageEntity : imageEntities) {
+ String imageId = imageEntity.getId();
+ QuestionnaireResponse imageQuestionnaire =
+ imageManager.getImageQuestionnaire(vspId, version, componentId, imageId, user);
+ CompositionEntityResponse<Image> imageCompositionData =
+ imageManager.getImage(vspId, version, componentId, imageId, user);
+ if (Objects.nonNull(imageQuestionnaire)
+ && Objects.nonNull(imageQuestionnaire.getData())
+ && Objects.nonNull(imageCompositionData)) {
+ ImageDetails imageDetails;
+ try {
+ imageDetails = JsonUtil.json2Object(imageQuestionnaire.getData(),
+ ImageDetails.class);
+ } catch (Exception ex) {
+ imageDetails = null;
+ }
+ if (Objects.nonNull(imageDetails)
+ && Objects.nonNull(imageDetails.getVersion())) {
+ //Image version is used as a key for the image block
+ //So excluding the population if questionnaire data is absent or invalid
+ multiFlavorVfcImage = new MultiFlavorVfcImage();
+ Image image = imageCompositionData.getData();
+ Optional<String> toscaImageFileName = getToscaImageFileName(image, imageDetails);
+ toscaImageFileName.ifPresent(multiFlavorVfcImage::setFile_name);
+ multiFlavorVfcImage.setSoftware_version(imageDetails.getVersion());
+ if (Objects.nonNull(imageDetails.getMd5())) {
+ multiFlavorVfcImage.setFile_hash(imageDetails.getMd5());
+ }
+ multiFlavorVfcImage.setFile_hash_type("md5");
+ componentImages.add(multiFlavorVfcImage);
+ }
+ }
+ }
+ }
+ return componentImages;
+ }
+
+ private Optional<String> getToscaImageFileName(Image image, ImageDetails imageDetails) {
+ String toscaImageFileName = null;
+ StringBuilder builder = new StringBuilder();
+ if (Objects.nonNull(image.getFileName())) {
+ builder.append(image.getFileName());
+ builder.append("-");
+ builder.append(imageDetails.getVersion());
+ if (Objects.nonNull(imageDetails.getFormat())) {
+ builder.append(".");
+ builder.append(imageDetails.getFormat());
+ }
+ }
+ toscaImageFileName = builder.toString();
+ if (toscaImageFileName.isEmpty()) {
+ return Optional.empty();
+ }
+ return Optional.ofNullable(toscaImageFileName);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
index 3e7e83d3ba..08528408d6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
@@ -22,7 +22,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.utils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.enrichment.types.ArtifactType;
+import org.openecomp.core.enrichment.types.MonitoringUploadType;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.Messages;
@@ -35,7 +35,7 @@ import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerServiceName;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.slf4j.MDC;
@@ -47,6 +47,8 @@ import java.util.List;
import java.util.Map;
public class VendorSoftwareProductUtils {
+
+ private static final String MANUAL = "Manual";
protected static Logger logger =
(Logger) LoggerFactory.getLogger(VendorSoftwareProductUtils.class);
@@ -92,12 +94,7 @@ public class VendorSoftwareProductUtils {
public static void validateContentZipData(FileContentHandler contentMap,
Map<String, List<ErrorMessage>> errors) {
MDC.put(LoggerConstants.ERROR_DESCRIPTION, LoggerErrorDescription.INVALID_ZIP);
- if (contentMap == null) {
- ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors).add(
- new ErrorMessage(ErrorLevel.ERROR,
- Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage()));
-
- } else if (contentMap.getFileList().size() == 0) {
+ if (contentMap.getFileList().size() == 0) {
ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
.add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
}
@@ -105,27 +102,26 @@ public class VendorSoftwareProductUtils {
/**
- * Filter non trap or poll artifacts map.
+ * Maps all artifacts by type.
*
* @param artifacts the artifacts
* @return the map
*/
- public static Map<ArtifactType, String> filterNonTrapOrPollArtifacts(
- Collection<MibEntity> artifacts) {
- Map<ArtifactType, String> artifactTypeToFilename = new HashMap<>();
+ public static Map<MonitoringUploadType, String> mapArtifactsByType(
+ Collection<ComponentMonitoringUploadEntity> artifacts) {
+ Map<MonitoringUploadType, String> artifactTypeToFilename = new HashMap<>();
- for (MibEntity entity : artifacts) {
- if (isTrapOrPoll(entity.getType())) {
- artifactTypeToFilename.put(entity.getType(), entity.getArtifactName());
- }
+ for (ComponentMonitoringUploadEntity entity : artifacts) {
+ artifactTypeToFilename.put(entity.getType(), entity.getArtifactName());
}
return artifactTypeToFilename;
}
- private static boolean isTrapOrPoll(ArtifactType type) {
- return type.equals(ArtifactType.SNMP_POLL) || type.equals(ArtifactType.SNMP_TRAP);
+ private static boolean isTrapOrPoll(MonitoringUploadType type) {
+ return type.equals(MonitoringUploadType.SNMP_POLL) ||
+ type.equals(MonitoringUploadType.SNMP_TRAP);
}
@@ -178,4 +174,13 @@ public class VendorSoftwareProductUtils {
}
}
+ /*public static boolean isManual(String vspId, Version version, VendorSoftwareProductInfoDao
+ vspInfoDao) {
+ String onboardingMethod = vspInfoDao.get(new VspDetails(vspId, version)).getOnboardingMethod();
+ if (MANUAL.equals(onboardingMethod)) {
+ return true;
+ }
+ return false;
+ }*/
+
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json
index f736c8f115..71d42932d9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json
@@ -5,7 +5,10 @@
"org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.NicManagerFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.OrchestrationTemplateCandidateManagerFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ProcessManagerFactoryImpl",
- "org.openecomp.sdc.vendorsoftwareproduct.MibManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.MibManagerFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.MonitoringUploadsManagerFactoryImpl",
"org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ComponentDependencyModelManagerFactoryImpl",
- "org.openecomp.sdc.vendorsoftwareproduct.factories.VspServiceFactory": "org.openecomp.sdc.vendorsoftwareproduct.factories.impl.VspServiceFactoryImpl"
+ "org.openecomp.sdc.vendorsoftwareproduct.factories.VspServiceFactory": "org.openecomp.sdc.vendorsoftwareproduct.factories.impl.VspServiceFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.ComputeManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ComputeManagerFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.DeploymentFlavorManagerFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.ImageManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ImageManagerFactoryImpl"
} \ No newline at end of file