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.
16 package org.onap.nbi.apis.servicecatalog;
18 import java.util.LinkedHashMap;
19 import java.util.List;
20 import org.onap.nbi.commons.JsonRepresentation;
21 import org.onap.nbi.commons.Resource;
22 import org.onap.nbi.commons.ResourceManagement;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.http.MediaType;
25 import org.springframework.http.ResponseEntity;
26 import org.springframework.util.MultiValueMap;
27 import org.springframework.web.bind.annotation.GetMapping;
28 import org.springframework.web.bind.annotation.PathVariable;
29 import org.springframework.web.bind.annotation.RequestMapping;
30 import org.springframework.web.bind.annotation.RequestParam;
31 import org.springframework.web.bind.annotation.RestController;
34 @RequestMapping("/serviceSpecification")
35 public class ServiceSpecificationResource extends ResourceManagement<Resource> {
39 ServiceSpecificationService serviceSpecificationService;
41 @GetMapping(value = "/{serviceSpecId}", produces = MediaType.APPLICATION_JSON_VALUE)
42 public ResponseEntity<Object> getServiceSpecification(@PathVariable String serviceSpecId,
43 @RequestParam MultiValueMap<String, String> params) {
44 LinkedHashMap response = serviceSpecificationService.get(serviceSpecId);
45 JsonRepresentation filter = new JsonRepresentation(params);
46 if (response.get("serviceSpecCharacteristic") != null) {
47 return this.getResponse(response, filter);
49 return this.getPartialResponse(response, filter);
54 @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
55 public ResponseEntity<Object> findServiceSpecification(@RequestParam MultiValueMap<String, String> params) {
56 List<LinkedHashMap> response = serviceSpecificationService.find(params);
57 JsonRepresentation filter = new JsonRepresentation(params);
58 return this.findResponse(response, filter, null);