summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2018-05-27 14:47:32 +0300
committertalig <talig@amdocs.com>2018-05-27 14:47:32 +0300
commitfa2c7f888495ed0969ce9178b9f770ac088a5f07 (patch)
treef3b28e1bd6bbff6b5fc1ffb3ea4c4bda40788136 /openecomp-be/api
parentc42dd9b1b5659244d6306899cecd346dedfd32e1 (diff)
Refactor candidate heat dao
As a result OrchestrationTemplateCandidate element will be added if not exists instead of failing. Change-Id: I1a1c9afed65018ed01be65ff07dabe1c2081bea7 Issue-ID: SDC-1371 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-be/api')
-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.java85
1 files changed, 45 insertions, 40 deletions
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 03f36978cf..71e188851e 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
@@ -16,29 +16,6 @@
package org.openecomp.sdcrests.vsp.rest.services;
-import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION;
-import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME;
-import static org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod.NetworkPackage;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID;
-import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import javax.inject.Named;
-import javax.ws.rs.core.Response;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.dao.UniqueValueDaoFactory;
import org.openecomp.core.util.UniqueValueUtil;
@@ -109,6 +86,30 @@ 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;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION;
+import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME;
+import static org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod.NetworkPackage;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID;
+import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME;
+
@Named
@Service("vendorSoftwareProducts")
@Scope(value = "prototype")
@@ -565,25 +566,29 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
.build();
}
- private void addNetworkPackageInfo(String vspId, Version version, VspDetailsDto vspDetailsDto) {
- OrchestrationTemplateCandidateData candidateInfo =
- OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface()
- .getInfo(vspId, version);
- 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) && Objects.nonNull(orchestrationTemplateInfo
- .getFileSuffix())) {
- vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure());
- vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName());
- vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix());
- }
+ private void addNetworkPackageInfo(String vspId, Version version, VspDetailsDto vspDetailsDto) {
+ Optional<OrchestrationTemplateCandidateData> candidateInfo =
+ OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface()
+ .getInfo(vspId, version);
+ if (candidateInfo.isPresent()) {
+ if (candidateInfo.get().getValidationDataStructure() != null) {
+ vspDetailsDto.setValidationData(candidateInfo.get().getValidationDataStructure());
+ }
+ vspDetailsDto.setNetworkPackageName(candidateInfo.get().getFileName());
+ vspDetailsDto.setCandidateOnboardingOrigin(candidateInfo.get().getFileSuffix());
+ } else {
+ OrchestrationTemplateEntity orchestrationTemplateInfo =
+ vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version);
+ if (Objects.nonNull(orchestrationTemplateInfo) && Objects.nonNull(orchestrationTemplateInfo
+ .getFileSuffix())) {
+ if (orchestrationTemplateInfo.getValidationDataStructure() != null) {
+ vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure());
}
+ vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName());
+ vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix());
+ }
}
+ }
private boolean userHasPermission(String itemId, String userId) {
return permissionsManager.getUserItemPermission(itemId, userId)