Format Java code with respect to ONAP Code Style
[externalapi/nbi.git] / src / main / java / org / onap / nbi / apis / serviceinventory / ServiceInventoryResource.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
17 package org.onap.nbi.apis.serviceinventory;
18
19 import java.util.LinkedHashMap;
20 import java.util.List;
21 import java.util.Map;
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;
34
35 @RestController
36 @RequestMapping(OnapComponentsUrlPaths.SERVICE_INVENTORY_PATH)
37 public class ServiceInventoryResource extends ResourceManagement {
38
39     @Autowired
40     ServiceInventoryService serviceInventoryService;
41
42     @GetMapping(value = "/{serviceId}", produces = MediaType.APPLICATION_JSON_VALUE)
43     public ResponseEntity<Object> getServiceInventory(@PathVariable String serviceId,
44             @RequestParam MultiValueMap<String, String> params) {
45
46         Map response = serviceInventoryService.get(serviceId, params);
47
48         JsonRepresentation filter = new JsonRepresentation(params);
49         return this.getResponse(response, filter);
50
51     }
52
53     @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
54     public ResponseEntity<Object> findServiceInventory(@RequestParam MultiValueMap<String, String> params) {
55
56         List<LinkedHashMap> response = serviceInventoryService.find(params);
57         JsonRepresentation filter = new JsonRepresentation(params);
58         return this.findResponse(response, filter, null);
59
60     }
61
62 }