summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src')
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java21
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java4
2 files changed, 17 insertions, 8 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java
index 78a23f43ea..46a5904299 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaSolConverterImpl.java
@@ -55,19 +55,21 @@ public class ToscaSolConverterImpl extends AbstractToscaConverter {
Map<String, ServiceTemplate> serviceTemplates = new HashMap<>();
FileContentHandler artifacts = new FileContentHandler();
GlobalSubstitutionServiceTemplate gsst = new GlobalSubstitutionServiceTemplate();
- String mServiceDefinitionFileName = getMainServiceDefinitionFileName(fileContentHandler);
- handleMainServiceTemplate(csarFiles, serviceTemplates, gsst, mServiceDefinitionFileName);
+ String mServiceDefinitionPath = getMainServiceDefinitionFileName(fileContentHandler);
+ handleMainServiceTemplate(csarFiles, serviceTemplates, gsst, mServiceDefinitionPath);
handleExternalArtifacts(csarFiles, serviceTemplates, artifacts);
handleMetadataFile(csarFiles);
- updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, mServiceDefinitionFileName);
+ updateToscaServiceModel(toscaServiceModel, serviceTemplates, artifacts, gsst, csarFiles, getSimpleName(mServiceDefinitionPath));
return toscaServiceModel;
}
private void handleMainServiceTemplate(Map<String, byte[]> csarFiles, Map<String, ServiceTemplate> serviceTemplates,
GlobalSubstitutionServiceTemplate gsst, String mServiceDefinitionFileName) {
- handleServiceTemplate(mServiceDefinitionFileName, mServiceDefinitionFileName, csarFiles, serviceTemplates);
- handleImportDefinitions(mServiceDefinitionFileName, csarFiles, mServiceDefinitionFileName.substring(0,
- mServiceDefinitionFileName.lastIndexOf("/")), gsst);
+ if(mServiceDefinitionFileName != null){
+ handleServiceTemplate(getSimpleName(mServiceDefinitionFileName), mServiceDefinitionFileName, csarFiles, serviceTemplates);
+ String parentDir = mServiceDefinitionFileName.substring(0, mServiceDefinitionFileName.lastIndexOf("/"));
+ handleImportDefinitions(mServiceDefinitionFileName, csarFiles, parentDir, gsst);
+ }
}
private void handleExternalArtifacts(Map<String, byte[]> csarFiles, Map<String, ServiceTemplate> serviceTemplates, FileContentHandler artifacts) {
@@ -128,4 +130,11 @@ public class ToscaSolConverterImpl extends AbstractToscaConverter {
throw new IOException(e.getMessage());
}
}
+
+ private String getSimpleName(String path){
+ if(path != null && path.contains("/")){
+ path = path.substring(path.lastIndexOf("/") + 1);
+ }
+ return path;
+ }
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java
index ad2e61523f..45d6332e06 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/test/java/org/openecomp/core/impl/ToscaSolConverterImplTest.java
@@ -71,9 +71,9 @@ public class ToscaSolConverterImplTest {
Map<String, ServiceTemplate> serviceTemplateMap = toscaServiceModel.getServiceTemplates();
String entryDefinitionTemplateName = toscaServiceModel.getEntryDefinitionServiceTemplate();
Assert.assertTrue("Artifacts should contain external files", contentHandler.containsFile("Main.mf"));
- Assert.assertTrue("Main service template should exist", serviceTemplateMap.containsKey("Definitions/Main.yaml"));
+ Assert.assertTrue("Main service template should exist", serviceTemplateMap.containsKey("Main.yaml"));
Assert.assertEquals("Entry Definition name should be same as passed in TOSCA.meta",
- "Definitions/Main.yaml", entryDefinitionTemplateName);
+ "Main.yaml", entryDefinitionTemplateName);
}
@Test(expected = IOException.class)