diff options
Diffstat (limited to 'src/main')
3 files changed, 20 insertions, 12 deletions
diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationResource.java b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationResource.java index d4a53a4..e8ef9e3 100644 --- a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationResource.java +++ b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationResource.java @@ -43,7 +43,12 @@ public class ServiceSpecificationResource extends ResourceManagement { @RequestParam MultiValueMap<String, String> params) { Map response = serviceSpecificationService.get(serviceSpecId); JsonRepresentation filter = new JsonRepresentation(params); - return this.getResponse(response, filter); + if (response.get("serviceSpecCharacteristic") != null) { + return this.getResponse(response, filter); + } else { + return this.getPartialResponse(response, filter); + + } } @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE) diff --git a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java index 3094f7b..69e4a51 100644 --- a/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java +++ b/src/main/java/org/onap/nbi/apis/servicecatalog/ServiceSpecificationService.java @@ -23,6 +23,8 @@ import org.apache.commons.collections.CollectionUtils; import org.onap.nbi.apis.servicecatalog.jolt.FindServiceSpecJsonTransformer; import org.onap.nbi.apis.servicecatalog.jolt.GetServiceSpecJsonTransformer; import org.onap.nbi.apis.serviceorder.ServiceCatalogUrl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.MultiValueMap; @@ -45,16 +47,23 @@ public class ServiceSpecificationService { @Autowired private ServiceCatalogUrl serviceCatalogUrl; - private static final String SERVICE_SPEC_INPUT_SCHEMA = "serviceSpecInputSchema"; + + private static final Logger LOGGER = LoggerFactory.getLogger(ServiceSpecificationService.class); public Map get(String serviceSpecId) { Map sdcResponse = sdcClient.callGet(serviceSpecId); - sdcResponse.put(SERVICE_SPEC_INPUT_SCHEMA,serviceCatalogUrl.getServiceCatalogUrl()+serviceSpecId+"/"+SERVICE_SPEC_INPUT_SCHEMA); - return (LinkedHashMap) getServiceSpecJsonTransformer.transform(sdcResponse); + LinkedHashMap serviceCatalogResponse = (LinkedHashMap) getServiceSpecJsonTransformer.transform(sdcResponse); + Map toscaInfosTopologyTemplate = toscaInfosProcessor.getToscaInfos(serviceCatalogResponse); + if (toscaInfosTopologyTemplate != null) { + LOGGER.debug("tosca file found, retrieving informations"); + toscaInfosProcessor.buildResponseWithToscaInfos(toscaInfosTopologyTemplate, serviceCatalogResponse); + } else { + LOGGER.debug("no tosca file found, partial response"); + } + return serviceCatalogResponse; } - public List<LinkedHashMap> find(MultiValueMap<String, String> parametersMap) { List<LinkedHashMap> sdcResponse = sdcClient.callFind(parametersMap); List<LinkedHashMap> serviceCatalogResponse = new ArrayList<>(); diff --git a/src/main/resources/jolt/getServiceCatalog.json b/src/main/resources/jolt/getServiceCatalog.json index 6b260b6..6fdadd6 100644 --- a/src/main/resources/jolt/getServiceCatalog.json +++ b/src/main/resources/jolt/getServiceCatalog.json @@ -42,8 +42,7 @@ } - }, - "serviceSpecInputSchema" : "serviceSpecCharacteristic.serviceSpecInputSchema" + } } }, { @@ -70,11 +69,6 @@ "@type": "ONAPresource" } - }, - "serviceSpecCharacteristic" : { - "valueType": "complex", - "@type": "serviceSpecInputSchema" - } } } |