diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java index bd82de3..a39bc1a 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java @@ -128,12 +128,20 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou } private void addOffset(Map queryParams) throws UnsupportedEncodingException{ + addOffset(queryParams, offset); + } + + private void addOffset(Map queryParams, Integer offset) throws UnsupportedEncodingException{ if(offset!=null) { queryParams.put(AccessPath.OFFSET_QUERY_PARAMETER, offset.toString()); } } private void addLimit(Map queryParams) throws UnsupportedEncodingException{ + addLimit(queryParams, limit); + } + + private void addLimit(Map queryParams, Integer limit) throws UnsupportedEncodingException{ if(limit!=null) { queryParams.put(AccessPath.LIMIT_QUERY_PARAMETER, limit.toString()); } @@ -143,7 +151,7 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou @Override public List renew() throws ResourceRegistryException { - return getAllContextFromServer(); + return getAllContextFromServer(0, BaseRequestInfo.UNBOUNDED_LIMIT); } }; @@ -186,7 +194,6 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou } - /** * It reads all the contexts from server. * The cache used for contexts is bypassed and not updated. @@ -194,6 +201,16 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou * @throws ResourceRegistryException */ public List getAllContextFromServer() throws ResourceRegistryException { + return getAllContextFromServer(offset, limit); + } + + /** + * It reads all the contexts from server. + * The cache used for contexts is bypassed and not updated. + * @return All Contexts read from server + * @throws ResourceRegistryException + */ + protected List getAllContextFromServer(Integer offset, Integer limit) throws ResourceRegistryException { try { logger.info("Going to read all {}s", Context.NAME); GXHTTPStringRequest gxHTTPStringRequest = getGXHTTPStringRequest(); @@ -203,8 +220,8 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou Map parameters = new HashMap<>(); addIncludeMeta(parameters); - addOffset(parameters); - addLimit(parameters); + addOffset(parameters, offset); + addLimit(parameters, limit); gxHTTPStringRequest.queryParams(parameters); HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();