summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
diff options
context:
space:
mode:
authorAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
committerAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
commit280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch)
tree9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main
parentfd3821dad11780d33c5373d74c957c442489945e (diff)
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi <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/ComponentDependencyModelManager.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManagerFactory.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java54
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactory.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NetworkCompositionSchemaInput.java)28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManager.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java)32
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManagerFactory.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateInput.java)14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java)43
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManagerFactory.java31
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java50
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManagerFactory.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java)17
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java45
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManagerFactory.java32
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java54
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManagerFactory.java31
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java127
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VspManagerFactory.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java)28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java61
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CompositionEditNotAllowedErrorBuilder.java37
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/FileCreationErrorBuilder.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/InformationArtifactCreationErrorBuilder.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java)49
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MibUploadErrorBuilder.java17
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OrchestrationTemplateNotFoundErrorBuilder.java (renamed from openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductNotFoundErrorBuilder.java)28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageInvalidErrorBuilder.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java18
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java15
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/UploadInvalidErrorBuilder.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java84
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java41
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java234
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerFactoryImpl.java37
-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/NetworkManagerFactoryImpl.java38
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java177
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java40
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java250
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java55
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java421
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java38
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java297
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java1735
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java60
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/CompositionDataExtractor.java386
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/CompositionEntityDataManager.java257
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/SchemaGenerator.java70
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/SchemaGeneratorConfig.java184
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityValidationData.java122
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ExtractCompositionDataContext.java204
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java69
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java69
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java3
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponse.java118
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileResponse.java80
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java3
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ValidationResponse.java67
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/VersionedVendorSoftwareProductInfo.java10
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/zusammen/ItemProperties.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/util/CompilationUtil.java126
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/util/VendorSoftwareProductUtils.java254
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java61
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java181
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json11
67 files changed, 3721 insertions, 3245 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
new file mode 100644
index 0000000000..a651b0bb12
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
@@ -0,0 +1,15 @@
+package org.openecomp.sdc.vendorsoftwareproduct;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+import java.util.List;
+
+public interface ComponentDependencyModelManager {
+
+ void createComponentDependencyModel(List<ComponentDependencyModelEntity> entities, String
+ vspId, Version version, String user);
+
+ Collection<ComponentDependencyModelEntity> list(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/ComponentDependencyModelManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManagerFactory.java
new file mode 100644
index 0000000000..13d48707b4
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManagerFactory.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 ComponentDependencyModelManagerFactory extends
+ AbstractComponentFactory<ComponentDependencyModelManager> {
+
+ public static ComponentDependencyModelManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ComponentDependencyModelManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
new file mode 100644
index 0000000000..b895f5595f
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public interface ComponentManager {
+
+ Collection<ComponentEntity> listComponents(String vspId, Version version, String user);
+
+ void deleteComponents(String vspId, Version version, String user);
+
+ ComponentEntity createComponent(ComponentEntity componentEntity, String user);
+
+ CompositionEntityValidationData updateComponent(ComponentEntity componentEntity, String user);
+
+ CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
+ String componentId, String user);
+
+ void deleteComponent(String vspId, Version version, String componentId, String user);
+
+ QuestionnaireResponse getQuestionnaire(String vspId, Version version, String componentId,
+ String user);
+
+ void updateQuestionnaire(String vspId, Version version, String componentId,
+ String questionnaireData, String user);
+
+ void validateComponentExistence(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/types/schemagenerator/NetworkCompositionSchemaInput.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactory.java
index 456b4409fd..21a77b3c97 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NetworkCompositionSchemaInput.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,26 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
+package org.openecomp.sdc.vendorsoftwareproduct;
-public class NetworkCompositionSchemaInput implements SchemaTemplateInput {
- private boolean manual;
- private org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network network;
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
- public boolean isManual() {
- return manual;
- }
-
- public void setManual(boolean manual) {
- this.manual = manual;
- }
-
- public org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network getNetwork() {
- return network;
- }
+public abstract class ComponentManagerFactory extends AbstractComponentFactory<ComponentManager> {
- public void setNetwork(org.openecomp.sdc.vendorsoftwareproduct.types.composition
- .Network network) {
- this.network = network;
+ public static ComponentManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ComponentManagerFactory.class);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManager.java
index 7fb5ec890b..7d2db68c1d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentCompositionSchemaInput.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManager.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,26 +18,20 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
+package org.openecomp.sdc.vendorsoftwareproduct;
-public class ComponentCompositionSchemaInput implements SchemaTemplateInput {
- private boolean manual;
- private org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData component;
+import org.openecomp.core.enrichment.types.ArtifactType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus;
+import org.openecomp.sdc.versioning.dao.types.Version;
- public boolean isManual() {
- return manual;
- }
+import java.io.InputStream;
- public void setManual(boolean manual) {
- this.manual = manual;
- }
+public interface MibManager {
+ void delete(String vspId, Version version, String componentId,
+ ArtifactType artifactType, String user);
- public org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData getComponent() {
- return component;
- }
+ void upload(InputStream object, String filename, String vspId, Version version,
+ String componentId, ArtifactType artifactType, String user);
- public void setComponent(
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData component) {
- this.component = component;
- }
+ MibUploadStatus 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/types/schemagenerator/SchemaTemplateInput.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManagerFactory.java
index 93e614f98b..f25658bf0f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateInput.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MibManagerFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,8 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
+package org.openecomp.sdc.vendorsoftwareproduct;
-public interface SchemaTemplateInput {
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+public abstract class MibManagerFactory extends AbstractComponentFactory<MibManager> {
+
+ public static MibManagerFactory getInstance() {
+ return AbstractFactory.getInstance(MibManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
index 87693a492c..b647735188 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/NicCompositionSchemaInput.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,38 +18,25 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
+package org.openecomp.sdc.vendorsoftwareproduct;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
+import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-public class NicCompositionSchemaInput implements SchemaTemplateInput {
- private boolean manual;
- private Nic nic;
- private Collection<String> networkIds;
+public interface NetworkManager {
+ Collection<NetworkEntity> listNetworks(String vspId, Version version, String user);
- public boolean isManual() {
- return manual;
- }
+ NetworkEntity createNetwork(NetworkEntity network, String user);
- public void setManual(boolean manual) {
- this.manual = manual;
- }
+ CompositionEntityValidationData updateNetwork(NetworkEntity networkEntity, String user);
- public Nic getNic() {
- return nic;
- }
+ CompositionEntityResponse<Network> getNetwork(String vspId, Version version, String networkId,
+ String user);
- public void setNic(Nic nic) {
- this.nic = nic;
- }
-
- public Collection<String> getNetworkIds() {
- return networkIds;
- }
-
- public void setNetworkIds(Collection<String> networkIds) {
- this.networkIds = networkIds;
- }
+ void deleteNetwork(String vspId, Version version, String networkId, String user);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManagerFactory.java
new file mode 100644
index 0000000000..943e676727
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManagerFactory.java
@@ -0,0 +1,31 @@
+/*-
+ * ============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;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class NetworkManagerFactory extends AbstractComponentFactory<NetworkManager> {
+
+ public static NetworkManagerFactory getInstance() {
+ return AbstractFactory.getInstance(NetworkManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
new file mode 100644
index 0000000000..466583edfd
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
@@ -0,0 +1,50 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+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.Nic;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public interface NicManager {
+
+ Collection<NicEntity> listNics(String vspId, Version version, String componentId, String user);
+
+ NicEntity createNic(NicEntity nic, String user);
+
+ CompositionEntityValidationData updateNic(NicEntity nicEntity, String user);
+
+ CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
+ String nicId, String user);
+
+ void deleteNic(String vspId, Version version, String componentId, String nicId, String user);
+
+ QuestionnaireResponse getNicQuestionnaire(String vspId, Version version, String componentId,
+ String nicId, String user);
+
+ void updateNicQuestionnaire(String vspId, Version version, String componentId, String nicId,
+ String questionnaireData, String user);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManagerFactory.java
index 3ee3e4a5e6..73f7f79996 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/SchemaTemplateContext.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManagerFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,9 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
+package org.openecomp.sdc.vendorsoftwareproduct;
-public enum SchemaTemplateContext {
- composition,
- questionnaire
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class NicManagerFactory extends AbstractComponentFactory<NicManager> {
+
+ public static NicManagerFactory getInstance() {
+ return AbstractFactory.getInstance(NicManagerFactory.class);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
new file mode 100644
index 0000000000..e648ccef26
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
@@ -0,0 +1,45 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Optional;
+
+public interface OrchestrationTemplateCandidateManager {
+ UploadFileResponse upload(String vspId, Version version, InputStream heatFileToUpload,
+ String user);
+
+ OrchestrationTemplateActionResponse process(String vspId, Version version, String user);
+
+ Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version, String user);
+
+ ValidationResponse updateFilesDataStructure(String vspId, Version version, String user,
+ FilesDataStructure fileDataStructure);
+
+ Optional<byte[]> get(String vspId, Version version, String user) throws IOException;
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManagerFactory.java
new file mode 100644
index 0000000000..ddc24adeb6
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManagerFactory.java
@@ -0,0 +1,32 @@
+/*-
+ * ============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;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class OrchestrationTemplateCandidateManagerFactory
+ extends AbstractComponentFactory<OrchestrationTemplateCandidateManager> {
+
+ public static OrchestrationTemplateCandidateManagerFactory getInstance() {
+ return AbstractFactory.getInstance(OrchestrationTemplateCandidateManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
new file mode 100644
index 0000000000..afe88d2053
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Collection;
+
+public interface ProcessManager {
+ Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId,
+ String user);
+
+ void deleteProcesses(String vspId, Version version, String componentId, String user);
+
+ ProcessEntity createProcess(ProcessEntity processEntity, String user);
+
+ ProcessEntity getProcess(String vspId, Version version, String componentId, String processId,
+ String user);
+
+ void updateProcess(ProcessEntity processEntity, String user);
+
+ void deleteProcess(String vspId, Version version, String componentId, String processId,
+ String user);
+
+ File getProcessArtifact(String vspId, Version version, String componentId, String processId,
+ String user);
+
+ void deleteProcessArtifact(String vspId, Version version, String componentId, String processId,
+ String user);
+
+ void uploadProcessArtifact(InputStream uploadFile, String fileName, String vspId,
+ Version version, String componentId, String processId, String user);
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManagerFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManagerFactory.java
new file mode 100644
index 0000000000..7da0bef128
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManagerFactory.java
@@ -0,0 +1,31 @@
+/*-
+ * ============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;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ProcessManagerFactory extends AbstractComponentFactory<ProcessManager> {
+
+ public static ProcessManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ProcessManagerFactory.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 0d38d165c2..7e9a002ad1 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,29 +20,19 @@
package org.openecomp.sdc.vendorsoftwareproduct;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionInfo;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
import java.util.List;
-public interface VendorSoftwareProductManager {
+public interface VendorSoftwareProductManager {
Version checkout(String vendorSoftwareProductId, String user);
@@ -53,121 +43,36 @@ public interface VendorSoftwareProductManager {
ValidationResponse submit(String vendorSoftwareProductId, String user) throws IOException;
- VspDetails createNewVsp(VspDetails vspDetails, String user);
+ List<VersionedVendorSoftwareProductInfo> listVsps(String versionFilter, String user);
- List<VersionedVendorSoftwareProductInfo> getVspList(String versionFilter, String user);
+ VspDetails createVsp(VspDetails vspDetails, String user);
void updateVsp(VspDetails vspDetails, String user);
- VersionedVendorSoftwareProductInfo getVspDetails(String vspId, Version version, String user);
+ VspDetails getVsp(String vspId, Version version, String user);
- void deleteVsp(String vspIdToDelete, String user);
-
-
- UploadFileResponse uploadFile(String vspId, InputStream heatFileToUpload, String user);
-
- PackageInfo createPackage(String vspId, String user) throws IOException;
-
- List<PackageInfo> listPackages(String category, String subCategory);
-
- File getTranslatedFile(String vspId, Version version, String user);
+ Version callAutoHeal(String vspId, VersionInfo versionInfo,
+ VspDetails vendorSoftwareProductInfo, String user) throws Exception;
- File getLatestHeatPackage(String vspId, String user);
+ void deleteVsp(String vspIdToDelete, String user);
QuestionnaireResponse getVspQuestionnaire(String vspId, Version version, String user);
- void updateVspQuestionnaire(String vspId, String questionnaireData, String user);
-
-
- Collection<NetworkEntity> listNetworks(String vspId, Version version, String user);
-
- NetworkEntity createNetwork(NetworkEntity network, String user);
-
- CompositionEntityValidationData updateNetwork(NetworkEntity networkEntity, String user);
-
- CompositionEntityResponse<Network> getNetwork(String vspId, Version version, String networkId,
- String user);
-
- void deleteNetwork(String vspId, String networkId, String user);
-
-
- QuestionnaireResponse getComponentQuestionnaire(String vspId, Version version, String componentId,
- String user);
-
- void updateComponentQuestionnaire(String vspId, String componentId, String questionnaireData,
- String user);
-
-
- Collection<ComponentEntity> listComponents(String vspId, Version version, String user);
+ void updateVspQuestionnaire(String vspId, Version version, String questionnaireData, String user);
- void deleteComponents(String vspId, String user);
- ComponentEntity createComponent(ComponentEntity componentEntity, String user);
+ byte[] getOrchestrationTemplateFile(String vspId, Version version, String user);
- CompositionEntityValidationData updateComponent(ComponentEntity componentEntity, String user);
+ PackageInfo createPackage(String vspId, Version version, String user) throws IOException;
- CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
- String componentId, String user);
-
- void deleteComponent(String vspId, String componentId, String user);
-
-
- Collection<org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity> listProcesses(
- String vspId, Version version, String componentId,
- String user);
-
- void deleteProcesses(String vspId, String componentId, String user);
-
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity createProcess(
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity processEntity, String user);
-
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity getProcess(String vspId,
- Version version,
- String componentId,
- String processId,
- String user);
-
- void updateProcess(org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity processEntity,
- String user);
-
- void deleteProcess(String vspId, String componentId, String processId, String user);
-
-
- File getProcessArtifact(String vspId, Version version, String componentId, String processId,
- String user);
-
- void deleteProcessArtifact(String vspId, String componentId, String processId, String user);
-
- void uploadProcessArtifact(InputStream uploadFile, String fileName, String vspId,
- String componentId, String processId, String user);
-
-
- Collection<org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity> listNics(String vspId,
- Version version,
- String componentId,
- String user);
-
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity createNic(
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity nic, String user);
-
- CompositionEntityValidationData updateNic(
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity nicEntity, String user);
-
- CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
- String nicId, String user);
-
- void deleteNic(String vspId, String componentId, String nicId, String user);
+ List<PackageInfo> listPackages(String category, String subCategory);
- QuestionnaireResponse getNicQuestionnaire(String vspId, Version version, String componentId,
- String nicId, String user);
+ File getTranslatedFile(String vspId, Version version, String user);
- void updateNicQuestionnaire(String vspId, String componentId, String nicId,
- String questionnaireData, String user);
+ void heal(String vspId, Version version, String user);
- void deleteComponentMib(String vspId, String componentId, boolean isTrap, String user);
+ File getInformationArtifact(String vspId, Version version, String user);
- void uploadComponentMib(InputStream object, String filename, String vspId, String componentId,
- boolean isTrap, String user);
- MibUploadStatus listMibFilenames(String vspId, String componentId, String user);
+ String fetchValidationVsp(String user);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VspManagerFactory.java
index 1f92e6d957..99d6988b61 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/schemagenerator/ComponentQuestionnaireSchemaInput.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VspManagerFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,25 +18,15 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator;
+package org.openecomp.sdc.vendorsoftwareproduct;
-import java.util.List;
-import java.util.Map;
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
-public class ComponentQuestionnaireSchemaInput implements SchemaTemplateInput {
- private List<String> nicNames;
- private Map componentQuestionnaireData;
+public abstract class VspManagerFactory
+ extends AbstractComponentFactory<VendorSoftwareProductManager> {
- public ComponentQuestionnaireSchemaInput(List<String> nicNames, Map componentQuestionnaireData) {
- this.nicNames = nicNames;
- this.componentQuestionnaireData = componentQuestionnaireData;
- }
-
- public List<String> getNicNames() {
- return nicNames;
- }
-
- public Map getComponentQuestionnaireData() {
- return componentQuestionnaireData;
+ public static VspManagerFactory getInstance() {
+ return AbstractFactory.getInstance(VspManagerFactory.class);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
new file mode 100644
index 0000000000..78605c86fc
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
@@ -0,0 +1,61 @@
+package org.openecomp.sdc.vendorsoftwareproduct.errors;
+
+
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
+ .CYCLIC_DEPENDENCY_IN_COMPONENTS;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
+ .INVALID_COMPONENT_RELATION_TYPE;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
+ .NO_SOURCE_COMPONENT;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
+ .SAME_SOURCE_TARGET_COMPONENT;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class ComponentDependencyModelErrorBuilder {
+
+ private static final String CYCLIC_DEPENDENCY_COMPONENT_MSG = "Cyclic dependency exists between"
+ + " components.";
+
+ private static final String INVALID_REALTION_TYPE_MSG = "Invalid relation type for components.";
+
+ private static final String NO_SOURCE_COMPONENT_MSG = "Source component is mandatory.";
+
+ private static final String SOURCE_TARGET_COMPONENT_EQUAL_MSG = "Source and target components "
+ + "are same.";
+
+
+
+ public static ErrorCode getcyclicDependencyComponentErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(CYCLIC_DEPENDENCY_IN_COMPONENTS);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(CYCLIC_DEPENDENCY_COMPONENT_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getInvalidRelationTypeErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(INVALID_COMPONENT_RELATION_TYPE);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_REALTION_TYPE_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getNoSourceComponentErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(NO_SOURCE_COMPONENT);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(NO_SOURCE_COMPONENT_MSG));
+ return builder.build();
+ }
+
+ public static ErrorCode getSourceTargetComponentEqualErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(SAME_SOURCE_TARGET_COMPONENT);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(SOURCE_TARGET_COMPONENT_EQUAL_MSG));
+ return builder.build();
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CompositionEditNotAllowedErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CompositionEditNotAllowedErrorBuilder.java
new file mode 100644
index 0000000000..1ce9bcd90a
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CompositionEditNotAllowedErrorBuilder.java
@@ -0,0 +1,37 @@
+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 CompositionEditNotAllowedErrorBuilder {
+ private static final String VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG =
+ "Composition entities may not be created / deleted for Vendor Software Product %s, version %s"
+ + "whose entities were uploaded";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new error builder.
+ *
+ * @param vendorSoftwareProductId the vendor software product id
+ * @param version the version
+ */
+ public CompositionEditNotAllowedErrorBuilder(String vendorSoftwareProductId, Version version) {
+ builder.withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(
+ String.format(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG, vendorSoftwareProductId,
+ version == null ? null : version.toString()));
+
+ }
+
+ /**
+ * Build error code.
+ *
+ * @return the error code
+ */
+ 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/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java
index 527530d4de..04038fe6bc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilder.java
@@ -24,14 +24,14 @@ import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
-/**
- * The type Create package for non final vendor software product error builder.
- */
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.CREATE_PACKAGE_FOR_NON_FINAL_VSP;
+
+
public class CreatePackageForNonFinalVendorSoftwareProductErrorBuilder {
private static final String CREATE_PACKAGE_FOR_NON_FINAL_VSP_MSG =
- "Package creation for vendor software product with id %s and version %s is not allowed "
- + "since it is not final (submitted).";
+ "Package creation for vendor software product with id %s and version %s is not allowed since "
+ + "it is not final (submitted).";
private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
/**
@@ -42,17 +42,12 @@ public class CreatePackageForNonFinalVendorSoftwareProductErrorBuilder {
*/
public CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(String vendorSoftwareProductId,
Version version) {
- builder.withId(VendorSoftwareProductErrorCodes.CREATE_PACKAGE_FOR_NON_FINAL_VSP);
+ builder.withId(CREATE_PACKAGE_FOR_NON_FINAL_VSP);
builder.withCategory(ErrorCategory.APPLICATION);
builder.withMessage(String
- .format(CREATE_PACKAGE_FOR_NON_FINAL_VSP_MSG, vendorSoftwareProductId, version.toString()));
+ .format(CREATE_PACKAGE_FOR_NON_FINAL_VSP_MSG, vendorSoftwareProductId, version == null ? null : version.toString()));
}
- /**
- * Build error code.
- *
- * @return the error code
- */
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/FileCreationErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/FileCreationErrorBuilder.java
index 5a40609270..e00e145020 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/FileCreationErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/FileCreationErrorBuilder.java
@@ -20,14 +20,12 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.HEAT_PACKAGE_FILE_CREATION;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-/**
- * The type File creation error builder.
- */
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.HEAT_PACKAGE_FILE_CREATION;
+
public class FileCreationErrorBuilder {
private static final String HEAT_PKG_FILE_CREATION_ERROR_MSG =
"Error while trying to create heat file from the package of vendor software product "
@@ -45,11 +43,6 @@ public class FileCreationErrorBuilder {
builder.withMessage(String.format(HEAT_PKG_FILE_CREATION_ERROR_MSG, vendorSoftwareProductId));
}
- /**
- * Build error code.
- *
- * @return the error code
- */
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/VendorSoftwareProductErrorCodes.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/InformationArtifactCreationErrorBuilder.java
index 369e99d75f..ca5b9bfcbb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductErrorCodes.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/InformationArtifactCreationErrorBuilder.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,29 +20,28 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-public class VendorSoftwareProductErrorCodes {
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
- public static final String VSP_NOT_FOUND = "VSP_NOT_FOUND";
- public static final String VSP_INVALID = "VSP_INVALID";
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.HEAT_PACKAGE_FILE_CREATION;
- public static final String UPLOAD_INVALID = "UPLOAD_INVALID";
- public static final String PACKAGE_NOT_FOUND = "PACKAGE_NOT_FOUND";
-
- public static final String PACKAGE_INVALID = "PACKAGE_INVALID";
- public static final String VSP_COMPOSITION_EDIT_NOT_ALLOWED = "VSP_COMPOSITION_EDIT_NOT_ALLOWED";
-
- public static final String CREATE_PACKAGE_FOR_NON_FINAL_VSP = "CREATE_PACKAGE_FOR_NON_FINAL_VSP";
-
- public static final String TRANSLATION_FILE_CREATION = "TRANSLATION_FILE_CREATION";
-
- public static final String HEAT_PACKAGE_FILE_CREATION = "HEAT_PACKAGE_FILE_CREATION";
-
- public static final String TOSCA_ENTRY_NOT_FOUND = "TOSCA_ENTRY_NOT_FOUND";
- public static final String TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE =
- "TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE";
-
- public static final String MIB_UPLOAD_INVALID = "MIB_UPLOAD_INVALID";
-
-
-}
+/**
+ * Created by Talio on 11/24/2016.
+ */
+public class InformationArtifactCreationErrorBuilder {
+ private static final String INFO_ARTIFACT_FILE_CREATION_ERROR_MSG =
+ "Error while trying to information artifact file for vendor software product with Id %s.";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public InformationArtifactCreationErrorBuilder(String vendorSoftwareProductId) {
+ builder.withId(HEAT_PACKAGE_FILE_CREATION);
+ builder.withCategory(ErrorCategory.SYSTEM);
+ builder
+ .withMessage(String.format(INFO_ARTIFACT_FILE_CREATION_ERROR_MSG, vendorSoftwareProductId));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+} \ No newline at end of file
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/MibUploadErrorBuilder.java
index 75a4aa3ff7..bffe805618 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/MibUploadErrorBuilder.java
@@ -22,10 +22,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.errors;
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;
-/**
- * The type Mib upload error builder.
- */
public class MibUploadErrorBuilder 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";
@@ -38,12 +38,11 @@ public class MibUploadErrorBuilder extends BaseErrorBuilder {
* @param version the version
* @param error the error
*/
- public MibUploadErrorBuilder(String vendorSoftwareProductId, org.openecomp.sdc.versioning.dao
- .types.Version version, String error) {
- getErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.MIB_UPLOAD_INVALID);
+ public MibUploadErrorBuilder(String vendorSoftwareProductId, Version version, String error) {
+ getErrorCodeBuilder().withId(MIB_UPLOAD_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
- getErrorCodeBuilder().withMessage(String
- .format(UPLOAD_INVALID_DETAILED_MSG, vendorSoftwareProductId, version.toString(), error));
+ getErrorCodeBuilder().withMessage(String.format(UPLOAD_INVALID_DETAILED_MSG,
+ vendorSoftwareProductId, version == null ? null : version.toString(), error));
}
/**
@@ -52,7 +51,7 @@ public class MibUploadErrorBuilder extends BaseErrorBuilder {
* @param errorMessage the error message
*/
public MibUploadErrorBuilder(String errorMessage) {
- getErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.MIB_UPLOAD_INVALID);
+ getErrorCodeBuilder().withId(MIB_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/VendorSoftwareProductNotFoundErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OrchestrationTemplateNotFoundErrorBuilder.java
index 89fc08cdb0..84ce956911 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductNotFoundErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OrchestrationTemplateNotFoundErrorBuilder.java
@@ -20,34 +20,28 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_NOT_FOUND;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-/**
- * The type Vendor software product not found error builder.
- */
-public class VendorSoftwareProductNotFoundErrorBuilder {
- private static final String VSP_FOUND_MSG = "Vendor software product with Id %s not found.";
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ORCHESTRATION_NOT_FOUND;
+
+public class OrchestrationTemplateNotFoundErrorBuilder {
+ private static final String ORCHESTRATION_TEMPLATE_NOT_FOUND_MESSAGE =
+ "Failed to get orchestration template for VSP with id %s";
private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
/**
- * Instantiates a new Vendor software product not found error builder.
+ * Instantiates a new Orchestration template not found error builder.
*
- * @param vendorSoftwareProductId the vendor software product id
+ * @param vspId the vsp id
*/
- public VendorSoftwareProductNotFoundErrorBuilder(String vendorSoftwareProductId) {
- builder.withId(VSP_NOT_FOUND);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(VSP_FOUND_MSG, vendorSoftwareProductId));
+ public OrchestrationTemplateNotFoundErrorBuilder(String vspId) {
+ builder.withId(ORCHESTRATION_NOT_FOUND)
+ .withCategory(ErrorCategory.APPLICATION)
+ .withMessage(String.format(ORCHESTRATION_TEMPLATE_NOT_FOUND_MESSAGE, vspId));
}
- /**
- * Build error code.
- *
- * @return the error code
- */
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/PackageInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageInvalidErrorBuilder.java
index 279dbfe4ea..ce9794aa3b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageInvalidErrorBuilder.java
@@ -20,13 +20,13 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .PACKAGE_INVALID;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.PACKAGE_INVALID;
+
/**
* The type Package invalid error builder.
*/
@@ -45,8 +45,8 @@ public class PackageInvalidErrorBuilder {
public PackageInvalidErrorBuilder(String vendorSoftwareProductId, Version version) {
builder.withId(PACKAGE_INVALID);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(
- String.format(PACKAGE_INVALID_MSG, vendorSoftwareProductId, version.toString()));
+ builder.withMessage(String.format(PACKAGE_INVALID_MSG,
+ vendorSoftwareProductId, version == null ? null : version.toString()));
}
/**
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java
index 3a32fa30b1..54ae9ce398 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/PackageNotFoundErrorBuilder.java
@@ -20,15 +20,10 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.PACKAGE_NOT_FOUND;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
-/**
- * The type Package not found error builder.
- */
public class PackageNotFoundErrorBuilder {
private static final String PACKAGE_VERSION_NOT_FOUND_MSG =
"Package for vendor software product with Id %s and version %s does not exist.";
@@ -43,10 +38,10 @@ public class PackageNotFoundErrorBuilder {
* @param version the version
*/
public PackageNotFoundErrorBuilder(String vendorSoftwareProductId, Version version) {
- builder.withId(PACKAGE_NOT_FOUND);
+ builder.withId(VendorSoftwareProductErrorCodes.PACKAGE_NOT_FOUND);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(
- String.format(PACKAGE_VERSION_NOT_FOUND_MSG, vendorSoftwareProductId, version.toString()));
+ builder.withMessage(String.format(PACKAGE_VERSION_NOT_FOUND_MSG,
+ vendorSoftwareProductId, version == null ? null : version.toString()));
}
/**
@@ -55,16 +50,11 @@ public class PackageNotFoundErrorBuilder {
* @param vendorSoftwareProductId the vendor software product id
*/
public PackageNotFoundErrorBuilder(String vendorSoftwareProductId) {
- builder.withId(PACKAGE_NOT_FOUND);
+ builder.withId(VendorSoftwareProductErrorCodes.PACKAGE_NOT_FOUND);
builder.withCategory(ErrorCategory.APPLICATION);
builder.withMessage(String.format(PACKAGE_NOT_FOUND_MSG, vendorSoftwareProductId));
}
- /**
- * Build error code.
- *
- * @return the error code
- */
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/TranslationFileCreationErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
index 2267e1d80a..1ec3af397f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
@@ -20,20 +20,16 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .TRANSLATION_FILE_CREATION;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.TRANSLATION_FILE_CREATION;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
-/**
- * The type Translation file creation error builder.
- */
public class TranslationFileCreationErrorBuilder {
private static final String TRANSLATION_FILE_CREATION_ERROR_MSG =
- "Error while trying to create translation file from the package of vendor software "
- + "product with Id %s and version %s.";
+ "Error while trying to create translation file from the package of vendor software product "
+ + "with Id %s and version %s.";
private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
/**
@@ -49,11 +45,6 @@ public class TranslationFileCreationErrorBuilder {
.format(TRANSLATION_FILE_CREATION_ERROR_MSG, vendorSoftwareProductId, version.toString()));
}
- /**
- * Build error code.
- *
- * @return the error code
- */
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/UploadInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/UploadInvalidErrorBuilder.java
index 0974af1c6a..91912bc0c9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/UploadInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/UploadInvalidErrorBuilder.java
@@ -20,9 +20,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .UPLOAD_INVALID;
-
import org.openecomp.sdc.common.errors.BaseErrorBuilder;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -31,9 +28,6 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.List;
import java.util.Map;
-/**
- * The type Upload invalid error builder.
- */
public class UploadInvalidErrorBuilder extends BaseErrorBuilder {
private static final String UPLOAD_INVALID_DETAILED_MSG =
"File uploaded for vendor software product with Id %s and version %s is invalid: %s";
@@ -48,7 +42,7 @@ public class UploadInvalidErrorBuilder extends BaseErrorBuilder {
*/
public UploadInvalidErrorBuilder(String vendorSoftwareProductId, Version version,
Map<String, List<ErrorMessage>> errors) {
- getErrorCodeBuilder().withId(UPLOAD_INVALID);
+ getErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.UPLOAD_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(String
.format(UPLOAD_INVALID_DETAILED_MSG, vendorSoftwareProductId, version.toString(),
@@ -59,7 +53,7 @@ public class UploadInvalidErrorBuilder extends BaseErrorBuilder {
* Instantiates a new Upload invalid error builder.
*/
public UploadInvalidErrorBuilder() {
- getErrorCodeBuilder().withId(UPLOAD_INVALID);
+ getErrorCodeBuilder().withId(VendorSoftwareProductErrorCodes.UPLOAD_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(UPLOAD_INVALID_MSG);
}
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 1439563b17..8fe2bfc396 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
@@ -20,16 +20,10 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_INVALID;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
-
-/**
- * The type Vendor software product invalid error builder.
- */
public class VendorSoftwareProductInvalidErrorBuilder {
private static final String VSP_INVALID_MSG =
"Vendor software product with Id %s and version %s is invalid - does not contain "
@@ -43,17 +37,12 @@ public class VendorSoftwareProductInvalidErrorBuilder {
* @param version the version
*/
public VendorSoftwareProductInvalidErrorBuilder(String vendorSoftwareProductId, Version version) {
- builder.withId(VSP_INVALID);
+ builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
builder.withCategory(ErrorCategory.APPLICATION);
builder
.withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.toString()));
}
- /**
- * Build error code.
- *
- * @return the error code
- */
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/impl/ComponentDependencyModelManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
new file mode 100644
index 0000000000..b4513dec79
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
@@ -0,0 +1,19 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+
+public class ComponentDependencyModelManagerFactoryImpl extends
+ ComponentDependencyModelManagerFactory {
+ private static final ComponentDependencyModelManager INSTANCE =
+ new ComponentDependencyModelManagerImpl(VendorSoftwareProductDaoFactory.getInstance()
+ .createInterface(), ComponentManagerFactory.getInstance().createInterface());
+
+ @Override
+ public ComponentDependencyModelManager createInterface() {
+ return INSTANCE;
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
new file mode 100644
index 0000000000..86774381e0
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
@@ -0,0 +1,84 @@
+package org.openecomp.sdc.vendorsoftwareproduct.impl;
+
+import org.apache.commons.lang3.StringUtils;
+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.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.LoggerTragetServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+import java.util.List;
+
+public class ComponentDependencyModelManagerImpl implements ComponentDependencyModelManager {
+
+ private VendorSoftwareProductDao vendorSoftwareProductDao;
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ protected static final Logger logger =
+ LoggerFactory.getLogger(ComponentDependencyModelManagerImpl.class);
+
+ private ComponentManager componentManager;
+
+ public ComponentDependencyModelManagerImpl(VendorSoftwareProductDao vendorSoftwareProductDao, ComponentManager componentManager) {
+ this.vendorSoftwareProductDao = vendorSoftwareProductDao;
+ this.componentManager = componentManager;
+ }
+
+ @Override
+ public void createComponentDependencyModel(List<ComponentDependencyModelEntity> entities,
+ String vspId, Version version, String user) {
+
+ mdcDataDebugMessage.debugEntryMessage("createComponentDependencyModel");
+ for(ComponentDependencyModelEntity entity : entities) {
+ if (!StringUtils.isEmpty(entity.getSourceComponentId())) {
+ componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
+ entity.getSourceComponentId(), user);
+ if (entity.getSourceComponentId().equals(entity.getTargetComponentId())) {
+ ErrorCode errorCode =
+ ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder();
+ raiseException(errorCode);
+ }
+ } else {
+ ErrorCode errorCode = ComponentDependencyModelErrorBuilder
+ .getNoSourceComponentErrorBuilder();
+ raiseException(errorCode);
+ }
+
+ if (!StringUtils.isEmpty(entity.getTargetComponentId())) {
+ componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
+ entity.getTargetComponentId(), user);
+ }
+ }
+
+ vendorSoftwareProductDao.createComponentDependencyModel(entities, vspId, version );
+
+ mdcDataDebugMessage.debugExitMessage("createComponentDependencyModel");
+ }
+
+ private void raiseException(ErrorCode errorCode) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
+ throw new CoreException(errorCode);
+ }
+
+ @Override
+ public Collection<ComponentDependencyModelEntity> list(String vspId, Version version, String
+ user) {
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, version", vspId, version.toString());
+
+ return vendorSoftwareProductDao.listComponentDependencies(vspId, version);
+ }
+}
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
new file mode 100644
index 0000000000..a2aaf2f8f5
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerFactoryImpl.java
@@ -0,0 +1,41 @@
+/*-
+ * ============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.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.factory.CompositionEntityDataManagerFactory;
+
+public class ComponentManagerFactoryImpl extends ComponentManagerFactory {
+ private static final ComponentManager INSTANCE =
+ new ComponentManagerImpl(
+ ComponentDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ NicManagerFactory.getInstance().createInterface()
+ );
+
+ @Override
+ public ComponentManager createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..75a5377ec3
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
@@ -0,0 +1,234 @@
+/*-
+ * ============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.CollectionUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.common.errors.CoreException;
+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.ComponentManager;
+import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+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.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.ComponentData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentCompositionSchemaInput;
+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.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class ComponentManagerImpl implements ComponentManager {
+ private static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private ComponentDao componentDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+ private NicManager nicManager;
+
+ public ComponentManagerImpl(
+ ComponentDao componentDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ NicManager nicManager) {
+ this.componentDao = componentDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.nicManager = nicManager;
+ }
+
+ @Override
+ public Collection<ComponentEntity> listComponents(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return componentDao.list(new ComponentEntity(vspId, version, null));
+ }
+
+ @Override
+ public void deleteComponents(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ if (!isManual(vspId, version)) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete component");
+ throw new CoreException(
+ new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ }
+
+ //componentDao.updateVspLatestModificationTime(vspId, version);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ }
+
+ @Override
+ public ComponentEntity createComponent(ComponentEntity component, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", component.getId());
+
+ if (!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 CompositionEditNotAllowedErrorBuilder(component.getVspId(), component.getVersion())
+ .build());
+
+ }
+ //componentDao.updateVspLatestModificationTime(component.getVspId(), component.getVersion());
+ mdcDataDebugMessage.debugExitMessage("VSP id", component.getId());
+ return null;
+ }
+
+ @Override
+ public CompositionEntityValidationData updateComponent(ComponentEntity component, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", component
+ .getVspId(), component.getId());
+ ComponentEntity retrieved =
+ getComponent(component.getVspId(), component.getVersion(), component.getId());
+
+ ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
+ schemaInput.setManual(isManual(component.getVspId(), component.getVersion()));
+ schemaInput.setComponent(retrieved.getComponentCompositionData());
+
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(component, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ componentDao.update(component);
+ //componentDao.updateVspLatestModificationTime(component.getVspId(), component.getVersion());
+ }
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", component.getVspId(),
+ component.getId());
+
+ return validationData;
+ }
+
+ public CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
+ String componentId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ ComponentEntity componentEntity = getComponent(vspId, version, componentId);
+ ComponentData component = componentEntity.getComponentCompositionData();
+
+ ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
+ schemaInput.setManual(isManual(vspId, version));
+ schemaInput.setComponent(component);
+
+ CompositionEntityResponse<ComponentData> response = new CompositionEntityResponse<>();
+ response.setId(componentId);
+ response.setData(component);
+ response.setSchema(getComponentCompositionSchema(schemaInput));
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ return response;
+ }
+
+ @Override
+ public void deleteComponent(String vspId, Version version, String componentId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ if (!isManual(vspId, version)) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_COMPONENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete component");
+ throw new CoreException(
+ new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ }
+
+ //componentDao.updateVspLatestModificationTime(vspId, version);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ @Override
+ public QuestionnaireResponse getQuestionnaire(String vspId, Version version,
+ String componentId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ ComponentEntity component = componentDao.getQuestionnaireData(vspId, version, componentId);
+ VersioningUtil
+ .validateEntityExistence(component, new ComponentEntity(vspId, version, componentId),
+ VspDetails.ENTITY_TYPE);
+
+ questionnaireResponse.setData(component.getQuestionnaireData());
+ List<String> nicNames = nicManager.listNics(vspId, version, componentId, user).stream()
+ .map(nic -> nic.getNicCompositionData().getName()).collect(Collectors.toList());
+ questionnaireResponse.setSchema(getComponentQuestionnaireSchema(
+ new ComponentQuestionnaireSchemaInput(nicNames, questionnaireResponse.getData() == null
+ ? null
+ : JsonUtil.json2Object(questionnaireResponse.getData(), Map.class))));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ return questionnaireResponse;
+ }
+
+ @Override
+ public void updateQuestionnaire(String vspId, Version version, String componentId,
+ String questionnaireData, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ validateComponentExistence(vspId, version, componentId, user);
+
+ componentDao.updateQuestionnaireData(vspId, version, componentId, questionnaireData);
+
+ //componentDao.updateVspLatestModificationTime(vspId, version);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ @Override
+ public void validateComponentExistence(String vspId, Version version, String componentId,
+ String user) {
+ getComponent(vspId, version, componentId);
+ }
+
+ 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;
+ }
+
+ protected String getComponentCompositionSchema(ComponentCompositionSchemaInput schemaInput) {
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.component, schemaInput);
+ }
+
+ protected String getComponentQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component,
+ schemaInput);
+ }
+
+ 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/MibManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerFactoryImpl.java
new file mode 100644
index 0000000000..8c887e0140
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerFactoryImpl.java
@@ -0,0 +1,37 @@
+/*-
+ * ============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.openecomp.sdc.activityLog.ActivityLogManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.MibManager;
+import org.openecomp.sdc.vendorsoftwareproduct.MibManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDaoFactory;
+
+public class MibManagerFactoryImpl extends MibManagerFactory {
+ private static final MibManager INSTANCE =
+ new MibManagerImpl(MibDaoFactory.getInstance().createInterface(),
+ ActivityLogManagerFactory.getInstance().createInterface());
+
+ @Override
+ public MibManager createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..185cfa091b
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MibManagerImpl.java
@@ -0,0 +1,226 @@
+/*-
+ * ============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/NetworkManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerFactoryImpl.java
new file mode 100644
index 0000000000..34aaa0fee6
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerFactoryImpl.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.openecomp.sdc.vendorsoftwareproduct.NetworkManager;
+import org.openecomp.sdc.vendorsoftwareproduct.NetworkManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
+
+public class NetworkManagerFactoryImpl extends NetworkManagerFactory {
+ private static final NetworkManager INSTANCE =
+ new NetworkManagerImpl(
+ NetworkDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface());
+
+ @Override
+ public NetworkManager createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
new file mode 100644
index 0000000000..77b6b0039e
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
@@ -0,0 +1,177 @@
+/*-
+ * ============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.CollectionUtils;
+import org.openecomp.sdc.common.errors.CoreException;
+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.NetworkManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.CompositionEditNotAllowedErrorBuilder;
+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.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.NetworkCompositionSchemaInput;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
+import org.openecomp.sdc.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+
+public class NetworkManagerImpl implements NetworkManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ private NetworkDao networkDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+
+ public NetworkManagerImpl(NetworkDao networkDao,
+ CompositionEntityDataManager compositionEntityDataManager) {
+ this.networkDao = networkDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ }
+
+ @Override
+ public Collection<NetworkEntity> listNetworks(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
+ return networkDao.list(new NetworkEntity(vspId, version, null));
+ }
+
+ @Override
+ public NetworkEntity createNetwork(NetworkEntity network, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", network.getVspId());
+
+ if (!isManual(network.getVspId(), network.getVersion())) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_NETWORK, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create network");
+ throw new CoreException(
+ new CompositionEditNotAllowedErrorBuilder(network.getVspId(), network.getVersion())
+ .build());
+ }
+
+/* networkDao
+ .updateVspLatestModificationTime(network.getVspId(), network.getVersion());*/
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", network.getVspId());
+
+ return null;
+ }
+
+ private NetworkEntity createNetwork(NetworkEntity network) {
+ return compositionEntityDataManager.createNetwork(network);
+ }
+
+ @Override
+ public CompositionEntityValidationData updateNetwork(NetworkEntity network, String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, network id", network.getVspId(), network.getId());
+
+ NetworkEntity retrieved = getNetwork(network.getVspId(), network.getVersion(), network.getId());
+
+ NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
+ schemaInput.setManual(isManual(network.getVspId(), network.getVersion()));
+ schemaInput.setNetwork(retrieved.getNetworkCompositionData());
+
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(network, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ networkDao.update(network);
+ }
+
+/* networkDao
+ .updateVspLatestModificationTime(network.getVspId(), network.getVersion());*/
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, network id", network.getVspId(), network.getId());
+
+ return validationData;
+ }
+
+ @Override
+ public CompositionEntityResponse<Network> getNetwork(String vspId, Version version,
+ String networkId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, network id", vspId, networkId);
+
+ NetworkEntity networkEntity = getNetwork(vspId, version, networkId);
+ Network network = networkEntity.getNetworkCompositionData();
+
+ NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
+ schemaInput.setManual(isManual(vspId, version));
+ schemaInput.setNetwork(network);
+
+ CompositionEntityResponse<Network> response = new CompositionEntityResponse<>();
+ response.setId(networkId);
+ response.setData(network);
+ response.setSchema(getCompositionSchema(schemaInput));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, network id", vspId, networkId);
+
+ return response;
+ }
+
+
+ private NetworkEntity getNetwork(String vspId, Version version, String networkId) {
+ NetworkEntity retrieved = networkDao.get(new NetworkEntity(vspId, version, networkId));
+ VersioningUtil.validateEntityExistence(retrieved, new NetworkEntity(vspId, version, networkId),
+ VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ @Override
+ public void deleteNetwork(String vspId, Version version, String networkId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, network id", vspId, networkId);
+
+ if (!isManual(vspId, version)) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_NETWORK, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't delete network");
+ throw new CoreException(
+ new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
+ }
+
+ //networkDao.updateVspLatestModificationTime(vspId, version);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, network id", vspId, networkId);
+ }
+
+ // todo *************************** move to reusable place! *************************
+
+ private boolean isManual(String vspId, Version version) {
+ return false;
+ }
+
+ protected String getCompositionSchema(NetworkCompositionSchemaInput schemaInput) {
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.network, schemaInput);
+ }
+}
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
new file mode 100644
index 0000000000..1d911701f9
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerFactoryImpl.java
@@ -0,0 +1,40 @@
+/*-
+ * ============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.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.factory.CompositionEntityDataManagerFactory;
+
+public class NicManagerFactoryImpl extends NicManagerFactory {
+ private static final NicManager INSTANCE =
+ new NicManagerImpl(
+ NicDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ NetworkManagerFactory.getInstance().createInterface());
+
+ @Override
+ public NicManager createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..d73e0f5def
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
@@ -0,0 +1,250 @@
+/*-
+ * ============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.CollectionUtils;
+import org.openecomp.sdc.common.errors.CoreException;
+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.NetworkManager;
+import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
+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.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.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.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class NicManagerImpl implements NicManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ private NicDao nicDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+ private NetworkManager networkManager;
+
+ public NicManagerImpl(NicDao nicDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ NetworkManager networkManager) {
+ this.nicDao = nicDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.networkManager = networkManager;
+ }
+
+ @Override
+ public Collection<NicEntity> listNics(String vspId, Version version, String componentId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentId, null));
+
+ if (!nics.isEmpty()) {
+ Map<String, String> networksNameById = listNetworksNameById(vspId, version, user);
+ nics.forEach(nicEntity -> {
+ Nic nic = nicEntity.getNicCompositionData();
+ nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
+ nicEntity.setNicCompositionData(nic);
+ });
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ return nics;
+ }
+
+ private Map<String, String> listNetworksNameById(String vspId, Version version, String user) {
+ Collection<NetworkEntity> networks = networkManager.listNetworks(vspId, version, user);
+ return networks.stream().collect(Collectors.toMap(NetworkEntity::getId,
+ networkEntity -> networkEntity.getNetworkCompositionData().getName()));
+ }
+
+ @Override
+ public NicEntity createNic(NicEntity nic, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", nic.getVspId(),
+ nic.getComponentId());
+
+ if (!isManual(nic.getVspId(), nic.getVersion())) {
+ 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());
+ }
+
+ //nicDao.updateVspLatestModificationTime(nic.getVspId(), nic.getVersion());
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", nic.getVspId(), nic.getComponentId());
+
+ return null;
+ }
+
+ @Override
+ public CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
+ String nicId, String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id, nic id", vspId, componentId, nicId);
+
+ NicEntity nicEntity = getNic(vspId, version, componentId, nicId);
+ Nic nic = nicEntity.getNicCompositionData();
+
+ NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
+ schemaInput.setManual(isManual(vspId, version));
+ schemaInput.setNic(nic);
+ Map<String, String> networksNameById = listNetworksNameById(vspId, version, user);
+ nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
+ schemaInput.setNetworkIds(networksNameById.keySet());
+
+ CompositionEntityResponse<Nic> response = new CompositionEntityResponse<>();
+ response.setId(nicId);
+ response.setData(nic);
+ response.setSchema(getNicCompositionSchema(schemaInput));
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", vspId, componentId, nicId);
+
+ return response;
+ }
+
+
+ private NicEntity getNic(String vspId, Version version, String componentId, String nicId) {
+ NicEntity retrieved = nicDao.get(new NicEntity(vspId, version, componentId, nicId));
+ VersioningUtil
+ .validateEntityExistence(retrieved, new NicEntity(vspId, version, componentId, nicId),
+ VspDetails.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ @Override
+ public void deleteNic(String vspId, Version version, String componentId, String nicId,
+ String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
+
+ if (!isManual(vspId, version)) {
+ 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());
+ }
+
+ //nicDao.updateVspLatestModificationTime(vspId, version);
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", vspId, componentId, nicId);
+ }
+
+ @Override
+ public CompositionEntityValidationData updateNic(NicEntity nic, String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", nic.getVspId(), nic.getComponentId(),
+ nic.getId());
+
+ NicEntity retrieved =
+ getNic(nic.getVspId(), nic.getVersion(), nic.getComponentId(), nic.getId());
+
+ NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
+ schemaInput.setManual(isManual(nic.getVspId(), nic.getVersion()));
+ schemaInput.setNic(retrieved.getNicCompositionData());
+
+ CompositionEntityValidationData validationData = compositionEntityDataManager
+ .validateEntity(nic, SchemaTemplateContext.composition, schemaInput);
+ if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ nicDao.update(nic);
+ }
+
+ //nicDao.updateVspLatestModificationTime(nic.getVspId(), nic.getVersion());
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", nic.getVspId(), nic.getComponentId(),
+ nic.getId());
+
+ return validationData;
+ }
+
+ @Override
+ public QuestionnaireResponse getNicQuestionnaire(String vspId, Version version,
+ String componentId, String nicId, String user) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
+
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, version, componentId, nicId);
+ VersioningUtil.validateEntityExistence(nicQuestionnaire,
+ new NicEntity(vspId, version, componentId, nicId), VspDetails.ENTITY_TYPE);
+
+ questionnaireResponse.setData(nicQuestionnaire.getQuestionnaireData());
+ questionnaireResponse.setSchema(getNicQuestionnaireSchema(null));
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id", vspId, componentId, nicId);
+
+ return questionnaireResponse;
+ }
+
+ @Override
+ public void updateNicQuestionnaire(String vspId, Version version, String componentId,
+ String nicId, String questionnaireData, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
+
+ getNic(vspId, version, componentId, nicId);
+
+ nicDao.updateQuestionnaireData(vspId, version, componentId, nicId, questionnaireData);
+
+ //nicDao.updateVspLatestModificationTime(vspId, version);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId, nicId);
+ }
+
+ protected String getNicQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, schemaInput);
+ }
+
+ protected String getNicCompositionSchema(NicCompositionSchemaInput schemaInput) {
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.nic, schemaInput);
+ }
+ // todo *************************** move to reusable place! *************************
+
+ 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
new file mode 100644
index 0000000000..65aab2d9f4
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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.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.OrchestrationTemplateDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
+
+public class OrchestrationTemplateCandidateManagerFactoryImpl extends
+ OrchestrationTemplateCandidateManagerFactory {
+ private static final OrchestrationTemplateCandidateManager INSTANCE =
+ new OrchestrationTemplateCandidateManagerImpl(
+ VendorSoftwareProductDaoFactory.getInstance().createInterface(),
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ OrchestrationTemplateDaoFactory.getInstance().createInterface(),
+ CandidateServiceFactory.getInstance().createInterface(),
+ HealingManagerFactory.getInstance().createInterface(),
+ CompositionDataExtractorFactory.getInstance().createInterface(),
+ ServiceModelDaoFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ ActivityLogManagerFactory.getInstance().createInterface());
+
+
+ @Override
+ public OrchestrationTemplateCandidateManager createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..9373bfb3a6
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
@@ -0,0 +1,421 @@
+/*-
+ * ============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.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.core.model.dao.ServiceModelDao;
+import org.openecomp.core.model.types.ServiceElement;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+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.healing.api.HealingManager;
+import org.openecomp.sdc.healing.types.HealCode;
+import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
+import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
+import org.openecomp.sdc.heat.services.tree.HeatTreeManager;
+import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.logging.api.annotations.Metrics;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.types.LoggerServiceName;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+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.OrchestrationTemplateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.OrchestrationTemplateNotFoundErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
+import org.openecomp.sdc.vendorsoftwareproduct.services.utils.CandidateEntityBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.activitylog.types.ActivityType;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+public class OrchestrationTemplateCandidateManagerImpl
+ implements OrchestrationTemplateCandidateManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final Logger logger =
+ LoggerFactory.getLogger(OrchestrationTemplateCandidateManagerImpl.class);
+
+ private VendorSoftwareProductDao vendorSoftwareProductDao;
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private OrchestrationTemplateDao orchestrationTemplateDataDao;
+ private CandidateService candidateService;
+ private HealingManager healingManager;
+ private CompositionDataExtractor compositionDataExtractor;
+ private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
+ private CompositionEntityDataManager compositionEntityDataManager;
+ private ActivityLogManager activityLogManager;
+
+ public OrchestrationTemplateCandidateManagerImpl(
+ VendorSoftwareProductDao vendorSoftwareProductDao, VendorSoftwareProductInfoDao
+ vspInfoDao,
+ OrchestrationTemplateDao orchestrationTemplateDataDao,
+ CandidateService candidateService, HealingManager healingManager,
+ CompositionDataExtractor compositionDataExtractor,
+ ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ ActivityLogManager activityLogManager) {
+ this.vendorSoftwareProductDao = vendorSoftwareProductDao;
+ this.vspInfoDao = vspInfoDao;
+ this.orchestrationTemplateDataDao = orchestrationTemplateDataDao;
+ this.candidateService = candidateService;
+ this.healingManager = healingManager;
+ this.compositionDataExtractor = compositionDataExtractor;
+ this.serviceModelDao = serviceModelDao;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.activityLogManager = activityLogManager;
+ }
+
+ @Override
+ @Metrics
+ public UploadFileResponse upload(String vspId, Version version, InputStream heatFileToUpload,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ VspDetails vspDetails = getVspDetails(vspId, version);
+
+ UploadFileResponse uploadFileResponse = new UploadFileResponse();
+ if (isNotEmptyFileToUpload(heatFileToUpload, uploadFileResponse)) {
+ return uploadFileResponse;
+ }
+
+ byte[] uploadedFileData = FileUtils.toByteArray(heatFileToUpload);
+ if (isInvalidRawZipData(uploadFileResponse, uploadedFileData)) {
+ return uploadFileResponse;
+ }
+
+ Optional<FileContentHandler> optionalContentMap =
+ getZipContentMap(uploadFileResponse, uploadedFileData);
+ if (!optionalContentMap.isPresent()) {
+ logger.error(Messages.ZIP_CONTENT_MAP.getErrorMessage());
+ uploadFileResponse
+ .addStructureError(
+ SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.ERROR, Messages.ZIP_CONTENT_MAP.getErrorMessage()));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return uploadFileResponse;
+ }
+
+ if (!MapUtils.isEmpty(uploadFileResponse.getErrors())) {
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return uploadFileResponse;
+ }
+ try {
+ OrchestrationTemplateCandidateData candidateData =
+ new CandidateEntityBuilder(candidateService)
+ .buildCandidateEntityFromZip(vspDetails, uploadedFileData, optionalContentMap.get(),
+ uploadFileResponse.getErrors(), user);
+ candidateService.updateCandidateUploadData(candidateData, vspDetails.getId());
+ } catch (Exception exception) {
+ logger.error(Messages.ZIP_CONTENT_MAP.getErrorMessage());
+ uploadFileResponse
+ .addStructureError(
+ SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return uploadFileResponse;
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return uploadFileResponse;
+ }
+
+ @Override
+ public OrchestrationTemplateActionResponse process(String vspId,
+ Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ Optional<OrchestrationTemplateCandidateData> candidate =
+ fetchCandidateDataEntity(vspId, version);
+ if (!candidate.isPresent()) {
+ throw new CoreException(new OrchestrationTemplateNotFoundErrorBuilder(vspId).build());
+ }
+
+ OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
+ UploadFileResponse uploadFileResponse = new UploadFileResponse();
+ OrchestrationTemplateCandidateData candidateDataEntity = candidate.get();
+ Optional<FileContentHandler> fileContent =
+ getZipContentMap(uploadFileResponse, candidateDataEntity.getContentData().array());
+ if (!fileContent.isPresent()) {
+ response.addStructureErrors(uploadFileResponse.getErrors());
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return response;
+ }
+
+ Map<String, List<ErrorMessage>> uploadErrors = uploadFileResponse.getErrors();
+ FileContentHandler fileContentMap = fileContent.get();
+ FilesDataStructure structure =
+ JsonUtil.json2Object(candidateDataEntity.getFilesDataStructure(), FilesDataStructure.class);
+
+ if (CollectionUtils.isNotEmpty(structure.getUnassigned())) {
+ response.addErrorMessageToMap(SdcCommon.UPLOAD_FILE,
+ Messages.FOUND_UNASSIGNED_FILES.getErrorMessage(), ErrorLevel.ERROR);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return response;
+ }
+
+ VspDetails vspDetails =
+ getVspDetails(vspId, version);
+
+ 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;
+ }
+ deleteUploadDataAndContent(vspId, version);
+ saveHotData(vspId, version, zipByteArrayInputStream.get(), fileContentMap, tree);
+
+ ToscaServiceModel toscaServiceModel =
+ HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap)
+ .getToscaServiceModel();
+ if (toscaServiceModel != null) {
+ serviceModelDao.storeServiceModel(vspId, version, toscaServiceModel);
+ compositionEntityDataManager.saveCompositionData(vspId, version,
+ compositionDataExtractor.extractServiceCompositionData(toscaServiceModel));
+ }
+ uploadFileResponse.addStructureErrors(uploadErrors);
+
+ ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspId, String.valueOf(version.getMajor()+1),
+ ActivityType.UPLOAD_HEAT.toString(), user, true, "", "");
+ activityLogManager.addActionLog(activityLogEntity, user);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return response;
+ }
+
+
+ @Override
+ public Optional<FilesDataStructure> getFilesDataStructure(
+ String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ Optional<FilesDataStructure> candidateFileDataStructure =
+ candidateService.getOrchestrationTemplateCandidateFileDataStructure(vspId, version);
+ if (candidateFileDataStructure.isPresent()) {
+ return candidateFileDataStructure;
+ } else {
+ Map<String, Object> healingParams = getHealingParamsAsMap(vspId, version, user);
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id", vspId);
+ return (Optional<FilesDataStructure>) healingManager
+ .heal(HealCode.FILE_DATA_STRUCTURE_HEALER, healingParams);
+ }
+ }
+
+ @Override
+
+ public ValidationResponse updateFilesDataStructure(String vspId,
+ Version version, String user,
+ FilesDataStructure fileDataStructure) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ ValidationResponse response = new ValidationResponse();
+ Optional<List<ErrorMessage>> validateErrors =
+ candidateService.validateFileDataStructure(fileDataStructure);
+ if (validateErrors.isPresent()) {
+ List<ErrorMessage> errorMessages = validateErrors.get();
+ if (CollectionUtils.isNotEmpty(errorMessages)) {
+ Map<String, List<ErrorMessage>> errorsMap = new HashMap<>();
+ errorsMap.put(SdcCommon.UPLOAD_FILE, errorMessages);
+ response.setUploadDataErrors(errorsMap, LoggerServiceName.Update_Manifest,
+ LoggerTragetServiceName.VALIDATE_FILE_DATA_STRUCTURE);
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id", vspId);
+ return response;
+ }
+ }
+ candidateService.updateOrchestrationTemplateCandidateFileDataStructure(vspId, version,
+ fileDataStructure);
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id", vspId);
+ return response;
+ }
+
+ @Override
+
+ public Optional<byte[]> get(String vspId, Version version, String user)
+ throws IOException {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ VspDetails vspDetails =
+ getVspDetails(vspId, version);
+
+ Optional<OrchestrationTemplateCandidateData> candidateDataEntity =
+ fetchCandidateDataEntity(vspId, version);
+
+ if (!candidateDataEntity.isPresent()) {
+ ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage());
+ logger.error(errorMessage.getMessage());
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id", vspId);
+ return Optional.empty();
+ }
+
+ FilesDataStructure structure = JsonUtil
+ .json2Object(candidateDataEntity.get().getFilesDataStructure(), FilesDataStructure.class);
+ String manifest = candidateService.createManifest(vspDetails, structure);
+
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id", vspId);
+ return Optional.ofNullable(candidateService
+ .replaceManifestInZip(candidateDataEntity.get().getContentData(), manifest, vspId));
+ }
+
+ private Optional<OrchestrationTemplateCandidateData> fetchCandidateDataEntity(
+ String vspId, Version version) {
+ return Optional
+ .ofNullable(candidateService.getOrchestrationTemplateCandidate(vspId, version));
+ }
+
+ private HeatStructureTree createAndValidateHeatTree(OrchestrationTemplateActionResponse response,
+ FileContentHandler fileContentMap) {
+ VendorSoftwareProductUtils.addFileNamesToUploadFileResponse(fileContentMap, response);
+ Map<String, List<ErrorMessage>> validationErrors =
+ ValidationManagerUtil.initValidationManager(fileContentMap).validate();
+ response.getErrors().putAll(validationErrors);
+
+ HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(fileContentMap);
+ heatTreeManager.createTree();
+ heatTreeManager.addErrors(validationErrors);
+ return heatTreeManager.getTree();
+ }
+
+ private void saveHotData(String vspId, Version activeVersion, InputStream uploadedFileData,
+ FileContentHandler fileContentMap, HeatStructureTree tree) {
+ Map<String, Object> manifestAsMap =
+ (Map<String, Object>) JsonUtil.json2Object(fileContentMap.getFileContent(
+ SdcCommon.MANIFEST_NAME), Map.class);
+
+ UploadData uploadData = new UploadData();
+ uploadData.setPackageName((String) manifestAsMap.get("name"));
+ uploadData.setPackageVersion((String) manifestAsMap.get("version"));
+ uploadData.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(uploadedFileData)));
+ uploadData.setValidationDataStructure(new ValidationStructureList(tree));
+ orchestrationTemplateDataDao.updateOrchestrationTemplateData(vspId, uploadData);
+ }
+
+ private void deleteUploadDataAndContent(String vspId, Version version) {
+ //fixme change this when more tables are zusammenized
+ vendorSoftwareProductDao.deleteUploadData(vspId, version);
+ }
+
+ private boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData) {
+ Optional<ErrorMessage> errorMessage;
+ errorMessage = candidateService.validateRawZipData(uploadedFileData);
+ if (errorMessage.isPresent()) {
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isNotEmptyFileToUpload(InputStream heatFileToUpload,
+ UploadFileResponse uploadFileResponse) {
+ Optional<ErrorMessage> errorMessage =
+ candidateService.validateNonEmptyFileToUpload(heatFileToUpload);
+ if (errorMessage.isPresent()) {
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
+ return true;
+ }
+ return false;
+ }
+
+ private Optional<FileContentHandler> getZipContentMap(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData) {
+ FileContentHandler contentMap = null;
+ try {
+ contentMap = CommonUtil.loadUploadFileContent(uploadedFileData);
+ } catch (IOException exception) {
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
+ } catch (CoreException coreException) {
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
+ }
+ return Optional.ofNullable(contentMap);
+ }
+
+ // todo *************************** move to reusable place! *************************
+
+ private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
+ Map<String, Object> healingParams = new HashMap<>();
+
+ healingParams.put(SdcCommon.VSP_ID, vspId);
+ healingParams.put(SdcCommon.VERSION, version);
+ healingParams.put(SdcCommon.USER, user);
+
+ return healingParams;
+ }
+
+ public 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/ProcessManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
new file mode 100644
index 0000000000..d870454de7
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.openecomp.sdc.activityLog.ActivityLogManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.ProcessManager;
+import org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+
+public class ProcessManagerFactoryImpl extends ProcessManagerFactory {
+ private static final ProcessManager INSTANCE =
+ new ProcessManagerImpl(
+ VendorSoftwareProductDaoFactory.getInstance().createInterface(),
+ ActivityLogManagerFactory.getInstance().createInterface());
+
+ @Override
+ public ProcessManager createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..4fa67ff2d3
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
@@ -0,0 +1,297 @@
+/*-
+ * ============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.openecomp.core.util.UniqueValueUtil;
+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.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.ProcessManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.UploadInvalidErrorBuilder;
+import org.openecomp.sdc.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdcrests.activitylog.types.ActivityType;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+
+public class ProcessManagerImpl implements ProcessManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private ActivityLogManager activityLogManager;
+
+ private VendorSoftwareProductDao vendorSoftwareProductDao;
+
+ public ProcessManagerImpl(VendorSoftwareProductDao vendorSoftwareProductDao, ActivityLogManager activityLogManager) {
+ this.vendorSoftwareProductDao = vendorSoftwareProductDao;
+ this.activityLogManager = activityLogManager;
+ }
+
+ @Override
+ public Collection<ProcessEntity> listProcesses(String vspId, Version version,
+ String componentId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ return vendorSoftwareProductDao.listProcesses(vspId, version, componentId);
+ }
+
+ @Override
+ public void deleteProcesses(String vspId, Version version, String componentId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ Collection<ProcessEntity> processes =
+ vendorSoftwareProductDao.listProcesses(vspId, version, componentId);
+
+ if (!processes.isEmpty()) {
+ for (ProcessEntity process : processes) {
+ deleteUniqueValue(process.getVspId(), process.getVersion(), process.getComponentId(),
+ process.getName());
+ }
+
+ vendorSoftwareProductDao.deleteProcesses(vspId, version, componentId);
+ }
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ @Override
+ public ProcessEntity createProcess(ProcessEntity process, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", process.getId(),
+ process.getComponentId());
+ validateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
+ process.getName());
+ //process.setId(CommonMethods.nextUuId());
+
+ vendorSoftwareProductDao.createProcess(process);
+ createUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
+ process.getName());
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", process.getId(),
+ process.getComponentId());
+
+ return process;
+ }
+
+
+ @Override
+ public ProcessEntity getProcess(String vspId, Version version, String componentId,
+ String processId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ProcessEntity retrieved =
+ vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
+ validateProcessExistence(vspId, version, componentId, processId, retrieved);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ return retrieved;
+ }
+
+ @Override
+ public void updateProcess(ProcessEntity process, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", process.getId(),
+ process.getComponentId());
+
+ ProcessEntity retrieved = vendorSoftwareProductDao
+ .getProcess(process.getVspId(), process.getVersion(), process.getComponentId(),
+ process.getId());
+ validateProcessExistence(process.getVspId(), process.getVersion(), process.getComponentId(),
+ process.getId(), retrieved);
+
+ updateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
+ retrieved.getName(), process.getName());
+ vendorSoftwareProductDao.updateProcess(process);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", process.getId(),
+ process.getComponentId());
+ }
+
+ @Override
+ public void deleteProcess(String vspId, Version version, String componentId, String processId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ProcessEntity retrieved =
+ vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
+ validateProcessExistence(vspId, version, componentId, processId, retrieved);
+
+ vendorSoftwareProductDao.deleteProcess(vspId, version, componentId, processId);
+ deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(),
+ retrieved.getName());
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+
+ @Override
+ public File getProcessArtifact(String vspId, Version version, String componentId,
+ String processId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ProcessEntity retrieved =
+ vendorSoftwareProductDao.getProcessArtifact(vspId, version, componentId, processId);
+ validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
+
+ File file = new File(String.format("%s_%s_%s", vspId, componentId, processId));
+ try {
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(retrieved.getArtifact().array());
+ fos.close();
+ } catch (IOException exception) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't get process artifact");
+ throw new CoreException(new UploadInvalidErrorBuilder().build());
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ return file;
+ }
+
+ @Override
+ public void deleteProcessArtifact(String vspId, Version version, String componentId,
+ String processId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ProcessEntity retrieved =
+ vendorSoftwareProductDao.getProcessArtifact(vspId, version, componentId, processId);
+ validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
+
+ vendorSoftwareProductDao.deleteProcessArtifact(vspId, version, componentId, processId);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ @Override
+ public void uploadProcessArtifact(InputStream artifactFile, String artifactFileName, String vspId,
+ Version version, String componentId, String processId,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ProcessEntity retrieved =
+ vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
+ validateProcessExistence(vspId, version, componentId, processId, retrieved);
+
+ if (artifactFile == null) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPLOAD_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't upload process artifact");
+ throw new CoreException(new UploadInvalidErrorBuilder().build());
+ }
+
+ byte[] artifact;
+ try {
+ artifact = FileUtils.toByteArray(artifactFile);
+ } catch (RuntimeException exception) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.UPLOAD_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't upload process artifact");
+ throw new CoreException(new UploadInvalidErrorBuilder().build());
+ }
+
+ vendorSoftwareProductDao.uploadProcessArtifact(vspId, version, componentId, processId, artifact,
+ artifactFileName);
+ 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 validateProcessExistence(String vspId, Version version, String componentId,
+ String processId, ProcessEntity retrieved) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
+ processId);
+
+ if (retrieved != null) {
+ return;
+ }
+ VersioningUtil.validateEntityExistence(retrieved,
+ new ProcessEntity(vspId, version, componentId, processId),
+ VspDetails.ENTITY_TYPE);//todo retrieved is always null ??
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, process id", vspId, componentId,
+ processId);
+ }
+
+ private void validateProcessArtifactExistence(String vspId, Version version, String componentId,
+ String processId, ProcessEntity retrieved) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
+ processId);
+
+ if (retrieved != null) {
+ VersioningUtil.validateEntityExistence(retrieved.getArtifact(),
+ new ProcessEntity(vspId, version, componentId, processId),
+ VspDetails.ENTITY_TYPE);
+ } else {
+ VersioningUtil.validateEntityExistence(retrieved,
+ new ProcessEntity(vspId, version, componentId, processId),
+ VspDetails.ENTITY_TYPE); //todo retrieved is always null ??
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id, process id", vspId, componentId,
+ processId);
+ }
+
+
+ protected void validateUniqueName(String vspId, Version version, String componentId,
+ String processName) {
+ UniqueValueUtil.validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME,
+ vspId, version.toString(), componentId, processName);
+ }
+
+ protected void createUniqueName(String vspId, Version version, String componentId,
+ String processName) {
+ UniqueValueUtil
+ .createUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
+ version.toString(), componentId, processName);
+ }
+
+ protected void updateUniqueName(String vspId, Version version, String componentId,
+ String oldProcessName, String newProcessName) {
+ UniqueValueUtil
+ .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, oldProcessName,
+ newProcessName, vspId, version.toString(), componentId);
+ }
+
+ protected void deleteUniqueValue(String vspId, Version version, String componentId,
+ String processName) {
+ UniqueValueUtil
+ .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
+ version.toString(), componentId, processName);
+ }
+}
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 191c8d728c..0d2023f387 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
@@ -7,9 +7,9 @@
* 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.
@@ -20,166 +20,300 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.CSAR;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UPLOAD_RAW_DATA;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.VSP_PACKAGE_ZIP;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.enrichment.EnrichmentArtifactsServiceFactory;
import org.openecomp.core.enrichment.api.EnrichmentManager;
-import org.openecomp.core.enrichment.enrichmentartifacts.EnrichmentArtifactsService;
import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
-import org.openecomp.core.enrichment.types.ComponentArtifactType;
import org.openecomp.core.model.dao.EnrichedServiceModelDao;
-import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
import org.openecomp.core.model.dao.ServiceModelDao;
-import org.openecomp.core.model.dao.ServiceModelDaoFactory;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.util.UniqueValueUtil;
-import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileContentHandler;
-import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonSchemaDataGenerator;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.validation.api.ValidationManager;
-import org.openecomp.core.validation.errors.Messages;
-import org.openecomp.core.validation.types.MessageContainerUtil;
+import org.openecomp.core.validation.util.MessageContainerUtil;
+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.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
-import org.openecomp.sdc.common.utils.AsdcCommon;
+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.enrichment.impl.tosca.ComponentInfo;
-import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
-import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
-import org.openecomp.sdc.heat.services.tree.HeatTreeManager;
-import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil;
+import org.openecomp.sdc.healing.api.HealingManager;
+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.LoggerServiceName;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
-import org.openecomp.sdc.validation.utils.ValidationManagerUtil;
-import org.openecomp.sdc.vendorlicense.VendorLicenseArtifactServiceFactory;
+import org.openecomp.sdc.validation.util.ValidationManagerUtil;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentArtifactEntity;
+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.NetworkEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessArtifactEntity;
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.CreatePackageForNonFinalVendorSoftwareProductErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.FileCreationErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.MibUploadErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.InformationArtifactCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageInvalidErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.UploadInvalidErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductNotFoundErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.services.CompositionDataExtractor;
-import org.openecomp.sdc.vendorsoftwareproduct.services.CompositionEntityDataManager;
-import org.openecomp.sdc.vendorsoftwareproduct.services.SchemaGenerator;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData;
+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.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
-import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentCompositionSchemaInput;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQuestionnaireSchemaInput;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.NetworkCompositionSchemaInput;
-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.util.CompilationUtil;
-import org.openecomp.sdc.vendorsoftwareproduct.util.VendorSoftwareProductUtils;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.ComponentDependencyTracker;
import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
import org.openecomp.sdc.versioning.types.VersionInfo;
import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+import org.openecomp.sdcrests.activitylog.types.ActivityType;
+import org.slf4j.MDC;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
+import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
-/**
- * The type Vendor software product manager.
- */
public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager {
+ private static final String VALIDATION_VSP_ID = "validationOnlyVspId";
+ private static final String VALIDATION_VSP_NAME = "validationOnlyVspName";
+ //private static final String VALIDATION_VSP_USER = "validationOnlyVspUser";
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final Logger logger =
+ LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
+
+ private OrchestrationTemplateDao orchestrationTemplateDao;
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private VersioningManager versioningManager;
+ private VendorSoftwareProductDao vendorSoftwareProductDao;
+ private VendorLicenseFacade vendorLicenseFacade;
+ private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
+ private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
+ private HealingManager healingManager;
+ private VendorLicenseArtifactsService licenseArtifactsService;
+ private CompositionEntityDataManager compositionEntityDataManager;
+ private InformationArtifactGenerator informationArtifactGenerator;
+ private PackageInfoDao packageInfoDao;
+ private ActivityLogManager activityLogManager;
+
+
+ public VendorSoftwareProductManagerImpl(
+ VersioningManager versioningManager,
+ VendorSoftwareProductDao vendorSoftwareProductDao,
+ OrchestrationTemplateDao orchestrationTemplateDataDao,
+ VendorSoftwareProductInfoDao vspInfoDao,
+ VendorLicenseFacade vendorLicenseFacade,
+ ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
+ EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao,
+ HealingManager healingManager,
+ VendorLicenseArtifactsService licenseArtifactsService,
+ CompositionEntityDataManager compositionEntityDataManager,
+ InformationArtifactGenerator informationArtifactGenerator,
+ PackageInfoDao packageInfoDao,
+ ActivityLogManager activityLogManager) {
+ this.versioningManager = versioningManager;
+ this.vendorSoftwareProductDao = vendorSoftwareProductDao;
+ this.orchestrationTemplateDao = orchestrationTemplateDataDao;
+ this.vspInfoDao = vspInfoDao;
+ this.vendorLicenseFacade = vendorLicenseFacade;
+ this.serviceModelDao = serviceModelDao;
+ this.enrichedServiceModelDao = enrichedServiceModelDao;
+ this.healingManager = healingManager;
+ this.licenseArtifactsService = licenseArtifactsService;
+ this.compositionEntityDataManager = compositionEntityDataManager;
+ this.informationArtifactGenerator = informationArtifactGenerator;
+ this.packageInfoDao = packageInfoDao;
+ this.activityLogManager = activityLogManager;
+
+ registerToVersioning();
+ }
+
+ private void registerToVersioning() {
+ vendorSoftwareProductDao.registerVersioning(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ serviceModelDao.registerVersioning(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ enrichedServiceModelDao.registerVersioning(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ }
+
+ @Override
+ public Version checkout(String vendorSoftwareProductId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vendorSoftwareProductId);
+ MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkout_Entity.toString());
+
+ Version newVersion = versioningManager
+ .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
+ vendorSoftwareProductId, user);
+
+ if (newVersion != null) {
+ ActivityLogEntity activityLogEntity =
+ new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(newVersion.getMajor() + 1),
+ ActivityType.CHECKOUT.toString(), user, true, "", "");
+ activityLogManager.addActionLog(activityLogEntity, user);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vendorSoftwareProductId);
+ return newVersion;
+ }
+
- private static final String VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG =
- "Composition entities may not be created / deleted for Vendor Software Product whose "
- + "entities were uploaded";
-
- private static final VersioningManager versioningManager =
- VersioningManagerFactory.getInstance().createInterface();
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
- private static final VendorLicenseFacade vendorLicenseFacade =
- VendorLicenseFacadeFactory.getInstance().createInterface();
- private static final ComponentArtifactDao componentArtifactDao =
- ComponentArtifactDaoFactory.getInstance().createInterface();
- private static final ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao =
- ServiceModelDaoFactory.getInstance().createInterface();
- private static final EnrichedServiceModelDao<ToscaServiceModel, ServiceElement>
- enrichedServiceModelDao = EnrichedServiceModelDaoFactory.getInstance().createInterface();
- private static VendorLicenseArtifactsService licenseArtifactsService =
- VendorLicenseArtifactServiceFactory.getInstance().createInterface();
- private static EnrichmentArtifactsService enrichmentArtifactsService =
- EnrichmentArtifactsServiceFactory.getInstance().createInterface();
-
-
- /**
- * Instantiates a new Vendor software product manager.
- */
- public VendorSoftwareProductManagerImpl() {
- vendorSoftwareProductDao.registerVersioning(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
- serviceModelDao.registerVersioning(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
- enrichedServiceModelDao.registerVersioning(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
- componentArtifactDao.registerVersioning(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ @Override
+ public Version undoCheckout(String vendorSoftwareProductId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vendorSoftwareProductId);
+
+ Version version =
+ getVersionInfo(vendorSoftwareProductId, VersionableEntityAction.Read, user)
+ .getActiveVersion();
+ String preVspName = vspInfoDao
+ .get(new VspDetails(vendorSoftwareProductId, version)).getName();
+
+ Version newVersion = versioningManager.undoCheckout(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
+ vendorSoftwareProductId, user);
+
+ String postVspName = vspInfoDao
+ .get(new VspDetails(vendorSoftwareProductId, newVersion))
+ .getName();
+
+ updateUniqueName(preVspName, postVspName);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vendorSoftwareProductId);
+
+ return newVersion;
}
- private static List<ErrorCode> validateCompletedVendorSoftwareProduct(VspDetails vspDetails,
- UploadDataEntity uploadData,
- Object serviceModel) {
+ @Override
+ public Version checkin(String vendorSoftwareProductId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vendorSoftwareProductId);
+
+ Version newVersion = versioningManager.checkin(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
+ vendorSoftwareProductId, user, null);
+
+ if (newVersion != null) {
+ ActivityLogEntity activityLogEntity =
+ new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(newVersion.getMajor() + 1),
+ ActivityType.CHECKIN.toString(), user, true, "", "");
+ activityLogManager.addActionLog(activityLogEntity, user);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vendorSoftwareProductId);
+
+ return newVersion;
+ }
+
+ @Override
+ public ValidationResponse submit(String vspId, String user) throws IOException {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ Version version = getVersionInfo(vspId, VersionableEntityAction.Read, user).getActiveVersion();
+ VspDetails vspDetails = getVsp(vspId, version, user);
+ UploadDataEntity uploadData = orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
+ ToscaServiceModel serviceModel =
+ serviceModelDao.getServiceModel(vspId, vspDetails.getVersion());
+
+ ValidationResponse validationResponse = new ValidationResponse();
+ validationResponse
+ .setVspErrors(validateCompletedVendorSoftwareProduct(vspDetails, uploadData, serviceModel),
+ LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
+
+ if (isCyclicDependencyInComponents(vspId, vspDetails.getVersion())) {
+ Collection<ErrorCode> vspErrors = validationResponse.getVspErrors() == null
+ ? new ArrayList<>()
+ : validationResponse.getVspErrors();
+ vspErrors.add(ComponentDependencyModelErrorBuilder
+ .getcyclicDependencyComponentErrorBuilder());
+ validationResponse.setVspErrors(vspErrors, LoggerServiceName.Submit_VSP,
+ LoggerTragetServiceName.SUBMIT_VSP);
+ }
+
+ validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
+ validationResponse
+ .setUploadDataErrors(validateUploadData(uploadData), LoggerServiceName.Submit_VSP,
+ LoggerTragetServiceName.SUBMIT_VSP);
+ validationResponse.setQuestionnaireValidationResult(
+ validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion()));
+
+ validationResponse.setCompilationErrors(
+ compile(vspId, vspDetails.getVersion(), serviceModel),
+ LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
+
+ if (validationResponse.isValid()) {
+ Version newVersion = versioningManager.submit(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
+ vspId, user, null);
+ ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspDetails.getId(), String
+ .valueOf(newVersion.getMajor()),
+ ActivityType.SUBMIT.toString(), user, true, "", "");
+ activityLogManager.addActionLog(activityLogEntity, user);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
+ return validationResponse;
+ }
+
+ private boolean isCyclicDependencyInComponents(String vendorSoftwareProductId,
+ Version version) {
+ final Collection<ComponentDependencyModelEntity> componentDependencyModelEntities =
+ vendorSoftwareProductDao.listComponentDependencies(vendorSoftwareProductId, version);
+ ComponentDependencyTracker dependencyTracker = new ComponentDependencyTracker();
+
+ for (ComponentDependencyModelEntity entity : componentDependencyModelEntities) {
+ dependencyTracker.addDependency(entity.getSourceComponentId(), entity.getTargetComponentId());
+ }
+ return dependencyTracker.isCyclicDependencyPresent();
+ }
+
+ private static List<ErrorCode> validateCompletedVendorSoftwareProduct(
+ VspDetails vspDetails, UploadDataEntity uploadData, Object serviceModel) {
+
List<ErrorCode> errros = new ArrayList<>();
if (vspDetails.getName() == null) {
@@ -220,171 +354,107 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return new ValidationErrorBuilder("must be supplied", fieldName).build();
}
- private static String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugExitMessage(null);
return SchemaGenerator
.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
}
- private static String getComponentQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component,
- schemaInput);
- }
-
- private static String getNicQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, schemaInput);
- }
-
private static void sortVspListByModificationTimeDescOrder(
- List<VersionedVendorSoftwareProductInfo> vendorLicenseModels) {
- Collections.sort(vendorLicenseModels, new Comparator<VersionedVendorSoftwareProductInfo>() {
- @Override
- public int compare(VersionedVendorSoftwareProductInfo o1,
- VersionedVendorSoftwareProductInfo o2) {
- return o2.getVspDetails().getWritetimeMicroSeconds()
- .compareTo(o1.getVspDetails().getWritetimeMicroSeconds());
- }
- });
- }
-
- private boolean isManual(String vspId, Version version) {
- return false;
- }
-
- @Override
- public Version checkout(String vendorSoftwareProductId, String user) {
- Version newVersion = versioningManager
- .checkout(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vendorSoftwareProductId, user);
- vendorSoftwareProductDao.updateVspLatestModificationTime(vendorSoftwareProductId, newVersion);
- return newVersion;
- }
-
- @Override
- public Version undoCheckout(String vendorSoftwareProductId, String user) {
- Version newVersion = versioningManager
- .undoCheckout(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vendorSoftwareProductId, user);
- vendorSoftwareProductDao.updateVspLatestModificationTime(vendorSoftwareProductId, newVersion);
- return newVersion;
- }
-
- @Override
- public Version checkin(String vendorSoftwareProductId, String user) {
- Version newVersion = versioningManager
- .checkin(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vendorSoftwareProductId, user, null);
- vendorSoftwareProductDao.updateVspLatestModificationTime(vendorSoftwareProductId, newVersion);
- return newVersion;
+ List<VersionedVendorSoftwareProductInfo> vsps) {
+ vsps.sort((o1, o2) -> o2.getVspDetails().getWritetimeMicroSeconds()
+ .compareTo(o1.getVspDetails().getWritetimeMicroSeconds()));
}
- @Override
- public ValidationResponse submit(String vendorSoftwareProductId, String user) throws IOException {
- VspDetails vspDetails = getVspDetails(vendorSoftwareProductId, null, user).getVspDetails();
- UploadDataEntity uploadData = vendorSoftwareProductDao
- .getUploadData(new UploadDataEntity(vendorSoftwareProductId, vspDetails.getVersion()));
- ToscaServiceModel serviceModel =
- serviceModelDao.getServiceModel(vendorSoftwareProductId, vspDetails.getVersion());
- Version newVersion = null;
-
- ValidationResponse validationResponse = new ValidationResponse();
- validationResponse
- .setVspErrors(validateCompletedVendorSoftwareProduct(vspDetails, uploadData, serviceModel));
- validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
- validationResponse.setUploadDataErrors(validateUploadData(uploadData));
- validationResponse.setQuestionnaireValidationResult(
- validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion()));
- validationResponse.setCompilationErrors(
- compile(vendorSoftwareProductId, vspDetails.getVersion(), serviceModel));
-
- if (validationResponse.isValid()) {
- newVersion = versioningManager
- .submit(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vendorSoftwareProductId, user, null);
- }
- //vendorSoftwareProductDao.updateVspLatestModificationTime(vendorSoftwareProductId, newVersion);
- return validationResponse;
- }
private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version,
ToscaServiceModel serviceModel) {
- Collection<ComponentEntity> components = listComponents(vendorSoftwareProductId, version);
if (serviceModel == null) {
return null;
}
- if (CollectionUtils.isEmpty(components)) {
- enrichedServiceModelDao.storeServiceModel(vendorSoftwareProductId, version, serviceModel);
- return null;
- }
+
+ enrichedServiceModelDao.deleteAll(vendorSoftwareProductId, version);
+
EnrichmentManager<ToscaServiceModel> enrichmentManager =
EnrichmentManagerFactory.getInstance().createInterface();
- enrichmentManager.initInput(vendorSoftwareProductId, version);
- enrichmentManager.addModel(serviceModel);
-
- ComponentInfo componentInfo = new ComponentInfo();
- Map<String, List<ErrorMessage>> compileErrors = new HashMap<>();
- CompilationUtil.addMonitoringInfo(componentInfo, compileErrors);
- for (ComponentEntity componentEntity : components) {
- ComponentInfo currentEntityComponentInfo = new ComponentInfo();
- currentEntityComponentInfo.setCeilometerInfo(componentInfo.getCeilometerInfo());
- CompilationUtil
- .addMibInfo(vendorSoftwareProductId, version, componentEntity, currentEntityComponentInfo,
- compileErrors);
- enrichmentManager.addEntityInput(componentEntity.getComponentCompositionData().getName(),
- currentEntityComponentInfo);
+ enrichmentManager.init(vendorSoftwareProductId, version);
+ enrichmentManager.setModel(serviceModel);
+ Map<String, List<ErrorMessage>> enrichErrors = enrichmentManager.enrich();
- }
- Map<String, List<ErrorMessage>> enrichErrors;
- enrichErrors = enrichmentManager.enrich();
enrichedServiceModelDao
.storeServiceModel(vendorSoftwareProductId, version, enrichmentManager.getModel());
- if (enrichErrors != null) {
- compileErrors.putAll(enrichErrors);
- }
- vendorSoftwareProductDao.updateVspLatestModificationTime(vendorSoftwareProductId, version);
-
- return compileErrors;
+ return enrichErrors;
}
private Collection<ErrorCode> validateLicensingData(VspDetails vspDetails) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspDetails.getId());
+
if (vspDetails.getVendorId() == null || vspDetails.getVlmVersion() == null
|| vspDetails.getLicenseAgreement() == null
|| CollectionUtils.isEmpty(vspDetails.getFeatureGroups())) {
return null;
}
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
return vendorLicenseFacade
.validateLicensingData(vspDetails.getVendorId(), vspDetails.getVlmVersion(),
vspDetails.getLicenseAgreement(), vspDetails.getFeatureGroups());
}
@Override
- public VspDetails createNewVsp(VspDetails vspDetails, String user) {
- UniqueValueUtil.validateUniqueValue(
- VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
- vspDetails.getName());
- vspDetails.setId(CommonMethods.nextUuId());
+ public String fetchValidationVsp(String user) {
+ try {
+ validateUniqueName(VALIDATION_VSP_NAME);
+ } catch (Exception ignored) {
+ return VALIDATION_VSP_ID;
+ }
+ VspDetails validationVsp = new VspDetails();
+ validationVsp.setName(VALIDATION_VSP_NAME);
+ validationVsp.setId(VALIDATION_VSP_ID);
+ Version version = versioningManager.create(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
+ validationVsp.getId(),
+ user);
+ validationVsp.setVersion(version);
- // vspDetails.setLastModificationTime(new Date());
+ vspInfoDao.create(validationVsp);
+ createUniqueName(VALIDATION_VSP_NAME);
+ return VALIDATION_VSP_ID;
+ }
- Version version = versioningManager
- .create(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspDetails.getId(), user);
- vspDetails.setVersion(version);
+ @Override
+ public VspDetails createVsp(VspDetails vspDetails, String user) {
+ mdcDataDebugMessage.debugEntryMessage(null);
- // vspDetails.setLastModificationTime(new Date());
+ validateUniqueName(vspDetails.getName());
- vendorSoftwareProductDao.createVendorSoftwareProductInfo(vspDetails);
- vendorSoftwareProductDao.updateQuestionnaire(vspDetails.getId(), version,
+ vspInfoDao.create(vspDetails);//id will be set in the dao
+ vspInfoDao.updateQuestionnaireData(vspDetails.getId(), null,
new JsonSchemaDataGenerator(getVspQuestionnaireSchema(null)).generateData());
- UniqueValueUtil
- .createUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
- vspDetails.getName());
+ Version version = versioningManager
+ .create(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
+ vspDetails.getId(), user);
+ vspDetails.setVersion(version);
+ ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspDetails.getId(), String
+ .valueOf(vspDetails.getVersion().getMajor() + 1),
+ ActivityType.CREATE_NEW.toString(), user, true, "", "");
+ activityLogManager.addActionLog(activityLogEntity, user);
+ String vspName = vspDetails.getName();
+ createUniqueName(vspName);
+ mdcDataDebugMessage.debugExitMessage(null);
return vspDetails;
}
@Override
- public List<VersionedVendorSoftwareProductInfo> getVspList(String versionFilter, String user) {
- Map<String, VersionInfo> idToVersionsInfo = versioningManager
- .listEntitiesVersionInfo(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, user,
- VersionableEntityAction.Read);
+ public List<VersionedVendorSoftwareProductInfo> listVsps(String versionFilter, String user) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ Map<String, VersionInfo> idToVersionsInfo = versioningManager.listEntitiesVersionInfo(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, user,
+ VersionableEntityAction.Read);
List<VersionedVendorSoftwareProductInfo> vsps = new ArrayList<>();
for (Map.Entry<String, VersionInfo> entry : idToVersionsInfo.entrySet()) {
@@ -398,260 +468,257 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
versionInfo.setLockingUser(null);
}
- VspDetails vsp = vendorSoftwareProductDao.getVendorSoftwareProductInfo(
- new VspDetails(entry.getKey(), entry.getValue().getActiveVersion()));
- if (vsp != null) {
+ Version version = versionInfo.getActiveVersion();
+ if (user.equals(versionInfo.getLockingUser())) {
+ version.setStatus(VersionStatus.Locked);
+ }
+ VspDetails vsp = vspInfoDao.get(new VspDetails(entry.getKey(), version));
+ if (vsp != null && !vsp.getId().equals(VALIDATION_VSP_ID)) {
vsp.setValidationDataStructure(null);
- vsps.add(new VersionedVendorSoftwareProductInfo(vsp, entry.getValue()));
+ vsps.add(new VersionedVendorSoftwareProductInfo(vsp, versionInfo));
}
}
sortVspListByModificationTimeDescOrder(vsps);
+
+ mdcDataDebugMessage.debugExitMessage(null);
+
return vsps;
}
@Override
public void updateVsp(VspDetails vspDetails, String user) {
- Version activeVersion =
- getVersionInfo(vspDetails.getId(), VersionableEntityAction.Write, user).getActiveVersion();
- vspDetails.setVersion(activeVersion);
- // vspDetails.setLastModificationTime(new Date());
-
- VspDetails retrieved = vendorSoftwareProductDao.getVendorSoftwareProductInfo(vspDetails);
- vspDetails.setValidationData(retrieved.getValidationData());
- UniqueValueUtil
- .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
- retrieved.getName(), vspDetails.getName());
- vendorSoftwareProductDao.updateVendorSoftwareProductInfo(vspDetails);
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspDetails.getId(), activeVersion);
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspDetails.getId());
+
+ VspDetails retrieved = vspInfoDao.get(vspDetails);
+
+ updateUniqueName(retrieved.getName(), vspDetails.getName());
+ vspDetails.setOldVersion(retrieved.getOldVersion());
+
+ vspInfoDao.update(vspDetails);
+ //vendorSoftwareProductDao.updateVspLatestModificationTime(vspDetails.getId(), activeVersion);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
}
+
@Override
- public VersionedVendorSoftwareProductInfo getVspDetails(String vspId, Version version,
- String user) {
- VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
- if (version == null) {
- version = versionInfo.getActiveVersion();
- } else {
- if (!versionInfo.getViewableVersions().contains(version)) {
- throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
- }
- }
+ public VspDetails getVsp(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- VspDetails vendorSoftwareProductInfo =
- vendorSoftwareProductDao.getVendorSoftwareProductInfo(new VspDetails(vspId, version));
- if (vendorSoftwareProductInfo == null) {
+ VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
+ if (vsp == null) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_VSP, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Requested VSP not found");
throw new CoreException(new VendorSoftwareProductNotFoundErrorBuilder(vspId).build());
}
- return new VersionedVendorSoftwareProductInfo(vendorSoftwareProductInfo, versionInfo);
+ vsp.setValidationData(orchestrationTemplateDao.getValidationData(vspId, version));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return vsp;
}
@Override
- public void deleteVsp(String vspId, String user) {
- throw new UnsupportedOperationException("Unsupported operation for 1607 release.");
+ public Version callAutoHeal(String vspId, VersionInfo versionInfo,
+ VspDetails vendorSoftwareProductInfo, String user)
+ throws Exception {
+ switch (versionInfo.getStatus()) {
+ case Locked:
+ if (user.equals(versionInfo.getLockingUser())) {
+ autoHeal(vspId, versionInfo.getActiveVersion(), vendorSoftwareProductInfo,
+ versionInfo.getLockingUser());
+ }
+ return versionInfo.getActiveVersion();
+ case Available:
+ Version checkoutVersion = checkout(vspId, user);
+ autoHeal(vspId, checkoutVersion, vendorSoftwareProductInfo, user);
+ return checkin(vspId, user);
+ case Final:
+ Version checkoutFinalVersion = checkout(vspId,user);
+ autoHeal(vspId, checkoutFinalVersion, vendorSoftwareProductInfo, user);
+ Version checkinFinalVersion = checkin(vspId,user);
+ ValidationResponse response = submit(vspId, user);
+ if(!response.isValid()) {
+ return checkout(vspId, user);
+ }
+
+ try {
+ Version finalVersion = checkinFinalVersion.calculateNextFinal();
+ createPackage(vspId, finalVersion, user);
+ return finalVersion;
+ } catch (IOException e) {
+ throw new Exception(e.getMessage());
+ }
+ }
+ return versionInfo.getActiveVersion();
}
@Override
- public UploadFileResponse uploadFile(String vspId, InputStream heatFileToUpload, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- UploadFileResponse uploadFileResponse = new UploadFileResponse();
-
- if (heatFileToUpload == null) {
- uploadFileResponse.addStructureError(AsdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- return uploadFileResponse;
- }
- InputStream uploadedFileData;
- FileContentHandler fileContentMap;
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- try {
- fileContentMap = getContent(heatFileToUpload, errors);
- if (!errors.isEmpty()) {
- return addStructureErrorsToResponse(uploadFileResponse, errors);
- }
+ public void deleteVsp(String vspId, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- uploadedFileData = fileContentMap.getFileContent(UPLOAD_RAW_DATA);
- fileContentMap.remove(UPLOAD_RAW_DATA);
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.DELETE_VSP, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Unsupported operation");
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- ValidationManagerUtil.handleMissingManifest(fileContentMap, errors);
- if (!errors.isEmpty()) {
- return addStructureErrorsToResponse(uploadFileResponse, errors);
- }
+ throw new UnsupportedOperationException(
+ VendorSoftwareProductConstants.UNSUPPORTED_OPERATION_ERROR);
+ }
- } catch (CoreException ce) {
- ErrorMessage.ErrorMessageUtil.addMessage(AsdcCommon.UPLOAD_FILE, errors)
- .add(new ErrorMessage(ErrorLevel.ERROR, ce.getMessage()));
- return addStructureErrorsToResponse(uploadFileResponse, errors);
- }
+ @Override
+ public void heal(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- HeatStructureTree tree = createAndValidateHeatTree(uploadFileResponse, fileContentMap);
+ VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
- deleteUploadDataAndContent(vspId, activeVersion);
- saveHotData(vspId, activeVersion, uploadedFileData, fileContentMap, tree);
+ version = VersionStatus.Locked.equals(versionInfo.getStatus())
+ ? versionInfo.getActiveVersion()
+ : checkout(vspId, user);
+ version.setStatus(VersionStatus.Locked);
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
+ healingManager.healAll(getHealingParamsAsMap(vspId, version, user));
- ToscaServiceModel toscaServiceModel =
- VendorSoftwareProductUtils.loadAndTranslateTemplateData(fileContentMap)
- .getToscaServiceModel();
- if (toscaServiceModel != null) {
- serviceModelDao.storeServiceModel(vspId, activeVersion, toscaServiceModel);
- saveCompositionData(vspId, activeVersion,
- CompositionDataExtractor.extractServiceCompositionData(toscaServiceModel));
- }
+ VspDetails vspDetails = new VspDetails(vspId, version);
+ vspDetails.setOldVersion(null);
+ vspInfoDao.updateOldVersionIndication(vspDetails);
- return uploadFileResponse;
+ logger.audit("Healed VSP " + vspDetails.getId());
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
}
- private UploadFileResponse addStructureErrorsToResponse(UploadFileResponse uploadFileResponse,
- Map<String, List<ErrorMessage>> errors) {
- uploadFileResponse.addStructureErrors(errors);
- return uploadFileResponse;
- }
+ private void autoHeal(String vspId, Version checkoutVersion, VspDetails vspDetails, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- private HeatStructureTree createAndValidateHeatTree(UploadFileResponse uploadFileResponse,
- FileContentHandler fileContentMap) {
- VendorSoftwareProductUtils.addFileNamesToUploadFileResponse(fileContentMap, uploadFileResponse);
- Map<String, List<ErrorMessage>> validationErrors =
- ValidationManagerUtil.initValidationManager(fileContentMap).validate();
- uploadFileResponse.getErrors().putAll(validationErrors);
-
- HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(fileContentMap);
- heatTreeManager.createTree();
- heatTreeManager.addErrors(validationErrors);
- return heatTreeManager.getTree();
- }
+ checkoutVersion.setStatus(VersionStatus.Locked);
+ Map<String, Object> healingParams = getHealingParamsAsMap(vspId, checkoutVersion, user);
+ healingManager.healAll(healingParams);
+ vspDetails.setVersion(checkoutVersion);
+ vspDetails.setOldVersion(null);
+ vspInfoDao.updateOldVersionIndication(vspDetails);
- private void saveHotData(String vspId, Version activeVersion, InputStream uploadedFileData,
- FileContentHandler fileContentMap, HeatStructureTree tree) {
- Map<String, Object> manifestAsMap = (Map<String, Object>) JsonUtil
- .json2Object(fileContentMap.getFileContent(AsdcCommon.MANIFEST_NAME), Map.class);
-
- UploadDataEntity uploadData = new UploadDataEntity(vspId, activeVersion);
- uploadData.setPackageName((String) manifestAsMap.get("name"));
- uploadData.setPackageVersion((String) manifestAsMap.get("version"));
- uploadData.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(uploadedFileData)));
- uploadData.setValidationDataStructure(new ValidationStructureList(tree));
- vendorSoftwareProductDao.updateUploadData(uploadData);
- }
+ logger.audit("Healed VSP " + vspDetails.getName());
- private FileContentHandler getContent(InputStream heatFileToUpload,
- Map<String, List<ErrorMessage>> errors) {
- FileContentHandler contentMap = null;
- byte[] uploadedFileData;
- try {
- uploadedFileData = FileUtils.toByteArray(heatFileToUpload);
- VendorSoftwareProductUtils.validateRawZipData(uploadedFileData, errors);
- contentMap = VendorSoftwareProductUtils.loadUploadFileContent(uploadedFileData);
- VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
- contentMap.addFile(UPLOAD_RAW_DATA, uploadedFileData);
- } catch (IOException e0) {
- ErrorMessage.ErrorMessageUtil.addMessage(AsdcCommon.UPLOAD_FILE, errors)
- .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
- }
- return contentMap;
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
}
- private void validateMibZipContent(String vspId, Version version, byte[] uploadedFileData,
- Map<String, List<ErrorMessage>> errors) {
- FileContentHandler contentMap;
- try {
- contentMap = VendorSoftwareProductUtils.loadUploadFileContent(uploadedFileData);
- VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
- } catch (IOException e0) {
- throw new CoreException(
- new MibUploadErrorBuilder(vspId, version, Messages.INVALID_ZIP_FILE.getErrorMessage())
- .build());
- }
+ private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
+ Map<String, Object> healingParams = new HashMap<>();
+
+ healingParams.put(SdcCommon.VSP_ID, vspId);
+ healingParams.put(SdcCommon.VERSION, version);
+ healingParams.put(SdcCommon.USER, user);
+
+ return healingParams;
}
@Override
public List<PackageInfo> listPackages(String category, String subCategory) {
- return vendorSoftwareProductDao.listPackages(category, subCategory);
+ return packageInfoDao.listByCategory(category, subCategory);
}
@Override
public File getTranslatedFile(String vspId, Version version, String user) {
- VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ String errorMessage;
if (version == null) {
- if (versionInfo.getLatestFinalVersion() == null) {
- throw new CoreException(new PackageNotFoundErrorBuilder(vspId).build());
- }
- version = versionInfo.getLatestFinalVersion();
- } else {
- if (!version.isFinal() || !versionInfo.getViewableVersions().contains(version)) {
- throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
- }
+ errorMessage = "Package not found";
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
+ throw new CoreException(new PackageNotFoundErrorBuilder(vspId).build());
+ } else if (!version.isFinal()) {
+ errorMessage = "Invalid requested version";
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_VERSION_INFO, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
+ throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
}
PackageInfo packageInfo =
- vendorSoftwareProductDao.getPackageInfo(new PackageInfo(vspId, version));
+ packageInfoDao.get(new PackageInfo(vspId, version));
if (packageInfo == null) {
+ errorMessage = "Package not found";
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
throw new CoreException(new PackageNotFoundErrorBuilder(vspId, version).build());
}
ByteBuffer translatedFileBuffer = packageInfo.getTranslatedFile();
if (translatedFileBuffer == null) {
+ errorMessage = "Package not found";
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
throw new CoreException(new PackageInvalidErrorBuilder(vspId, version).build());
}
- File translatedFile = new File(VSP_PACKAGE_ZIP);
+ File translatedFile = new File(VendorSoftwareProductConstants.VSP_PACKAGE_ZIP);
try {
FileOutputStream fos = new FileOutputStream(translatedFile);
fos.write(translatedFileBuffer.array());
fos.close();
- } catch (IOException e0) {
- throw new CoreException(new TranslationFileCreationErrorBuilder(vspId, version).build(), e0);
+ } catch (IOException exception) {
+ errorMessage = "Can't create package";
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
+ throw new CoreException(new TranslationFileCreationErrorBuilder(vspId, version).build(),
+ exception);
}
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
return translatedFile;
}
@Override
- public File getLatestHeatPackage(String vspId,
- String user) { //todo remove the writing to file system..
- VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
- Version version = versionInfo.getActiveVersion();
- UploadDataEntity uploadData =
- vendorSoftwareProductDao.getUploadData(new UploadDataEntity(vspId, version));
+ public byte[] getOrchestrationTemplateFile(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ UploadDataEntity uploadData = orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
ByteBuffer contentData = uploadData.getContentData();
if (contentData == null) {
return null;
}
- File heatPkgFile = new File(String.format("heats-for-%s.zip", vspId));
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- FileOutputStream fos = new FileOutputStream(heatPkgFile);
- fos.write(contentData.array());
- fos.close();
- } catch (IOException e0) {
- throw new CoreException(new FileCreationErrorBuilder(vspId).build(), e0);
+ try (final ZipOutputStream zos = new ZipOutputStream(baos);
+ ZipInputStream zipStream = new ZipInputStream(
+ new ByteArrayInputStream(contentData.array()))) {
+ zos.write(contentData.array());
+ } catch (IOException exception) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_UPLOADED_HEAT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't get uploaded HEAT");
+ throw new CoreException(new FileCreationErrorBuilder(vspId).build(), exception);
}
- return heatPkgFile;
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return baos.toByteArray();
}
@Override
- public PackageInfo createPackage(String vspId, String user) throws IOException {
- VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
- Version activeVersion = versionInfo.getActiveVersion();
- if (!activeVersion.isFinal()) {
+ public PackageInfo createPackage(String vspId, Version version, String user) throws IOException {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ if (!version.isFinal()) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.CREATE_PACKAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create package");
throw new CoreException(
- new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, activeVersion)
+ new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, version)
.build());
}
- ToscaServiceModel toscaServiceModel =
- enrichedServiceModelDao.getServiceModel(vspId, activeVersion);
- VspDetails vspDetails =
- vendorSoftwareProductDao.getVendorSoftwareProductInfo(new VspDetails(vspId, activeVersion));
+ ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version);
+ VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
Version vlmVersion = vspDetails.getVlmVersion();
PackageInfo packageInfo = createPackageInfo(vspId, vspDetails);
@@ -665,10 +732,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
packageInfo.setTranslatedFile(ByteBuffer.wrap(
toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts)));
- vendorSoftwareProductDao.insertPackageDetails(packageInfo);
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, vspDetails.getVersion());
+ packageInfoDao.create(packageInfo);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return packageInfo;
}
@@ -676,789 +742,46 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
PackageInfo packageInfo = new PackageInfo();
packageInfo.setVspId(vspId);
packageInfo.setVersion(vspDetails.getVersion());
- packageInfo.setDisplayName(vspDetails.getPackageName());
packageInfo.setVspName(vspDetails.getName());
packageInfo.setVspDescription(vspDetails.getDescription());
packageInfo.setCategory(vspDetails.getCategory());
packageInfo.setSubCategory(vspDetails.getSubCategory());
packageInfo.setVendorName(vspDetails.getVendorName());
- packageInfo.setPackageType(CSAR);
+ packageInfo.setPackageType(VendorSoftwareProductConstants.CSAR);
packageInfo.setVendorRelease("1.0"); //todo TBD
return packageInfo;
}
@Override
- public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version, String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
-
- QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
- questionnaireResponse.setData(getVspQuestionnaire(vspId, version).getQuestionnaireData());
- questionnaireResponse.setSchema(getVspQuestionnaireSchema(null));
- return questionnaireResponse;
- }
+ public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- private VspQuestionnaireEntity getVspQuestionnaire(String vspId, Version version) {
- VspQuestionnaireEntity retrieved = vendorSoftwareProductDao.getQuestionnaire(vspId, version);
+ VspQuestionnaireEntity retrieved = vspInfoDao.getQuestionnaire(vspId, version);
VersioningUtil.validateEntityExistence(retrieved, new VspQuestionnaireEntity(vspId, version),
VspDetails.ENTITY_TYPE);
- return retrieved;
- }
-
- @Override
- public void updateVspQuestionnaire(String vspId, String questionnaireData, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
-
- vendorSoftwareProductDao.updateQuestionnaire(vspId, activeVersion, questionnaireData);
- }
-
- @Override
- public Collection<NetworkEntity> listNetworks(String vspId, Version version, String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- return listNetworks(vspId, version);
- }
-
- private Collection<NetworkEntity> listNetworks(String vspId, Version version) {
- return vendorSoftwareProductDao.listNetworks(vspId, version);
- }
-
- @Override
- public NetworkEntity createNetwork(NetworkEntity network, String user) {
- Version activeVersion =
- getVersionInfo(network.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- network.setVersion(activeVersion);
- if (!isManual(network.getVspId(), activeVersion)) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
- .withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
- }
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(network.getVspId(), activeVersion);
- return null;
- }
-
- private NetworkEntity createNetwork(NetworkEntity network) {
- network.setId(CommonMethods.nextUuId());
- vendorSoftwareProductDao.createNetwork(network);
-
- return network;
- }
-
- @Override
- public CompositionEntityValidationData updateNetwork(NetworkEntity network, String user) {
- Version activeVersion =
- getVersionInfo(network.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- network.setVersion(activeVersion);
- NetworkEntity retrieved = getNetwork(network.getVspId(), activeVersion, network.getId());
-
- NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
- schemaInput.setManual(isManual(network.getVspId(), activeVersion));
- schemaInput.setNetwork(retrieved.getNetworkCompositionData());
-
- CompositionEntityValidationData validationData = CompositionEntityDataManager
- .validateEntity(network, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- vendorSoftwareProductDao.updateNetwork(network);
- }
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(network.getVspId(), activeVersion);
-
- return validationData;
- }
-
- @Override
- public CompositionEntityResponse<Network> getNetwork(String vspId, Version version,
- String networkId, String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- NetworkEntity networkEntity = getNetwork(vspId, version, networkId);
- Network network = networkEntity.getNetworkCompositionData();
-
- NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
- schemaInput.setManual(isManual(vspId, version));
- schemaInput.setNetwork(network);
-
- CompositionEntityResponse<Network> response = new CompositionEntityResponse<>();
- response.setId(networkId);
- response.setData(network);
- response.setSchema(SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.network, schemaInput));
-
- return response;
- }
-
- private NetworkEntity getNetwork(String vspId, Version version, String networkId) {
- NetworkEntity retrieved = vendorSoftwareProductDao.getNetwork(vspId, version, networkId);
- VersioningUtil.validateEntityExistence(retrieved, new NetworkEntity(vspId, version, networkId),
- VspDetails.ENTITY_TYPE);
- return retrieved;
- }
-
- @Override
- public void deleteNetwork(String vspId, String networkId, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- if (!isManual(vspId, activeVersion)) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
- .withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
- }
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public QuestionnaireResponse getComponentQuestionnaire(String vspId, Version version,
- String componentId, String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
+ String questionnaireData = retrieved.getQuestionnaireData();
QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
- questionnaireResponse.setData(getComponent(vspId, version, componentId).getQuestionnaireData());
- List<String> nicNames = listNics(vspId, version, componentId).stream()
- .map(nic -> nic.getNicCompositionData().getName()).collect(Collectors.toList());
- questionnaireResponse.setSchema(getComponentQuestionnaireSchema(
- new ComponentQuestionnaireSchemaInput(nicNames,
- JsonUtil.json2Object(questionnaireResponse.getData(), Map.class))));
-
- return questionnaireResponse;
- }
-
- @Override
- public void updateComponentQuestionnaire(String vspId, String componentId,
- String questionnaireData, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- getComponent(vspId, activeVersion, componentId);
-
- vendorSoftwareProductDao
- .updateComponentQuestionnaire(vspId, activeVersion, componentId, questionnaireData);
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public Collection<ComponentEntity> listComponents(String vspId, Version version, String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- return listComponents(vspId, version);
- }
-
- private Collection<ComponentEntity> listComponents(String vspId, Version version) {
- return vendorSoftwareProductDao.listComponents(vspId, version);
- }
-
- @Override
- public void deleteComponents(String vspId, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- if (!isManual(vspId, activeVersion)) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
- .withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
- }
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public ComponentEntity createComponent(ComponentEntity component, String user) {
- Version activeVersion =
- getVersionInfo(component.getVspId(), VersionableEntityAction.Write, user)
- .getActiveVersion();
- component.setVersion(activeVersion);
-
- if (!isManual(component.getVspId(), activeVersion)) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
- .withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
-
- }
-
- /* ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(true);
- CompositionEntityValidationData validationData = CompositionEntityDataManager
- .validateEntity(component, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- return createComponent(component);
- }
- return validationData;*/
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(component.getVspId(), activeVersion);
-
- return null;
- }
-
- private ComponentEntity createComponent(ComponentEntity component) {
- component.setId(CommonMethods.nextUuId());
- component.setQuestionnaireData(
- new JsonSchemaDataGenerator(getComponentQuestionnaireSchema(null)).generateData());
-
- vendorSoftwareProductDao.createComponent(component);
-
- return component;
- }
-
- @Override
- public CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
- String componentId, String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- ComponentEntity componentEntity = getComponent(vspId, version, componentId);
- ComponentData component = componentEntity.getComponentCompositionData();
-
- ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(isManual(vspId, version));
- schemaInput.setComponent(component);
-
- CompositionEntityResponse<ComponentData> response = new CompositionEntityResponse<>();
- response.setId(componentId);
- response.setData(component);
- response.setSchema(SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.component, schemaInput));
-
- return response;
- }
-
- private ComponentEntity getComponent(String vspId, Version version, String componentId) {
- ComponentEntity retrieved = vendorSoftwareProductDao.getComponent(vspId, version, componentId);
- VersioningUtil
- .validateEntityExistence(retrieved, new ComponentEntity(vspId, version, componentId),
- VspDetails.ENTITY_TYPE);
- return retrieved;
- }
-
- @Override
- public CompositionEntityValidationData updateComponent(ComponentEntity component, String user) {
- Version activeVersion =
- getVersionInfo(component.getVspId(), VersionableEntityAction.Write, user)
- .getActiveVersion();
- component.setVersion(activeVersion);
- ComponentEntity retrieved =
- getComponent(component.getVspId(), activeVersion, component.getId());
-
- ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(isManual(component.getVspId(), activeVersion));
- schemaInput.setComponent(retrieved.getComponentCompositionData());
-
- CompositionEntityValidationData validationData = CompositionEntityDataManager
- .validateEntity(component, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- vendorSoftwareProductDao.updateComponent(component);
- }
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(component.getVspId(), activeVersion);
-
- return validationData;
- }
-
- @Override
- public void deleteComponent(String vspId, String componentId, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- if (!isManual(vspId, activeVersion)) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
- .withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
- }
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public Collection<org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity> listProcesses(
- String vspId, Version version, String componentId,
- String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- if (!GENERAL_COMPONENT_ID.equals(componentId)) {
- getComponent(vspId, version, componentId);
- }
- return vendorSoftwareProductDao.listProcesses(vspId, version, componentId);
- }
-
- @Override
- public void deleteProcesses(String vspId, String componentId, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- if (!GENERAL_COMPONENT_ID.equals(componentId)) {
- getComponent(vspId, activeVersion, componentId);
- }
-
- Collection<org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity> processes =
- vendorSoftwareProductDao.listProcesses(vspId, activeVersion, componentId);
- for (org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity process : processes) {
- UniqueValueUtil.deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME,
- process.getVspId(), process.getVersion().toString(), process.getComponentId(),
- process.getName());
- }
-
- vendorSoftwareProductDao.deleteProcesses(vspId, activeVersion, componentId);
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity createProcess(
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity process, String user) {
- Version activeVersion =
- getVersionInfo(process.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- process.setVersion(activeVersion);
- UniqueValueUtil.validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME,
- process.getVspId(), process.getVersion().toString(), process.getComponentId(),
- process.getName());
- process.setId(CommonMethods.nextUuId());
- if (!GENERAL_COMPONENT_ID.equals(process.getComponentId())) {
- getComponent(process.getVspId(), activeVersion, process.getComponentId());
- }
-
- vendorSoftwareProductDao.createProcess(process);
- UniqueValueUtil.createUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME,
- process.getVspId(), process.getVersion().toString(), process.getComponentId(),
- process.getName());
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(process.getVspId(), activeVersion);
- return process;
- }
-
- @Override
- public org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity getProcess(String vspId,
- Version version,
- String componentId,
- String processId,
- String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
- validateProcessExistence(vspId, version, componentId, processId, retrieved);
- return retrieved;
- }
-
- @Override
- public void updateProcess(org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity process,
- String user) {
- Version activeVersion =
- getVersionInfo(process.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- process.setVersion(activeVersion);
-
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity retrieved =
- vendorSoftwareProductDao
- .getProcess(process.getVspId(), activeVersion, process.getComponentId(),
- process.getId());
- validateProcessExistence(process.getVspId(), activeVersion, process.getComponentId(),
- process.getId(), retrieved);
-
- UniqueValueUtil.updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME,
- retrieved.getName(), process.getName(), process.getVspId(), process.getVersion().toString(),
- process.getComponentId());
- vendorSoftwareProductDao.updateProcess(process);
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(process.getVspId(), activeVersion);
- }
-
- @Override
- public void deleteProcess(String vspId, String componentId, String processId, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcess(vspId, activeVersion, componentId, processId);
- validateProcessExistence(vspId, activeVersion, componentId, processId, retrieved);
-
- vendorSoftwareProductDao.deleteProcess(vspId, activeVersion, componentId, processId);
- UniqueValueUtil.deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME,
- retrieved.getVspId(), retrieved.getVersion().toString(), retrieved.getComponentId(),
- retrieved.getName());
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public File getProcessArtifact(String vspId, Version version, String componentId,
- String processId, String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- ProcessArtifactEntity retrieved =
- vendorSoftwareProductDao.getProcessArtifact(vspId, version, componentId, processId);
- validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
-
- File file = new File(String
- .format("%s_%s_%s_%s", vspId, version.toString().replace('.', '_'), componentId,
- processId));
- try {
- FileOutputStream fos = new FileOutputStream(file);
- fos.write(retrieved.getArtifact().array());
- fos.close();
- } catch (IOException e0) {
- throw new CoreException(new UploadInvalidErrorBuilder().build());
- }
-
- return file;
- }
-
- @Override
- public void deleteProcessArtifact(String vspId, String componentId, String processId,
- String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- ProcessArtifactEntity retrieved =
- vendorSoftwareProductDao.getProcessArtifact(vspId, activeVersion, componentId, processId);
- validateProcessArtifactExistence(vspId, activeVersion, componentId, processId, retrieved);
-
- vendorSoftwareProductDao.deleteProcessArtifact(vspId, activeVersion, componentId, processId);
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public void uploadProcessArtifact(InputStream artifactFile, String artifactFileName, String vspId,
- String componentId, String processId, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcess(vspId, activeVersion, componentId, processId);
- validateProcessExistence(vspId, activeVersion, componentId, processId, retrieved);
-
- if (artifactFile == null) {
- throw new CoreException(new UploadInvalidErrorBuilder().build());
- }
-
- byte[] artifact;
- try {
- artifact = FileUtils.toByteArray(artifactFile);
- } catch (RuntimeException e0) {
- throw new CoreException(new UploadInvalidErrorBuilder().build());
- }
-
- vendorSoftwareProductDao
- .uploadProcessArtifact(vspId, activeVersion, componentId, processId, artifact,
- artifactFileName);
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public Collection<org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity> listNics(
- String vspId, Version version, String componentId,
- String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- Collection<org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity> nics =
- listNics(vspId, version, componentId);
-
- Map<String, String> networksNameById = listNetworksNameById(vspId, version);
- nics.stream().forEach(nicEntity -> {
- Nic nic = nicEntity.getNicCompositionData();
- nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
- nicEntity.setNicCompositionData(nic);
- });
- return nics;
- }
-
- private Collection<org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity> listNics(
- String vspId, Version version, String componentId) {
- getComponent(vspId, version, componentId);
-
- return vendorSoftwareProductDao.listNics(vspId, version, componentId);
- }
-
- private Map<String, String> listNetworksNameById(String vspId, Version version) {
- Collection<NetworkEntity> networks = listNetworks(vspId, version);
- return networks.stream().collect(Collectors.toMap(NetworkEntity::getId,
- networkEntity -> networkEntity.getNetworkCompositionData().getName()));
- }
-
- @Override
- public org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity createNic(
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity nic, String user) {
- Version activeVersion =
- getVersionInfo(nic.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- nic.setVersion(activeVersion);
- if (!isManual(nic.getVspId(), activeVersion)) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
- .withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
- }
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(nic.getVspId(), activeVersion);
-
- return null;
- }
-
- private org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity createNic(
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity nic) {
- nic.setId(CommonMethods.nextUuId());
- nic.setQuestionnaireData(
- new JsonSchemaDataGenerator(getNicQuestionnaireSchema(null)).generateData());
-
- vendorSoftwareProductDao.createNic(nic);
-
- return nic;
- }
-
- @Override
- public CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
- String nicId, String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity
- nicEntity = getNic(vspId, version, componentId, nicId);
- Nic nic = nicEntity.getNicCompositionData();
-
- NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
- schemaInput.setManual(isManual(vspId, version));
- schemaInput.setNic(nic);
- Map<String, String> networksNameById = listNetworksNameById(vspId, version);
- nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
- schemaInput.setNetworkIds(networksNameById.keySet());
-
- CompositionEntityResponse<Nic> response = new CompositionEntityResponse<>();
- response.setId(nicId);
- response.setData(nic);
- response.setSchema(SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.nic, schemaInput));
-
- return response;
- }
-
- private org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity getNic(String vspId,
- Version version,
- String componentId,
- String nicId) {
- getComponent(vspId, version, componentId);
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity
- retrieved = vendorSoftwareProductDao.getNic(vspId, version, componentId, nicId);
- VersioningUtil
- .validateEntityExistence(retrieved,
- new org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity(vspId, version,
- componentId, nicId),
- VspDetails.ENTITY_TYPE);
- return retrieved;
- }
-
- @Override
- public void deleteNic(String vspId, String componentId, String nicId, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- if (!isManual(vspId, activeVersion)) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
- .withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
- }
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public CompositionEntityValidationData updateNic(
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity nic, String user) {
- Version activeVersion =
- getVersionInfo(nic.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- nic.setVersion(activeVersion);
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity
- retrieved = getNic(nic.getVspId(), activeVersion, nic.getComponentId(), nic.getId());
-
- NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
- schemaInput.setManual(isManual(nic.getVspId(), activeVersion));
- schemaInput.setNic(retrieved.getNicCompositionData());
-
- CompositionEntityValidationData validationData = CompositionEntityDataManager
- .validateEntity(nic, SchemaTemplateContext.composition, schemaInput);
- if (CollectionUtils.isEmpty(validationData.getErrors())) {
- vendorSoftwareProductDao.updateNic(nic);
- }
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(nic.getVspId(), activeVersion);
- return validationData;
- }
-
- @Override
- public QuestionnaireResponse getNicQuestionnaire(String vspId, Version version,
- String componentId, String nicId, String user) {
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
+ questionnaireResponse.setData(questionnaireData);
+ questionnaireResponse.setSchema(getVspQuestionnaireSchema(null));
- QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
- questionnaireResponse
- .setData(getNic(vspId, version, componentId, nicId).getQuestionnaireData());
- questionnaireResponse.setSchema(getNicQuestionnaireSchema(null));
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return questionnaireResponse;
}
@Override
- public void updateNicQuestionnaire(String vspId, String componentId, String nicId,
- String questionnaireData, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- getNic(vspId, activeVersion, componentId, nicId);
-
- vendorSoftwareProductDao
- .updateNicQuestionnaire(vspId, activeVersion, componentId, nicId, questionnaireData);
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public void deleteComponentMib(String vspId, String componentId, boolean isTrap, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- ComponentArtifactEntity componentArtifactEntity =
- setValuesForComponentArtifactEntityUpload(vspId, activeVersion, null, componentId, null,
- isTrap, null);
- ComponentArtifactEntity retrieved =
- componentArtifactDao.getArtifactByType(componentArtifactEntity);
-
- componentArtifactDao.delete(retrieved);
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- @Override
- public void uploadComponentMib(InputStream object, String filename, String vspId,
- String componentId, boolean isTrap, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- ComponentArtifactEntity componentArtifactEntity;
-
-
- if (object == null) {
- throw new CoreException(new MibUploadErrorBuilder(
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()).build());
- } else {
- byte[] uploadedFileData;
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- try {
- uploadedFileData = FileUtils.toByteArray(object);
- validateMibZipContent(vspId, activeVersion, uploadedFileData, errors);
- if (MapUtils.isNotEmpty(errors)) {
- throw new CoreException(
- new MibUploadErrorBuilder(errors.values().iterator().next().get(0).getMessage())
- .build());
- }
-
- createArtifactInDatabase(vspId, activeVersion, filename, componentId, isTrap,
- uploadedFileData);
-
- } catch (Exception e0) {
- throw new CoreException(new MibUploadErrorBuilder(e0.getMessage()).build());
- }
- }
-
- vendorSoftwareProductDao.updateVspLatestModificationTime(vspId, activeVersion);
- }
-
- private void createArtifactInDatabase(String vspId, Version activeVersion, String filename,
- String componentId, boolean isTrap,
- byte[] uploadedFileData) {
- ComponentArtifactEntity componentArtifactEntity;
-
- String artifactId = CommonMethods.nextUuId();
- componentArtifactEntity =
- setValuesForComponentArtifactEntityUpload(vspId, activeVersion, filename, componentId,
- artifactId, isTrap, uploadedFileData);
- componentArtifactDao.update(componentArtifactEntity);
- }
-
- @Override
- public MibUploadStatus listMibFilenames(String vspId, String componentId, String user) {
- Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Read, user).getActiveVersion();
- ComponentArtifactEntity current =
- new ComponentArtifactEntity(vspId, activeVersion, componentId, null);
-
- return setMibUploadStatusValues(current);
-
- }
-
- private MibUploadStatus setMibUploadStatusValues(
- ComponentArtifactEntity componentArtifactEntity) {
- MibUploadStatus mibUploadStatus = new MibUploadStatus();
-
- Collection<ComponentArtifactEntity> artifactNames =
- componentArtifactDao.getArtifactNamesAndTypesForComponent(componentArtifactEntity);
- Map<ComponentArtifactType, String> artifactTypeToFilename =
- VendorSoftwareProductUtils.filterNonTrapOrPollArtifacts(artifactNames);
-
- if (MapUtils.isNotEmpty(artifactTypeToFilename)) {
- if (artifactTypeToFilename.containsKey(ComponentArtifactType.SNMP_TRAP)) {
- mibUploadStatus.setSnmpTrap(artifactTypeToFilename.get(ComponentArtifactType.SNMP_TRAP));
- }
- if (artifactTypeToFilename.containsKey(ComponentArtifactType.SNMP_POLL)) {
- mibUploadStatus.setSnmpPoll(artifactTypeToFilename.get(ComponentArtifactType.SNMP_POLL));
- }
- }
-
- return mibUploadStatus;
- }
-
- private ComponentArtifactEntity setValuesForComponentArtifactEntityUpload(String vspId,
- Version version,
- String filename,
- String componentId,
- String artifactId,
- boolean isTrap,
- byte[]
- uploadedFileData) {
- ComponentArtifactEntity componentArtifactEntity = new ComponentArtifactEntity();
-
- componentArtifactEntity.setVspId(vspId);
- componentArtifactEntity.setVersion(version);
- componentArtifactEntity.setComponentId(componentId);
- componentArtifactEntity.setId(artifactId);
- componentArtifactEntity.setType(ComponentArtifactType.getComponentArtifactType(isTrap));
- componentArtifactEntity.setArtifactName(filename);
-
- if (Objects.nonNull(uploadedFileData)) {
- componentArtifactEntity.setArtifact(ByteBuffer.wrap(uploadedFileData));
- }
+ public void updateVspQuestionnaire(String vspId, Version version, String questionnaireData,
+ String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- return componentArtifactEntity;
- }
+ vspInfoDao.updateQuestionnaireData(vspId, version, questionnaireData);
- private void validateProcessExistence(String vspId, Version version, String componentId,
- String processId,
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity retrieved) {
- if (retrieved != null) {
- return;
- }
- if (!GENERAL_COMPONENT_ID.equals(componentId)) {
- getComponent(vspId, version, componentId);
- }
- VersioningUtil.validateEntityExistence(retrieved,
- new org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity(vspId, version,
- componentId, processId),
- VspDetails.ENTITY_TYPE);//todo retrieved is always null ??
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
}
- private void validateProcessArtifactExistence(String vspId, Version version, String componentId,
- String processId, ProcessArtifactEntity retrieved) {
- if (retrieved != null) {
- VersioningUtil.validateEntityExistence(retrieved.getArtifact(),
- new ProcessArtifactEntity(vspId, version, componentId, processId),
- VspDetails.ENTITY_TYPE);
- } else {
- if (!GENERAL_COMPONENT_ID.equals(componentId)) {
- getComponent(vspId, version, componentId);
- }
- VersioningUtil.validateEntityExistence(retrieved,
- new org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity(vspId, version,
- componentId, processId),
- VspDetails.ENTITY_TYPE); //todo retrieved is always null ??
- }
- }
private Map<String, List<ErrorMessage>> validateUploadData(UploadDataEntity uploadData)
throws IOException {
@@ -1467,7 +790,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
FileContentHandler fileContentMap =
- VendorSoftwareProductUtils.loadUploadFileContent(uploadData.getContentData().array());
+ CommonUtil.loadUploadFileContent(uploadData.getContentData().array());
+ //todo - check
ValidationManager validationManager =
ValidationManagerUtil.initValidationManager(fileContentMap);
Map<String, List<ErrorMessage>> validationErrors = validationManager.validate();
@@ -1479,77 +803,36 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private VersionInfo getVersionInfo(String vendorSoftwareProductId, VersionableEntityAction action,
String user) {
- return versioningManager
- .getEntityVersionInfo(VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vendorSoftwareProductId,
- user, action);
+ return versioningManager.getEntityVersionInfo(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
+ vendorSoftwareProductId, user, action);
}
- private void saveCompositionData(String vspId, Version version, CompositionData compositionData) {
- Map<String, String> networkIdByName = new HashMap<>();
- for (Network network : compositionData.getNetworks()) {
-
- NetworkEntity networkEntity = new NetworkEntity(vspId, version, null);
- networkEntity.setNetworkCompositionData(network);
-
- if (network.getName() != null) {
- networkIdByName.put(network.getName(), createNetwork(networkEntity).getId());
- }
- }
- for (Component component : compositionData.getComponents()) {
- ComponentEntity componentEntity = new ComponentEntity(vspId, version, null);
- componentEntity.setComponentCompositionData(component.getData());
-
- String componentId = createComponent(componentEntity).getId();
-
- if (CollectionUtils.isNotEmpty(component.getNics())) {
- for (Nic nic : component.getNics()) {
- if (nic.getNetworkName() != null) {
- nic.setNetworkId(networkIdByName.get(nic.getNetworkName()));
- nic.setNetworkName(null);
- }
-
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity
- nicEntity =
- new org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity(vspId, version,
- componentId, null);
- nicEntity.setNicCompositionData(nic);
- createNic(nicEntity);
- }
- }
- }
- }
+ private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- private void deleteUploadDataAndContent(String vspId, Version version) {
- vendorSoftwareProductDao.deleteUploadData(vspId, version);
- }
- private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version) {
- CompositionEntityDataManager compositionEntityDataManager = new CompositionEntityDataManager();
compositionEntityDataManager
- .addEntity(vendorSoftwareProductDao.getQuestionnaire(vspId, version), null);
+ .addEntity(vspInfoDao.getQuestionnaire(vspId, version), null);
- Collection<org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity> nics =
- vendorSoftwareProductDao.listNicsByVsp(vspId, version);
+ Collection<NicEntity> nics = vendorSoftwareProductDao.listNicsByVsp(vspId, version);
Map<String, List<String>> nicNamesByComponent = new HashMap<>();
- for (org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity nicEntity : nics) {
+ for (NicEntity nicEntity : nics) {
compositionEntityDataManager.addEntity(nicEntity, null);
Nic nic = nicEntity.getNicCompositionData();
if (nic != null && nic.getName() != null) {
- List<String> nicNames = nicNamesByComponent.get(nicEntity.getComponentId());
- if (nicNames == null) {
- nicNames = new ArrayList<>();
- nicNamesByComponent.put(nicEntity.getComponentId(), nicNames);
- }
+ List<String> nicNames =
+ nicNamesByComponent.computeIfAbsent(nicEntity.getComponentId(), k -> new ArrayList<>());
nicNames.add(nic.getName());
}
}
Collection<ComponentEntity> components =
- vendorSoftwareProductDao.listComponentsQuestionnaire(vspId, version);
- components.stream().forEach(component -> compositionEntityDataManager.addEntity(component,
+ vendorSoftwareProductDao.listComponentsCompositionAndQuestionnaire(vspId, version);
+ components.forEach(component -> compositionEntityDataManager.addEntity(component,
new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
JsonUtil.json2Object(component.getQuestionnaireData(), Map.class))));
@@ -1558,10 +841,62 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
if (MapUtils.isNotEmpty(errorsByEntityId)) {
compositionEntityDataManager.buildTrees();
compositionEntityDataManager.addErrorsToTrees(errorsByEntityId);
- Collection<CompositionEntityValidationData> roots = compositionEntityDataManager.getTrees();
- return new QuestionnaireValidationResult(roots.iterator().next());
+/* Set<CompositionEntityValidationData> entitiesWithValidationErrors =
+ compositionEntityDataManager.getEntityListWithErrors();*/
+ //Collection<CompositionEntityValidationData> roots = compositionEntityDataManager.getTrees();
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return new QuestionnaireValidationResult(
+ compositionEntityDataManager.getAllErrorsByVsp(vspId));
}
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return null;
}
+
+ @Override
+ public File getInformationArtifact(String vspId, Version version, String user) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
+
+ if (vspDetails == null) {
+ return null;
+ }
+
+ String vspName = vspDetails.getName();
+ ByteBuffer infoArtifactAsByteBuffer;
+ File infoArtifactFile;
+ try {
+ infoArtifactAsByteBuffer = ByteBuffer.wrap(informationArtifactGenerator.generate(vspId,
+ version).getBytes());
+
+ infoArtifactFile =
+ new File(
+ String.format(VendorSoftwareProductConstants.INFORMATION_ARTIFACT_NAME, vspName));
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(infoArtifactFile));
+ out.write(infoArtifactAsByteBuffer.array());
+ out.close();
+ } catch (IOException e) {
+ throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), e);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return infoArtifactFile;
+ }
+
+ void validateUniqueName(String vspName) {
+ UniqueValueUtil.validateUniqueValue(
+ VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, vspName);
+ }
+
+ void createUniqueName(String vspName) {
+ UniqueValueUtil.createUniqueValue(
+ VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, vspName);
+ }
+
+ void updateUniqueName(String oldVspName, String newVspName) {
+ UniqueValueUtil.updateUniqueValue(
+ VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
+ oldVspName, newVspName);
+ }
}
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
new file mode 100644
index 0000000000..16f17e6192
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
+import org.openecomp.core.model.dao.ServiceModelDaoFactory;
+import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
+import org.openecomp.sdc.healing.factory.HealingManagerFactory;
+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.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.CompositionEntityDataManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+
+public class VspManagerFactoryImpl extends VspManagerFactory {
+ private static final VendorSoftwareProductManager INSTANCE =
+ new VendorSoftwareProductManagerImpl(
+ VersioningManagerFactory.getInstance().createInterface(),
+ VendorSoftwareProductDaoFactory.getInstance().createInterface(),
+ OrchestrationTemplateDaoFactory.getInstance().createInterface(),
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ VendorLicenseFacadeFactory.getInstance().createInterface(),
+ ServiceModelDaoFactory.getInstance().createInterface(),
+ EnrichedServiceModelDaoFactory.getInstance().createInterface(),
+ HealingManagerFactory.getInstance().createInterface(),
+ VendorLicenseArtifactServiceFactory.getInstance().createInterface(),
+ CompositionEntityDataManagerFactory.getInstance().createInterface(),
+ InformationArtifactGeneratorFactory.getInstance().createInterface(),
+ PackageInfoDaoFactory.getInstance().createInterface(),
+ ActivityLogManagerFactory.getInstance().createInterface());
+
+ @Override
+ public VendorSoftwareProductManager createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/CompositionDataExtractor.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/CompositionDataExtractor.java
deleted file mode 100644
index f92b83532e..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/CompositionDataExtractor.java
+++ /dev/null
@@ -1,386 +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.services;
-
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.MapUtils;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
-import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
-import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
-import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
-import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition;
-import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
-import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.sdc.tosca.errors.ToscaInvalidEntryNotFoundErrorBuilder;
-import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstituteNodeTemplateErrorBuilder;
-import org.openecomp.sdc.tosca.errors.ToscaMissingSubstitutionMappingForReqCapErrorBuilder;
-import org.openecomp.sdc.tosca.services.ToscaAnalyzerService;
-import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
-import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil;
-import org.openecomp.sdc.vendorsoftwareproduct.types.ExtractCompositionDataContext;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * The type Composition data extractor.
- */
-public class CompositionDataExtractor {
-
- /**
- * The constant logger.
- */
- protected static Logger logger;
- private static ToscaAnalyzerService toscaAnalyzerService;
-
- static {
- logger = LoggerFactory.getLogger(CompositionDataExtractor.class);
- toscaAnalyzerService = new ToscaAnalyzerServiceImpl();
- }
-
- /**
- * Extract service composition data composition data.
- *
- * @param toscaServiceModel the tosca service model
- * @return the composition data
- */
- public static CompositionData extractServiceCompositionData(ToscaServiceModel toscaServiceModel) {
- ExtractCompositionDataContext context = new ExtractCompositionDataContext();
- String entryDefinitionServiceTemplateFileName =
- toscaServiceModel.getEntryDefinitionServiceTemplate();
- ServiceTemplate entryDefinitionServiceTemplate =
- toscaServiceModel.getServiceTemplates().get(entryDefinitionServiceTemplateFileName);
- extractServiceCompositionData(entryDefinitionServiceTemplateFileName,
- entryDefinitionServiceTemplate, toscaServiceModel, context);
-
- CompositionData compositionData = new CompositionData();
- compositionData.setNetworks(context.getNetworks());
- compositionData.setComponents(context.getComponents());
- return compositionData;
- }
-
- private static void extractServiceCompositionData(String serviceTemplateFileName,
- ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel,
- ExtractCompositionDataContext context) {
- if (context.getHandledServiceTemplates().contains(serviceTemplateFileName)) {
- return;
- }
- context.addNetworks(extractNetworks(serviceTemplate, toscaServiceModel));
- extractComponents(serviceTemplate, toscaServiceModel, context);
- handleSubstitution(serviceTemplate, toscaServiceModel, context);
- context.addHandledServiceTemplates(serviceTemplateFileName);
- }
-
- private static void handleSubstitution(ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel,
- ExtractCompositionDataContext context) {
- Map<String, NodeTemplate> substitutableNodeTemplates =
- toscaAnalyzerService.getSubstitutableNodeTemplates(serviceTemplate);
-
- if (substitutableNodeTemplates != null) {
- for (String substitutableNodeTemplateId : substitutableNodeTemplates.keySet()) {
- handleSubstitutableNodeTemplate(serviceTemplate, toscaServiceModel,
- substitutableNodeTemplateId,
- substitutableNodeTemplates.get(substitutableNodeTemplateId), context);
- }
- }
- }
-
- private static void handleSubstitutableNodeTemplate(ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel,
- String substitutableNodeTemplateId,
- NodeTemplate substitutableNodeTemplate,
- ExtractCompositionDataContext context) {
- ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil();
- Optional<String> substituteServiceTemplateFileName = toscaAnalyzerService
- .getSubstituteServiceTemplateName(substitutableNodeTemplateId, substitutableNodeTemplate);
- if (!substituteServiceTemplateFileName.isPresent()) {
- throw new CoreException(
- new ToscaInvalidSubstituteNodeTemplateErrorBuilder(substitutableNodeTemplateId).build());
- }
- if (context.getHandledServiceTemplates().contains(substituteServiceTemplateFileName.get())) {
- return;
- }
-
- ServiceTemplate substituteServiceTemplate =
- toscaServiceModel.getServiceTemplates().get(substituteServiceTemplateFileName.get());
- extractServiceCompositionData(substituteServiceTemplateFileName.get(),
- substituteServiceTemplate, toscaServiceModel, context);
-
- List<Map<String, RequirementAssignment>> substitutableRequirements =
- substitutableNodeTemplate.getRequirements();
-
- if (CollectionUtils.isEmpty(substitutableRequirements)) {
- return;
- }
-
- for (Map<String, RequirementAssignment> substitutableReq : substitutableRequirements) {
- substitutableReq.keySet().stream().filter(reqId -> {
- RequirementAssignment reqAssignment = toscaExtensionYamlUtil
- .yamlToObject(toscaExtensionYamlUtil.objectToYaml(substitutableReq.get(reqId)),
- RequirementAssignment.class);
- return isLinkToNetworkRequirementAssignment(reqAssignment);
- }).forEach(reqId -> {
- RequirementAssignment linkToNetworkRequirement = toscaExtensionYamlUtil
- .yamlToObject(toscaExtensionYamlUtil.objectToYaml(substitutableReq.get(reqId)),
- RequirementAssignment.class);
- String connectedNodeId = linkToNetworkRequirement.getNode();
- Optional<NodeTemplate> connectedNodeTemplate =
- toscaAnalyzerService.getNodeTemplateById(serviceTemplate, connectedNodeId);
-
- if (connectedNodeTemplate.isPresent() && toscaAnalyzerService
- .isTypeOf(connectedNodeTemplate.get(), ToscaNodeType.NETWORK.getDisplayName(),
- serviceTemplate, toscaServiceModel)) {
- Optional<Map.Entry<String, NodeTemplate>> mappedNodeTemplate = toscaAnalyzerService
- .getSubstitutionMappedNodeTemplateByExposedReq(
- substituteServiceTemplateFileName.get(), substituteServiceTemplate, reqId);
- if (!mappedNodeTemplate.isPresent()) {
- throw new CoreException(new ToscaMissingSubstitutionMappingForReqCapErrorBuilder(
- ToscaMissingSubstitutionMappingForReqCapErrorBuilder.MappingExposedEntry
- .REQUIREMENT, connectedNodeId).build());
- }
-
- if (toscaAnalyzerService.isTypeOf(mappedNodeTemplate.get().getValue(),
- ToscaNodeType.NETWORK_PORT.getDisplayName(), serviceTemplate, toscaServiceModel)) {
- Nic port = context.getNics().get(mappedNodeTemplate.get().getKey());
- if (port != null) {
- port.setNetworkName(connectedNodeId);
- } else {
- logger.warn(
- "Different ports define for the same component which is used in different "
- + "substitution service templates.");
- }
- }
- } else if (!connectedNodeTemplate.isPresent()) {
- throw new CoreException(
- new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", connectedNodeId).build());
- }
- });
- }
- }
-
- private static boolean isLinkToNetworkRequirementAssignment(RequirementAssignment requirement) {
- return toscaAnalyzerService.isDesiredRequirementAssignment(requirement,
- ToscaCapabilityType.NETWORK_LINKABLE.getDisplayName(), null,
- ToscaRelationshipType.NETWORK_LINK_TO.getDisplayName());
- }
-
-
- private static void connectPortToNetwork(Nic port, NodeTemplate portNodeTemplate) {
- List<RequirementAssignment> linkRequirementsToNetwork =
- toscaAnalyzerService.getRequirements(portNodeTemplate, ToscaConstants.LINK_REQUIREMENT_ID);
-
- //port is connected to one network
- for (RequirementAssignment linkRequirementToNetwork : linkRequirementsToNetwork) {
- port.setNetworkName(linkRequirementToNetwork.getNode());
- }
-
- }
-
- /*
- return Map with key - compute node template id, value - list of connected port node template id
- */
- private static Map<String, List<String>> getComputeToPortsConnection(
- Map<String, NodeTemplate> portNodeTemplates) {
- Map<String, List<String>> computeToPortConnection = new HashMap<>();
- if (MapUtils.isEmpty(portNodeTemplates)) {
- return computeToPortConnection;
- }
- for (String portId : portNodeTemplates.keySet()) {
- List<RequirementAssignment> bindingRequirementsToCompute = toscaAnalyzerService
- .getRequirements(portNodeTemplates.get(portId), ToscaConstants.BINDING_REQUIREMENT_ID);
- for (RequirementAssignment bindingRequirementToCompute : bindingRequirementsToCompute) {
- computeToPortConnection
- .putIfAbsent(bindingRequirementToCompute.getNode(), new ArrayList<>());
- computeToPortConnection.get(bindingRequirementToCompute.getNode()).add(portId);
- }
-
- }
-
- return computeToPortConnection;
- }
-
- private static void extractComponents(ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel,
- ExtractCompositionDataContext context) {
- Map<String, NodeTemplate> computeNodeTemplates = toscaAnalyzerService
- .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.COMPUTE.getDisplayName(),
- toscaServiceModel);
- if (MapUtils.isEmpty(computeNodeTemplates)) {
- return;
- }
- Map<String, NodeTemplate> portNodeTemplates = toscaAnalyzerService
- .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NETWORK_PORT.getDisplayName(),
- toscaServiceModel);
- Map<String, List<String>> computeToPortsConnection =
- getComputeToPortsConnection(portNodeTemplates);
- Map<String, List<String>> computesGroupedByType =
- getNodeTemplatesGroupedByType(computeNodeTemplates);
-
- computesGroupedByType.keySet()
- .stream()
- .filter(nodeType ->
- !context.getCreatedComponents().contains(nodeType))
- .forEach(nodeType -> extractComponent(serviceTemplate, computeToPortsConnection,
- computesGroupedByType, nodeType, context));
- }
-
- private static void extractComponent(ServiceTemplate serviceTemplate,
- Map<String, List<String>> computeToPortsConnection,
- Map<String, List<String>> computesGroupedByType,
- String computeNodeType,
- ExtractCompositionDataContext context) {
- ComponentData component = new ComponentData();
- component.setName(computeNodeType);
- component.setDisplayName(getComponentDisplayName(component.getName()));
- Component componentModel = new Component();
- componentModel.setData(component);
-
- String computeId = computesGroupedByType.get(computeNodeType).get(0);
- List<String> connectedPortIds = computeToPortsConnection.get(computeId);
-
- if (connectedPortIds != null) {
- componentModel.setNics(new ArrayList<>());
- for (String portId : connectedPortIds) {
- Nic port = extractPort(serviceTemplate, portId);
- componentModel.getNics().add(port);
- context.addNic(portId, port);
- }
- }
- context.addComponent(componentModel);
- context.getCreatedComponents().add(computeNodeType);
- }
-
- private static Nic extractPort(ServiceTemplate serviceTemplate, String portNodeTemplateId) {
- Optional<NodeTemplate> portNodeTemplate =
- toscaAnalyzerService.getNodeTemplateById(serviceTemplate, portNodeTemplateId);
- if (portNodeTemplate.isPresent()) {
- Nic port = new Nic();
- port.setName(portNodeTemplateId);
- connectPortToNetwork(port, portNodeTemplate.get());
- return port;
- } else {
- throw new CoreException(
- new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", portNodeTemplateId).build());
- }
- }
-
-
- private static Map<String, List<String>> getNodeTemplatesGroupedByType(
- Map<String, NodeTemplate> nodeTemplates) {
- Map<String, List<String>> nodeTemplatesGrouped =
- new HashMap<>(); //key - node type, value - list of node ids with this type
- for (String nodeId : nodeTemplates.keySet()) {
- String nodeType = nodeTemplates.get(nodeId).getType();
- nodeTemplatesGrouped.putIfAbsent(nodeType, new ArrayList<>());
- nodeTemplatesGrouped.get(nodeType).add(nodeId);
- }
- return nodeTemplatesGrouped;
- }
-
- private static List<Network> extractNetworks(ServiceTemplate serviceTemplate,
- ToscaServiceModel toscaServiceModel) {
- List<Network> networks = new ArrayList<>();
- Map<String, NodeTemplate> networkNodeTemplates = toscaAnalyzerService
- .getNodeTemplatesByType(serviceTemplate, ToscaNodeType.NETWORK.getDisplayName(),
- toscaServiceModel);
- if (MapUtils.isEmpty(networkNodeTemplates)) {
- return networks;
- }
- for (String networkId : networkNodeTemplates.keySet()) {
- Network network = new Network();
- network.setName(networkId);
- Optional<Boolean> networkDhcpValue =
- getNetworkDhcpValue(serviceTemplate, networkNodeTemplates.get(networkId));
- network.setDhcp(networkDhcpValue.isPresent() ? networkDhcpValue.get() : true);
- networks.add(network);
- }
-
- return networks;
- }
-
- //dhcp default value is true
- private static Optional<Boolean> getNetworkDhcpValue(ServiceTemplate serviceTemplate,
- NodeTemplate networkNodeTemplate) {
- if (networkNodeTemplate == null) {
- return Optional.empty();
- }
- if (networkNodeTemplate.getProperties() == null
- || networkNodeTemplate.getProperties().get(ToscaConstants.DHCP_ENABLED_PROPERTY_NAME)
- == null) {
- return Optional.of(true);
- }
-
- Object dhcp =
- networkNodeTemplate.getProperties().get(ToscaConstants.DHCP_ENABLED_PROPERTY_NAME);
- if (dhcp instanceof String) {
- return Optional.of(Boolean.valueOf((String) dhcp));
- } else if (dhcp instanceof Boolean) {
- return Optional.of((Boolean) dhcp);
- } else if (dhcp instanceof Map) {
- String inputParameterName =
- (String) ((Map) dhcp).get(ToscaFunctions.GET_INPUT.getDisplayName());
- if (inputParameterName != null) {
- ParameterDefinition inputParameterDefinition =
- serviceTemplate.getTopology_template().getInputs().get(inputParameterName);
- if (inputParameterDefinition != null) {
- if (inputParameterDefinition.get_default() != null) {
- return Optional.of(Boolean.valueOf(inputParameterDefinition.get_default().toString()));
- }
- } else {
- throw new CoreException(
- new ToscaInvalidEntryNotFoundErrorBuilder("Input Parameter", inputParameterName)
- .build());
- }
- }
- }
-
- return Optional.of(true);
- }
-
- private static String getComponentDisplayName(String componentName) {
- if (componentName == null) {
- return null;
- }
- String delimiterChar = ".";
- if (componentName.contains(delimiterChar)) {
- return componentName.substring(componentName.lastIndexOf(delimiterChar) + 1);
- }
- return componentName;
-
- }
-
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/CompositionEntityDataManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/CompositionEntityDataManager.java
deleted file mode 100644
index e3f56a6578..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/CompositionEntityDataManager.java
+++ /dev/null
@@ -1,257 +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.services;
-
-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.vendorsoftwareproduct.types.CompositionEntityValidationData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The type Composition entity data manager.
- */
-public class CompositionEntityDataManager {
-
- private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR =
- "COMPOSITION_ENTITY_DATA_MANAGER_ERR";
- private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG =
- "Invalid input: %s may not be null";
-
- private Map<org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId,
- CompositionEntityData> entities = new HashMap<>();
- private Map<org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType,
- String> nonDynamicSchemas = new HashMap<>();
- private List<CompositionEntityValidationData> roots = new ArrayList<>();
-
- /**
- * Validate entity composition entity validation data.
- *
- * @param entity the entity
- * @param schemaTemplateContext the schema template context
- * @param schemaTemplateInput the schema template input
- * @return the composition entity validation data
- */
- public static CompositionEntityValidationData validateEntity(
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity entity,
- SchemaTemplateContext schemaTemplateContext,
- SchemaTemplateInput schemaTemplateInput) {
- if (entity == null) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
- .build());
- }
- if (schemaTemplateContext == null) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "schema template context"))
- .build());
- }
-
- CompositionEntityValidationData validationData =
- new CompositionEntityValidationData(entity.getType(), entity.getId());
- String json =
- schemaTemplateContext == SchemaTemplateContext.composition ? entity.getCompositionData()
- : entity.getQuestionnaireData();
- validationData.setErrors(JsonUtil.validate(
- json == null ? JsonUtil.object2Json(new Object()) : json,
- SchemaGenerator.generate(schemaTemplateContext, entity.getType(), schemaTemplateInput)));
-
- return validationData;
- }
-
- /**
- * Add entity.
- *
- * @param entity the entity
- * @param schemaTemplateInput the schema template input
- */
- public void addEntity(org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity entity,
- SchemaTemplateInput schemaTemplateInput) {
- if (entity == null) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(COMPOSITION_ENTITY_DATA_MANAGER_ERR).withMessage(
- String.format(COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG, "composition entity"))
- .build());
- }
- entities.put(entity.getCompositionEntityId(),
- new CompositionEntityData(entity, schemaTemplateInput));
- }
-
- /**
- * Validate entities questionnaire map.
- *
- * @return the map
- */
- public Map<org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId,
- Collection<String>> validateEntitiesQuestionnaire() {
- Map<org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId,
- Collection<String>>
- errorsByEntityId = new HashMap<>();
-
- entities.entrySet().stream().forEach(entry -> {
- Collection<String> errors = validateQuestionnaire(entry.getValue());
- if (errors != null) {
- errorsByEntityId.put(entry.getKey(), errors);
- }
- });
-
- return errorsByEntityId;
- }
-
- /**
- * Build trees.
- */
- public void buildTrees() {
- Map<org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId,
- CompositionEntityValidationData>
- entitiesValidationData =
- new HashMap<>();
- entities.entrySet().stream().forEach(
- entry -> addValidationDataEntity(entitiesValidationData, entry.getKey(),
- entry.getValue().entity));
- }
-
- /**
- * Gets trees.
- *
- * @return the trees
- */
- public Collection<CompositionEntityValidationData> getTrees() {
- return roots;
- }
-
- /**
- * Add errors to trees.
- *
- * @param errors the errors
- */
- public void addErrorsToTrees(
- Map<org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId,
- Collection<String>> errors) {
- roots.stream().forEach(root -> addErrorsToTree(root, null, errors));
- }
-
- private void addValidationDataEntity(
- Map<org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId,
- CompositionEntityValidationData> entitiesValidationData,
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId entityId,
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity entity) {
- if (entitiesValidationData.containsKey(entityId)) {
- return;
- }
-
- CompositionEntityValidationData validationData =
- new CompositionEntityValidationData(entity.getType(), entity.getId());
- entitiesValidationData.put(entityId, validationData);
-
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId parentEntityId =
- entityId.getParentId();
- if (parentEntityId == null) {
- roots.add(validationData);
- } else {
- CompositionEntityData parentEntity = entities.get(parentEntityId);
- if (parentEntity == null) {
- roots.add(validationData);
- } else {
- addValidationDataEntity(entitiesValidationData, parentEntityId, parentEntity.entity);
- entitiesValidationData.get(parentEntityId).addSubEntityValidationData(validationData);
- }
- }
- }
-
- private void addErrorsToTree(CompositionEntityValidationData node,
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId parentNodeId,
- Map<org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId,
- Collection<String>> errors) {
- if (node == null) {
- return;
- }
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId
- nodeId = new org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId(
- node.getEntityId(), parentNodeId);
- node.setErrors(errors.get(nodeId));
-
- if (node.getSubEntitiesValidationData() != null) {
- node.getSubEntitiesValidationData().stream()
- .forEach(subNode -> addErrorsToTree(subNode, nodeId, errors));
- }
- }
-
- private Collection<String> validateQuestionnaire(CompositionEntityData compositionEntityData) {
- return JsonUtil.validate(
- compositionEntityData.entity.getQuestionnaireData() == null ? JsonUtil
- .object2Json(new Object()) : compositionEntityData.entity.getQuestionnaireData(),
- getSchema(compositionEntityData.entity.getType(), SchemaTemplateContext.questionnaire,
- compositionEntityData.schemaTemplateInput));
- }
-
- private String getSchema(
- org.openecomp.sdc.vendorsoftwareproduct.types
- .composition.CompositionEntityType compositionEntityType,
- SchemaTemplateContext schemaTemplateContext,
- SchemaTemplateInput schemaTemplateInput) {
- return schemaTemplateInput == null ? getNonDynamicSchema(schemaTemplateContext,
- compositionEntityType) : SchemaGenerator
- .generate(schemaTemplateContext, compositionEntityType, schemaTemplateInput);
- }
-
- private String getNonDynamicSchema(SchemaTemplateContext schemaTemplateContext,
- org.openecomp.sdc.vendorsoftwareproduct.types.composition
- .CompositionEntityType compositionEntityType) {
- String schema = nonDynamicSchemas.get(compositionEntityType);
- if (schema == null) {
- schema = SchemaGenerator.generate(schemaTemplateContext, compositionEntityType, null);
- nonDynamicSchemas.put(compositionEntityType, schema);
- }
- return schema;
- }
-
- private static class CompositionEntityData {
- private org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity entity;
- private SchemaTemplateInput schemaTemplateInput;
-
- /**
- * Instantiates a new Composition entity data.
- *
- * @param entity the entity
- * @param schemaTemplateInput the schema template input
- */
- public CompositionEntityData(
- org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity entity,
- SchemaTemplateInput schemaTemplateInput) {
- this.entity = entity;
- this.schemaTemplateInput = schemaTemplateInput;
- }
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/SchemaGenerator.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/SchemaGenerator.java
deleted file mode 100644
index 53fe5455fb..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/SchemaGenerator.java
+++ /dev/null
@@ -1,70 +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.services;
-
-import freemarker.template.Template;
-import freemarker.template.TemplateException;
-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.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-
-/**
- * The type Schema generator.
- */
-public class SchemaGenerator {
- /**
- * The constant SCHEMA_GENERATION_ERROR.
- */
- public static final String SCHEMA_GENERATION_ERROR = "SCHEMA_GENERATION_ERROR";
-
- /**
- * Generate string.
- *
- * @param schemaTemplateContext the schema template context
- * @param entityType the entity type
- * @param input the input
- * @return the string
- */
- public static String generate(SchemaTemplateContext schemaTemplateContext,
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType entityType,
- SchemaTemplateInput input) {
- Template schemaTemplate =
- SchemaGeneratorConfig.getSchemaTemplate(schemaTemplateContext, entityType);
- return processTemplate(input, schemaTemplate);
- }
-
- private static String processTemplate(SchemaTemplateInput input, Template schemaTemplate) {
- try (Writer writer = new StringWriter(1024)) {
- schemaTemplate.process(input, writer);
- return writer.toString();
- } catch (IOException | TemplateException exception) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(SCHEMA_GENERATION_ERROR).withMessage(exception.getMessage()).build());
- }
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/SchemaGeneratorConfig.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/SchemaGeneratorConfig.java
deleted file mode 100644
index 034d8520fb..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/SchemaGeneratorConfig.java
+++ /dev/null
@@ -1,184 +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.services;
-
-import freemarker.cache.StringTemplateLoader;
-import freemarker.template.Configuration;
-import freemarker.template.Template;
-import freemarker.template.TemplateExceptionHandler;
-import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
-import org.openecomp.core.utilities.applicationconfig.ApplicationConfigFactory;
-import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
-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.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The type Schema generator config.
- */
-public class SchemaGeneratorConfig {
- /**
- * The constant SCHEMA_GENERATOR_INITIALIZATION_ERROR.
- */
- public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR =
- "SCHEMA_GENERATOR_INITIALIZATION_ERROR";
- /**
- * The constant SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG.
- */
- public static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG =
- "Error occurred while loading questionnaire schema schemaTemplates";
- private static final String CONFIGURATION_NAMESPACE = "vsp.schemaTemplates";
- private static Map<SchemaTemplateId, SchemaTemplate> schemaTemplates = new HashMap<>();
- private static ApplicationConfig applicationConfig =
- ApplicationConfigFactory.getInstance().createInterface();
-
- private static Configuration configuration = new Configuration(Configuration.VERSION_2_3_23);
- private static StringTemplateLoader stringLoader = new StringTemplateLoader();
-
- static {
- configuration.setClassLoaderForTemplateLoading(SchemaGenerator.class.getClassLoader(),
- File.pathSeparator);
- configuration.setDefaultEncoding("UTF-8");
- configuration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
- configuration.setLogTemplateExceptions(true);
- configuration.setTemplateLoader(stringLoader);
- }
-
- /**
- * Insert schema template.
- *
- * @param schemaTemplateContext the schema template context
- * @param entityType the entity type
- * @param schemaTemplateString the schema template string
- */
- public static void insertSchemaTemplate(SchemaTemplateContext schemaTemplateContext,
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType entityType,
- String schemaTemplateString) {
- applicationConfig.insertValue(CONFIGURATION_NAMESPACE,
- new SchemaTemplateId(schemaTemplateContext, entityType).toString(), schemaTemplateString);
- }
-
- /**
- * Gets schema template.
- *
- * @param schemaTemplateContext the schema template context
- * @param entityType the entity type
- * @return the schema template
- */
- public static Template getSchemaTemplate(SchemaTemplateContext schemaTemplateContext,
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType entityType) {
- SchemaTemplateId id = new SchemaTemplateId(schemaTemplateContext, entityType);
- ConfigurationData configurationData =
- applicationConfig.getConfigurationData(CONFIGURATION_NAMESPACE, id.toString());
-
- SchemaTemplate schemaTemplate = schemaTemplates.get(id);
- if (schemaTemplate == null || schemaTemplate.timestamp != configurationData.getTimeStamp()) {
- stringLoader.putTemplate(id.toString(), configurationData.getValue());
- Template template;
- try {
- template = configuration.getTemplate(id.toString());
- } catch (IOException exception) {
- throw new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- .withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR)
- .withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).build(), exception);
- }
- schemaTemplate = new SchemaTemplate(template, configurationData.getTimeStamp());
- schemaTemplates.put(id, schemaTemplate);
- }
- return schemaTemplate.template;
- }
-
- private static class SchemaTemplateId {
- private SchemaTemplateContext context;
- private org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType
- entityType;
-
- /**
- * Instantiates a new Schema template id.
- *
- * @param context the context
- * @param entityType the entity type
- */
- public SchemaTemplateId(SchemaTemplateContext context,
- org.openecomp.sdc.vendorsoftwareproduct.types.composition
- .CompositionEntityType entityType) {
- this.context = context;
- this.entityType = entityType;
- }
-
- @Override
- public String toString() {
- return context + "." + entityType;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
-
- SchemaTemplateId that = (SchemaTemplateId) obj;
-
- if (entityType != that.entityType) {
- return false;
- }
- if (context != that.context) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = entityType != null ? entityType.hashCode() : 0;
- result = 31 * result + (context != null ? context.hashCode() : 0);
- return result;
- }
- }
-
- private static class SchemaTemplate {
- private Template template;
- private long timestamp;
-
- /**
- * Instantiates a new Schema template.
- *
- * @param template the template
- * @param timestamp the timestamp
- */
- public SchemaTemplate(Template template, long timestamp) {
- this.template = template;
- this.timestamp = timestamp;
- }
- }
-
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java
index 6a71db041b..24d28b198a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityResponse.java
@@ -20,8 +20,9 @@
package org.openecomp.sdc.vendorsoftwareproduct.types;
-public class CompositionEntityResponse<T extends org.openecomp.sdc
- .vendorsoftwareproduct.types.composition.CompositionDataEntity> {
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionDataEntity;
+
+public class CompositionEntityResponse<T extends CompositionDataEntity> {
private String id;
private String schema;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityValidationData.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityValidationData.java
deleted file mode 100644
index d334e18637..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/CompositionEntityValidationData.java
+++ /dev/null
@@ -1,122 +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.types;
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * The type Composition entity validation data.
- */
-public class CompositionEntityValidationData {
- private CompositionEntityType entityType;
- private String entityId;
- private Collection<String> errors;
- private Collection<CompositionEntityValidationData> subEntitiesValidationData;
-
- /**
- * Instantiates a new Composition entity validation data.
- *
- * @param entityType the entity type
- * @param entityId the entity id
- */
- public CompositionEntityValidationData(CompositionEntityType entityType, String entityId) {
- this.entityType = entityType;
- this.entityId = entityId;
- }
-
- /**
- * Gets entity type.
- *
- * @return the entity type
- */
- public CompositionEntityType getEntityType() {
- return entityType;
- }
-
- /**
- * Sets entity type.
- *
- * @param entityType the entity type
- */
- public void setEntityType(CompositionEntityType entityType) {
- this.entityType = entityType;
- }
-
- /**
- * Gets entity id.
- *
- * @return the entity id
- */
- public String getEntityId() {
- return entityId;
- }
-
- /**
- * Sets entity id.
- *
- * @param entityId the entity id
- */
- public void setEntityId(String entityId) {
- this.entityId = entityId;
- }
-
- /**
- * Gets errors.
- *
- * @return the errors
- */
- public Collection<String> getErrors() {
- return errors;
- }
-
- /**
- * Sets errors.
- *
- * @param errors the errors
- */
- public void setErrors(Collection<String> errors) {
- this.errors = errors;
- }
-
- /**
- * Gets sub entities validation data.
- *
- * @return the sub entities validation data
- */
- public Collection<CompositionEntityValidationData> getSubEntitiesValidationData() {
- return subEntitiesValidationData;
- }
-
- /**
- * Add sub entity validation data.
- *
- * @param subEntityValidationData the sub entity validation data
- */
- public void addSubEntityValidationData(CompositionEntityValidationData subEntityValidationData) {
- if (subEntitiesValidationData == null) {
- subEntitiesValidationData = new ArrayList<>();
- }
- subEntitiesValidationData.add(subEntityValidationData);
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ExtractCompositionDataContext.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ExtractCompositionDataContext.java
deleted file mode 100644
index 0e34fc4e56..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/ExtractCompositionDataContext.java
+++ /dev/null
@@ -1,204 +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.types;
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * The type Extract composition data context.
- */
-public class ExtractCompositionDataContext {
- private List<org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network> networks =
- new ArrayList<>();
- private List<org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component> components =
- new ArrayList<>();
- private Map<String, Nic> nics = new HashMap<>();
- private Set<String> handledServiceTemplates = new HashSet<>();
- private Set<String> createdComponents = new HashSet<>();
-
- /**
- * Gets created components.
- *
- * @return the created components
- */
- public Set<String> getCreatedComponents() {
- return createdComponents;
- }
-
- /**
- * Sets created components.
- *
- * @param createdComponents the created components
- */
- public void setCreatedComponents(Set<String> createdComponents) {
- this.createdComponents = createdComponents;
- }
-
- /**
- * Gets handled service templates.
- *
- * @return the handled service templates
- */
- public Set<String> getHandledServiceTemplates() {
- return handledServiceTemplates;
- }
-
- /**
- * Sets handled service templates.
- *
- * @param handledServiceTemplates the handled service templates
- */
- public void setHandledServiceTemplates(Set<String> handledServiceTemplates) {
- this.handledServiceTemplates = handledServiceTemplates;
- }
-
- /**
- * Add handled service templates.
- *
- * @param handledServiceTemplate the handled service template
- */
- public void addHandledServiceTemplates(String handledServiceTemplate) {
- this.handledServiceTemplates.add(handledServiceTemplate);
- }
-
- /**
- * Gets networks.
- *
- * @return the networks
- */
- public List<org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network> getNetworks() {
- return networks;
- }
-
- /**
- * Sets networks.
- *
- * @param networks the networks
- */
- public void setNetworks(
- List<org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network> networks) {
- this.networks = networks;
- }
-
- /**
- * Add network.
- *
- * @param network the network
- */
- public void addNetwork(
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network network) {
- if (network != null) {
- networks.add(network);
- }
- }
-
- /**
- * Add networks.
- *
- * @param network the network
- */
- public void addNetworks(
- List<org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network> network) {
- if (networks != null) {
- networks.addAll(network);
- }
- }
-
- /**
- * Gets components.
- *
- * @return the components
- */
- public List<org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component> getComponents() {
- return components;
- }
-
- /**
- * Sets components.
- *
- * @param components the components
- */
- public void setComponents(
- List<org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component> components) {
- this.components = components;
- }
-
- /**
- * Add component.
- *
- * @param component the component
- */
- public void addComponent(
- org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component component) {
- if (component != null) {
- components.add(component);
- }
- }
-
- /**
- * Add components.
- *
- * @param components the components
- */
- public void addComponents(
- List<org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component> components) {
- if (components != null) {
- this.components.addAll(components);
- }
- }
-
- /**
- * Gets nics.
- *
- * @return the nics
- */
- public Map<String, Nic> getNics() {
- return nics;
- }
-
- /**
- * Sets nics.
- *
- * @param nics the nics
- */
- public void setNics(Map<String, Nic> nics) {
- this.nics = nics;
- }
-
- /**
- * Add nic.
- *
- * @param nicId the nic id
- * @param nic the nic
- */
- public void addNic(String nicId, Nic nic) {
- this.nics.put(nicId, nic);
- }
-
-
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java
new file mode 100644
index 0000000000..8cb367367c
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java
@@ -0,0 +1,69 @@
+/*-
+ * ============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.types;
+
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Avrahamg
+ * @since November 07, 2016
+ */
+public class FileDataStructureDto {
+ private List<Module> modules = new ArrayList<>();
+ private List<String> unassigned = new ArrayList<>();
+ private List<String> artifacts = new ArrayList<>();
+ private List<String> nested = new ArrayList<>();
+
+ public List<Module> getModules() {
+ return modules;
+ }
+
+ public void setModules(List<Module> modules) {
+ this.modules = modules;
+ }
+
+ public List<String> getUnassigned() {
+ return unassigned;
+ }
+
+ public void setUnassigned(List<String> unassigned) {
+ this.unassigned = unassigned;
+ }
+
+ public List<String> getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(List<String> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public List<String> getNested() {
+ return nested;
+ }
+
+ public void setNested(List<String> nested) {
+ this.nested = nested;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java
new file mode 100644
index 0000000000..c30978266f
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java
@@ -0,0 +1,69 @@
+/*-
+ * ============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.types;
+
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Avrahamg
+ * @since November 07, 2016
+ */
+public class GetFileDataStructureResponseDTO {
+ private List<Module> modules = new ArrayList<>();
+ private List<String> unassigned = new ArrayList<>();
+ private List<String> artifacts = new ArrayList<>();
+ private List<String> nested = new ArrayList<>();
+
+ public List<Module> getModules() {
+ return modules;
+ }
+
+ public void setModules(List<Module> modules) {
+ this.modules = modules;
+ }
+
+ public List<String> getUnassigned() {
+ return unassigned;
+ }
+
+ public void setUnassigned(List<String> unassigned) {
+ this.unassigned = unassigned;
+ }
+
+ public List<String> getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(List<String> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public List<String> getNested() {
+ return nested;
+ }
+
+ public void setNested(List<String> nested) {
+ this.nested = nested;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java
index f0f6c095dd..e5b8f7ff66 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingData.java
@@ -22,6 +22,9 @@ package org.openecomp.sdc.vendorsoftwareproduct.types;
import java.util.List;
+/**
+ * Created by TALIO on 5/15/2016.
+ */
public class LicensingData {
private String licenseAgreement;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponse.java
new file mode 100644
index 0000000000..cca20351bd
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponse.java
@@ -0,0 +1,118 @@
+/*-
+ * ============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.types;
+
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class OrchestrationTemplateActionResponse {
+ private List<String> fileNames;
+ private Map<String, List<ErrorMessage>> errors = new HashMap<>();
+ private UploadFileStatus status = UploadFileStatus.Success;
+
+ public UploadFileStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(UploadFileStatus status) {
+ this.status = status;
+ }
+
+ public List<String> getFileNames() {
+ return fileNames;
+ }
+
+ public void setFileNames(List<String> fileNames) {
+ this.fileNames = fileNames;
+ }
+
+ public void addNewFileToList(String filename) {
+ this.fileNames.add(filename);
+ }
+
+ public void removeFileFromList(String toRemove) {
+ this.fileNames.remove(toRemove);
+ }
+
+ /**
+ * Add structure errors.
+ *
+ * @param errorsByFileName the errors by file name
+ */
+ public void addStructureErrors(Map<String, List<ErrorMessage>> errorsByFileName) {
+ if (errorsByFileName == null) {
+ return;
+ }
+
+ errors.putAll(errorsByFileName);
+
+ if (status == UploadFileStatus.Failure) {
+ return;
+ }
+ for (Map.Entry<String, List<ErrorMessage>> entry : errorsByFileName.entrySet()) {
+ for (ErrorMessage errorMessage : entry.getValue()) {
+ if (errorMessage.getLevel() == ErrorLevel.ERROR) {
+ status = UploadFileStatus.Failure;
+ return;
+ }
+ }
+ }
+ }
+
+ /**
+ * Add error message to map.
+ *
+ * @param key the key
+ * @param error the error
+ * @param level the level
+ */
+ public void addErrorMessageToMap(String key, String error, ErrorLevel level) {
+ ErrorMessage errorMessage = new ErrorMessage(level, error);
+ List<ErrorMessage> errorMessages = getErrorList(key);
+
+ errorMessages.add(errorMessage);
+ this.errors.put(key, errorMessages);
+
+ if (level.equals(ErrorLevel.ERROR)) {
+ status = UploadFileStatus.Failure;
+ }
+ }
+
+ private List<ErrorMessage> getErrorList(String key) {
+ List<ErrorMessage> errorMessages = this.errors.get(key);
+ if (CollectionUtils.isEmpty(errorMessages)) {
+ errorMessages = new ArrayList<>();
+ }
+
+ return errorMessages;
+ }
+
+ public Map<String, List<ErrorMessage>> getErrors() {
+ return errors;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java
index 84a2ed58f8..3e7ef9f744 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireResponse.java
@@ -20,9 +20,12 @@
package org.openecomp.sdc.vendorsoftwareproduct.types;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+
public class QuestionnaireResponse {
private String schema;
private String data;
+ private ErrorMessage errorMessage;
public String getSchema() {
return schema;
@@ -39,4 +42,12 @@ public class QuestionnaireResponse {
public void setData(String data) {
this.data = data;
}
+
+ public ErrorMessage getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(ErrorMessage errorMessage) {
+ this.errorMessage = errorMessage;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java
index d970e73a06..3e059f4ccb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResult.java
@@ -20,11 +20,16 @@
package org.openecomp.sdc.vendorsoftwareproduct.types;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
+
+import java.util.List;
+import java.util.Set;
+
public class QuestionnaireValidationResult {
private boolean valid;
- private CompositionEntityValidationData validationData;
+ private Set<CompositionEntityValidationData> validationData;
- public QuestionnaireValidationResult(CompositionEntityValidationData validationData) {
+ public QuestionnaireValidationResult(Set<CompositionEntityValidationData> validationData) {
this.validationData = validationData;
valid = validationData == null;
}
@@ -33,7 +38,7 @@ public class QuestionnaireValidationResult {
return valid;
}
- public CompositionEntityValidationData getValidationData() {
+ 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/UploadFileResponse.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileResponse.java
index 68389b6ed9..99f3fa1fdf 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileResponse.java
@@ -21,86 +21,43 @@
package org.openecomp.sdc.vendorsoftwareproduct.types;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+/**
+ * Created by TALIO on 4/27/2016.
+ */
public class UploadFileResponse {
- private List<String> fileNames;
- private Map<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> errors =
- new HashMap<>();
+ private Map<String, List<ErrorMessage>> errors = new HashMap<>();
private UploadFileStatus status = UploadFileStatus.Success;
- /**
- * Gets status.
- *
- * @return the status
- */
public UploadFileStatus getStatus() {
return status;
}
- /**
- * Sets status.
- *
- * @param status the status
- */
public void setStatus(UploadFileStatus status) {
this.status = status;
}
/**
- * Gets file names.
- *
- * @return the file names
- */
- public List<String> getFileNames() {
- return fileNames;
- }
-
- /**
- * Sets file names.
- *
- * @param fileNames the file names
- */
- public void setFileNames(List<String> fileNames) {
- this.fileNames = fileNames;
- }
-
- /**
- * Add new file to list.
- *
- * @param filename the filename
- */
- public void addNewFileToList(String filename) {
- this.fileNames.add(filename);
- }
-
- /**
- * Remove file from list.
- *
- * @param toRemove the to remove
- */
- public void removeFileFromList(String toRemove) {
- this.fileNames.remove(toRemove);
- }
-
- /**
* Add structure error.
*
* @param fileName the file name
* @param errorMessage the error message
*/
- public void addStructureError(String fileName,
- org.openecomp.sdc.datatypes.error.ErrorMessage errorMessage) {
- List<org.openecomp.sdc.datatypes.error.ErrorMessage> errorList = errors.get(fileName);
+ public void addStructureError(String fileName, ErrorMessage errorMessage) {
+ List<ErrorMessage> errorList = errors.get(fileName);
if (errorList == null) {
errorList = new ArrayList<>();
errors.put(fileName, errorList);
}
errorList.add(errorMessage);
- if (org.openecomp.sdc.datatypes.error.ErrorLevel.ERROR.equals(errorMessage.getLevel())) {
+ if (ErrorLevel.ERROR.equals(errorMessage.getLevel())) {
status = UploadFileStatus.Failure;
}
}
@@ -110,8 +67,7 @@ public class UploadFileResponse {
*
* @param errorsByFileName the errors by file name
*/
- public void addStructureErrors(
- Map<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> errorsByFileName) {
+ public void addStructureErrors(Map<String, List<ErrorMessage>> errorsByFileName) {
if (errorsByFileName == null) {
return;
}
@@ -121,10 +77,9 @@ public class UploadFileResponse {
if (status == UploadFileStatus.Failure) {
return;
}
- for (Map.Entry<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> entry
- : errorsByFileName.entrySet()) {
- for (org.openecomp.sdc.datatypes.error.ErrorMessage errorMessage : entry.getValue()) {
- if (errorMessage.getLevel() == org.openecomp.sdc.datatypes.error.ErrorLevel.ERROR) {
+ for (Map.Entry<String, List<ErrorMessage>> entry : errorsByFileName.entrySet()) {
+ for (ErrorMessage errorMessage : entry.getValue()) {
+ if (errorMessage.getLevel() == ErrorLevel.ERROR) {
status = UploadFileStatus.Failure;
return;
}
@@ -132,12 +87,7 @@ public class UploadFileResponse {
}
}
- /**
- * Gets errors.
- *
- * @return the errors
- */
- public Map<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> getErrors() {
+ public Map<String, List<ErrorMessage>> getErrors() {
return errors;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java
index 1e21c60577..525d627f4f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructure.java
@@ -22,6 +22,9 @@ package org.openecomp.sdc.vendorsoftwareproduct.types;
import java.util.List;
+/**
+ * Created by TALIO on 4/27/2016.
+ */
public class UploadFileStructure {
private List<String> fileNames;
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 29e5f73bce..eb03ba62b4 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,17 +22,19 @@ 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.types.LoggerServiceName;
+import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-/**
- * The type Validation response.
- */
public class ValidationResponse {
+ protected static Logger logger = (Logger) LoggerFactory.getLogger(ValidationResponse.class);
private boolean valid = true;
private Collection<ErrorCode> vspErrors;
private Collection<ErrorCode> licensingDataErrors;
@@ -40,20 +42,10 @@ public class ValidationResponse {
private Map<String, List<ErrorMessage>> compilationErrors;
private QuestionnaireValidationResult questionnaireValidationResult;
- /**
- * Is valid boolean.
- *
- * @return the boolean
- */
public boolean isValid() {
return valid;
}
- /**
- * Gets vsp errors.
- *
- * @return the vsp errors
- */
public Collection<ErrorCode> getVspErrors() {
return vspErrors;
}
@@ -61,20 +53,20 @@ public class ValidationResponse {
/**
* Sets vsp errors.
*
- * @param vspErrors the vsp errors
+ * @param vspErrors the vsp errors
+ * @param serviceName the service name
+ * @param targetServiceName the target service name
*/
- public void setVspErrors(Collection<ErrorCode> vspErrors) {
+ public void setVspErrors(Collection<ErrorCode> vspErrors, LoggerServiceName serviceName,
+ String targetServiceName) {
this.vspErrors = vspErrors;
if (CollectionUtils.isNotEmpty(vspErrors)) {
valid = false;
}
+
+ VendorSoftwareProductUtils.setErrorsIntoLogger(vspErrors, serviceName, targetServiceName);
}
- /**
- * Gets licensing data errors.
- *
- * @return the licensing data errors
- */
public Collection<ErrorCode> getLicensingDataErrors() {
return licensingDataErrors;
}
@@ -91,11 +83,6 @@ public class ValidationResponse {
}
}
- /**
- * Gets upload data errors.
- *
- * @return the upload data errors
- */
public Map<String, List<ErrorMessage>> getUploadDataErrors() {
return uploadDataErrors;
}
@@ -103,20 +90,21 @@ public class ValidationResponse {
/**
* Sets upload data errors.
*
- * @param uploadDataErrors the upload data errors
+ * @param uploadDataErrors the upload data errors
+ * @param serviceName the service name
+ * @param targetServiceName the target service name
*/
- public void setUploadDataErrors(Map<String, List<ErrorMessage>> uploadDataErrors) {
+ public void setUploadDataErrors(Map<String, List<ErrorMessage>> uploadDataErrors,
+ LoggerServiceName serviceName, String targetServiceName) {
this.uploadDataErrors = uploadDataErrors;
if (MapUtils.isNotEmpty(uploadDataErrors)) {
valid = false;
}
+
+ VendorSoftwareProductUtils
+ .setErrorsIntoLogger(uploadDataErrors, serviceName, targetServiceName);
}
- /**
- * Gets compilation errors.
- *
- * @return the compilation errors
- */
public Map<String, List<ErrorMessage>> getCompilationErrors() {
return compilationErrors;
}
@@ -125,19 +113,20 @@ public class ValidationResponse {
* Sets compilation errors.
*
* @param compilationErrors the compilation errors
+ * @param serviceName the service name
+ * @param targetServiceName the target service name
*/
- public void setCompilationErrors(Map<String, List<ErrorMessage>> compilationErrors) {
+ public void setCompilationErrors(Map<String, List<ErrorMessage>> compilationErrors,
+ LoggerServiceName serviceName, String targetServiceName) {
this.compilationErrors = compilationErrors;
if (MapUtils.isNotEmpty(compilationErrors)) {
valid = false;
}
+
+ VendorSoftwareProductUtils
+ .setErrorsIntoLogger(uploadDataErrors, serviceName, targetServiceName);
}
- /**
- * Gets questionnaire validation result.
- *
- * @return the questionnaire validation result
- */
public QuestionnaireValidationResult getQuestionnaireValidationResult() {
return questionnaireValidationResult;
}
@@ -154,4 +143,6 @@ public class ValidationResponse {
valid = false;
}
}
+
+
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/VersionedVendorSoftwareProductInfo.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/VersionedVendorSoftwareProductInfo.java
index cbc81da1ee..7bb97e1df5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/VersionedVendorSoftwareProductInfo.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/VersionedVendorSoftwareProductInfo.java
@@ -21,16 +21,16 @@
package org.openecomp.sdc.vendorsoftwareproduct.types;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.types.VersionInfo;
public class VersionedVendorSoftwareProductInfo {
private VspDetails vspDetails;
- private org.openecomp.sdc.versioning.types.VersionInfo versionInfo;
+ private VersionInfo versionInfo;
public VersionedVendorSoftwareProductInfo() {
}
- public VersionedVendorSoftwareProductInfo(VspDetails vspDetails,
- org.openecomp.sdc.versioning.types.VersionInfo versionInfo) {
+ public VersionedVendorSoftwareProductInfo(VspDetails vspDetails, VersionInfo versionInfo) {
this.vspDetails = vspDetails;
this.versionInfo = versionInfo;
}
@@ -43,11 +43,11 @@ public class VersionedVendorSoftwareProductInfo {
this.vspDetails = vspDetails;
}
- public org.openecomp.sdc.versioning.types.VersionInfo getVersionInfo() {
+ public VersionInfo getVersionInfo() {
return versionInfo;
}
- public void setVersionInfo(org.openecomp.sdc.versioning.types.VersionInfo versionInfo) {
+ public void setVersionInfo(VersionInfo versionInfo) {
this.versionInfo = versionInfo;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/zusammen/ItemProperties.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/zusammen/ItemProperties.java
new file mode 100644
index 0000000000..c5f132f0f2
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/zusammen/ItemProperties.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.vendorsoftwareproduct.types.zusammen;
+
+/**
+ * @author Avrahamg
+ * @since February 16, 2017
+ */
+public class ItemProperties {
+ public static final String TYPE = "type";
+ public static final String CATEGORY = "category";
+ public static final String VENDOR_NAME = "vendorName";
+ public static final String VSP_ID = "vspId";
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/util/CompilationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/util/CompilationUtil.java
deleted file mode 100644
index 54038bcd73..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/util/CompilationUtil.java
+++ /dev/null
@@ -1,126 +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.util;
-
-import org.openecomp.core.enrichment.types.ComponentArtifactType;
-import org.openecomp.core.enrichment.types.ComponentCeilometerInfo;
-import org.openecomp.core.enrichment.types.ComponentMibInfo;
-import org.openecomp.core.enrichment.types.MibInfo;
-import org.openecomp.core.utilities.applicationconfig.ApplicationConfig;
-import org.openecomp.core.utilities.applicationconfig.ApplicationConfigFactory;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.enrichment.impl.tosca.ComponentInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentArtifactEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-/**
- * The type Compilation util.
- */
-public class CompilationUtil {
-
- private static final ApplicationConfig applicationConfig =
- ApplicationConfigFactory.getInstance().createInterface();
- private static final ComponentArtifactDao componentArtifactDao =
- ComponentArtifactDaoFactory.getInstance().createInterface();
-
- /**
- * Add monitoring info.
- *
- * @param componentInfo the component info
- * @param compileErrors the compile errors
- */
- public static void addMonitoringInfo(ComponentInfo componentInfo,
- Map<String, List<ErrorMessage>> compileErrors) {
-
- String ceilometerJson =
- applicationConfig.getConfigurationData("vsp.monitoring", "component.ceilometer").getValue();
- ComponentCeilometerInfo ceilometerInfo =
- JsonUtil.json2Object(ceilometerJson, ComponentCeilometerInfo.class);
- componentInfo.setCeilometerInfo(ceilometerInfo);
- }
-
- /**
- * Add mib info.
- *
- * @param vspId the vsp id
- * @param version the version
- * @param componentEntity the component entity
- * @param componentInfo the component info
- * @param compileErrors the compile errors
- */
- public static void addMibInfo(String vspId, Version version, org.openecomp.sdc
- .vendorsoftwareproduct.dao.type.ComponentEntity componentEntity,
- ComponentInfo componentInfo,
- Map<String, List<ErrorMessage>> compileErrors) {
-
- String componentId = componentEntity.getId();
-
- ComponentArtifactEntity entity = new ComponentArtifactEntity();
- entity.setVspId(vspId);
- entity.setVersion(version);
- entity.setComponentId(componentId);
-
- ComponentMibInfo componentMibInfo = new ComponentMibInfo();
-
- extractAndInsertMibContentToComponentInfo(componentId, ComponentArtifactType.SNMP_POLL, entity,
- componentMibInfo, compileErrors);
- extractAndInsertMibContentToComponentInfo(componentId, ComponentArtifactType.SNMP_TRAP, entity,
- componentMibInfo, compileErrors);
- componentInfo.setMibInfo(componentMibInfo);
- }
-
- private static void extractAndInsertMibContentToComponentInfo(String componentId,
- ComponentArtifactType type,
- ComponentArtifactEntity componentArtifactEntity,
- ComponentMibInfo componentMibInfo,
- Map<String, List<ErrorMessage>> compileErrors) {
- String path;
- componentArtifactEntity.setType(type);
- ComponentArtifactEntity artifact =
- componentArtifactDao.getArtifactByType(componentArtifactEntity);
-
- if (artifact == null) {
- return;
- }
- path = componentId + File.separator + type.name();
- MibInfo mibInfo = new MibInfo();
- mibInfo.setName(path);
- mibInfo.setContent(artifact.getArtifact().array());
- switch (type) {
- case SNMP_POLL:
- componentMibInfo.setSnmpPoll(mibInfo);
- break;
- case SNMP_TRAP:
- componentMibInfo.setSnmpTrap(mibInfo);
- break;
- default:
- }
-
-
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/util/VendorSoftwareProductUtils.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/util/VendorSoftwareProductUtils.java
deleted file mode 100644
index 62e8dd8b87..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/util/VendorSoftwareProductUtils.java
+++ /dev/null
@@ -1,254 +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.util;
-
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.enrichment.types.ComponentArtifactType;
-import org.openecomp.core.translator.api.HeatToToscaTranslator;
-import org.openecomp.core.translator.datatypes.TranslatorOutput;
-import org.openecomp.core.translator.factory.HeatToToscaTranslatorFactory;
-import org.openecomp.core.utilities.file.FileContentHandler;
-import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.core.validation.errors.Messages;
-import org.openecomp.core.validation.types.MessageContainerUtil;
-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.common.utils.AsdcCommon;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
-import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
-import org.openecomp.sdc.heat.services.tree.HeatTreeManager;
-import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentArtifactEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-/**
- * The type Vendor software product utils.
- */
-public class VendorSoftwareProductUtils {
-
- private static org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao
- vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
-
- /**
- * Load upload file content file content handler.
- *
- * @param uploadedFileData the uploaded file data
- * @return the file content handler
- * @throws IOException the io exception
- */
- public static FileContentHandler loadUploadFileContent(byte[] uploadedFileData)
- throws IOException {
- return getFileContentMapFromZip(uploadedFileData);
- }
-
- private static FileContentHandler getFileContentMapFromZip(byte[] uploadFileData)
- throws IOException, CoreException {
- ZipEntry zipEntry;
- List<String> folderList = new ArrayList<>();
- FileContentHandler mapFileContent = new FileContentHandler();
- try {
- ZipInputStream inputZipStream;
-
- byte[] fileByteContent;
- String currentEntryName;
- inputZipStream = new ZipInputStream(new ByteArrayInputStream(uploadFileData));
-
- while ((zipEntry = inputZipStream.getNextEntry()) != null) {
- currentEntryName = zipEntry.getName();
- // else, get the file content (as byte array) and save it in a map.
- fileByteContent = FileUtils.toByteArray(inputZipStream);
-
- int index = lastIndexFileSeparatorIndex(currentEntryName);
- String currSubstringWithoutSeparator =
- currentEntryName.substring(index + 1, currentEntryName.length());
- if (index != -1) { //todo ?
- folderList.add(currentEntryName);
- } else {
- mapFileContent.addFile(currentEntryName, fileByteContent);
- }
-
- }
-
- } catch (RuntimeException e0) {
- throw new IOException(e0);
- }
-
- if (CollectionUtils.isNotEmpty(folderList)) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
- .withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
- }
-
- return mapFileContent;
- }
-
- /**
- * Load and translate template data translator output.
- *
- * @param fileNameContentMap the file name content map
- * @return the translator output
- */
- public static TranslatorOutput loadAndTranslateTemplateData(
- FileContentHandler fileNameContentMap) {
- HeatToToscaTranslator heatToToscaTranslator =
- HeatToToscaTranslatorFactory.getInstance().createInterface();
- InputStream fileContent = fileNameContentMap.getFileContent(AsdcCommon.MANIFEST_NAME);
-
- heatToToscaTranslator.addManifest(AsdcCommon.MANIFEST_NAME, FileUtils.toByteArray(fileContent));
-
- fileNameContentMap.getFileList().stream()
- .filter(fileName -> !(fileName.equals(AsdcCommon.MANIFEST_NAME))).forEach(
- fileName -> heatToToscaTranslator
- .addFile(fileName, FileUtils.toByteArray(fileNameContentMap.getFileContent(fileName))));
-
- Map<String, List<ErrorMessage>> errors = heatToToscaTranslator.validate();
- if (MapUtils.isNotEmpty(MessageContainerUtil.getMessageByLevel(
- org.openecomp.sdc.datatypes.error.ErrorLevel.ERROR, errors))) {
- TranslatorOutput translatorOutput = new TranslatorOutput();
- translatorOutput.setErrorMessages(errors);
- return translatorOutput;
- }
-
- InputStream structureFile = getHeatStructureTreeFile(fileNameContentMap);
- heatToToscaTranslator.addExternalArtifacts(AsdcCommon.HEAT_META, structureFile);
- return heatToToscaTranslator.translate();
- }
-
- private static InputStream getHeatStructureTreeFile(FileContentHandler fileNameContentMap) {
- HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(fileNameContentMap);
- heatTreeManager.createTree();
- HeatStructureTree tree = heatTreeManager.getTree();
- ValidationStructureList validationStructureList = new ValidationStructureList(tree);
- return FileUtils.convertToInputStream(validationStructureList, FileUtils.FileExtension.JSON);
- }
-
-
- private static int lastIndexFileSeparatorIndex(String filePath) {
- int length = filePath.length() - 1;
-
- for (int i = length; i >= 0; i--) {
- char currChar = filePath.charAt(i);
- if (currChar == '/' || currChar == File.separatorChar || currChar == File.pathSeparatorChar) {
- return i;
- }
- }
- // if we've reached to the start of the string and didn't find file separator - return -1
- return -1;
- }
-
- /**
- * Add file names to upload file response.
- *
- * @param fileContentMap the file content map
- * @param uploadFileResponse the upload file response
- */
- public static void addFileNamesToUploadFileResponse(FileContentHandler fileContentMap,
- UploadFileResponse uploadFileResponse) {
- uploadFileResponse.setFileNames(new ArrayList<>());
- for (String filename : fileContentMap.getFileList()) {
- if (!new File(filename).isDirectory()) {
- uploadFileResponse.addNewFileToList(filename);
- }
- }
- uploadFileResponse.removeFileFromList(AsdcCommon.MANIFEST_NAME);
- }
-
- /**
- * Validate raw zip data.
- *
- * @param uploadedFileData the uploaded file data
- * @param errors the errors
- */
- public static void validateRawZipData(byte[] uploadedFileData,
- Map<String, List<ErrorMessage>> errors) {
- if (uploadedFileData.length == 0) {
- ErrorMessage.ErrorMessageUtil.addMessage(AsdcCommon.UPLOAD_FILE, errors).add(
- new ErrorMessage(org.openecomp.sdc.datatypes.error.ErrorLevel.ERROR,
- Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
- }
- }
-
- /**
- * Validate content zip data.
- *
- * @param contentMap the content map
- * @param errors the errors
- */
- public static void validateContentZipData(FileContentHandler contentMap,
- Map<String, List<ErrorMessage>> errors) {
- if (contentMap == null) {
- ErrorMessage.ErrorMessageUtil.addMessage(AsdcCommon.UPLOAD_FILE, errors).add(
- new ErrorMessage(org.openecomp.sdc.datatypes.error.ErrorLevel.ERROR,
- Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage()));
-
- } else if (contentMap.getFileList().size() == 0) {
- ErrorMessage.ErrorMessageUtil.addMessage(AsdcCommon.UPLOAD_FILE, errors)
- .add(new ErrorMessage(org.openecomp.sdc.datatypes.error.ErrorLevel.ERROR,
- Messages.INVALID_ZIP_FILE.getErrorMessage()));
- }
- }
-
-
- /**
- * Filter non trap or poll artifacts map.
- *
- * @param artifacts the artifacts
- * @return the map
- */
- public static Map<ComponentArtifactType, String> filterNonTrapOrPollArtifacts(
- Collection<ComponentArtifactEntity> artifacts) {
- Map<ComponentArtifactType, String> artifactTypeToFilename = new HashMap<>();
-
- for (ComponentArtifactEntity entity : artifacts) {
- if (isTrapOrPoll(entity.getType())) {
- artifactTypeToFilename.put(entity.getType(), entity.getArtifactName());
- }
- }
-
- return artifactTypeToFilename;
- }
-
-
- private static boolean isTrapOrPoll(ComponentArtifactType type) {
- return type.equals(ComponentArtifactType.SNMP_POLL)
- || type.equals(ComponentArtifactType.SNMP_TRAP);
- }
-
-
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java
new file mode 100644
index 0000000000..a31558f4f9
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTracker.java
@@ -0,0 +1,61 @@
+package org.openecomp.sdc.vendorsoftwareproduct.utils;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class ComponentDependencyTracker {
+ Map<String, Set<String>> store = new HashMap<>();
+
+ /**
+ * Add dependency.
+ *
+ * @param dependent the dependent
+ * @param dependsOn the depends on
+ */
+ public void addDependency(String dependent, String dependsOn) {
+ if (dependent != null && dependsOn != null && dependent.trim().length() > 0 && dependsOn.trim()
+ .length() > 0) {
+ dependent = dependent.toLowerCase();
+ dependsOn = dependsOn.toLowerCase();
+ Set<String> dependsOnList = store.get(dependent);
+ if (dependsOnList == null) {
+ dependsOnList = new HashSet<>();
+ store.put(dependent, dependsOnList);
+ }
+ dependsOnList.add(dependsOn);
+ }
+ }
+
+ /**
+ * Is cyclic dependency present boolean.
+ *
+ * @return the boolean
+ */
+ public boolean isCyclicDependencyPresent() {
+ Set<Map.Entry<String, Set<String>>> entries = store.entrySet();
+ for (Map.Entry<String, Set<String>> entry : entries) {
+ for (String dependentOn : entry.getValue()) {
+ if (!entry.getKey().equals(dependentOn) && isCyclicDependencyPresent(entry.getKey(),
+ dependentOn)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean isCyclicDependencyPresent(String root, String dependentOn) {
+ Set<String> dependentOnList = store.get(dependentOn);
+ if (dependentOnList != null && dependentOnList.contains(root)) {
+ return true;
+ } else if (dependentOnList != null) {
+ for (String item : dependentOnList) {
+ return isCyclicDependencyPresent(root, item);
+ }
+ }
+ return false;
+ }
+
+}
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
new file mode 100644
index 0000000000..3e7e83d3ba
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/utils/VendorSoftwareProductUtils.java
@@ -0,0 +1,181 @@
+/*-
+ * ============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.utils;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.openecomp.core.enrichment.types.ArtifactType;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.errors.Messages;
+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.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.types.OrchestrationTemplateActionResponse;
+import org.slf4j.MDC;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class VendorSoftwareProductUtils {
+ protected static Logger logger =
+ (Logger) LoggerFactory.getLogger(VendorSoftwareProductUtils.class);
+
+ /**
+ * Add file names to upload file response.
+ *
+ * @param fileContentMap the file content map
+ * @param uploadFileResponse the upload file response
+ */
+ public static void addFileNamesToUploadFileResponse(FileContentHandler fileContentMap,
+ OrchestrationTemplateActionResponse uploadFileResponse) {
+ uploadFileResponse.setFileNames(new ArrayList<>());
+ for (String filename : fileContentMap.getFileList()) {
+ if (!new File(filename).isDirectory()) {
+ uploadFileResponse.addNewFileToList(filename);
+ }
+ }
+ uploadFileResponse.removeFileFromList(SdcCommon.MANIFEST_NAME);
+ }
+
+ /**
+ * Validate raw zip data.
+ *
+ * @param uploadedFileData the uploaded file data
+ * @param errors the errors
+ */
+ public static void validateRawZipData(byte[] uploadedFileData,
+ Map<String, List<ErrorMessage>> errors) {
+ if (uploadedFileData.length == 0) {
+ MDC.put(LoggerConstants.ERROR_DESCRIPTION, LoggerErrorDescription.INVALID_ZIP);
+ ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors).add(
+ new ErrorMessage(ErrorLevel.ERROR,
+ Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage()));
+ }
+ }
+
+ /**
+ * Validate content zip data.
+ *
+ * @param contentMap the content map
+ * @param errors the errors
+ */
+ 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) {
+ ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
+ }
+ }
+
+
+ /**
+ * Filter non trap or poll artifacts map.
+ *
+ * @param artifacts the artifacts
+ * @return the map
+ */
+ public static Map<ArtifactType, String> filterNonTrapOrPollArtifacts(
+ Collection<MibEntity> artifacts) {
+ Map<ArtifactType, String> artifactTypeToFilename = new HashMap<>();
+
+ for (MibEntity entity : artifacts) {
+ if (isTrapOrPoll(entity.getType())) {
+ 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);
+ }
+
+
+ /**
+ * Sets errors into logger.
+ *
+ * @param errors the errors
+ * @param serviceName the service name
+ * @param targetServiceName the target service name
+ */
+ public static void setErrorsIntoLogger(Map<String, List<ErrorMessage>> errors,
+ LoggerServiceName serviceName, String targetServiceName) {
+ MdcDataErrorMessage mdcDataErrorMessage =
+ new MdcDataErrorMessage(targetServiceName, LoggerConstants.TARGET_ENTITY_DB,
+ ErrorLevel.ERROR.name(), null, null);
+ mdcDataErrorMessage.setMdcValues();
+
+ if (MapUtils.isEmpty(errors)) {
+ return;
+ }
+
+ for (Map.Entry<String, List<ErrorMessage>> listEntry : errors.entrySet()) {
+ List<ErrorMessage> errorList = listEntry.getValue();
+ for (ErrorMessage message : errorList) {
+ logger.error(message.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Sets errors into logger.
+ *
+ * @param errors the errors
+ * @param serviceName the service name
+ * @param targetServiceName the target service name
+ */
+ public static void setErrorsIntoLogger(Collection<ErrorCode> errors,
+ LoggerServiceName serviceName, String targetServiceName) {
+ MdcDataErrorMessage mdcDataErrorMessage =
+ new MdcDataErrorMessage(targetServiceName, LoggerConstants.TARGET_ENTITY_DB,
+ ErrorLevel.ERROR.name(), null, null);
+ mdcDataErrorMessage.setMdcValues();
+
+ if (CollectionUtils.isEmpty(errors)) {
+ return;
+ }
+
+ for (ErrorCode error : errors) {
+ logger.error(error.message());
+ }
+ }
+
+}
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
new file mode 100644
index 0000000000..f736c8f115
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,11 @@
+{
+ "org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.VspManagerFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ComponentManagerFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.NetworkManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.NetworkManagerFactoryImpl",
+ "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.ComponentDependencyModelManagerFactory": "org.openecomp.sdc.vendorsoftwareproduct.impl.ComponentDependencyModelManagerFactoryImpl",
+ "org.openecomp.sdc.vendorsoftwareproduct.factories.VspServiceFactory": "org.openecomp.sdc.vendorsoftwareproduct.factories.impl.VspServiceFactoryImpl"
+} \ No newline at end of file