summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java45
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java18
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/DuplicateResourceIdsInDifferentFilesErrorBuilder.java16
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java19
7 files changed, 51 insertions, 62 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
index b5ca183ab7..72a38bbb5d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.VFC_NODE_TYPE_PREFIX;
-
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.CoreException;
@@ -60,6 +58,8 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import static org.openecomp.sdc.tosca.datatypes.ToscaNodeType.COMPUTE_TYPE_PREFIX;
+
public class ComponentManagerImpl implements ComponentManager {
private static final MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private ComponentDao componentDao;
@@ -154,9 +154,8 @@ public class ComponentManagerImpl implements ComponentManager {
}
private void updateComponentName(ComponentEntity component) {
- final String NAME_PREFIX = VFC_NODE_TYPE_PREFIX + "heat.";
ComponentData data = component.getComponentCompositionData();
- data.setName(NAME_PREFIX + data.getDisplayName());
+ data.setName(COMPUTE_TYPE_PREFIX + data.getDisplayName());
component.setComponentCompositionData(data);
}
@@ -209,21 +208,23 @@ public class ComponentManagerImpl implements ComponentManager {
ComponentEntity retrieved =
getComponent(component.getVspId(), component.getVersion(), component.getId());
- if (vspInfoDao.isManual(component.getVspId(), component.getVersion())) {
+ boolean isManual = vspInfoDao.isManual(component.getVspId(), component.getVersion());
+ if (isManual) {
validateComponentUpdateManual(component, retrieved, user);
}
ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
- schemaInput.setManual(vspInfoDao.isManual(component.getVspId(), component.getVersion()));
+ schemaInput.setManual(isManual);
schemaInput.setComponent(retrieved.getComponentCompositionData());
CompositionEntityValidationData validationData = compositionEntityDataManager
.validateEntity(component, SchemaTemplateContext.composition, schemaInput);
if (CollectionUtils.isEmpty(validationData.getErrors())) {
- updateComponentName(component);
+ if (isManual) {
+ updateComponentName(component);
+ }
componentDao.update(component);
- //componentDao.updateVspLatestModificationTime(component.getVspId(), component.getVersion());
}
mdcDataDebugMessage.debugExitMessage("VSP id, component id", component.getVspId(),
component.getId());
@@ -233,28 +234,8 @@ public class ComponentManagerImpl implements ComponentManager {
private void validateComponentUpdateManual(ComponentEntity component, ComponentEntity
retrieved, String user) {
- Collection<ComponentEntity> vspComponentList = listComponents(component.getVspId()
- , component.getVersion(), user);
- //Removing check from name as we will ignore passed value
- // and re-genarate new name from displayName
- // List<String> invalidParameters = new LinkedList<>();
- // if (!component.getComponentCompositionData().getName().equals(retrieved
- // .getComponentCompositionData().getName())) {
- // invalidParameters.add(NAME);
- // }
- // if (!invalidParameters.isEmpty()) {
- // String msg = String.format(VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED_MSG, StringUtils
- // .join(invalidParameters, ", "));
- // MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- // LoggerTragetServiceName.UPDATE_COMPONENT, ErrorLevel.ERROR.name(),
- // LoggerErrorCode.DATA_ERROR.getErrorCode(), msg);
- //
- // throw new CoreException(
- // new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
- // .withId(VendorSoftwareProductErrorCodes.VFC_ATTRIBUTE_UPDATE_NOT_ALLOWED)
- // .withMessage(msg).build());
- // }
-
+ Collection<ComponentEntity> vspComponentList =
+ listComponents(component.getVspId(), component.getVersion(), user);
//VFC name should be unique within VSP
//Removing VFC with same ID from list to avoid self compare
for(ComponentEntity ce : vspComponentList) {
@@ -265,8 +246,6 @@ public class ComponentManagerImpl implements ComponentManager {
}
if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData()
.getDisplayName())) {
- final String VSP_VFC_DUPLICATE_NAME_MSG = "VFC with specified name "
- + "already present in given VSP.";
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPDATE_COMPONENT, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Component with same name already " +
@@ -274,7 +253,7 @@ public class ComponentManagerImpl implements ComponentManager {
throw new CoreException(
new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION)
.withId(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME)
- .withMessage(VSP_VFC_DUPLICATE_NAME_MSG).build());
+ .withMessage("VFC with specified name already present in given VSP.").build());
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
index a0034a3828..ddbcaf72b9 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/TranslationContext.java
@@ -25,14 +25,12 @@ import org.openecomp.config.api.ConfigurationManager;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.configuration.ImplementationConfiguration;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestFile;
import org.openecomp.sdc.heat.datatypes.model.Resource;
import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
-import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.translator.datatypes.heattotosca.to.TranslatedHeatResource;
@@ -42,6 +40,7 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida
import org.openecomp.sdc.translator.services.heattotosca.ConfigConstants;
import org.openecomp.sdc.translator.services.heattotosca.Constants;
import org.openecomp.sdc.translator.services.heattotosca.NameExtractor;
+import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
import org.openecomp.sdc.translator.services.heattotosca.globaltypes.GlobalTypesGenerator;
import java.io.InputStream;
@@ -385,10 +384,7 @@ public class TranslationContext {
}
if(nodeAbstractNodeTemplateIdMap.containsKey(originalNodeTemplateId)){
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + originalNodeTemplateId + " occures more than once in different addOn files")
- .build());
+ throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(originalNodeTemplateId).build());
}
nodeAbstractNodeTemplateIdMap.put(originalNodeTemplateId, abstractNodeTemplateId);
this.getUnifiedSubstitutionData().get(serviceTemplateFileName).setNodesRelatedAbstractNode(
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
index b86038d175..5d1bb1c61e 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationDataUtil.java
@@ -31,6 +31,7 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.PortTemplateConsolidationData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.RequirementAssignmentData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.TypeComputeConsolidationData;
+import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
import java.util.ArrayList;
import java.util.Collection;
@@ -154,10 +155,7 @@ public class ConsolidationDataUtil {
if(isNestedResourceIdOccuresInDifferentNestedFiles(context, nestedHeatFileName,
nestedNodeTemplateId)){
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + nestedNodeTemplateId + " occures more than once in different addOn "
- + "files").build());
+ throw new CoreException(new DuplicateResourceIdsInDifferentFilesErrorBuilder(nestedNodeTemplateId).build());
}
ConsolidationData consolidationData = context.getConsolidationData();
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java
index 16a6301968..d3f2a721c9 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/ConsolidationService.java
@@ -24,6 +24,7 @@ import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolida
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.PortTemplateConsolidationData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.RequirementAssignmentData;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.TypeComputeConsolidationData;
+import org.openecomp.sdc.translator.services.heattotosca.errors.DuplicateResourceIdsInDifferentFilesErrorBuilder;
import java.util.ArrayList;
import java.util.Collection;
@@ -637,20 +638,16 @@ public class ConsolidationService {
NodeTemplate startingPortNodeTemplate = nodeTemplates.get(portNodeTemplateIdList.get(0));
if (Objects.isNull(startingPortNodeTemplate)) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + portNodeTemplateIdList.get(0) + " occures more than once in different addOn files")
- .build());
+ throw new CoreException(
+ new DuplicateResourceIdsInDifferentFilesErrorBuilder(portNodeTemplateIdList.get(0)).build());
}
for (int i = 1; i < portNodeTemplateIdList.size(); i++) {
NodeTemplate portNodeTemplate = nodeTemplates.get(portNodeTemplateIdList.get(i));
if (Objects.isNull(portNodeTemplate)) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + portNodeTemplateIdList.get(i) + " occures more than once in different addOn "
- + "files").build());
+ throw new CoreException(
+ new DuplicateResourceIdsInDifferentFilesErrorBuilder(portNodeTemplateIdList.get(i)).build());
}
if (!isPropertySimilarBetweenNodeTemplates(propertyToCheck, portNodeTemplateIdList, nodeTemplates)) {
@@ -695,9 +692,8 @@ public class ConsolidationService {
for (int i = 1; i < entityNodeTemplateIds.size(); i++) {
NodeTemplate currentNodeTemplate = idToNodeTemplate.get(entityNodeTemplateIds.get(i));
if (Objects.isNull(currentNodeTemplate)) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage("Resource with id "
- + entityNodeTemplateIds.get(i) + " occures more than once in different addOn files").build());
+ throw new CoreException(
+ new DuplicateResourceIdsInDifferentFilesErrorBuilder(entityNodeTemplateIds.get(i)).build());
}
if(propertyExistCondition != isPropertyExistInNodeTemplate(propertyToCheck, currentNodeTemplate)){
return false;
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/DuplicateResourceIdsInDifferentFilesErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/DuplicateResourceIdsInDifferentFilesErrorBuilder.java
new file mode 100644
index 0000000000..a75e8b391d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/DuplicateResourceIdsInDifferentFilesErrorBuilder.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.translator.services.heattotosca.errors;
+
+import org.openecomp.sdc.common.errors.BaseErrorBuilder;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+
+public final class DuplicateResourceIdsInDifferentFilesErrorBuilder extends BaseErrorBuilder {
+
+ private static final String DUPLICATE_RESOURCE_ID_MSG = "Resource with id %s occurs more than once in " +
+ "different addOn files";
+
+ public DuplicateResourceIdsInDifferentFilesErrorBuilder(String resourceId) {
+ getErrorCodeBuilder().withId(TranslatorErrorCodes.DUPLICATE_RESOURCE_ID_IN_DIFFERENT_FILES)
+ .withCategory(ErrorCategory.APPLICATION)
+ .withMessage(String.format(DUPLICATE_RESOURCE_ID_MSG, resourceId));
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java
index bfcf834ae1..5afb1ae3c2 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/errors/TranslatorErrorCodes.java
@@ -29,4 +29,5 @@ public class TranslatorErrorCodes {
"REFERENCE_TO_UNSUPPORTED_RESOURCE";
public static final String NOT_IN_SYNC_NUMBER_OF_INTERFACES = "NOT_IN_SYNC_NUMBER_OF_INTERFACES";
public static final String INVALID_PROPERTY_VALUE = "INVALID_PROPERTY_VALUE";
+ public static final String DUPLICATE_RESOURCE_ID_IN_DIFFERENT_FILES = "DUPLICATE_RESOURCE_ID_IN_DIFFERENT_FILES";
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java
index b1946b3f9b..9399b91ce1 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/test/java/org/openecomp/sdc/translator/services/heattotosca/impl/fulltest/UnifiedCompositionMixPatternFullTest.java
@@ -2,7 +2,10 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.fulltest;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation.BaseFullTranslationTest;
@@ -19,6 +22,9 @@ public class UnifiedCompositionMixPatternFullTest extends BaseFullTranslationTes
// do not delete this function. it prevents the superclass setup from running
}
+ @Rule
+ public ExpectedException exception = ExpectedException.none();
+
@Test
public void testMixPatterns() throws IOException {
inputFilesPath =
@@ -52,16 +58,13 @@ public class UnifiedCompositionMixPatternFullTest extends BaseFullTranslationTes
@Test
public void testDuplicateResourceIdsInDiffAddOnFiles() throws IOException {
+ exception.expect(CoreException.class);
+ exception.expectMessage("Resource with id lb_0_int_oam_int_0_port occurs more " +
+ "than once in different addOn files");
+
inputFilesPath =
"/mock/services/heattotosca/fulltest/mixPatterns/duplicateResourceIdsInDiffAddOnFiles/in";
-
- try {
- testTranslationWithInit();
- }catch(Exception e){
- log.debug("",e);
- Assert.assertEquals(e.getMessage(), "Resource with id lb_0_int_oam_int_0_port occures more " +
- "than once in different addOn files");
- }
+ testTranslationWithInit();
}
@Test