From c179fdae1c2ff7c3dbb92eb89552456047e96fda Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Fri, 14 Oct 2016 13:43:34 +0000 Subject: [PATCH] Sanitizing limit git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@133206 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../resourceregistry/resources/impl/QueryImpl.java | 5 ++--- .../resourceregistry/resources/impl/QueryImplTest.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/impl/QueryImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/impl/QueryImpl.java index 8211e2f..0825e38 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/impl/QueryImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/impl/QueryImpl.java @@ -9,7 +9,6 @@ import java.util.List; import org.gcube.informationsystem.resourceregistry.api.Query; import org.gcube.informationsystem.resourceregistry.api.exceptions.InvalidQueryException; -import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.context.SecurityContextMapper.PermissionMode; import org.gcube.informationsystem.resourceregistry.resources.utils.ContextUtility; import org.gcube.informationsystem.resourceregistry.resources.utils.Utility; @@ -126,7 +125,7 @@ public class QueryImpl implements Query { public String query(String query, int limit, String fetchPlan) throws InvalidQueryException { - int sanitizedLimit = limit > 4 ? limit : AccessPath.DEFAULT_LIMIT; + limit = (limit <= 0) ? -1 : limit; ODatabaseDocumentTx oDatabaseDocumentTx = null; @@ -135,7 +134,7 @@ public class QueryImpl implements Query { .getActualSecurityContextDatabaseTx(PermissionMode.READER); - OSQLSynchQuery osqlSynchQuery = new OSQLSynchQuery<>(query, sanitizedLimit); + OSQLSynchQuery osqlSynchQuery = new OSQLSynchQuery<>(query, limit); osqlSynchQuery.setFetchPlan(fetchPlan); osqlSynchQuery.setCacheableResult(true); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/QueryImplTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/QueryImplTest.java index 913ed39..582f7b0 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/QueryImplTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/QueryImplTest.java @@ -23,7 +23,7 @@ public class QueryImplTest { QueryImpl queryImpl = new QueryImpl(); String query = "select * from CPUFacet"; - String ret = queryImpl.query(query, 2, null); + String ret = queryImpl.query(query, -7, null); logger.debug(ret); }