summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java20
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java121
3 files changed, 88 insertions, 57 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
index 8fa8bd2088..ab0881268e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DeploymentFlavorErrorBuilder.java
@@ -35,6 +35,8 @@ public class DeploymentFlavorErrorBuilder {
+ ": name : must match %s";
private static final String INVALID_COMPUTE_FLAVOR_ID_MSG =
"Invalid request, Compute Flavor provided does not exist for this VFC.";
+ private static final String INVALID_COMPONENT_ID_MSG =
+ "Invalid request, Component provided does not exist for this VSP.";
private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG="VSP cannot be " +
"submitted with an invalid Deployment Flavor. All Deployment Flavor should have atleast a VFC included with it's required Compute needs. " +
"Please fix the Deployment Flavor %s and re-submit the VSP.";
@@ -55,8 +57,7 @@ public class DeploymentFlavorErrorBuilder {
return builder.build();
}
- public static ErrorCode getFeatureGroupNotexistErrorBuilder( String featureGroupId, String
- vspId, Version activeVersion){
+ public static ErrorCode getFeatureGroupNotexistErrorBuilder(){
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP);
builder.withCategory(ErrorCategory.APPLICATION);
@@ -89,13 +90,20 @@ public class DeploymentFlavorErrorBuilder {
builder.withMessage(String.format(DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG,name,vspId));
return builder.build();
}
- public static ErrorCode getInvalidComputeIdErrorBuilder(String computeFlavorId, String
- vfcId){
+
+ public static ErrorCode getInvalidComputeIdErrorBuilder() {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(INVALID_COMPUTE_FLAVOR_ID_MSG,computeFlavorId,
- vfcId));
+ builder.withMessage(INVALID_COMPUTE_FLAVOR_ID_MSG);
+ return builder.build();
+ }
+
+ public static ErrorCode getInvalidComponentIdErrorBuilder() {
+ ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+ builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_ID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(INVALID_COMPONENT_ID_MSG);
return builder.build();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
index 0eef5246c3..4c0d8de014 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerFactoryImpl.java
@@ -19,6 +19,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager;
import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
@@ -30,7 +31,8 @@ public class DeploymentFlavorManagerFactoryImpl extends DeploymentFlavorManagerF
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
DeploymentFlavorDaoFactory.getInstance().createInterface(),
CompositionEntityDataManagerFactory.getInstance().createInterface(),
- ComputeDaoFactory.getInstance().createInterface()
+ ComputeDaoFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface()
);
@Override
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
index 56678abfd5..cb5533a0a3 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
@@ -16,14 +16,23 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
@@ -40,26 +49,22 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTempl
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
private final VendorSoftwareProductInfoDao vspInfoDao;
private final DeploymentFlavorDao deploymentFlavorDao;
private final CompositionEntityDataManager compositionEntityDataManager;
private final ComputeDao computeDao;
+ private final ComponentDao componentDao;
public DeploymentFlavorManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
DeploymentFlavorDao deploymentFlavorDao,
CompositionEntityDataManager compositionEntityDataManager,
- ComputeDao computeDao) {
+ ComputeDao computeDao, ComponentDao componentDao) {
this.vspInfoDao = vspInfoDao;
this.deploymentFlavorDao = deploymentFlavorDao;
this.compositionEntityDataManager = compositionEntityDataManager;
this.computeDao = computeDao;
+ this.componentDao = componentDao;
}
@@ -72,8 +77,7 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
public DeploymentFlavorEntity createDeploymentFlavor(
DeploymentFlavorEntity deploymentFlavorEntity) {
DeploymentFlavorEntity createDeploymentFlavor;
- if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
- deploymentFlavorEntity.getVersion())) {
+ if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion())) {
ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
.getAddDeploymentNotSupportedHeatOnboardErrorBuilder();
throw new CoreException(deploymentFlavorErrorBuilder);
@@ -100,8 +104,7 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
if (featureGroup != null && featureGroup.trim().length() > 0
&& (isEmpty(featureGroups) || (!(validFeatureGroup(featureGroups, featureGroup))))) {
ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
- .getFeatureGroupNotexistErrorBuilder(featureGroup, deploymentFlavorEntity.getVspId(),
- version);
+ .getFeatureGroupNotexistErrorBuilder();
throw new CoreException(deploymentFlavorErrorBuilder);
}
validateComponentComputeAssociation(deploymentFlavorEntity, version);
@@ -145,47 +148,66 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
return valid;
}
- private void validateComponentComputeAssociation(DeploymentFlavorEntity deploymentFlavorEntity,
- Version version) {
- List<ComponentComputeAssociation> componentComputeAssociationList = deploymentFlavorEntity
- .getDeploymentFlavorCompositionData().getComponentComputeAssociations();
- List<String> vfcList = new ArrayList<>();
- if (!isEmpty(componentComputeAssociationList)) {
- componentComputeAssociationList.forEach(componentComputeAssociation ->
- validateComponentComputeAssocoationList(deploymentFlavorEntity,
- version, vfcList, componentComputeAssociation));
- Map<String, Integer> frequencyMapping = CollectionUtils.getCardinalityMap(vfcList);
-
- for (Integer vfcCount : frequencyMapping.values()) {
- if (vfcCount != 1) {
- ErrorCode duplicateVfcAssociationErrorBuilder = DeploymentFlavorErrorBuilder
- .getDuplicateVfcAssociationErrorBuilder();
- throw new CoreException(duplicateVfcAssociationErrorBuilder);
+ private void validateComponentComputeAssociation(DeploymentFlavorEntity deploymentFlavorEntity,
+ Version version) {
+ List<ComponentComputeAssociation> componentComputeAssociationList =
+ deploymentFlavorEntity.getDeploymentFlavorCompositionData().getComponentComputeAssociations();
+ List<String> vfcList = new ArrayList<>();
+ if (!isEmpty(componentComputeAssociationList)) {
+ componentComputeAssociationList.forEach(
+ componentComputeAssociation -> validateComponentComputeAssocoationList(deploymentFlavorEntity,
+ version,
+ vfcList, componentComputeAssociation));
+ Map<String, Integer> frequencyMapping = CollectionUtils.getCardinalityMap(vfcList);
+
+ for (Integer vfcCount : frequencyMapping.values()) {
+ if (vfcCount != 1) {
+ ErrorCode duplicateVfcAssociationErrorBuilder =
+ DeploymentFlavorErrorBuilder.getDuplicateVfcAssociationErrorBuilder();
+ throw new CoreException(duplicateVfcAssociationErrorBuilder);
+ }
+ }
}
- }
}
- }
- private void validateComponentComputeAssocoationList(
- DeploymentFlavorEntity deploymentFlavorEntity,
- Version version,
- List<String> vfcList,
- ComponentComputeAssociation componentComputeAssociation) {
- if ((componentComputeAssociation.getComponentId() == null || componentComputeAssociation
- .getComponentId().trim().length() == 0)
- && (componentComputeAssociation
- .getComputeFlavorId() != null && componentComputeAssociation
- .getComputeFlavorId().trim().length() > 0)) {
- ErrorCode invalidAssociationErrorBuilder = DeploymentFlavorErrorBuilder
- .getInvalidAssociationErrorBuilder();
- throw new CoreException(invalidAssociationErrorBuilder);
- } else if (componentComputeAssociation.getComponentId() != null
- && componentComputeAssociation.getComponentId().trim().length() > 0) {
- validateComponentComputeAssociationFlavour(deploymentFlavorEntity,
- version, componentComputeAssociation);
- vfcList.add(componentComputeAssociation.getComponentId());
+ private void validateComponentComputeAssocoationList(
+ DeploymentFlavorEntity deploymentFlavorEntity,
+ Version version,
+ List<String> vfcList,
+ ComponentComputeAssociation componentComputeAssociation) {
+ if ((componentComputeAssociation.getComponentId() == null || componentComputeAssociation
+ .getComponentId().trim().length() == 0)
+ && (componentComputeAssociation
+ .getComputeFlavorId() != null && componentComputeAssociation
+ .getComputeFlavorId().trim().length() > 0)) {
+ ErrorCode invalidAssociationErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidAssociationErrorBuilder();
+ throw new CoreException(invalidAssociationErrorBuilder);
+ } else if (componentComputeAssociation.getComponentId() != null
+ && componentComputeAssociation.getComponentId().trim().length() > 0) {
+ validateComponentAssociation(deploymentFlavorEntity,
+ version, componentComputeAssociation);
+
+ validateComponentComputeAssociationFlavour(deploymentFlavorEntity,
+ version, componentComputeAssociation);
+ vfcList.add(componentComputeAssociation.getComponentId());
+ }
+ }
+
+ private void validateComponentAssociation(DeploymentFlavorEntity deploymentFlavorEntity, Version version,
+ ComponentComputeAssociation componentComputeAssociation) {
+
+ if (StringUtils.isNotBlank(componentComputeAssociation.getComponentId())) {
+ ComponentEntity componentEntity =
+ componentDao.get(new ComponentEntity(deploymentFlavorEntity.getVspId(), version,
+ componentComputeAssociation.getComponentId()));
+ if (componentEntity == null) {
+ ErrorCode invalidComputeIdErrorBuilder =
+ DeploymentFlavorErrorBuilder.getInvalidComponentIdErrorBuilder();
+ throw new CoreException(invalidComputeIdErrorBuilder);
+ }
+ }
}
- }
private void validateComponentComputeAssociationFlavour(
DeploymentFlavorEntity deploymentFlavorEntity,
@@ -199,8 +221,7 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
componentComputeAssociation.getComputeFlavorId()));
if (computeFlavor == null) {
ErrorCode invalidComputeIdErrorBuilder = DeploymentFlavorErrorBuilder
- .getInvalidComputeIdErrorBuilder(componentComputeAssociation.getComputeFlavorId(),
- componentComputeAssociation.getComponentId());
+ .getInvalidComputeIdErrorBuilder();
throw new CoreException(invalidComputeIdErrorBuilder);
}
}