summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-08-30 12:28:05 +0100
committerAndr� Schmid <andre.schmid@est.tech>2021-09-02 10:57:18 +0000
commita7b1f9beb7db0c03915b4a69f9a4ddff6dd7c414 (patch)
treefdf5ed22fc31f3a374f20d9d2b76f2744f53f840 /catalog-be/src/main
parent20d9463537de3840dcb47bc549168f77f64fbe36 (diff)
Fix mismatch in requirement name in sub mapping
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3701 Change-Id: I0898d8b16c6e5cda035f33024f26644d7c6b1ef5
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java4
2 files changed, 12 insertions, 4 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java
index 8cc5868341..bf42af8322 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CapabilityRequirementConverter.java
@@ -322,7 +322,7 @@ public class CapabilityRequirementConverter {
(StringUtils.isEmpty(r.getExternalName()) ?
addEntry(componentsCache, toscaRequirements, component, new SubstitutionEntry(r.getName(), r.getParentName(), ""),
r.getPreviousName(), r.getOwnerId(), r.getPath()):
- addEntry(componentsCache, toscaRequirements, component, new SubstitutionEntry(r.getExternalName(), r.getName(), ""),
+ addEntry(componentsCache, toscaRequirements, component, new SubstitutionEntry(r.getExternalName(), r.getPreviousName() == null ? r.getName(): r.getPreviousName(), ""),
r.getPreviousName(), r.getOwnerId(), r.getPath(), false))
).findAny();
}
@@ -667,7 +667,15 @@ public class CapabilityRequirementConverter {
* @return
*/
public Either<String, Boolean> buildSubstitutedName(Map<String, Component> componentsCache, Component originComponent, List<String> path,
- String name, String previousName) {
+ String name, String previousName) {
+ return buildSubstitutedName(componentsCache, originComponent, path, name, previousName, null);
+ }
+
+ public Either<String, Boolean> buildSubstitutedName(Map<String, Component> componentsCache, Component originComponent, List<String> path,
+ String name, String previousName, String externalName) {
+ if (StringUtils.isNotEmpty(externalName)) {
+ return Either.left(externalName);
+ }
if (StringUtils.isNotEmpty(previousName)) {
return Either.left(name);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 1b27857869..6a1ba4ef63 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -1379,7 +1379,7 @@ public class ToscaExportHandler {
}
final RelationshipInfo relationshipInfo = capabilityRequirementRelationship.getRelation();
final Either<String, Boolean> capabilityNameEither = capabilityRequirementConverter.buildSubstitutedName(componentCache,
- toOriginComponent, reducedPath, relationshipInfo.getCapability(), capability.getPreviousName());
+ toOriginComponent, reducedPath, relationshipInfo.getCapability(), capability.getPreviousName(), capability.getExternalName());
if (capabilityNameEither.isRight()) {
final String errorMsg = String.format(
"Failed to build a substituted capability name for the capability with name %s on a component with uniqueId %s",
@@ -1390,7 +1390,7 @@ public class ToscaExportHandler {
}
final Either<String, Boolean> requirementNameEither = capabilityRequirementConverter
.buildSubstitutedName(componentCache, fromOriginComponent,
- requirement.getPath(), relationshipInfo.getRequirement(), requirement.getPreviousName());
+ requirement.getPath(), relationshipInfo.getRequirement(), requirement.getPreviousName(), requirement.getExternalName());
if (requirementNameEither.isRight()) {
final String errorMsg = String.format("Failed to build a substituted requirement name for the requirement "
+ "with name %s on a component with uniqueId %s",