diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java | 40 | ||||
-rw-r--r-- | src/main/resources/jolt/getServiceCatalog.json | 1 |
2 files changed, 25 insertions, 16 deletions
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java b/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java index e3dbbd7..0503e34 100644 --- a/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java +++ b/src/main/java/org/onap/nbi/apis/servicecatalog/ToscaInfosProcessor.java @@ -21,6 +21,9 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.apache.commons.collections.CollectionUtils; @@ -48,9 +51,12 @@ public class ToscaInfosProcessor { if (toscaInfosTopologyTemplate.get("inputs") != null) { ArrayList serviceSpecCharacteristic = new ArrayList(); LinkedHashMap toscaInfos = (LinkedHashMap) toscaInfosTopologyTemplate.get("inputs"); - for (Object key : toscaInfos.entrySet()) { - String keyString = (String) key; - LinkedHashMap inputParameter = (LinkedHashMap) toscaInfos.get(key); + Set<Entry<String, LinkedHashMap>> stringLinkedHashMapEntry = (Set<Entry<String, LinkedHashMap>>) toscaInfos + .entrySet(); + + for (Map.Entry<String,LinkedHashMap> key :stringLinkedHashMapEntry) { + String keyString = key.getKey(); + LinkedHashMap inputParameter = key.getValue(); LinkedHashMap mapParameter = new LinkedHashMap(); String parameterType = (String) inputParameter.get("type"); mapParameter.put("name", keyString); @@ -60,7 +66,7 @@ public class ToscaInfosProcessor { mapParameter.put("required", inputParameter.get("required")); mapParameter.put("status", inputParameter.get("status")); List<LinkedHashMap> serviceSpecCharacteristicValues = - buildServiceSpecCharacteristicsValues(inputParameter, parameterType); + buildServiceSpecCharacteristicsValues(inputParameter, parameterType); mapParameter.put("serviceSpecCharacteristicValue", serviceSpecCharacteristicValues); serviceSpecCharacteristic.add(mapParameter); } @@ -72,14 +78,14 @@ public class ToscaInfosProcessor { List<LinkedHashMap> resourceSpecifications = (List<LinkedHashMap>) serviceCatalogResponse.get("resourceSpecification"); for (LinkedHashMap resourceSpecification : resourceSpecifications) { - String id = (String) resourceSpecification.get("id"); - LOGGER.debug("get tosca infos for service id: {0}", id); - LinkedHashMap toscaInfosFromResourceId = getToscaInfosFromResourceUUID(nodeTemplate, id); - if (toscaInfosFromResourceId != null) { - resourceSpecification.put("modelCustomizationId", toscaInfosFromResourceId.get("customizationUUID")); - resourceSpecification.put("modelCustomizationName", toscaInfosFromResourceId.get("name")); + if(resourceSpecification.get("id")!=null){ + String id = (String) resourceSpecification.get("id"); + LOGGER.debug("get tosca infos for service id: {0}", id); + LinkedHashMap toscaInfosFromResourceId = getToscaInfosFromResourceUUID(nodeTemplate, id); + if (toscaInfosFromResourceId != null && toscaInfosFromResourceId.get("customizationUUID")!=null) { + resourceSpecification.put("modelCustomizationId", toscaInfosFromResourceId.get("customizationUUID")); + } } - } } @@ -128,10 +134,12 @@ public class ToscaInfosProcessor { for (Object nodeTemplateObject : node_templates.values()) { LinkedHashMap nodeTemplate = (LinkedHashMap) nodeTemplateObject; LinkedHashMap metadata = (LinkedHashMap) nodeTemplate.get("metadata"); - String metadataUUID = (String) metadata.get("UUID"); - String metadataType = (String) metadata.get("type"); - if ("VF".equalsIgnoreCase(metadataType) && name.equalsIgnoreCase(metadataUUID)) { - return metadata; + if(metadata.get("UUID")!=null && metadata.get("type")!=null) { + String metadataUUID = (String) metadata.get("UUID"); + String metadataType = (String) metadata.get("type"); + if ("VF".equalsIgnoreCase(metadataType) && name!=null && name.equalsIgnoreCase(metadataUUID)) { + return metadata; + } } } } @@ -144,7 +152,7 @@ public class ToscaInfosProcessor { LinkedHashMap topologyTemplate = null; String toscaModelUrl = (String) sdcResponse.get("toscaModelURL"); - String serviceId = (String) sdcResponse.get("uuid"); + String serviceId = (String) sdcResponse.get("id"); File toscaFile = sdcClient.callGetWithAttachment(toscaModelUrl); Timestamp timestamp = new Timestamp(System.currentTimeMillis()); String tempFolderName = serviceId + timestamp; diff --git a/src/main/resources/jolt/getServiceCatalog.json b/src/main/resources/jolt/getServiceCatalog.json index cac223e..f0b3787 100644 --- a/src/main/resources/jolt/getServiceCatalog.json +++ b/src/main/resources/jolt/getServiceCatalog.json @@ -8,6 +8,7 @@ "invariantUUID": "invariantUUID", "toscaModelURL": "toscaModelURL", "toscaResourceName": "toscaResourceName", + "resourceInstanceName" : "modelCustomizationName", "category ": "category", "subcategory": "subcategory", "distributionStatus": "distributionStatus", |