Remove 'All rights reserved.' on apache 2 license
[externalapi/nbi.git] / src / main / java / org / onap / nbi / apis / servicecatalog / ServiceSpecificationResource.java
1 /**
2  *     Copyright (c) 2018 Orange
3  *
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
7  *
8  *         http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.onap.nbi.apis.servicecatalog;
17
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;
32
33 @RestController
34 @RequestMapping("/serviceSpecification")
35 public class ServiceSpecificationResource extends ResourceManagement<Resource> {
36
37
38     @Autowired
39     ServiceSpecificationService serviceSpecificationService;
40
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);
48         } else {
49             return this.getPartialResponse(response, filter);
50
51         }
52     }
53
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);
59     }
60
61 }