Improved limit offset request for contexts
This commit is contained in:
parent
5189194b5e
commit
848d1ee835
|
@ -128,12 +128,20 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou
|
|||
}
|
||||
|
||||
private void addOffset(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
||||
addOffset(queryParams, offset);
|
||||
}
|
||||
|
||||
private void addOffset(Map<String,String> queryParams, Integer offset) throws UnsupportedEncodingException{
|
||||
if(offset!=null) {
|
||||
queryParams.put(AccessPath.OFFSET_QUERY_PARAMETER, offset.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void addLimit(Map<String,String> queryParams) throws UnsupportedEncodingException{
|
||||
addLimit(queryParams, limit);
|
||||
}
|
||||
|
||||
private void addLimit(Map<String,String> 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<Context> 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<Context> 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<Context> 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<String,String> parameters = new HashMap<>();
|
||||
addIncludeMeta(parameters);
|
||||
addOffset(parameters);
|
||||
addLimit(parameters);
|
||||
addOffset(parameters, offset);
|
||||
addLimit(parameters, limit);
|
||||
gxHTTPStringRequest.queryParams(parameters);
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||
|
|
Loading…
Reference in New Issue