Ravi Nori has uploaded a new change for review.

Change subject: restapi : if "filter: ..." header is set, use query instead of 
search to list items
......................................................................

restapi : if "filter: ..." header is set, use query instead of search to list 
items

When the filter option is specified the api query should not
throw a insufficient permissions exception. Instead the query should
return a list of objects that the user has permissions for.

This patch fixes /events/{id}

Change-Id: Ia2ab0e1e62b9cc67fad51da5e5e0b2c1163087a6
Bug-Url: https://bugzilla.redhat.com/869334
Signed-off-by: Ravi Nori <rn...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllEventMessagesQuery.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
3 files changed, 9 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/75/14275/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllEventMessagesQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllEventMessagesQuery.java
index ae0f132..e845780 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllEventMessagesQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllEventMessagesQuery.java
@@ -5,7 +5,7 @@
 import org.ovirt.engine.core.common.queries.*;
 
 // not in use
-public class GetAllEventMessagesQuery<P extends GetEventMessagesParameters> 
extends QueriesCommandBase<P> {
+public class GetAllEventMessagesQuery<P extends VdcQueryParametersBase> 
extends QueriesCommandBase<P> {
     public GetAllEventMessagesQuery(P parameters) {
         super(parameters);
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
index 83f2f87..8ef618c 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
@@ -97,7 +97,7 @@
     GetAllDisksByStorageDomainId,
     GetAllDisks(VdcQueryAuthType.User),
     GetImageByImageId,
-    GetDiskByDiskId,
+    GetDiskByDiskId(VdcQueryAuthType.User),
 
     // Users queries
     GetUserVmsByUserIdAndGroups(VdcQueryAuthType.User),
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
index 51d4002..aaa418e 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendEventsResource.java
@@ -14,8 +14,8 @@
 import org.ovirt.engine.core.common.businessentities.AuditLog;
 import org.ovirt.engine.core.common.interfaces.SearchType;
 import org.ovirt.engine.core.common.queries.GetAuditLogByIdParameters;
-import org.ovirt.engine.core.common.queries.GetEventMessagesParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
+import org.ovirt.engine.core.common.queries.VdcQueryParametersBase;
 
 public class BackendEventsResource extends
 AbstractBackendCollectionResource<Event, AuditLog> implements
@@ -26,11 +26,7 @@
 
     @Override
     public Events list() {
-        if (isFiltered()) {
-            return 
mapCollection(getBackendCollection(VdcQueryType.GetAllEventMessages, new 
GetEventMessagesParameters()));
-        } else {
-            return mapCollection(getBackendCollection());
-        }
+        return mapCollection(getBackendCollection());
     }
 
     private Events mapCollection(List<AuditLog> entities) {
@@ -48,7 +44,11 @@
     }
 
     private List<AuditLog> getBackendCollection() {
-        return getBackendCollection(SearchType.AuditLog);
+        if (isFiltered()) {
+            return getBackendCollection(VdcQueryType.GetAllEventMessages, new 
VdcQueryParametersBase());
+        } else {
+            return getBackendCollection(SearchType.AuditLog);
+        }
     }
 
     public Event lookupEvent(String id) {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2ab0e1e62b9cc67fad51da5e5e0b2c1163087a6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: engine_3.2
Gerrit-Owner: Ravi Nori <rn...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to