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 <juan.hernan...@redhat.com>
---
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/48/30548/1

diff --git a/backend/manager/modules/restapi/types/pom.xml 
b/backend/manager/modules/restapi/types/pom.xml
index c829bd7..8594e2b 100644
--- a/backend/manager/modules/restapi/types/pom.xml
+++ b/backend/manager/modules/restapi/types/pom.xml
@@ -69,6 +69,11 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
+
   </dependencies>
 
   <build>
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 6024b72..d5ea4d3 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
@@ -403,9 +403,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 00dc7dd..144ac45 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
@@ -569,7 +569,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);
@@ -1127,7 +1127,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/30548
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2dc13b1dabc08e38def31297148f135ec299ec9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to