Added limit parameter to query

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-client@133205 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-10-14 13:35:46 +00:00
parent 3772efab75
commit 58505a8a6f
2 changed files with 12 additions and 3 deletions

View File

@ -63,8 +63,15 @@ public class ResourceRegistryClient {
String encodedValue = URLEncoder.encode(value, "UTF-8");
builder.append(encodedValue).append("&");
}
public String query(final String query, final String fetchPlan)
protected void appendQueryParameter(StringBuilder builder, String name,
int value) throws UnsupportedEncodingException {
builder.append("?").append(name).append("=");
String encodedValue = URLEncoder.encode(String.valueOf(value), "UTF-8");
builder.append(encodedValue).append("&");
}
public String query(final String query, final int limit, final String fetchPlan)
throws InvalidQueryException {
Call<EndpointReference, String> call = new Call<EndpointReference, String>() {
@ -82,6 +89,8 @@ public class ResourceRegistryClient {
callUrl.append("/").append(AccessPath.ACCESS_PATH_PART)
.append("/");
appendQueryParameter(callUrl, AccessPath.QUERY_PARAM, query);
appendQueryParameter(callUrl, AccessPath.LIMIT_PARAM, limit);
if (fetchPlan != null) {
appendQueryParameter(callUrl,

View File

@ -30,7 +30,7 @@ public class ResourceRegistryClientTest {
ResourceRegistryClient rrc = new StatelessBuilderImpl<EndpointReference, ResourceRegistryClient>(plugin).build();
String res = rrc.query("SELECT FROM V", null);
String res = rrc.query("SELECT FROM V", 0, null);
logger.debug(res);
}
}