Sonar clean-up: braces for control statements
[netvirt.git] / ovsdb-plugin-compatibility-layer / src / main / java / org / opendaylight / ovsdb / compatibility / plugin / impl / ConfigurationServiceImpl.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.ovsdb.compatibility.plugin.impl;
9
10 import java.util.List;
11 import java.util.concurrent.ConcurrentMap;
12 import java.util.concurrent.ExecutionException;
13
14 import org.opendaylight.controller.sal.core.Node;
15 import org.opendaylight.controller.sal.utils.Status;
16 import org.opendaylight.ovsdb.compatibility.plugin.api.NodeUtils;
17 import org.opendaylight.ovsdb.compatibility.plugin.api.OvsdbConfigurationService;
18 import org.opendaylight.ovsdb.compatibility.plugin.api.StatusWithUuid;
19 import org.opendaylight.ovsdb.compatibility.plugin.error.OvsdbPluginException;
20 import org.opendaylight.ovsdb.lib.notation.Row;
21 import org.opendaylight.ovsdb.lib.notation.UUID;
22 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
23 import org.opendaylight.ovsdb.lib.schema.typed.TypedBaseTable;
24
25 /**
26  * This is a proxy class for ovsdb plugin's OvsdbConfigurationService class
27  * It just forward the call to OvsdbConfigurationService instance and pass
28  * back the response to the caller.
29  *
30  * @author Anil Vishnoi (vishnoianil@gmail.com)
31  *
32  */
33 public class ConfigurationServiceImpl implements OvsdbConfigurationService
34 {
35     private volatile org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService pluginOvsdbConfigurationService;
36
37     void init() {
38     }
39
40     /**
41      * Function called by the dependency manager when at least one dependency
42      * become unsatisfied or when the component is shutting down because for
43      * example bundle is being stopped.
44      *
45      */
46     void destroy() {
47     }
48
49     /**
50      * Function called by dependency manager after "init ()" is called and after
51      * the services provided by the class are registered in the service registry
52      *
53      */
54     void start() {
55     }
56
57     /**
58      * Function called by the dependency manager before the services exported by
59      * the component are unregistered, this will be followed by a "destroy ()"
60      * calls
61      *
62      */
63     void stop() {
64     }
65
66     public void setOvsdbConfigurationService(org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService pluginOvsdbConfigurationService){
67         this.pluginOvsdbConfigurationService = pluginOvsdbConfigurationService;
68     }
69
70     public void unsetOvsdbConfigurationService(org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService pluginOvsdbConfigurationService){
71         this.pluginOvsdbConfigurationService = null;
72     }
73
74
75     @Override
76     public StatusWithUuid insertRow(Node node, String tableName, String parentUuid, Row<GenericTableSchema> row) {
77         return StatusConvertorUtil.convertOvsdbStatusWithUuidToCompLayerStatusWithUuid(pluginOvsdbConfigurationService.insertRow(NodeUtils.getMdsalNode(node), tableName, parentUuid, row));
78     }
79
80     @Override
81     public Status updateRow (Node node, String tableName, String parentUUID, String rowUUID, Row row) {
82         return StatusConvertorUtil
83                 .convertOvsdbStatusToSalStatus(pluginOvsdbConfigurationService
84                         .updateRow(NodeUtils.getMdsalNode(node), tableName, parentUUID, rowUUID, row));
85     }
86
87     @Override
88     public Status deleteRow(Node node, String tableName, String uuid) {
89         return StatusConvertorUtil
90                 .convertOvsdbStatusToSalStatus(pluginOvsdbConfigurationService.
91                         deleteRow(NodeUtils.getMdsalNode(node), tableName, uuid));
92     }
93
94     @Override
95     public ConcurrentMap<String, Row> getRows(Node node, String tableName) {
96         return pluginOvsdbConfigurationService.getRows(NodeUtils.getMdsalNode(node), tableName);
97     }
98
99     @Override
100     public Row getRow(Node node, String tableName, String uuid) {
101         return pluginOvsdbConfigurationService.getRow(NodeUtils.getMdsalNode(node), tableName, uuid);
102     }
103
104     @Override
105     public List<String> getTables(Node node) {
106         return pluginOvsdbConfigurationService.getTables(NodeUtils.getMdsalNode(node));
107     }
108
109     @Override
110     public Boolean setOFController(Node node, String bridgeUUID) throws InterruptedException, ExecutionException {
111         return pluginOvsdbConfigurationService.setOFController(NodeUtils.getMdsalNode(node), bridgeUUID);
112     }
113
114     @Override
115     public <T extends TypedBaseTable<?>> String getTableName(Node node, Class<T> typedClass) {
116         return pluginOvsdbConfigurationService.getTableName(NodeUtils.getMdsalNode(node), typedClass);
117     }
118
119     @Override
120     public <T extends TypedBaseTable<?>> T getTypedRow(Node node, Class<T> typedClass, Row row) {
121         return pluginOvsdbConfigurationService.getTypedRow(NodeUtils.getMdsalNode(node), typedClass, row);
122     }
123
124     @Override
125     public <T extends TypedBaseTable<?>> T createTypedRow(Node node, Class<T> typedClass) {
126         return pluginOvsdbConfigurationService.createTypedRow(NodeUtils.getMdsalNode(node), typedClass);
127     }
128
129     @Override
130     public UUID insertRow(Node node, String databaseName, String tableName, String parentTable, UUID parentUuid,
131                           String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException {
132         return pluginOvsdbConfigurationService
133                 .insertRow(NodeUtils.getMdsalNode(node), databaseName, tableName, parentTable, parentUuid,
134                         parentColumn, row);
135     }
136
137     @Override
138     public UUID insertRow(Node node, String databaseName, String tableName,
139             UUID parentRowUuid, Row<GenericTableSchema> row)
140             throws OvsdbPluginException {
141         return this.insertRow(node, databaseName, tableName, null, parentRowUuid, null, row);
142     }
143
144     @Override
145     public Row<GenericTableSchema> insertTree(Node node, String databaseName, String tableName, String parentTable, UUID parentUuid,
146                                               String parentColumn, Row<GenericTableSchema> row) throws OvsdbPluginException {
147         return pluginOvsdbConfigurationService
148                 .insertTree(NodeUtils.getMdsalNode(node), databaseName, tableName, parentTable,
149                         parentUuid, parentColumn, row);
150     }
151
152     @Override
153     public Row<GenericTableSchema> insertTree(Node node, String databaseName,
154             String tableName, UUID parentRowUuid, Row<GenericTableSchema> row)
155             throws OvsdbPluginException {
156         return this.insertTree(node, databaseName, tableName, null, parentRowUuid, null, row);
157     }
158
159     @Override
160     public Row<GenericTableSchema> updateRow(Node node, String databaseName,
161             String tableName, UUID rowUuid, Row<GenericTableSchema> row,
162             boolean overwrite) throws OvsdbPluginException {
163         return pluginOvsdbConfigurationService
164                 .updateRow(NodeUtils.getMdsalNode(node), databaseName, tableName, rowUuid, row, overwrite);
165     }
166
167     @Override
168     public void deleteRow(Node node, String databaseName, String tableName, String parentTable, UUID parentRowUuid,
169             String parentColumn, UUID rowUuid) throws OvsdbPluginException {
170         pluginOvsdbConfigurationService
171                 .deleteRow(NodeUtils.getMdsalNode(node), databaseName, tableName, parentTable,
172                         parentRowUuid, parentColumn, rowUuid);
173     }
174
175     @Override
176     public void deleteRow(Node node, String databaseName, String tableName, UUID rowUuid) throws OvsdbPluginException {
177         this.deleteRow(node, databaseName, tableName, null, null, null, rowUuid);
178     }
179
180     @Override
181     public Row<GenericTableSchema> getRow(Node node, String databaseName,
182             String tableName, UUID uuid) throws OvsdbPluginException {
183         return pluginOvsdbConfigurationService
184                 .getRow(NodeUtils.getMdsalNode(node), databaseName, tableName, uuid);
185     }
186
187     @Override
188     public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node,
189             String databaseName, String tableName) throws OvsdbPluginException {
190         return pluginOvsdbConfigurationService
191                 .getRows(NodeUtils.getMdsalNode(node), databaseName, tableName);
192     }
193
194     @Override
195     public ConcurrentMap<UUID, Row<GenericTableSchema>> getRows(Node node,
196             String databaseName, String tableName, String fiqlQuery)
197             throws OvsdbPluginException {
198         return this.getRows(node, databaseName, tableName);
199     }
200
201     @Override
202     public List<String> getTables(Node node, String databaseName) throws OvsdbPluginException {
203         return pluginOvsdbConfigurationService.getTables(NodeUtils.getMdsalNode(node), databaseName);
204     }
205 }