Bug 4775 - handle cases when tenant-id is an empty string
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronObject.java
index 093cac1d4a9a7ce846afb8314147be5865cd59e7..7ccbe695072f91eac5b6e3e64bee349b740678ce 100644 (file)
@@ -16,6 +16,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
@@ -29,16 +30,32 @@ public class NeutronObject extends Neutron_ID implements Serializable, INeutronO
         super();
     }
 
+    @Override
     public String getTenantID() {
+        if (tenantID != null && tenantID.isEmpty()) {
+            // Bug 4775 - Treat empty string tenantId as null, so no attempt is made
+            //            to turn it into a uuid.
+            return null;
+        }
         return tenantID;
     }
 
+    @Override
     public void setTenantID(String tenantID) {
         this.tenantID = tenantID;
     }
 
+    @Override
+    public void setTenantID(Uuid tenantID) {
+        this.tenantID = tenantID.getValue().replace("-", "");
+    }
+
     @Override
     public String toString() {
         return "NeutronObject [id=" + uuid + ", tenantID=" + tenantID + "]";
     }
+
+    @Override
+    public void initDefaults() {
+    }
 }