Juan Hernandez has uploaded a new change for review.

Change subject: restapi: Ignore blank domains
......................................................................

restapi: Ignore blank domains

Currently the the value of the "domain" column of the "vm_init" table
can be null or an empty string, both meaning that the VM doesn't have a
domain assigned. But when the value of the column is an empty string it
will be included in the RESTAPI representation as follows:

  <domain>
    <name></name>
  </domain>

This is confusing for callers, and in particular it triggers wrong
behaviour in the Python SDK. To avoid this issue this patch changes the
RESTAPI so that it won't generate the "domain" element if the domain
name is a blank string.

Change-Id: Ic2dc13b1dabc08e38def31297148f135ec299ec9
Bug-Url: https://bugzilla.redhat.com/1113571
Signed-off-by: Juan Hernandez <[email protected]>
(cherry picked from commit ac78f2b7687df6f8e0ed40cf783729f9eda8c9c0)
---
M backend/manager/modules/restapi/types/pom.xml
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
3 files changed, 8 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/17/30617/1

diff --git a/backend/manager/modules/restapi/types/pom.xml 
b/backend/manager/modules/restapi/types/pom.xml
index a8a57e0..5937824 100644
--- a/backend/manager/modules/restapi/types/pom.xml
+++ b/backend/manager/modules/restapi/types/pom.xml
@@ -64,6 +64,11 @@
       <artifactId>commons-codec</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
+
   </dependencies>
 
   <profiles>
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
index 10cea77..53875a7 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java
@@ -366,9 +366,7 @@
         if (entity.getCreationDate() != null) {
             model.setCreationTime(DateMapper.map(entity.getCreationDate(), 
null));
         }
-        if (entity.getVmInit() != null &&
-                entity.getVmInit().getDomain() != null &&
-                !entity.getVmInit().getDomain().isEmpty()) {
+        if (entity.getVmInit() != null && 
StringUtils.isNotBlank(entity.getVmInit().getDomain())) {
             Domain domain = new Domain();
             domain.setName(entity.getVmInit().getDomain());
             model.setDomain(domain);
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
index 1a25331..cba9865 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
@@ -521,7 +521,7 @@
 
         if (entity.getVmInit() != null) {
             model.setInitialization(map(entity.getVmInit(), null));
-            if (entity.getVmInit().getDomain() != null) {
+            if (StringUtils.isNotBlank(entity.getVmInit().getDomain())) {
                 Domain domain = new Domain();
                 domain.setName(entity.getVmInit().getDomain());
                 model.setDomain(domain);
@@ -1040,7 +1040,7 @@
         if (entity.getHostname() != null) {
             model.setHostName(entity.getHostname());
         }
-        if (entity.getDomain() != null) {
+        if (StringUtils.isNotBlank(entity.getDomain())) {
             model.setDomain(entity.getDomain());
         }
         if (entity.getTimeZone() != null) {


-- 
To view, visit http://gerrit.ovirt.org/30617
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2dc13b1dabc08e38def31297148f135ec299ec9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Juan Hernandez <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to