aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshrikantawachar <shrikant.awachar@amdocs.com>2018-02-12 16:57:59 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2018-02-14 11:23:44 +0000
commit9f33060362b6bf8b3a7cdcdab6ce3d1c81946300 (patch)
tree4900df52242ab5804408ccda3e51159e344f01e4
parent71904f241cd3047054dc0a36c04120a3f53205ae (diff)
Enforcing HEAT validation after HEAT upload
Back end implementation , Junits for Enforcing HEAT validation after heat upload. Change-Id: I0572b1d5e455023d45dc3b50b0bae7f3b6bbcc2e Issue-ID: SDC-1027 Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
-rw-r--r--openecomp-bdd/features/AbortFunctionality/TestAbort_ForInvalidHeatFile.feature45
-rw-r--r--openecomp-bdd/features/AbortFunctionality/TestAbort_ForValidHeatFile.feature30
-rw-r--r--openecomp-bdd/features/AbortFunctionality/TestProperties.feature33
-rw-r--r--openecomp-bdd/features/AbortFunctionality/TestRollback.feature41
-rw-r--r--openecomp-bdd/features/AbortFunctionality/TestSubmit.feature35
-rw-r--r--openecomp-bdd/stepDefinitions/REST_Steps.js13
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java20
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java31
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java38
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java17
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java32
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java131
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java3
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java20
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java57
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java91
-rw-r--r--openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java21
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java20
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java18
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java19
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java186
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java79
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java28
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java32
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java40
31 files changed, 934 insertions, 255 deletions
diff --git a/openecomp-bdd/features/AbortFunctionality/TestAbort_ForInvalidHeatFile.feature b/openecomp-bdd/features/AbortFunctionality/TestAbort_ForInvalidHeatFile.feature
new file mode 100644
index 0000000000..cdfea4f456
--- /dev/null
+++ b/openecomp-bdd/features/AbortFunctionality/TestAbort_ForInvalidHeatFile.feature
@@ -0,0 +1,45 @@
+# Copyright © 2016-2018 European Support Limited
+#
+# 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.
+
+Feature: Abort Flow
+
+ Background: Init
+ Given I want to create a VLM
+
+ Scenario: Test abort functionality , Check validation data for invalid heat
+ When I want to create a VSP with onboarding type "NetworkPackage"
+ Then I want to make sure this Item has status "Draft"
+
+ When I want to upload a NetworkPackage for this VSP from path "resources/uploads/errorHeat.zip"
+ # abort
+ When I want to delete for path "/vendor-software-products/{item.id}/versions/{item.versionId}/orchestration-template-candidate"
+
+ When I want to get path "/vendor-software-products/{item.id}/versions/{item.versionId}"
+ Then I want to check property "onboardingOrigin" does not exist
+ Then I want to check property "candidateOnboardingOrigin" does not exist
+ Then I want to check property "validationData" does not exist
+
+ When I want to upload a NetworkPackage for this VSP from path "resources/uploads/errorHeat.zip"
+ When I want to process the NetworkPackage file for this VSP
+ # validation data should have been updated as heat is invalid
+ Then I want to get path "/vendor-software-products/{item.id}/versions/{item.versionId}"
+ Then I want to check property "validationData" exists
+
+ # abort - processed invalid file and check validation data
+ When I want to delete for path "/vendor-software-products/{item.id}/versions/{item.versionId}/orchestration-template-candidate"
+
+ When I want to get path "/vendor-software-products/{item.id}/versions/{item.versionId}"
+ Then I want to check property "onboardingOrigin" does not exist
+ Then I want to check property "candidateOnboardingOrigin" does not exist
+ Then I want to check property "validationData" does not exist
diff --git a/openecomp-bdd/features/AbortFunctionality/TestAbort_ForValidHeatFile.feature b/openecomp-bdd/features/AbortFunctionality/TestAbort_ForValidHeatFile.feature
new file mode 100644
index 0000000000..3eb0463b86
--- /dev/null
+++ b/openecomp-bdd/features/AbortFunctionality/TestAbort_ForValidHeatFile.feature
@@ -0,0 +1,30 @@
+# Copyright © 2016-2018 European Support Limited
+#
+# 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.
+
+Feature: Abort Flow
+
+ Background: Init
+ Given I want to create a VLM
+
+ Scenario: Test abort functionality for valid heat
+ When I want to create a VSP with onboarding type "NetworkPackage"
+ Then I want to make sure this Item has status "Draft"
+
+ When I want to upload a NetworkPackage for this VSP from path "resources/uploads/BASE_MUX.zip"
+ Then I want to process the NetworkPackage file for this VSP
+
+ When I want to delete for path "/vendor-software-products/{item.id}/versions/{item.versionId}/orchestration-template-candidate"
+ Then I want to get path "/vendor-software-products/{item.id}/versions/{item.versionId}"
+ Then I want to check property "candidateOnboardingOrigin" does not exist
+ Then I want to check property "onboardingOrigin" for value "zip" \ No newline at end of file
diff --git a/openecomp-bdd/features/AbortFunctionality/TestProperties.feature b/openecomp-bdd/features/AbortFunctionality/TestProperties.feature
new file mode 100644
index 0000000000..d268c64ac4
--- /dev/null
+++ b/openecomp-bdd/features/AbortFunctionality/TestProperties.feature
@@ -0,0 +1,33 @@
+# Copyright © 2016-2018 European Support Limited
+#
+# 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.
+
+Feature: Abort Flow
+
+ Background: Init
+ Given I want to create a VLM
+
+ Scenario: Create VSP , Upload Network Pacakage and check properties candidateOnboardingOrigin,onboardingOrigin
+ When I want to create a VSP with onboarding type "NetworkPackage"
+ Then I want to make sure this Item has status "Draft"
+
+ When I want to get path "/vendor-software-products/{item.id}/versions/{item.versionId}"
+ Then I want to check property "onboardingOrigin" does not exist
+ Then I want to check property "candidateOnboardingOrigin" does not exist
+
+ When I want to upload a NetworkPackage for this VSP from path "resources/uploads/errorHeat.zip"
+ Then I want to get path "/vendor-software-products/{item.id}/versions/{item.versionId}"
+ Then I want to check property "candidateOnboardingOrigin" exists
+ Then I want to check property "candidateOnboardingOrigin" for value "zip"
+ Then I want to check property "onboardingOrigin" does not exist
+ # Then I want to print the context data \ No newline at end of file
diff --git a/openecomp-bdd/features/AbortFunctionality/TestRollback.feature b/openecomp-bdd/features/AbortFunctionality/TestRollback.feature
new file mode 100644
index 0000000000..50f16e66a9
--- /dev/null
+++ b/openecomp-bdd/features/AbortFunctionality/TestRollback.feature
@@ -0,0 +1,41 @@
+# Copyright © 2016-2018 European Support Limited
+#
+# 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.
+
+Feature: Abort Flow
+
+ Background: Init
+ Given I want to create a VLM
+
+ Scenario: Test rollback. In case abort it should successfully rollback to previously processed service model
+ When I want to create a VSP with onboarding type "NetworkPackage"
+ Then I want to make sure this Item has status "Draft"
+
+ When I want to upload a NetworkPackage for this VSP from path "resources/uploads/BASE_MUX.zip"
+ Then I want to process the NetworkPackage file for this VSP
+
+ When I want to get path "/vendor-software-products/{item.id}/versions/{item.versionId}"
+ Then I want to check property "onboardingOrigin" for value "zip"
+
+ When I want to upload a NetworkPackage for this VSP from path "resources/uploads/errorHeat.zip"
+ Then I want to process the NetworkPackage file for this VSP
+ Then I want to check property "status" for value "Failure"
+
+ When I want to get path "/vendor-software-products/{item.id}/versions/{item.versionId}"
+ Then I want to check property "candidateOnboardingOrigin" for value "zip"
+
+ When I want to delete for path "/vendor-software-products/{item.id}/versions/{item.versionId}/orchestration-template-candidate"
+ # rollback - check whether it rolled back to previous processed file
+ Then I want to get path "/vendor-software-products/{item.id}/versions/{item.versionId}"
+ Then I want to check property "onboardingOrigin" for value "zip"
+ Then I want to check property "candidateOnboardingOrigin" does not exist
diff --git a/openecomp-bdd/features/AbortFunctionality/TestSubmit.feature b/openecomp-bdd/features/AbortFunctionality/TestSubmit.feature
new file mode 100644
index 0000000000..f39b95d7f0
--- /dev/null
+++ b/openecomp-bdd/features/AbortFunctionality/TestSubmit.feature
@@ -0,0 +1,35 @@
+# Copyright © 2016-2018 European Support Limited
+#
+# 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.
+
+Feature: Abort Flow
+
+ Background: Init
+ Given I want to create a VLM
+
+ Scenario: Test submit if file is just uploaded
+ When I want to create a VSP with onboarding type "NetworkPackage"
+ Then I want to make sure this Item has status "Draft"
+
+ When I want to upload a NetworkPackage for this VSP from path "resources/uploads/BASE_MUX.zip"
+ Then I want the following to fail
+ When I want to submit this VSP
+
+ Scenario: Test submit if invalid file is uploaded and procced for validation
+ When I want to create a VSP with onboarding type "NetworkPackage"
+ Then I want to make sure this Item has status "Draft"
+
+ When I want to upload a NetworkPackage for this VSP from path "resources/uploads/errorHeat.zip"
+ Then I want to process the NetworkPackage file for this VSP
+ Then I want the following to fail
+ When I want to submit this VSP \ No newline at end of file
diff --git a/openecomp-bdd/stepDefinitions/REST_Steps.js b/openecomp-bdd/stepDefinitions/REST_Steps.js
index 314f86825b..c3844124d7 100644
--- a/openecomp-bdd/stepDefinitions/REST_Steps.js
+++ b/openecomp-bdd/stepDefinitions/REST_Steps.js
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,6 +45,17 @@ When('I want to delete for path {string} with the value from saved property {str
return util.request(this.context, 'DELETE', path);
});
+/**
+ * @module Rest_Calls
+ * @description makes a DELETE request to the given path and appends the saved property (path is appended after the "onboarding-api/v1.0" prefix)<br>
+ * @exampleFile Example_Rest_Calls.feature
+ * @step I want to delete for path {string} with the value from saved property {string}
+ **/
+When('I want to delete for path {string}', function (string) {
+ let path = getPath(string, this.context);
+ //path += '/' + this.context[string2];
+ return util.request(this.context, 'DELETE', path);
+});
/**
* @module Rest_Calls
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java
index 4f5e31aaaf..cb3abeebc2 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java
@@ -1,9 +1,6 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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
@@ -15,7 +12,6 @@
* 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.sdcrests.vsp.rest;
@@ -32,6 +28,7 @@ import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
@@ -76,6 +73,14 @@ public interface OrchestrationTemplateCandidate extends VspEntities {
@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
throws IOException;
+ @DELETE
+ @Path("/")
+ @ApiOperation(value = "Delete orchestration template candidate file and its files data structure")
+ Response abort(
+ @PathParam("vspId") String vspId,
+ @ApiParam(value = "Version Id") @PathParam("versionId") String versionId)
+ throws Exception;
+
@PUT
@Path("/process")
@ApiOperation(value = "process Orchestration Template Candidate",
@@ -106,5 +111,4 @@ public interface OrchestrationTemplateCandidate extends VspEntities {
@ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user)
throws Exception;
-
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
index e6be1dcbe9..d856cfc6e5 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
package org.openecomp.sdcrests.vsp.rest.services;
import org.apache.commons.beanutils.BeanUtils;
@@ -11,6 +27,8 @@ import org.openecomp.sdc.activitylog.dao.type.ActivityType;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
@@ -44,6 +62,8 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
private OrchestrationTemplateCandidateManager candidateManager =
OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface();
+ private VendorSoftwareProductManager vendorSoftwareProductManager = VspManagerFactory
+ .getInstance().createInterface();
private ActivityLogManager activityLogManager =
ActivityLogManagerFactory.getInstance().createInterface();
@@ -75,6 +95,12 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
}
@Override
+ public Response abort(String vspId, String versionId) throws Exception {
+ candidateManager.abort(vspId, new Version(versionId));
+ return Response.ok().build();
+ }
+
+ @Override
public Response process(String vspId, String versionId, String user)
throws InvocationTargetException, IllegalAccessException {
@@ -121,6 +147,10 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
throws Exception {
Optional<FilesDataStructure> filesDataStructure =
candidateManager.getFilesDataStructure(vspId, new Version(versionId));
+ if (!filesDataStructure.isPresent()) {
+ filesDataStructure = vendorSoftwareProductManager.getOrchestrationTemplateStructure(vspId,
+ new Version(versionId));
+ }
FileDataStructureDto fileDataStructureDto =
filesDataStructure.map(dataStructure -> new MapFilesDataStructureToDto()
@@ -128,4 +158,5 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
.orElse(new FileDataStructureDto());
return Response.ok(fileDataStructureDto).build();
}
+
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
index 7d1c5e1289..09cb0945b1 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2018 European Support Limited
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@ package org.openecomp.sdcrests.vsp.rest.services;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.util.UniqueValueUtil;
-import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.activitylog.ActivityLogManager;
import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
@@ -88,8 +87,6 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
-import javax.inject.Named;
-import javax.ws.rs.core.Response;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@@ -100,6 +97,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Predicate;
+import javax.inject.Named;
+import javax.ws.rs.core.Response;
import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION;
import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
@@ -112,7 +111,6 @@ import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBM
import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID;
import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME;
-
@Named
@Service("vendorSoftwareProducts")
@Scope(value = "prototype")
@@ -591,28 +589,22 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
}
private void addNetworkPackageInfo(String vspId, Version version, VspDetailsDto vspDetailsDto) {
- OrchestrationTemplateEntity orchestrationTemplateInfo =
- vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version);
-
- vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure());
- vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName());
- vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix() == null
- ? OnboardingTypesEnum.NONE.toString()
- : orchestrationTemplateInfo.getFileSuffix());
-
OrchestrationTemplateCandidateData candidateInfo =
OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface()
.getInfo(vspId, version);
-
- //todo - remove after fix missing candidate element
- if (candidateInfo == null) {
- candidateInfo = new OrchestrationTemplateCandidateData();
- candidateInfo.setFileSuffix("zip");
+ if (Objects.nonNull(candidateInfo) && Objects.nonNull(candidateInfo.getFileSuffix())) {
+ vspDetailsDto.setValidationData(candidateInfo.getValidationDataStructure());
+ vspDetailsDto.setNetworkPackageName(candidateInfo.getFileName());
+ vspDetailsDto.setCandidateOnboardingOrigin(candidateInfo.getFileSuffix());
+ } else {
+ OrchestrationTemplateEntity orchestrationTemplateInfo =
+ vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version);
+ if (Objects.nonNull(orchestrationTemplateInfo)) {
+ vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure());
+ vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName());
+ vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix());
+ }
}
-
- vspDetailsDto.setCandidateOnboardingOrigin(candidateInfo.getFileSuffix() == null
- ? OnboardingTypesEnum.NONE.toString()
- : candidateInfo.getFileSuffix());
}
private boolean userHasPermission(String itemId, String userId) {
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
index 84318dbdd8..a28e2c8144 100644
--- 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
@@ -1,9 +1,6 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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
@@ -15,7 +12,6 @@
* 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;
@@ -46,4 +42,6 @@ public interface OrchestrationTemplateCandidateManager {
Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException;
OrchestrationTemplateCandidateData getInfo(String vspId, Version version);
+
+ void abort(String vspId, Version version);
}
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 2e38122856..7528110d37 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
@@ -1,21 +1,17 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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;
@@ -27,6 +23,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
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.File;
@@ -34,6 +31,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
public interface VendorSoftwareProductManager {
@@ -59,6 +57,7 @@ public interface VendorSoftwareProductManager {
OrchestrationTemplateEntity getOrchestrationTemplateInfo(String vspId, Version version);
+ Optional<FilesDataStructure> getOrchestrationTemplateStructure(String vspId, Version version);
PackageInfo createPackage(String vspId, Version version) throws IOException;
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 ca20d97e4a..c3a2862e39 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
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +24,13 @@ public class VendorSoftwareProductInvalidErrorBuilder {
private static final String VSP_INVALID_MSG =
"Vendor software product with Id %s and version %s is invalid - does not contain "
+ "service model.";
- private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG = "VSP has to have a " +
- "minimum of one Deployment Flavor defined for being able to be instantiated.Please add a Deployment Flavor and re-submit the VSP.";
+ private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG = "VSP has to have a "
+ + "minimum of one Deployment Flavor defined for being able to be instantiated.Please add a "
+ + "Deployment Flavor and re-submit the VSP.";
+ private static final String CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED = "Uploaded network package"
+ + " file %s was not processed/aborted.";
+ private static final String INVALID_PROCESSED_CANDIDATE = "Uploaded network package file %s"
+ + " is invalid and need to be aborted";
private VendorSoftwareProductInvalidErrorBuilder() {
@@ -60,4 +65,25 @@ public class VendorSoftwareProductInvalidErrorBuilder {
return builder.build();
}
+ public static ErrorCode candidateDataNotProcessedOrAbortedErrorBuilder(String fileName) {
+ ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes
+ .VSP_INVALID, ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED, fileName));
+ return builder.build();
+ }
+
+ public static ErrorCode invalidProcessedCandidate(String fileName) {
+ ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes
+ .VSP_INVALID, ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(INVALID_PROCESSED_CANDIDATE, fileName));
+ return builder.build();
+ }
+
+ public static ErrorCode.ErrorCodeBuilder getErrorCodeBuilder(String errorCode, ErrorCategory
+ errorCategory) {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(errorCode);
+ builder.withCategory(errorCategory);
+ return builder;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
index aa90b5dee6..97a4a213af 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@ public class OrchestrationTemplateCandidateManagerImpl
public OrchestrationTemplateCandidateManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
CandidateService candidateService
- ) {
+ ) {
this.vspInfoDao = vspInfoDao;
this.candidateService = candidateService;
}
@@ -129,8 +129,8 @@ public class OrchestrationTemplateCandidateManagerImpl
if (!candidateDataEntity.isPresent()) {
ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage
- (), ""));
+ getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(),
+ ""));
LOGGER.error(errorMessage.getMessage());
return Optional.empty();
}
@@ -157,6 +157,11 @@ public class OrchestrationTemplateCandidateManagerImpl
return candidateService.getOrchestrationTemplateCandidateInfo(vspId, version);
}
+ @Override
+ public void abort(String vspId, Version version) {
+ candidateService.deleteOrchestrationTemplateCandidate(vspId, version);
+ }
+
private Optional<OrchestrationTemplateCandidateData> fetchCandidateDataEntity(
String vspId, Version version) {
return Optional
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 78ce0787bf..cc24873e92 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
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,6 +44,7 @@ import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsSe
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
+import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
@@ -63,6 +64,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
@@ -82,6 +84,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGe
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
@@ -114,6 +117,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -121,6 +125,7 @@ import java.util.zip.ZipOutputStream;
public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager {
private final OrchestrationTemplateDao orchestrationTemplateDao;
+ private final OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager;
private final VendorSoftwareProductInfoDao vspInfoDao;
private final VendorLicenseFacade vendorLicenseFacade;
private final ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
@@ -137,22 +142,24 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private final ManualVspToscaManager manualVspToscaManager;
public VendorSoftwareProductManagerImpl(
- OrchestrationTemplateDao orchestrationTemplateDataDao,
- VendorSoftwareProductInfoDao vspInfoDao,
- VendorLicenseFacade vendorLicenseFacade,
- ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
- EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao,
- VendorLicenseArtifactsService licenseArtifactsService,
- InformationArtifactGenerator informationArtifactGenerator,
- PackageInfoDao packageInfoDao,
- DeploymentFlavorDao deploymentFlavorDao,
- ComponentDao componentDao,
- ComponentDependencyModelDao componentDependencyModelDao,
- NicDao nicDao,
- ComputeDao computeDao,
- ImageDao imageDao,
- ManualVspToscaManager manualVspToscaManager) {
+ OrchestrationTemplateDao orchestrationTemplateDataDao,
+ OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager,
+ VendorSoftwareProductInfoDao vspInfoDao,
+ VendorLicenseFacade vendorLicenseFacade,
+ ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
+ EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao,
+ VendorLicenseArtifactsService licenseArtifactsService,
+ InformationArtifactGenerator informationArtifactGenerator,
+ PackageInfoDao packageInfoDao,
+ DeploymentFlavorDao deploymentFlavorDao,
+ ComponentDao componentDao,
+ ComponentDependencyModelDao componentDependencyModelDao,
+ NicDao nicDao,
+ ComputeDao computeDao,
+ ImageDao imageDao,
+ ManualVspToscaManager manualVspToscaManager) {
this.orchestrationTemplateDao = orchestrationTemplateDataDao;
+ this.orchestrationTemplateCandidateManager = orchestrationTemplateCandidateManager;
this.vspInfoDao = vspInfoDao;
this.vendorLicenseFacade = vendorLicenseFacade;
this.serviceModelDao = serviceModelDao;
@@ -170,6 +177,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
registerToVersioning();
}
+
private void registerToVersioning() {
serviceModelDao.registerVersioning(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
@@ -177,27 +185,19 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
}
-
@Override
public ValidationResponse validate(String vspId, Version version) throws IOException {
VspDetails vspDetails = getValidatedVsp(vspId, version);
- Collection<ComponentDependencyModelEntity> componentDependencies =
- componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
-
- ValidationResponse validationResponse = new ValidationResponse();
- validationResponse.setQuestionnaireValidationResult(
- validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(),
- vspDetails.getOnboardingMethod()));
-
List<ErrorCode> vspErrors = new ArrayList<>(validateVspFields(vspDetails));
- if (validateComponentDependencies(componentDependencies)) {
- vspErrors
- .add(ComponentDependencyModelErrorBuilder.getcyclicDependencyComponentErrorBuilder());
- }
- if (Objects.nonNull(vspDetails.getOnboardingMethod()) &&
- OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod())) {
+ ValidationResponse validationResponse = new ValidationResponse();
+ if (Objects.nonNull(vspDetails.getOnboardingMethod())
+ && OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod())) {
validateManualOnboardingMethod(vspDetails, validationResponse, vspErrors);
} else {
+ validateOrchestrationTemplateCandidate(validationResponse, vspErrors, vspId, version);
+ if (!validationResponse.isValid()) {
+ return validationResponse;
+ }
if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
|| vspDetails.getFeatureGroups() != null) {
vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
@@ -206,20 +206,59 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
orchestrationTemplateDao.get(vspId, version);
ToscaServiceModel serviceModel =
serviceModelDao.getServiceModel(vspId, vspDetails.getVersion());
- if (!isOrchestrationTemplateExist(orchestrationTemplate) ||
- !isServiceModelExist(serviceModel)) {
+ if (!isOrchestrationTemplateExist(orchestrationTemplate)
+ || !isServiceModelExist(serviceModel)) {
vspErrors.add(VendorSoftwareProductInvalidErrorBuilder
.vendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
vspDetails.getVersion()));
}
validationResponse.setUploadDataErrors(validateOrchestrationTemplate(orchestrationTemplate));
}
+ Collection<ComponentDependencyModelEntity> componentDependencies =
+ componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
+
+ QuestionnaireValidationResult questionnaireValidationResult = validateQuestionnaire
+ (vspDetails.getId(), vspDetails.getVersion(), vspDetails.getOnboardingMethod());
+
+ if (Objects.nonNull(questionnaireValidationResult)) {
+ if (validationResponse.getQuestionnaireValidationResult() == null || validationResponse
+ .getQuestionnaireValidationResult().getValidationData() == null) {
+ validationResponse.setQuestionnaireValidationResult(questionnaireValidationResult);
+ } else {
+ validationResponse.getQuestionnaireValidationResult().getValidationData().addAll
+ (questionnaireValidationResult.getValidationData());
+ }
+ }
+
+ if (validateComponentDependencies(componentDependencies)) {
+ vspErrors
+ .add(ComponentDependencyModelErrorBuilder.getcyclicDependencyComponentErrorBuilder());
+ }
validationResponse
.setVspErrors(vspErrors);
validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
return validationResponse;
}
+ private void validateOrchestrationTemplateCandidate(ValidationResponse validationResponse,
+ List<ErrorCode> vspErrors, String vspId,
+ Version version) {
+ OrchestrationTemplateCandidateData orchestrationTemplateCandidateData =
+ orchestrationTemplateCandidateManager.getInfo(vspId, version);
+ String validationData = orchestrationTemplateCandidateData.getValidationData();
+ String fileName = orchestrationTemplateCandidateData.getFileName();
+ if (Objects.nonNull(orchestrationTemplateCandidateData.getFileSuffix())) {
+ if (validationData.isEmpty()) {
+ vspErrors.add(VendorSoftwareProductInvalidErrorBuilder
+ .candidateDataNotProcessedOrAbortedErrorBuilder(fileName));
+ validationResponse.setVspErrors(vspErrors);
+ } else {
+ vspErrors.add(VendorSoftwareProductInvalidErrorBuilder.invalidProcessedCandidate(fileName));
+ validationResponse.setVspErrors(vspErrors);
+ }
+ }
+ }
+
private void validateManualOnboardingMethod(VspDetails vspDetails,
ValidationResponse validationResponse,
List<ErrorCode> vspErrors) {
@@ -236,8 +275,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
Set<CompositionEntityValidationData> componentValidationResult =
componentValidation(vspDetails.getId(), vspDetails.getVersion());
if (!CollectionUtils.isEmpty(componentValidationResult)) {
- if (validationResponse.getQuestionnaireValidationResult() == null ||
- validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
+ if (validationResponse.getQuestionnaireValidationResult() == null
+ || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
validationResponse.setQuestionnaireValidationResult(
new QuestionnaireValidationResult(componentValidationResult));
} else {
@@ -588,6 +627,20 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
+ public Optional<FilesDataStructure> getOrchestrationTemplateStructure(String vspId,
+ Version version) {
+ Optional<String> jsonFileDataStructure =
+ orchestrationTemplateDao.getOrchestrationTemplateStructure(vspId, version);
+
+ if (jsonFileDataStructure.isPresent() && JsonUtil.isValidJson(jsonFileDataStructure.get())) {
+ return Optional
+ .of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ @Override
public PackageInfo createPackage(String vspId, Version version) {
ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version);
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
@@ -770,10 +823,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
private boolean isOrchestrationTemplateExist(OrchestrationTemplateEntity orchestrationTemplate) {
- return orchestrationTemplate != null &&
- orchestrationTemplate.getContentData() != null &&
- orchestrationTemplate.getFileSuffix() != null &&
- orchestrationTemplate.getFileName() != null;
+ return orchestrationTemplate != null
+ && orchestrationTemplate.getContentData() != null
+ && orchestrationTemplate.getFileSuffix() != null
+ && orchestrationTemplate.getFileName() != null;
}
private boolean isServiceModelExist(ToscaServiceModel serviceModel) {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
index a2c0aea423..4749e7f2dd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
@@ -1,9 +1,6 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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
@@ -15,7 +12,6 @@
* 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;
@@ -24,6 +20,7 @@ import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
import org.openecomp.sdc.vendorlicense.VendorLicenseArtifactServiceFactory;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
@@ -41,6 +38,7 @@ public class VspManagerFactoryImpl extends VspManagerFactory {
private static final VendorSoftwareProductManager INSTANCE =
new VendorSoftwareProductManagerImpl(
OrchestrationTemplateDaoFactory.getInstance().createInterface(),
+ OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(),
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
VendorLicenseFacadeFactory.getInstance().createInterface(),
ServiceModelDaoFactory.getInstance().createInterface(),
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
index 9031e926a4..fae8f8b697 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -317,6 +317,7 @@ public class OrchestrationUtil {
(String) manifestAsMap.get("name"));
uploadData.setPackageVersion(Objects.isNull(manifestAsMap.get("version")) ? null :
(String) manifestAsMap.get("version"));
+ uploadData.setFilesDataStructure(candidateData.getFilesDataStructure());
orchestrationTemplateDataDao.update(vspDetails.getId(), vspDetails.getVersion(), uploadData);
VspMergeDaoFactory.getInstance().createInterface()
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
index 1db8875a05..6365b9ef74 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ import org.openecomp.sdc.common.errors.GeneralErrorBuilder;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
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.ToscaTreeManager;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -97,7 +98,13 @@ public class OrchestrationTemplateProcessCsarHandler
OrchestrationTemplateActionResponse response) throws IOException {
response.setFileNames(new ArrayList<>(fileContentHandler.getFileList()));
Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler);
+ toscaTreeManager.createTree();
+
if (!isValid(errors)) {
+ response.addStructureErrors(errors);
+ toscaTreeManager.addErrors(errors);
+ candidateService.updateValidationData(vspDetails.getId(), vspDetails.getVersion(),
+ new ValidationStructureList(toscaTreeManager.getTree()));
return;
}
@@ -126,7 +133,8 @@ public class OrchestrationTemplateProcessCsarHandler
orchestrationUtil.saveServiceModel(vspDetails.getId(),
vspDetails.getVersion(), toscaServiceModel,
toscaServiceModel);
-
+ candidateService
+ .deleteOrchestrationTemplateCandidate(vspDetails.getId(), vspDetails.getVersion());
}
private void addFiles(FileContentHandler fileContentHandler) {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
index 9f29d9316b..f155e45c06 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2016-2017 European Support Limited
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ 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.heat.datatypes.structure.HeatStructureTree;
+import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.messages.AuditMessages;
@@ -61,7 +62,6 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp
private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessZipHandler.class);
private final CandidateService candidateService =
CandidateServiceFactory.getInstance().createInterface();
- private static final String VSP_ID = "VSP id";
@Override
public OrchestrationTemplateActionResponse process(VspDetails vspDetails,
@@ -108,7 +108,12 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp
}
HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap);
-
+ Map<String, List<ErrorMessage>> errors = getErrors(response);
+ if (MapUtils.isNotEmpty(errors)) {
+ response.addStructureErrors(errors);
+ candidateService.updateValidationData(vspId, version, new ValidationStructureList(tree));
+ return response;
+ }
Map<String, String> componentsQuestionnaire = new HashMap<>();
Map<String, Map<String, String>> componentNicsQuestionnaire = new HashMap<>();
Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList = new HashMap<>();
@@ -152,9 +157,18 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp
LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_TRANSLATION_COMPLETED + vspId);
uploadFileResponse.addStructureErrors(uploadErrors);
+ candidateService.deleteOrchestrationTemplateCandidate(vspId, version);
return response;
}
+ private Map<String, List<ErrorMessage>> getErrors(OrchestrationTemplateActionResponse
+ orchestrationTemplateActionResponse) {
+ Map<String, List<ErrorMessage>> errors =
+ MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR,
+ orchestrationTemplateActionResponse.getErrors());
+ return MapUtils.isEmpty(errors) ? null : orchestrationTemplateActionResponse.getErrors();
+ }
+
private HeatStructureTree createAndValidateHeatTree(OrchestrationTemplateActionResponse response,
FileContentHandler fileContentMap) {
VendorSoftwareProductUtils.addFileNamesToUploadFileResponse(fileContentMap, response);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
index 5af39551b4..e1d58c6a18 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import static org.mockito.Matchers.any;
@@ -11,6 +27,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
@@ -23,6 +40,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
import org.openecomp.sdc.vendorsoftwareproduct.utils.ZipFileUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -59,6 +77,8 @@ public class OrchestrationTemplateCandidateManagerImplTest {
private static final String COMPONENT_NAME_3 = "oam_server";
private static final String COMPONENT_NAME_4 = "ps_server";
+ private static final String USER1 = "vspTestUser1";
+
@Mock
private VendorSoftwareProductInfoDao vspInfoDaoMock;
@Mock
@@ -240,6 +260,43 @@ public class OrchestrationTemplateCandidateManagerImplTest {
Assert.assertEquals(componentDependenciesBeforeDelete.size(), 2);
}
+ @Test
+ public void testGetFileDataStructure() {
+ Optional<String> jsonFileDataStructure = Optional.of(new String("{\n" +
+ " \"modules\": [\n" +
+ " {\n" +
+ " \"yaml\": \"hot-mog-0108-bs1271.yml\",\n" +
+ " \"env\": \"hot-mog-0108-bs1271.env\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"unassigned\": [],\n" +
+ " \"artifacts\": [],\n" +
+ " \"nested\": []\n" +
+ "}"));
+ Optional<FilesDataStructure> filesDataStructureOptional = Optional.of(JsonUtil.json2Object
+ (jsonFileDataStructure.get(), FilesDataStructure.class));
+ doReturn(filesDataStructureOptional).when(candidateServiceMock)
+ .getOrchestrationTemplateCandidateFileDataStructure(VSP_ID, VERSION01);
+ Optional<FilesDataStructure> filesDataStructure = candidateManager.getFilesDataStructure(VSP_ID,
+ VERSION01);
+ assertNotNull(filesDataStructure);
+ assertEquals(filesDataStructureOptional.get().getModules().size(), filesDataStructure.get()
+ .getModules().size());
+ assertEquals(filesDataStructureOptional.get().getModules().get(0).getName(),
+ filesDataStructure.get().getModules().get(0).getName());
+ }
+
+ @Test
+ public void testAbort() {
+
+ Mockito.doNothing().when(candidateServiceMock).deleteOrchestrationTemplateCandidate(VSP_ID,
+ VERSION01);
+ candidateManager.abort(VSP_ID, VERSION01);
+
+ Mockito.verify(candidateServiceMock, Mockito.times(1)).deleteOrchestrationTemplateCandidate
+ (VSP_ID, VERSION01);
+ }
+
private Map<String, String> getVspInitComponentIdNameInfo() {
Map<String, String> componentIdNameInfoBeforeProcess = new HashMap<>();
componentIdNameInfoBeforeProcess.put(COMPONENT_ORIG_ID_1, COMPONENT_NAME_1);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
index fd274d0898..2e10f1351e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
@@ -1,9 +1,6 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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
@@ -15,11 +12,18 @@
* 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 static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
@@ -40,32 +44,31 @@ import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
+import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.EnrichmentManagerFactoryImpl;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
-import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.errors.EditOnEntityLockedByOtherErrorBuilder;
-import org.openecomp.sdc.versioning.errors.EntityNotExistErrorBuilder;
import org.openecomp.sdc.versioning.types.VersionInfo;
import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.testng.Assert;
@@ -84,18 +87,9 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
public class VendorSoftwareProductManagerImplTest {
private static final String INVALID_VERSION_MSG = "Invalid requested version.";
@@ -142,6 +136,10 @@ public class VendorSoftwareProductManagerImplTest {
@InjectMocks
private VendorSoftwareProductManagerImpl vendorSoftwareProductManager;
+ @Mock
+ private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManagerMock;
+ @Mock
+ private ComponentDependencyModelDao componentDependencyModelDao;
private OrchestrationTemplateCandidateManager candidateManager;
private MonitoringUploadsManager monitoringUploadsManager;
@@ -587,6 +585,59 @@ public class VendorSoftwareProductManagerImplTest {
assertVSPInWantedLocationInVSPList(id007, 0, USER3);
}
*/
+ @Test
+ public void testSubmitWithCandidateDataNotProcessed() throws IOException {
+ VspDetails vsp =
+ createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
+ "category", "subCategory", "licenseAgreementId",
+ Collections.singletonList("featureGroupId"));
+ vsp.setOnboardingMethod("NetworkPackage");
+ doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
+
+ OrchestrationTemplateCandidateData orchestrationTemplateCandidateData = new
+ OrchestrationTemplateCandidateData();
+ orchestrationTemplateCandidateData.setFileSuffix("zip");
+ orchestrationTemplateCandidateData.setFilesDataStructure("testdata");
+ orchestrationTemplateCandidateData.setValidationData("");
+ doReturn(orchestrationTemplateCandidateData).when(orchestrationTemplateCandidateManagerMock)
+ .getInfo(VSP_ID, VERSION01);
+ ValidationResponse validationResponse =
+ vendorSoftwareProductManager.validate(VSP_ID, VERSION01);
+ Assert.assertNotNull(validationResponse);
+ Assert.assertFalse(validationResponse.isValid());
+ Assert.assertNotNull(validationResponse.getVspErrors());
+ Assert.assertEquals(validationResponse.getVspErrors().size(), 1);
+
+ verify(versioningManagerMock, never())
+ .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
+ USER1, null);
+ }
+
+ @Test
+ public void testSubmitWithCandidateProcessedIsInvalid() throws IOException {
+ VspDetails vsp = createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-VSP", "vendorName",
+ "vl1Id", "icond", "category", "subcategory", "licenseAgreementId", Collections
+ .singletonList("featureGroupId"));
+ vsp.setOnboardingMethod("NetworkPackage");
+ doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
+
+ OrchestrationTemplateCandidateData orchestrationTemplateCandidateData = new
+ OrchestrationTemplateCandidateData();
+ orchestrationTemplateCandidateData.setFileSuffix("zip");
+ orchestrationTemplateCandidateData.setValidationData("Invalid processed data");
+ doReturn(orchestrationTemplateCandidateData).when(orchestrationTemplateCandidateManagerMock)
+ .getInfo(VSP_ID, VERSION01);
+ ValidationResponse validationResponse =
+ vendorSoftwareProductManager.validate(VSP_ID, VERSION01);
+ Assert.assertNotNull(validationResponse);
+ Assert.assertFalse(validationResponse.isValid());
+ Assert.assertNotNull(validationResponse.getVspErrors());
+ Assert.assertEquals(validationResponse.getVspErrors().size(), 1);
+
+ verify(versioningManagerMock, never())
+ .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
+ USER1, null);
+ }
private void testLegalUpload(String vspId, Version version, InputStream upload, String user) {
candidateManager.upload(vspId, VERSION01, upload, "zip", "file");
diff --git a/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java
index 19d5656036..1eb688b057 100644
--- a/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java
+++ b/openecomp-be/lib/openecomp-sdc-datatypes-lib/src/main/java/org/openecomp/sdc/datatypes/model/ElementType.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
package org.openecomp.sdc.datatypes.model;
public enum ElementType {
@@ -15,8 +31,11 @@ public enum ElementType {
VspModel, NetworkPackage,
OrchestrationTemplateCandidate, OrchestrationTemplateCandidateContent,
+ OrchestrationTemplateCandidateValidationData,
+ OrchestrationTemplateStructure, OrchestrationTemplate,
+ OrchestrationTemplateValidationData,
// todo - remove OrchestrationTemplateContent
- OrchestrationTemplate, OrchestrationTemplateValidationData, OrchestrationTemplateContent,
+ OrchestrationTemplateContent,
Networks, Network,
Components, Component, ComponentQuestionnaire, ComponentDependencies, ComponentDependency,
Nics, Nic, NicQuestionnaire,
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java
index 3d7c621d67..9743814b11 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateCandidateDao.java
@@ -1,25 +1,22 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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.dao;
+import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.versioning.dao.VersionableDao;
@@ -33,10 +30,15 @@ public interface OrchestrationTemplateCandidateDao extends VersionableDao {
OrchestrationTemplateCandidateData getInfo(String vspId, Version version);
+ void delete(String vspId, Version version);
+
void update(String vspId, Version version, OrchestrationTemplateCandidateData candidateData);
void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure);
Optional<String> getStructure(String vspId, Version version);
+
+ void updateValidationData(String vspId, Version version, ValidationStructureList
+ validationData);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java
index 4d82ed37af..ddee436331 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/OrchestrationTemplateDao.java
@@ -1,21 +1,17 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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.dao;
@@ -24,6 +20,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEnt
import org.openecomp.sdc.versioning.dao.VersionableDao;
import org.openecomp.sdc.versioning.dao.types.Version;
+import java.util.Optional;
+
public interface OrchestrationTemplateDao extends VersionableDao {
OrchestrationTemplateEntity getInfo(String vspId, Version version);
@@ -31,5 +29,7 @@ public interface OrchestrationTemplateDao extends VersionableDao {
OrchestrationTemplateEntity get(String vspId, Version version);
void update(String vspId, Version version, OrchestrationTemplateEntity uploadData);
+
+ Optional<String> getOrchestrationTemplateStructure(String vspId, Version version);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java
index 7b19e8630c..398d84c8e5 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateCandidateData.java
@@ -1,5 +1,24 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
+
import java.nio.ByteBuffer;
public class OrchestrationTemplateCandidateData {
@@ -7,6 +26,7 @@ public class OrchestrationTemplateCandidateData {
private String filesDataStructure;
private String fileSuffix;
private String fileName;
+ private String validationData;
public OrchestrationTemplateCandidateData() {
}
@@ -50,4 +70,22 @@ public class OrchestrationTemplateCandidateData {
public void setFileName(String fileName) {
this.fileName = fileName;
}
+
+ public String getValidationData() {
+ return validationData;
+ }
+
+ public void setValidationData(String validationData) {
+ this.validationData = validationData;
+ }
+
+ public ValidationStructureList getValidationDataStructure() {
+ return validationData == null ? null
+ : JsonUtil.json2Object(validationData, ValidationStructureList.class);
+ }
+
+ public void setValidationDataStructure(ValidationStructureList validationData) {
+ this.validationData = validationData == null ? null
+ : JsonUtil.object2Json(validationData);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java
index ef3a4b6012..1bbe1b0ddf 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/OrchestrationTemplateEntity.java
@@ -1,9 +1,6 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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
@@ -15,7 +12,6 @@
* 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.dao.type;
@@ -38,8 +34,10 @@ public class OrchestrationTemplateEntity implements VersionableEntity {
private String packageVersion;
private String validationData;
private ByteBuffer contentData;
+ private String filesDataStructure;
public OrchestrationTemplateEntity() {
+ //default constructor implementation is not provided for OrchestrationTemplateEntity
}
public OrchestrationTemplateEntity(String id, Version version) {
@@ -57,10 +55,12 @@ public class OrchestrationTemplateEntity implements VersionableEntity {
return getId();
}
+ @Override
public String getId() {
return id;
}
+ @Override
public void setId(String id) {
this.id = id;
}
@@ -132,4 +132,12 @@ public class OrchestrationTemplateEntity implements VersionableEntity {
public void setContentData(ByteBuffer contentData) {
this.contentData = contentData;
}
+
+ public String getFilesDataStructure() {
+ return filesDataStructure;
+ }
+
+ public void setFilesDataStructure(String filesDataStructure) {
+ this.filesDataStructure = filesDataStructure;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
index 08dc908a3f..f3d2916636 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/filedatastructuremodule/CandidateService.java
@@ -1,21 +1,17 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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.filedatastructuremodule;
@@ -24,6 +20,7 @@ import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
+import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.CandidateDataEntityTo;
@@ -64,6 +61,8 @@ public interface CandidateService {
OrchestrationTemplateCandidateData getOrchestrationTemplateCandidateInfo(String vspId,
Version version);
+ void deleteOrchestrationTemplateCandidate(String vspId, Version version);
+
Optional<ByteArrayInputStream> fetchZipFileByteArrayInputStream(String vspId,
OrchestrationTemplateCandidateData candidateDataEntity,
String manifest,
@@ -80,4 +79,6 @@ public interface CandidateService {
String createManifest(VspDetails vspDetails, FilesDataStructure structure);
Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure);
+
+ void updateValidationData(String vspId, Version version, ValidationStructureList validationData);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java
index a0c3fd4032..bf592e2169 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateCandidateDaoZusammenImpl.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -7,10 +23,10 @@ import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.utils.fileutils.FileUtils;
-import org.apache.commons.io.IOUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
@@ -19,10 +35,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStru
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.nio.ByteBuffer;
-import java.util.Arrays;
+import java.util.Collection;
import java.util.Optional;
import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
@@ -36,6 +50,8 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
private ZusammenAdaptor zusammenAdaptor;
+ private static final String EMPTY_DATA = "{}";
+
public OrchestrationTemplateCandidateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
this.zusammenAdaptor = zusammenAdaptor;
}
@@ -56,25 +72,38 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
zusammenAdaptor.getElementByName(context, elementContext, null,
ElementType.OrchestrationTemplateCandidate.name());
if (candidateElement.isPresent()) {
- if (hasEmptyData(candidateElement.get().getData())) {
+ if (VspZusammenUtil.hasEmptyData(candidateElement.get().getData())) {
return null;
}
OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
candidateData.setFilesDataStructure(
new String(FileUtils.toByteArray(candidateElement.get().getData())));
- Optional<Element> candidateContentElement = zusammenAdaptor
- .getElementByName(context, elementContext, candidateElement.get().getElementId(),
- ElementType.OrchestrationTemplateCandidateContent.name());
-
- if (candidateContentElement.isPresent()) {
- candidateData.setContentData(
- ByteBuffer.wrap(FileUtils.toByteArray(candidateContentElement.get().getData())));
- candidateData.setFileSuffix(candidateContentElement.get().getInfo()
- .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
- candidateData.setFileName(candidateContentElement.get().getInfo()
- .getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ Collection<Element> subElements = candidateElement.get().getSubElements();
+ if (subElements.isEmpty()) {
+ return candidateData;
+ }
+
+ for (Element element : subElements) {
+ Optional<Element> subElement = zusammenAdaptor.getElement(context,
+ elementContext, element.getElementId().toString());
+
+ if (subElement.get().getInfo().getName()
+ .equals(ElementType.OrchestrationTemplateCandidateContent
+ .name())) {
+ candidateData.setContentData(
+ ByteBuffer.wrap(FileUtils.toByteArray(subElement.get().getData())));
+ candidateData.setFileSuffix(subElement.get().getInfo()
+ .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
+ candidateData.setFileName(subElement.get().getInfo()
+ .getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ } else if (subElement.get().getInfo().getName()
+ .equals(ElementType.OrchestrationTemplateCandidateValidationData.name())) {
+ candidateData.setValidationData(new String(FileUtils.toByteArray(subElement
+ .get().getData())));
+ }
}
+
logger
.info("Finished getting orchestration template for VendorSoftwareProduct id -> " + vspId);
return candidateData;
@@ -91,22 +120,36 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
SessionContext context = createSessionContext();
ElementContext elementContext = new ElementContext(vspId, version.getId());
+ OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
+
Optional<ElementInfo> candidateElement =
zusammenAdaptor.getElementInfoByName(context, elementContext, null,
ElementType.OrchestrationTemplateCandidate.name());
- if (candidateElement.isPresent()) {
- OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
- Optional<Element> candidateContentElement = zusammenAdaptor
- .getElementByName(context, elementContext, candidateElement.get().getId(),
- ElementType.OrchestrationTemplateCandidateContent.name());
+ if (candidateElement.isPresent()) {
+ Collection<ElementInfo> subElements = candidateElement.get().getSubElements();
+ if (subElements.isEmpty()) {
+ return candidateData;
+ }
- if (candidateContentElement.isPresent()) {
- candidateData.setFileSuffix(candidateContentElement.get().getInfo()
- .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
- candidateData.setFileName(candidateContentElement.get().getInfo()
- .getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ for (ElementInfo elementInfo : subElements) {
+ Optional<Element> subElement = zusammenAdaptor.getElement(context,
+ elementContext, elementInfo.getId().toString());
+
+ if (subElement.get().getInfo().getName().equals(ElementType
+ .OrchestrationTemplateCandidateContent.name())) {
+
+ candidateData.setFileSuffix(subElement.get().getInfo()
+ .getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
+ candidateData.setFileName(subElement.get().getInfo()
+ .getProperty(InfoPropertyName.FILE_NAME.getVal()));
+ } else if (subElement.get().getInfo().getName().equals(ElementType
+ .OrchestrationTemplateCandidateValidationData.name())) {
+ candidateData.setValidationData(new String(FileUtils.toByteArray(subElement.get()
+ .getData())));
+ }
}
+
logger.info(
"Finished getting orchestration template info for VendorSoftwareProduct id -> " + vspId);
return candidateData;
@@ -118,6 +161,30 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
}
@Override
+ public void delete(String vspId, Version version) {
+ ByteArrayInputStream emptyData = new ByteArrayInputStream(EMPTY_DATA.getBytes());
+
+ ZusammenElement candidateContentElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.UPDATE);
+ candidateContentElement.setData(emptyData);
+
+ ZusammenElement validationData = buildStructuralElement(ElementType
+ .OrchestrationTemplateCandidateValidationData, Action.UPDATE);
+ validationData.setData(emptyData);
+
+ ZusammenElement candidateElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.UPDATE);
+ candidateElement.setData(emptyData);
+ candidateElement.addSubElement(candidateContentElement);
+ candidateElement.addSubElement(validationData);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ zusammenAdaptor.saveElement(context, elementContext, candidateElement,
+ "Delete Orchestration Template Candidate Elements's content");
+ }
+
+ @Override
public void update(String vspId, Version version,
OrchestrationTemplateCandidateData candidateData) {
logger.info("Uploading candidate data entity for VendorSoftwareProduct id -> " + vspId);
@@ -135,8 +202,15 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
.addProperty(InfoPropertyName.FILE_SUFFIX.getVal(), candidateData.getFileSuffix());
candidateContentElement.getInfo()
.addProperty(InfoPropertyName.FILE_NAME.getVal(), candidateData.getFileName());
- candidateElement.addSubElement(candidateContentElement);
+ ZusammenElement validationData = buildStructuralElement(ElementType
+ .OrchestrationTemplateCandidateValidationData, Action.UPDATE);
+ if (candidateData.getValidationData() != null) {
+ validationData
+ .setData(new ByteArrayInputStream(candidateData.getValidationData().getBytes()));
+ }
+ candidateElement.addSubElement(candidateContentElement);
+ candidateElement.addSubElement(validationData);
SessionContext context = createSessionContext();
ElementContext elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, candidateElement,
@@ -145,6 +219,28 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
.info("Finished uploading candidate data entity for VendorSoftwareProduct id -> " + vspId);
}
+ @Override
+ public void updateValidationData(String vspId, Version version, ValidationStructureList
+ validationData) {
+ logger.info("Updating validation data of orchestration template candidate for VSP id -> "
+ + vspId);
+
+ ZusammenElement validationDataElement = buildStructuralElement(ElementType
+ .OrchestrationTemplateCandidateValidationData, Action.UPDATE);
+ validationDataElement.setData(validationData == null ? new ByteArrayInputStream(EMPTY_DATA
+ .getBytes()) : new ByteArrayInputStream(JsonUtil.object2Json(validationData).getBytes()));
+
+ ZusammenElement candidateElement =
+ buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.IGNORE);
+ candidateElement.addSubElement(validationDataElement);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+ zusammenAdaptor.saveElement(context, elementContext, candidateElement,
+ "Update Orchestration Template Candidate validation data");
+ logger.info("Finished updating validation data of orchestration template candidate for VSP "
+ + "id -> " + vspId);
+ }
@Override
public void updateStructure(String vspId, Version version, FilesDataStructure fileDataStructure) {
@@ -166,40 +262,24 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
@Override
public Optional<String> getStructure(String vspId, Version version) {
- logger
- .info("Getting orchestration template structure for VendorSoftwareProduct id -> " + vspId);
+ logger.info("Getting orchestration template candidate structure for VendorSoftwareProduct id "
+ + "-> " + vspId);
SessionContext context = createSessionContext();
ElementContext elementContext = new ElementContext(vspId, version.getId());
- logger.info(
- "Finished getting orchestration template structure for VendorSoftwareProduct id -> " +
- vspId);
Optional<Element> element = zusammenAdaptor.getElementByName(context, elementContext, null,
ElementType.OrchestrationTemplateCandidate.name());
- if (element.isPresent()) {
- if (hasEmptyData(element.get().getData())) {
- return Optional.empty();
- }
+
+ if (element.isPresent() && !VspZusammenUtil.isEmpty(element.get().getData())) {
return Optional.of(new String(FileUtils.toByteArray(element.get().getData())));
- } else {
- return Optional.empty();
}
- }
- private boolean hasEmptyData(InputStream elementData) {
- String emptyData = "{}";
- byte[] byteElementData;
- try {
- byteElementData = IOUtils.toByteArray(elementData);
- } catch (IOException ex) {
- ex.printStackTrace();
- return false;
- }
- if (Arrays.equals(emptyData.getBytes(), byteElementData)) {
- return true;
- }
- return false;
+ logger.info(
+ "Finished getting orchestration template candidate structure for VendorSoftwareProduct "
+ + "id -> " + vspId);
+
+ return Optional.empty();
}
public enum InfoPropertyName {
@@ -209,7 +289,7 @@ public class OrchestrationTemplateCandidateDaoZusammenImpl
private String val;
InfoPropertyName(String val){
- this.val=val;
+ this.val = val;
}
public String getVal() {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
index d5e09ac298..3b3cdfead3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/OrchestrationTemplateDaoZusammenImpl.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
@@ -7,18 +23,16 @@ import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.utils.fileutils.FileUtils;
-import org.apache.commons.io.IOUtils;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
import java.nio.ByteBuffer;
-import java.util.Arrays;
import java.util.Optional;
import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
@@ -26,6 +40,8 @@ import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTemplateDao {
+ private static final Logger LOGGER = LoggerFactory.getLogger
+ (OrchestrationTemplateDaoZusammenImpl.class);
private ZusammenAdaptor zusammenAdaptor;
public OrchestrationTemplateDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
@@ -67,7 +83,7 @@ public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTempla
.setFileSuffix(element.get().getInfo().getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
orchestrationTemplate
.setFileName(element.get().getInfo().getProperty(InfoPropertyName.FILE_NAME.getVal()));
- if (!hasEmptyData(element.get().getData())) {
+ if (!VspZusammenUtil.hasEmptyData(element.get().getData())) {
orchestrationTemplate
.setValidationData(new String(FileUtils.toByteArray(element.get().getData())));
}
@@ -94,7 +110,7 @@ public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTempla
return orchestrationTemplate;
}
- if (!hasEmptyData(orchestrationTemplateElement.get().getData())) {
+ if (!VspZusammenUtil.hasEmptyData(orchestrationTemplateElement.get().getData())) {
orchestrationTemplate.setContentData(
ByteBuffer.wrap(FileUtils.toByteArray(orchestrationTemplateElement.get().getData())));
}
@@ -108,7 +124,7 @@ public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTempla
.getProperty(InfoPropertyName.FILE_SUFFIX.getVal()));
orchestrationTemplate.setFileName(validationDataElement.get().getInfo()
.getProperty(InfoPropertyName.FILE_NAME.getVal()));
- if (!hasEmptyData(validationDataElement.get().getData())) {
+ if (!VspZusammenUtil.hasEmptyData(validationDataElement.get().getData())) {
orchestrationTemplate.setValidationData(
new String(FileUtils.toByteArray(validationDataElement.get().getData())));
}
@@ -130,32 +146,55 @@ public class OrchestrationTemplateDaoZusammenImpl implements OrchestrationTempla
.addProperty(InfoPropertyName.FILE_SUFFIX.getVal(), orchestrationTemplate.getFileSuffix());
validationData.getInfo()
.addProperty(InfoPropertyName.FILE_NAME.getVal(), orchestrationTemplate.getFileName());
-
+ ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType
+ .OrchestrationTemplateStructure, Action.UPDATE);
+ orchestrationTemplateStructure
+ .setData(new ByteArrayInputStream(orchestrationTemplate.getFilesDataStructure()
+ .getBytes()));
ZusammenElement orchestrationTemplateElement =
buildStructuralElement(ElementType.OrchestrationTemplate, Action.UPDATE);
orchestrationTemplateElement
.setData(new ByteArrayInputStream(orchestrationTemplate.getContentData().array()));
orchestrationTemplateElement.addSubElement(validationData);
-
+ orchestrationTemplateElement.addSubElement(orchestrationTemplateStructure);
ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
vspModel.addSubElement(orchestrationTemplateElement);
zusammenAdaptor.saveElement(context, elementContext, vspModel, "Update Orchestration Template");
}
- private boolean hasEmptyData(InputStream elementData) {
- String emptyData = "{}";
- byte[] byteElementData;
- try {
- byteElementData = IOUtils.toByteArray(elementData);
- } catch (IOException ex) {
- ex.printStackTrace();
- return false;
+ @Override
+ public Optional<String> getOrchestrationTemplateStructure(String vspId, Version version) {
+ LOGGER.info("Getting orchestration template structure for VendorSoftwareProduct id" +
+ " " + "-> " + vspId);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(vspId, version.getId());
+
+ Optional<ElementInfo> vspModel = zusammenAdaptor.getElementInfoByName(context, elementContext,
+ null, ElementType.VspModel.name());
+ if (!vspModel.isPresent()) {
+ return Optional.empty();
}
- if (Arrays.equals(emptyData.getBytes(), byteElementData)) {
- return true;
+ Optional<Element> orchestrationTemplateElement = zusammenAdaptor.getElementByName(context,
+ elementContext, vspModel.get().getId(), ElementType.OrchestrationTemplate.name());
+ if (!orchestrationTemplateElement.isPresent()) {
+ return Optional.empty();
}
- return false;
+
+ Optional<Element> orchestrationTemplateStructureElement = zusammenAdaptor
+ .getElementByName(context, elementContext,
+ orchestrationTemplateElement.get().getElementId(),
+ ElementType.OrchestrationTemplateStructure.name());
+ if (orchestrationTemplateStructureElement.isPresent() &&
+ !VspZusammenUtil.isEmpty(orchestrationTemplateStructureElement.get().getData())) {
+ return Optional.of(new String(
+ FileUtils.toByteArray(orchestrationTemplateStructureElement.get().getData())));
+ }
+ LOGGER.info("Finished getting orchestration template structure for VendorSoftwareProduct " +
+ "id -> " + vspId);
+
+ return Optional.empty();
}
private enum InfoPropertyName {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
index c6909d8d07..8d9a8eed93 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
@@ -84,12 +99,13 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
ZusammenElement candidateContentElement =
buildStructuralElement(ElementType.OrchestrationTemplateCandidateContent, Action.CREATE);
candidateContentElement.setData(emptyData);
-
+ ZusammenElement validationData = buildStructuralElement(ElementType
+ .OrchestrationTemplateCandidateValidationData, Action.CREATE);
ZusammenElement candidateElement =
buildStructuralElement(ElementType.OrchestrationTemplateCandidate, Action.CREATE);
candidateElement.setData(emptyData);
candidateElement.addSubElement(candidateContentElement);
-
+ candidateElement.addSubElement(validationData);
zusammenAdaptor.saveElement(context, elementContext, candidateElement,
"Create Orchestration Template Candidate Elements");
}
@@ -119,10 +135,15 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
buildStructuralElement(ElementType.OrchestrationTemplateValidationData, Action.CREATE);
validationData.setData(emptyData);
+ ZusammenElement orchestrationTemplateStructure = buildStructuralElement(ElementType
+ .OrchestrationTemplateStructure, Action.CREATE);
+ validationData.setData(emptyData);
+
ZusammenElement orchestrationTemplate =
buildStructuralElement(ElementType.OrchestrationTemplate, Action.CREATE);
orchestrationTemplate.setData(emptyData);
orchestrationTemplate.addSubElement(validationData);
+ orchestrationTemplate.addSubElement(orchestrationTemplateStructure);
return orchestrationTemplate;
}
@@ -199,7 +220,7 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
public boolean isManual(String vspId, Version version) {
final VspDetails vspDetails = get(new VspDetails(vspId, version));
if (vspDetails != null && "Manual".equals(vspDetails.getOnboardingMethod())) {
- return true;
+ return true;
}
return false;
}
@@ -248,6 +269,7 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP
ON_BOARDING_METHOD("onboardingMethod");
private String value;
+
InfoPropertyName(String value){
this.value=value;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java
index b3acaf5421..09fd948030 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VspZusammenUtil.java
@@ -1,7 +1,12 @@
package org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.ArrayUtils;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
import java.util.Objects;
class VspZusammenUtil {
@@ -24,4 +29,31 @@ class VspZusammenUtil {
return head;
}
+
+ static boolean isEmpty(InputStream elementData) {
+ byte[] byteElementData;
+ if (Objects.isNull(elementData)) {
+ return true;
+ }
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException e) {
+ return false;
+ }
+ return ArrayUtils.isEmpty(byteElementData);
+ }
+
+ static boolean hasEmptyData(InputStream elementData) {
+ String EMPTY_DATA = "{}";
+ byte[] byteElementData;
+ try {
+ byteElementData = IOUtils.toByteArray(elementData);
+ } catch (IOException ex) {
+ return false;
+ }
+ if (Arrays.equals(EMPTY_DATA.getBytes(), byteElementData)) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
index 78723ae0d2..18910e3507 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
@@ -1,21 +1,17 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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.impl.filedatastructuremodule;
@@ -35,6 +31,7 @@ import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.heat.datatypes.structure.Artifact;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
+import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
@@ -136,12 +133,11 @@ public class CandidateServiceImpl implements CandidateService {
analyzedZipHeatFiles);
handleOtherResources(tree, usedEnvFiles, structure);
FilesDataStructure fileDataStructureFromManifest =
- createFileDataStructureFromManifest(zipContentMap.getFileContent
- (SdcCommon.MANIFEST_NAME));
+ createFileDataStructureFromManifest(zipContentMap.getFileContent(SdcCommon.MANIFEST_NAME));
List<String> structureArtifacts = structure.getArtifacts();
structureArtifacts.addAll(fileDataStructureFromManifest.getArtifacts().stream().filter
(artifact -> isNotStrctureArtifact(structureArtifacts, artifact))
- .collect((Collectors.toList())));
+ .collect(Collectors.toList()));
handleArtifactsFromTree(tree, structure);
return JsonUtil.object2Json(structure);
@@ -167,9 +163,9 @@ public class CandidateServiceImpl implements CandidateService {
zipContentMap, analyzedZipHeatFiles);
Set<String> filesDataStructureFiles = getFlatFileNames(filesDataStructure);
filesDataStructure.getUnassigned().addAll(zipFileList.stream()
- .filter(fileName -> (!filesDataStructureFiles.contains(fileName) &&
- !filesDataStructure.getNested().contains(fileName) &&
- !fileName.equals(SdcCommon.MANIFEST_NAME)))
+ .filter(fileName -> (!filesDataStructureFiles.contains(fileName)
+ && !filesDataStructure.getNested().contains(fileName)
+ && !fileName.equals(SdcCommon.MANIFEST_NAME)))
.collect(Collectors.toList()));
dataStructureJson = JsonUtil.object2Json(filesDataStructure);
} else {
@@ -290,8 +286,7 @@ public class CandidateServiceImpl implements CandidateService {
for (FileData fileData : data) {
if (fileData.getType().equals(FileData.Type.HEAT_ENV)) {
module.setEnv(fileData.getFile());
- } else if (fileData.getType().equals(FileData.Type.HEAT_VOL))// must be volume
- {
+ } else if (fileData.getType().equals(FileData.Type.HEAT_VOL)) { // must be volume
module.setVol(fileData.getFile());
if (!CollectionUtils.isEmpty(fileData.getData())) {
FileData volEnv = fileData.getData().get(0);
@@ -432,6 +427,17 @@ public class CandidateServiceImpl implements CandidateService {
return candidateServiceValidator.validateFileDataStructure(filesDataStructure);
}
+ @Override
+ public void deleteOrchestrationTemplateCandidate(String vspId, Version versionId) {
+ orchestrationTemplateCandidateDao.delete(vspId, versionId);
+ }
+
+ @Override
+ public void updateValidationData(String vspId, Version version, ValidationStructureList
+ validationData) {
+ orchestrationTemplateCandidateDao.updateValidationData(vspId, version, validationData);
+ }
+
private void writeManifest(String manifest,
OnboardingTypesEnum type,
ZipOutputStream zos) throws IOException {