50442042615bad3ef9c1495b1d1bc864d5b9c31f
[ccsdk/cds.git] /
1 /*\r
2  * Copyright © 2017-2018 AT&T Intellectual Property.\r
3  * Modifications Copyright © 2018 IBM.\r
4  *\r
5  * Licensed under the Apache License, Version 2.0 (the "License");\r
6  * you may not use this file except in compliance with the License.\r
7  * You may obtain a copy of the License at\r
8  *\r
9  *     http://www.apache.org/licenses/LICENSE-2.0\r
10  *\r
11  * Unless required by applicable law or agreed to in writing, software\r
12  * distributed under the License is distributed on an "AS IS" BASIS,\r
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14  * See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  */\r
17 \r
18 package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
19 \r
20 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
21 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping;\r
22 import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;\r
23 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;\r
24 import org.springframework.http.MediaType;\r
25 import org.springframework.web.bind.annotation.*;\r
26 \r
27 import java.util.List;\r
28 \r
29 /**\r
30  * {@inheritDoc}\r
31  */\r
32 @Deprecated\r
33 @RestController\r
34 @RequestMapping(value = "/api/v1/dictionary")\r
35 public class ResourceDictionaryRest {\r
36 \r
37 \r
38     private ResourceDictionaryService resourceDictionaryService;\r
39 \r
40     /**\r
41      * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database\r
42      *\r
43      * @param dataDictionaryService Data Dictionary Service\r
44      */\r
45     public ResourceDictionaryRest(ResourceDictionaryService dataDictionaryService) {\r
46         this.resourceDictionaryService = dataDictionaryService;\r
47     }\r
48 \r
49     @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
50     public @ResponseBody\r
51     ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException {\r
52         return resourceDictionaryService.saveResourceDictionary(dataDictionary);\r
53     }\r
54 \r
55     @DeleteMapping(path = "/{name}")\r
56     public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) {\r
57         resourceDictionaryService.deleteResourceDictionary(name);\r
58     }\r
59 \r
60     @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
61     public @ResponseBody\r
62     ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
63         return resourceDictionaryService.getResourceDictionaryByName(name);\r
64     }\r
65 \r
66     @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
67     public @ResponseBody\r
68     List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names) {\r
69         return resourceDictionaryService.searchResourceDictionaryByNames(names);\r
70     }\r
71 \r
72     @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
73     public @ResponseBody\r
74     List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) {\r
75         return resourceDictionaryService.searchResourceDictionaryByTags(tags);\r
76 \r
77     }\r
78 \r
79     @GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE)\r
80     public @ResponseBody\r
81     ResourceSourceMapping getResourceSourceMapping() {\r
82         return resourceDictionaryService.getResourceSourceMapping();\r
83     }\r
84 \r
85 }\r