Tomas Jelinek has uploaded a new change for review.

Change subject: core: added filtering to ensure only the templates return
......................................................................

core: added filtering to ensure only the templates return

If the search type in search query was "VmTemplate" it anyway returned all the
content of the vm_templastes_view which is a union of instance types, images
and templates.

Fixed by adding the filtering to the SearchQuery directly and not the DB level
because the vm_templates_view is used in a way that it expects that all three
types are present in it.

Change-Id: Id2b8366f9099fd4461ae7f876fda782e0c8568ab
Signed-off-by: Tomas Jelinek <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java
1 file changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/24731/3

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java
index a2946aa..9855372 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java
@@ -29,6 +29,7 @@
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.core.common.businessentities.VmEntityType;
 import org.ovirt.engine.core.common.businessentities.VmPool;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity;
@@ -243,11 +244,18 @@
         return genericSearch(getDbFacade().getVmTemplateDao(), true, new 
Filter<VmTemplate>() {
             @Override
             public List<VmTemplate> filter(final List<VmTemplate> data) {
+                List<VmTemplate> filtered = new ArrayList<>();
                 for (IVdcQueryable vmt_helper : data) {
                     VmTemplate vmt = (VmTemplate) vmt_helper;
+                    if (vmt.getTemplateType() != VmEntityType.TEMPLATE) {
+                        continue;
+                    }
+
                     VmTemplateHandler.updateDisksFromDb(vmt);
+                    filtered.add(vmt);
                 }
-                return data;
+
+                return filtered;
             }
         });
     }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id2b8366f9099fd4461ae7f876fda782e0c8568ab
Gerrit-PatchSet: 3
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tomas Jelinek <[email protected]>
Gerrit-Reviewer: Omer Frenkel <[email protected]>
Gerrit-Reviewer: Tomas Jelinek <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to