2 * Copyright (c) 2018 Orange
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.nbi.apis.servicecatalog;
19 import java.util.LinkedHashMap;
20 import java.util.List;
22 import org.onap.nbi.OnapComponentsUrlPaths;
23 import org.onap.nbi.commons.JsonRepresentation;
24 import org.onap.nbi.commons.ResourceManagement;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.http.MediaType;
27 import org.springframework.http.ResponseEntity;
28 import org.springframework.util.MultiValueMap;
29 import org.springframework.web.bind.annotation.GetMapping;
30 import org.springframework.web.bind.annotation.PathVariable;
31 import org.springframework.web.bind.annotation.RequestMapping;
32 import org.springframework.web.bind.annotation.RequestParam;
33 import org.springframework.web.bind.annotation.RestController;
36 @RequestMapping(OnapComponentsUrlPaths.SERVICE_SPECIFICATION_PATH)
37 public class ServiceSpecificationResource extends ResourceManagement {
40 ServiceSpecificationService serviceSpecificationService;
42 @GetMapping(value = "/{serviceSpecId}", produces = MediaType.APPLICATION_JSON_VALUE)
43 public ResponseEntity<Object> getServiceSpecification(@PathVariable String serviceSpecId,
44 @RequestParam MultiValueMap<String, String> params) {
45 Map response = serviceSpecificationService.get(serviceSpecId);
46 JsonRepresentation filter = new JsonRepresentation(params);
47 if (response.get("serviceSpecCharacteristic") != null) {
48 return this.getResponse(response, filter);
50 return this.getPartialResponse(response, filter);
55 @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
56 public ResponseEntity<Object> findServiceSpecification(@RequestParam MultiValueMap<String, String> params) {
57 List<LinkedHashMap> response = serviceSpecificationService.find(params);
58 JsonRepresentation filter = new JsonRepresentation(params);
59 return this.findResponse(response, filter, null);
62 @GetMapping(value = "/{serviceSpecId}/specificationInputSchema", produces = MediaType.APPLICATION_JSON_VALUE)
63 public ResponseEntity<Object> findSpecificationInputSchema(@PathVariable String serviceSpecId,
64 @RequestParam MultiValueMap<String, String> params) {
65 String response = serviceSpecificationService.getInputSchema(serviceSpecId);
66 JsonRepresentation filter = new JsonRepresentation(params);
67 return this.getResponse(response, filter);