Maor Lipchuk has uploaded a new change for review.

Change subject: core: Use null check for unregistered dal insert
......................................................................

core: Use null check for unregistered dal insert

Architeture and LowestCompVersion are not part of the OVF.
This patch adds a validation so we will not get an NPE when trying to
insert new VMs/Templates from the OVF disk into the DB

Change-Id: I5e7328464c3038d9298723e947fbf262e74c9df6
Signed-off-by: Maor Lipchuk <mlipc...@redhat.com>
---
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UnregisteredOVFDataDAODbFacadeImpl.java
1 file changed, 13 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/40/29040/1

diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UnregisteredOVFDataDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UnregisteredOVFDataDAODbFacadeImpl.java
index afb4c44..06b19b3 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UnregisteredOVFDataDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/UnregisteredOVFDataDAODbFacadeImpl.java
@@ -41,14 +41,19 @@
     @Override
     public void saveOVFData(OvfEntityData ovfEntityData) {
         // OVF data is not included since it is being updated in the stored 
procedure.
-        getCallsHandler().executeModification("InsertOVFDataForEntities", 
getCustomMapSqlParameterSource()
-                .addValue("entity_guid", ovfEntityData.getEntityId())
-                .addValue("entity_name", ovfEntityData.getEntityName())
-                .addValue("entity_type", ovfEntityData.getEntityType().name())
-                .addValue("architecture", 
ovfEntityData.getArchitecture().getValue())
-                .addValue("lowest_comp_version", 
ovfEntityData.getLowestCompVersion().getValue())
-                .addValue("storage_domain_id", 
ovfEntityData.getStorageDomainId())
-                .addValue("ovf_extra_data", ovfEntityData.getOvfExtraData()));
+        getCallsHandler().executeModification("InsertOVFDataForEntities",
+                getCustomMapSqlParameterSource()
+                        .addValue("entity_guid", ovfEntityData.getEntityId())
+                        .addValue("entity_name", ovfEntityData.getEntityName())
+                        .addValue("entity_type", 
ovfEntityData.getEntityType().name())
+                        .addValue("architecture",
+                                ovfEntityData.getArchitecture() != null ? 
ovfEntityData.getArchitecture().getValue()
+                                        : null)
+                        .addValue("lowest_comp_version",
+                                ovfEntityData.getLowestCompVersion() != null ? 
ovfEntityData.getLowestCompVersion()
+                                        .getValue() : null)
+                        .addValue("storage_domain_id", 
ovfEntityData.getStorageDomainId())
+                        .addValue("ovf_extra_data", 
ovfEntityData.getOvfExtraData()));
     }
 
     private static class OvfEntityDataRowMapper implements 
RowMapper<OvfEntityData> {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e7328464c3038d9298723e947fbf262e74c9df6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to