Sanitizing limit

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@133206 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-10-14 13:43:34 +00:00
parent c1e4e869bf
commit c179fdae1c
2 changed files with 3 additions and 4 deletions

View File

@ -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<ODocument> osqlSynchQuery = new OSQLSynchQuery<>(query, sanitizedLimit);
OSQLSynchQuery<ODocument> osqlSynchQuery = new OSQLSynchQuery<>(query, limit);
osqlSynchQuery.setFetchPlan(fetchPlan);
osqlSynchQuery.setCacheableResult(true);

View File

@ -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);
}