aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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.java73
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java72
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java2
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.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/VspMergeDao.java10
-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/VspMergeDaoImpl.java34
8 files changed, 114 insertions, 111 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 1c8114c2e8..be196bf326 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,28 +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.VendorSoftwareProductConstants.VALIDATION_VSP_NAME;
-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 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;
@@ -107,6 +85,29 @@ 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 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.VendorSoftwareProductConstants.VALIDATION_VSP_NAME;
+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")
@@ -120,7 +121,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
private static ItemCreationDto validationVsp;
- private final AsdcItemManager asdcItemManager = AsdcItemManagerFactory.getInstance()
+ private final AsdcItemManager itemManager = AsdcItemManagerFactory.getInstance()
.createInterface();
private final ItemPermissionsManager permissionsManager =
ItemPermissionsManagerFactory.getInstance().createInterface();
@@ -151,7 +152,8 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
itemCreationDto = getItemCreationDto(vspRequestDto, user, onboardingMethod);
} else {
- throwUnknownOnboardingMethodException(new IllegalArgumentException("Wrong parameter Onboarding Method"));
+ throwUnknownOnboardingMethodException(
+ new IllegalArgumentException("Wrong parameter Onboarding Method"));
}
return Response.ok(itemCreationDto).build();
@@ -167,7 +169,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
item.addProperty(VspItemProperty.ONBOARDING_METHOD, onboardingMethod.name());
uniqueValueUtil.validateUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, item.getName());
- item = asdcItemManager.create(item);
+ item = itemManager.create(item);
uniqueValueUtil.createUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, item.getName());
Version version = versioningManager.create(item.getId(), new Version(), null);
@@ -192,7 +194,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
private void throwUnknownOnboardingMethodException(IllegalArgumentException e) {
ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
.getInvalidOnboardingMethodErrorBuilder();
- throw new CoreException(onboardingMethodUpdateErrorCode,e);
+ throw new CoreException(onboardingMethodUpdateErrorCode, e);
}
@Override
@@ -213,7 +215,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
GenericCollectionWrapper<VspDetailsDto> results = new GenericCollectionWrapper<>();
MapItemToVspDetailsDto mapper = new MapItemToVspDetailsDto();
- asdcItemManager.list(itemPredicate).stream()
+ itemManager.list(itemPredicate).stream()
.sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime()))
.forEach(vspItem -> results.add(mapper.applyMapping(vspItem, VspDetailsDto.class)));
@@ -282,17 +284,19 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
@Override
public Response deleteVsp(String vspId, String user) {
- Item vsp = asdcItemManager.get(vspId);
+ Item vsp = itemManager.get(vspId);
- if(!vsp.getType().equals(ItemType.vsp.name())){
+ if (!vsp.getType().equals(ItemType.vsp.name())) {
throw new CoreException((new ErrorCode.ErrorCodeBuilder()
- .withMessage(String.format("Vsp with id %s does not exist.",
- vspId)).build()));
+ .withMessage(String.format("Vsp with id %s does not exist.",
+ vspId)).build()));
}
Integer certifiedVersionsCounter = vsp.getVersionStatusCounters().get(VersionStatus.Certified);
if (Objects.isNull(certifiedVersionsCounter) || certifiedVersionsCounter == 0) {
- asdcItemManager.delete(vsp);
+ versioningManager.list(vspId)
+ .forEach(version -> vendorSoftwareProductManager.deleteVsp(vspId, version));
+ itemManager.delete(vsp);
permissionsManager.deleteItemPermissions(vspId);
uniqueValueUtil.deleteUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, vsp.getName());
notifyUsers(vspId, vsp.getName(), null, "VSP was deleted", user,
@@ -352,7 +356,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
} catch (CoreException validationVspAlreadyExistException) {
// find validationVsp
- String validationVspId = asdcItemManager.list(item ->
+ String validationVspId = itemManager.list(item ->
ItemType.vsp.name().equals(item.getType()) && VALIDATION_VSP_NAME.equals(item.getName()))
.stream().findFirst().orElseThrow(() -> new IllegalStateException("Vsp with name %s "
+ "does not exist even though the name exists according to unique value util"))
@@ -510,7 +514,8 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts {
private void notifyUsers(String itemId, String itemName, Version version, String message,
String userName, NotificationEventTypes eventType) {
Map<String, Object> eventProperties = new HashMap<>();
- eventProperties.put(ITEM_NAME, itemName == null ? asdcItemManager.get(itemId).getName() : itemName);
+ eventProperties
+ .put(ITEM_NAME, itemName == null ? itemManager.get(itemId).getName() : itemName);
eventProperties.put(ITEM_ID, itemId);
if (version != null) {
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 7528110d37..423f9a51bb 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
@@ -41,7 +41,7 @@ public interface VendorSoftwareProductManager {
VspDetails getVsp(String vspId, Version version);
- void deleteVsp(String vspIdToDelete);
+ void deleteVsp(String vspId, Version version);
ValidationResponse validate(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/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index ad5717af25..ada88b8e1b 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
@@ -57,6 +57,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
@@ -125,6 +126,7 @@ import java.util.zip.ZipOutputStream;
public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager {
+ private final VspMergeDao vspMergeDao;
private final OrchestrationTemplateDao orchestrationTemplateDao;
private final OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager;
private final VendorSoftwareProductInfoDao vspInfoDao;
@@ -144,6 +146,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private final UniqueValueUtil uniqueValueUtil;
public VendorSoftwareProductManagerImpl(
+ VspMergeDao vspMergeDao,
OrchestrationTemplateDao orchestrationTemplateDataDao,
OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager,
VendorSoftwareProductInfoDao vspInfoDao,
@@ -161,6 +164,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
ImageDao imageDao,
ManualVspToscaManager manualVspToscaManager,
UniqueValueDao uniqueValueDao) {
+ this.vspMergeDao = vspMergeDao;
this.orchestrationTemplateDao = orchestrationTemplateDataDao;
this.orchestrationTemplateCandidateManager = orchestrationTemplateCandidateManager;
this.vspInfoDao = vspInfoDao;
@@ -210,8 +214,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
orchestrationTemplateDao.get(vspId, version);
ToscaServiceModel serviceModel =
serviceModelDao.getServiceModel(vspId, vspDetails.getVersion());
- if (!isOrchestrationTemplateExist(orchestrationTemplate)
- || !isServiceModelExist(serviceModel)) {
+ if (isOrchestrationTemplateMissing(orchestrationTemplate)
+ || isServiceModelMissing(serviceModel)) {
vspErrors.add(VendorSoftwareProductInvalidErrorBuilder
.vendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
vspDetails.getVersion()));
@@ -299,7 +303,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
.generateToscaModel(manualVspToscaManager.gatherVspInformation(vspId, version))
: serviceModelDao.getServiceModel(vspId, version);
- return compile(vspId, version, serviceModel);
+ return compile(vspId, version, serviceModel);
}
private boolean validateComponentDependencies(
@@ -320,28 +324,28 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
if (!CollectionUtils.isEmpty(deploymentFlavors)) {
deploymentFlavors.forEach(deploymentFlavor -> {
DeploymentFlavorEntity deployment = deploymentFlavorDao.get(deploymentFlavor);
- DeploymentFlavor deploymentlocalFlavor = deployment.getDeploymentFlavorCompositionData();
- if (deploymentlocalFlavor != null) {
- if (deploymentlocalFlavor.getFeatureGroupId() == null) {
+ DeploymentFlavor deploymentLocalFlavor = deployment.getDeploymentFlavorCompositionData();
+ if (deploymentLocalFlavor != null) {
+ if (deploymentLocalFlavor.getFeatureGroupId() == null) {
ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder.
- getFeatureGroupMandatoryErrorBuilder(deploymentlocalFlavor.getModel());
+ getFeatureGroupMandatoryErrorBuilder(deploymentLocalFlavor.getModel());
errorCodeList.add(deploymentFlavorErrorBuilder);
}
- validateComponetComputeAssociations(errorCodeList, deploymentFlavor,
- deployment, deploymentlocalFlavor);
+ validateComponentComputeAssociations(errorCodeList, deploymentFlavor,
+ deployment, deploymentLocalFlavor);
}
});
}
return errorCodeList;
}
- private void validateComponetComputeAssociations(Collection<ErrorCode> errorCodeList,
- DeploymentFlavorEntity deploymentFlavor,
- DeploymentFlavorEntity deployment,
- DeploymentFlavor deploymentlocalFlavor) {
- List<ComponentComputeAssociation> componetComputeAssociations =
+ private void validateComponentComputeAssociations(Collection<ErrorCode> errorCodeList,
+ DeploymentFlavorEntity deploymentFlavor,
+ DeploymentFlavorEntity deployment,
+ DeploymentFlavor deploymentlocalFlavor) {
+ List<ComponentComputeAssociation> componentComputeAssociations =
deploymentlocalFlavor.getComponentComputeAssociations();
- if (CollectionUtils.isEmpty(componetComputeAssociations)) {
+ if (CollectionUtils.isEmpty(componentComputeAssociations)) {
CompositionEntityValidationData compositionEntityValidationData = new
CompositionEntityValidationData(CompositionEntityType.deployment, deploymentFlavor
.getId());
@@ -353,10 +357,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
errorCodeList.add(deploymentFlavorErrorBuilder);
} else {
- componetComputeAssociations.forEach(componetComputeAssociation -> {
- if (componetComputeAssociation == null
- || !(componetComputeAssociation.getComponentId() != null
- && componetComputeAssociation.getComputeFlavorId() != null)) {
+ componentComputeAssociations.forEach(componentComputeAssociation -> {
+ if (componentComputeAssociation == null
+ || !(componentComputeAssociation.getComponentId() != null
+ && componentComputeAssociation.getComputeFlavorId() != null)) {
CompositionEntityValidationData compositionEntityValidationData = new
CompositionEntityValidationData(CompositionEntityType.deployment,
deploymentFlavor.getId());
@@ -473,7 +477,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version,
ToscaServiceModel serviceModel) {
- if (!isServiceModelExist(serviceModel)) {
+ if (isServiceModelMissing(serviceModel)) {
return null;
}
@@ -515,8 +519,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
VspDetails retrieved = vspInfoDao.get(vspDetails);
if (retrieved == null) {
throw new CoreException((new ErrorCode.ErrorCodeBuilder()
- .withMessage(String.format("Vsp with id %s and version %s does not exist.",
- vspDetails.getId(), vspDetails.getVersion().getId()))).build());
+ .withMessage(String.format("Vsp with id %s and version %s does not exist.",
+ vspDetails.getId(), vspDetails.getVersion().getId()))).build());
}
vspDetails.setOnboardingMethod(retrieved.getOnboardingMethod());
@@ -559,7 +563,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
public VspDetails getVsp(String vspId, Version version) {
- return getValidatedVsp(vspId, version);
+ return getValidatedVsp(vspId, version);
}
private VspDetails getValidatedVsp(String vspId, Version version) {
@@ -571,9 +575,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
- public void deleteVsp(String vspId) {
- throw new UnsupportedOperationException(
- VendorSoftwareProductConstants.UNSUPPORTED_OPERATION_ERROR);
+ public void deleteVsp(String vspId, Version version) {
+ vspMergeDao.deleteHint(vspId, version);
}
@Override
@@ -605,7 +608,6 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
-
public byte[] getOrchestrationTemplateFile(String vspId, Version version) {
OrchestrationTemplateEntity uploadData = orchestrationTemplateDao.get(vspId, version);
ByteBuffer contentData = uploadData.getContentData();
@@ -714,7 +716,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private Map<String, List<ErrorMessage>> validateOrchestrationTemplate(
OrchestrationTemplateEntity orchestrationTemplate) throws IOException {
- if (!isOrchestrationTemplateExist(orchestrationTemplate)) {
+ if (isOrchestrationTemplateMissing(orchestrationTemplate)) {
return null;
}
Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
@@ -826,15 +828,15 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return computeDao.listByVsp(vspId, version);
}
- private boolean isOrchestrationTemplateExist(OrchestrationTemplateEntity orchestrationTemplate) {
- return orchestrationTemplate != null
- && orchestrationTemplate.getContentData() != null
- && orchestrationTemplate.getFileSuffix() != null
- && orchestrationTemplate.getFileName() != null;
+ private boolean isOrchestrationTemplateMissing(OrchestrationTemplateEntity orchestrationTemplate) {
+ return orchestrationTemplate == null
+ || orchestrationTemplate.getContentData() == null
+ || orchestrationTemplate.getFileSuffix() == null
+ || orchestrationTemplate.getFileName() == null;
}
- private boolean isServiceModelExist(ToscaServiceModel serviceModel) {
- return serviceModel != null && serviceModel.getEntryDefinitionServiceTemplate() != null;
+ private boolean isServiceModelMissing(ToscaServiceModel serviceModel) {
+ return serviceModel == null || serviceModel.getEntryDefinitionServiceTemplate() == null;
}
}
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 177af3a8bc..da4328dd91 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
@@ -24,20 +24,13 @@ 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;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.*;
import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
public class VspManagerFactoryImpl extends VspManagerFactory {
private static final VendorSoftwareProductManager INSTANCE =
new VendorSoftwareProductManagerImpl(
+ VspMergeDaoFactory.getInstance().createInterface(),
OrchestrationTemplateDaoFactory.getInstance().createInterface(),
OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(),
VendorSoftwareProductInfoDaoFactory.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 71890bb9e8..6a195d72fb 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
@@ -324,7 +324,7 @@ public class OrchestrationUtil {
orchestrationTemplateDataDao.update(vspDetails.getId(), vspDetails.getVersion(), uploadData);
VspMergeDaoFactory.getInstance().createInterface()
- .updateVspModelId(vspDetails.getId(), vspDetails.getVersion());
+ .updateHint(vspDetails.getId(), vspDetails.getVersion());
}
public void saveServiceModel(String vspId, Version version,
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java
index f7d0bca392..8a5a53f98b 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java
@@ -14,14 +14,7 @@ import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
+import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -42,7 +35,7 @@ public class VspMergeHandler implements ItemMergeHandler {
.of(OrchestrationTemplateCandidateContent, OrchestrationTemplateValidationData)
.collect(Collectors.toSet());
private static final Map<ElementType, Set<ElementType>> ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES =
- new HashMap<>();
+ new EnumMap<>(ElementType.class);
static {
ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES.put(OrchestrationTemplateCandidate,
@@ -61,13 +54,13 @@ public class VspMergeHandler implements ItemMergeHandler {
@Override
public boolean isConflicted(String itemId, Version version) {
- return vspMergeDao.isVspModelConflicted(itemId, version);
+ return vspMergeDao.isConflicted(itemId, version);
}
@Override
public void finalizeMerge(String itemId, Version version) {
if (!conflictsDao.isConflicted(itemId, version)) {
- vspMergeDao.applyVspModelConflictResolution(itemId, version);
+ vspMergeDao.applyConflictResolution(itemId, version);
}
}
@@ -88,7 +81,7 @@ public class VspMergeHandler implements ItemMergeHandler {
}
}
- if (!vspModelConflicted && vspMergeDao.isVspModelConflicted(itemId, version)) {
+ if (!vspModelConflicted && vspMergeDao.isConflicted(itemId, version)) {
elementConflicts
.add(new ConflictInfo(VSP_MODEL_CONFLICT_ID, NetworkPackage, NetworkPackage.name()));
}
@@ -127,7 +120,7 @@ public class VspMergeHandler implements ItemMergeHandler {
public boolean resolveConflict(String itemId, Version version, String conflictId,
ConflictResolution resolution) {
if (VSP_MODEL_CONFLICT_ID.equals(conflictId)) {
- vspMergeDao.updateVspModelConflictResolution(itemId, version,
+ vspMergeDao.updateConflictResolution(itemId, version,
com.amdocs.zusammen.datatypes.item.Resolution.valueOf(resolution.getResolution().name()));
return true;
}
@@ -136,7 +129,7 @@ public class VspMergeHandler implements ItemMergeHandler {
throw getConflictNotExistException(itemId, version, conflictId);
}
if (conflict.getType() == VspModel) {
- vspMergeDao.updateVspModelConflictResolution(itemId, version,
+ vspMergeDao.updateConflictResolution(itemId, version,
com.amdocs.zusammen.datatypes.item.Resolution.valueOf(resolution.getResolution().name()));
conflictsDao.resolveConflict(itemId, version, conflictId, new ConflictResolution(
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/VspMergeDao.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/VspMergeDao.java
index c9525bfbd8..aefab60759 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/VspMergeDao.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/VspMergeDao.java
@@ -5,12 +5,14 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public interface VspMergeDao {
- boolean isVspModelConflicted(String vspId, Version version);
+ boolean isConflicted(String vspId, Version version);
- void updateVspModelId(String vspId, Version version);
+ void updateHint(String vspId, Version version);
+
+ void deleteHint(String vspId, Version version);
// TODO: 11/7/2017 change to sdc Resolution
- void updateVspModelConflictResolution(String vspId, Version version, Resolution resolution);
+ void updateConflictResolution(String vspId, Version version, Resolution resolution);
- void applyVspModelConflictResolution(String vspId, Version version);
+ void applyConflictResolution(String vspId, Version version);
}
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/VspMergeDaoImpl.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/VspMergeDaoImpl.java
index 2ccc47a651..3516263fbc 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/VspMergeDaoImpl.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/VspMergeDaoImpl.java
@@ -38,7 +38,7 @@ public class VspMergeDaoImpl implements VspMergeDao {
}
@Override
- public boolean isVspModelConflicted(String vspId, Version version) {
+ public boolean isConflicted(String vspId, Version version) {
SessionContext context = createSessionContext();
ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId()));
@@ -46,7 +46,7 @@ public class VspMergeDaoImpl implements VspMergeDao {
}
@Override
- public void updateVspModelId(String vspId, Version version) {
+ public void updateHint(String vspId, Version version) {
SessionContext context = createSessionContext();
ElementContext elementContext = new ElementContext(new Id(vspId), new Id(version.getId()));
@@ -60,13 +60,18 @@ public class VspMergeDaoImpl implements VspMergeDao {
}
@Override
- public void updateVspModelConflictResolution(String vspId, Version version,
- Resolution resolution) {
+ public void deleteHint(String vspId, Version version) {
+ accessor.delete(getUser(),vspId,version.getId());
+ }
+
+ @Override
+ public void updateConflictResolution(String vspId, Version version,
+ Resolution resolution) {
accessor.updateModelResolution(resolution, getUser(), vspId, version.getId());
}
@Override
- public void applyVspModelConflictResolution(String vspId, Version version) {
+ public void applyConflictResolution(String vspId, Version version) {
//called only when no conflicts
SessionContext context = createSessionContext();
@@ -83,7 +88,7 @@ public class VspMergeDaoImpl implements VspMergeDao {
}
String user = getUser();
- Row row = accessor.getModelMergeHint(user, vspId, version.getId()).one();
+ Row row = accessor.get(user, vspId, version.getId()).one();
if (row == null) {
throw new IllegalStateException(
"Vsp model id must exists if its conflict is being resolved");
@@ -99,7 +104,7 @@ public class VspMergeDaoImpl implements VspMergeDao {
String chosenModelId =
keepOnlyChosenVspModel(context, elementContext, vspModels, resolution, localModelId);
- accessor.updateModelMergeHint(chosenModelId, null, user, vspId, version.getId());
+ accessor.update(chosenModelId, null, user, vspId, version.getId());
}
private String keepOnlyChosenVspModel(SessionContext context, ElementContext elementContext,
@@ -130,7 +135,7 @@ public class VspMergeDaoImpl implements VspMergeDao {
}
private void updateVspModelId(String vspId, Version version, String vspModelId) {
- accessor.updateModelMergeHint(vspModelId, null, getUser(), vspId, version.getId());
+ accessor.update(vspModelId, null, getUser(), vspId, version.getId());
}
private String getUser() {
@@ -141,18 +146,21 @@ public class VspMergeDaoImpl implements VspMergeDao {
@Accessor
interface VspMergeHintAccessor {
+ @Query("SELECT model_id, model_resolution FROM vsp_merge_hint " +
+ "WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet get(String space, String itemId, String versionId);
+
@Query("UPDATE vsp_merge_hint SET model_id=?, model_resolution=? " +
"WHERE space=? AND item_id=? AND version_id=?")
- void updateModelMergeHint(String vspModelId, Resolution modelResolution, String space,
- String itemId, String versionId);
+ void update(String vspModelId, Resolution modelResolution, String space,
+ String itemId, String versionId);
@Query(
"UPDATE vsp_merge_hint SET model_resolution=? WHERE space=? AND item_id=? AND version_id=?")
void updateModelResolution(Resolution modelResolution, String space, String itemId,
String versionId);
- @Query("SELECT model_id, model_resolution FROM vsp_merge_hint " +
- "WHERE space=? AND item_id=? AND version_id=?")
- ResultSet getModelMergeHint(String space, String itemId, String versionId);
+ @Query("DELETE from vsp_merge_hint WHERE space=? AND item_id=? AND version_id=?")
+ void delete(String space, String itemId, String versionId);
}
}