Clean up logging
[ovsdb.git] / northbound / src / main / java / org / opendaylight / ovsdb / northbound / OvsdbNorthboundV2.java
index fd023f0470da3eede7902ecccdf3437104661096..ec7b7b1708cb97d8cffd0cb7572cd98cb184965a 100644 (file)
@@ -37,9 +37,7 @@ import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailab
 import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
 import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
 import org.opendaylight.controller.sal.authorization.Privilege;
-import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.utils.ServiceHelper;
-import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.ovsdb.plugin.api.Status;
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.notation.Row;
 import org.opendaylight.ovsdb.lib.notation.UUID;
@@ -48,8 +46,8 @@ import org.opendaylight.ovsdb.plugin.api.OvsVswitchdSchemaConstants;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
 import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 
 import com.fasterxml.jackson.databind.JsonNode;
 
@@ -72,7 +70,6 @@ import com.fasterxml.jackson.databind.JsonNode;
 @Path("/v2/")
 @Deprecated
 public class OvsdbNorthboundV2 {
-    protected static final Logger logger = LoggerFactory.getLogger(OvsdbNorthboundV2.class);
 
     @Context
     private UriInfo _uriInfo;
@@ -107,7 +104,7 @@ public class OvsdbNorthboundV2 {
      * @param nodeType type of node e.g OVS
      * @param nodeId ID of the node
      * @param tableName name of the OVSDB table
-     * @param row the {@link OvsdbRow} Row that is being inserted
+     * @param rowJson the {@link OvsdbRow} Row that is being inserted
      *
      * @return Response as dictated by the HTTP Response Status code
      *
@@ -332,9 +329,10 @@ public class OvsdbNorthboundV2 {
             throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString());
         }
 
-        Node node = Node.fromString(nodeType, nodeId);
         OvsdbConnectionService
                 connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
+        Node node = connectionService.getNode(nodeId);
+
         OvsdbClient client = connectionService.getConnection(node).getClient();
         OvsdbRow localRow = OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, rowJson);
         String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
@@ -354,7 +352,9 @@ public class OvsdbNorthboundV2 {
                     .entity(uuid.toString())
                     .build();
         }
-        return NorthboundUtils.getResponse(statusWithUuid);
+        return NorthboundUtils.getResponse(
+                new org.opendaylight.controller.sal.utils.Status(
+                        org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
     }
 
     /**
@@ -424,9 +424,9 @@ public class OvsdbNorthboundV2 {
             throw new ServiceUnavailableException("UserManager " + RestMessages.SERVICEUNAVAILABLE.toString());
         }
 
-        Node node = Node.fromString(nodeType, nodeId);
         OvsdbConnectionService
                 connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
+        Node node = connectionService.getNode(nodeId);
         OvsdbClient client = connectionService.getConnection(node).getClient();
         String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
 
@@ -507,9 +507,9 @@ public class OvsdbNorthboundV2 {
             throw new ServiceUnavailableException("UserManager " + RestMessages.SERVICEUNAVAILABLE.toString());
         }
 
-        Node node = Node.fromString(nodeType, nodeId);
         OvsdbConnectionService
                 connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
+        Node node = connectionService.getNode(nodeId);
         OvsdbClient client = connectionService.getConnection(node).getClient();
         String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
         Map<String, Row> rows = null;
@@ -582,9 +582,9 @@ public class OvsdbNorthboundV2 {
             throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString());
         }
 
-        Node node = Node.fromString(nodeType, nodeId);
         OvsdbConnectionService
                 connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
+        Node node = connectionService.getNode(nodeId);
         OvsdbClient client = connectionService.getConnection(node).getClient();
         String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
         OvsdbRow localRow = OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, rowJson);
@@ -594,7 +594,9 @@ public class OvsdbNorthboundV2 {
         }
 
         Status status = ovsdbTable.updateRow(node, bckCompatibleTableName, localRow.getParentUuid(), rowUuid, localRow.getRow());
-        return NorthboundUtils.getResponse(status);
+        return NorthboundUtils.getResponse(
+                new org.opendaylight.controller.sal.utils.Status(
+                        org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
     }
 
     /**
@@ -663,9 +665,9 @@ public class OvsdbNorthboundV2 {
             throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString());
         }
 
-        Node node = Node.fromString(nodeType, nodeId);
         OvsdbConnectionService
                 connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
+        Node node = connectionService.getNode(nodeId);
         OvsdbClient client = connectionService.getConnection(node).getClient();
         String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
 
@@ -673,14 +675,20 @@ public class OvsdbNorthboundV2 {
         if (status.isSuccess()) {
             return Response.noContent().build();
         }
-        return NorthboundUtils.getResponse(status);
+        return NorthboundUtils.getResponse(
+                new org.opendaylight.controller.sal.utils.Status(
+                        org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
     }
 
     private String getBackwardCompatibleTableName(OvsdbClient client, String databaseName, String tableName) {
         DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName);
-        if (dbSchema == null || tableName == null) return tableName;
+        if (dbSchema == null || tableName == null) {
+            return tableName;
+        }
         for (String dbTableName : dbSchema.getTables()) {
-            if (dbTableName.equalsIgnoreCase(tableName)) return dbTableName;
+            if (dbTableName.equalsIgnoreCase(tableName)) {
+                return dbTableName;
+            }
         }
         return tableName;
     }