Controller Blueprints MS
[ccsdk/cds.git] / ms / controllerblueprints / modules / service / src / main / java / org / onap / ccsdk / apps / controllerblueprints / service / rs / ConfigModelRestImpl.java
1 /*\r
2  * Copyright © 2017-2018 AT&T Intellectual Property.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
18 \r
19 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
20 import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;\r
21 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
22 import org.springframework.stereotype.Service;\r
23 \r
24 import java.util.List;\r
25 \r
26 /**\r
27  * {@inheritDoc}\r
28  */\r
29 @Service\r
30 public class ConfigModelRestImpl implements ConfigModelRest {\r
31 \r
32     private ConfigModelService configModelService;\r
33 \r
34     /**\r
35      * This is a ConfigModelRestImpl constructor.\r
36      *\r
37      * @param configModelService Config Model Service\r
38      */\r
39     public ConfigModelRestImpl(ConfigModelService configModelService) {\r
40         this.configModelService = configModelService;\r
41 \r
42     }\r
43 \r
44     @Override\r
45     public ConfigModel getInitialConfigModel(String name) throws BluePrintException {\r
46         try {\r
47             return this.configModelService.getInitialConfigModel(name);\r
48         } catch (Exception e) {\r
49             throw new BluePrintException(2000, e.getMessage(), e);\r
50         }\r
51     }\r
52 \r
53     @Override\r
54     public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException {\r
55         try {\r
56             return this.configModelService.saveConfigModel(configModel);\r
57         } catch (Exception e) {\r
58             throw new BluePrintException(2200, e.getMessage(), e);\r
59         }\r
60     }\r
61 \r
62     @Override\r
63     public void deleteConfigModel(Long id) throws BluePrintException {\r
64         try {\r
65             this.configModelService.deleteConfigModel(id);\r
66         } catch (Exception e) {\r
67             throw new BluePrintException(4000, e.getMessage(), e);\r
68         }\r
69     }\r
70 \r
71     @Override\r
72     public ConfigModel publishConfigModel(Long id) throws BluePrintException {\r
73         try {\r
74             return this.configModelService.publishConfigModel(id);\r
75         } catch (Exception e) {\r
76             throw new BluePrintException(2500, e.getMessage(), e);\r
77         }\r
78     }\r
79 \r
80     @Override\r
81     public ConfigModel getConfigModel(Long id) throws BluePrintException {\r
82         try {\r
83             return this.configModelService.getConfigModel(id);\r
84         } catch (Exception e) {\r
85             throw new BluePrintException(2001, e.getMessage(), e);\r
86         }\r
87     }\r
88 \r
89     @Override\r
90     public ConfigModel getConfigModelByNameAndVersion(String name, String version) throws BluePrintException {\r
91         try {\r
92             return this.configModelService.getConfigModelByNameAndVersion(name, version);\r
93         } catch (Exception e) {\r
94             throw new BluePrintException(2002, e.getMessage(), e);\r
95         }\r
96     }\r
97 \r
98     @Override\r
99     public List<ConfigModel> searchConfigModels(String tags) throws BluePrintException {\r
100         try {\r
101             return this.configModelService.searchConfigModels(tags);\r
102         } catch (Exception e) {\r
103             throw new BluePrintException(2003, e.getMessage(), e);\r
104         }\r
105     }\r
106 \r
107     @Override\r
108     public ConfigModel getCloneConfigModel(Long id) throws BluePrintException {\r
109         try {\r
110             return this.configModelService.getCloneConfigModel(id);\r
111         } catch (Exception e) {\r
112             throw new BluePrintException(2004, e.getMessage(), e);\r
113         }\r
114     }\r
115 \r
116 }\r