diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java index cd21cbf..7103daa 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java @@ -107,47 +107,59 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re private void addHierarchicalMode(Map queryParams) throws UnsupportedEncodingException{ if(hierarchicalMode) { - queryParams.put(AccessPath.HIERARCHICAL_MODE_QUERY_PARAMETER, Boolean.toString(hierarchicalMode)); + queryParams.put(InstancePath.HIERARCHICAL_MODE_QUERY_PARAMETER, Boolean.toString(hierarchicalMode)); } } private void addIncludeContexts(Map queryParams) throws UnsupportedEncodingException{ if(includeContexts) { - queryParams.put(AccessPath.INCLUDE_CONTEXTS_QUERY_PARAMETER, Boolean.toString(includeContexts)); + queryParams.put(InstancePath.INCLUDE_CONTEXTS_QUERY_PARAMETER, Boolean.toString(includeContexts)); } } private void addIncludeMeta(Map queryParams) throws UnsupportedEncodingException{ + addIncludeMeta(queryParams, includeMeta); + } + + private void addIncludeMeta(Map queryParams, boolean includeMeta) throws UnsupportedEncodingException{ if(includeMeta) { - queryParams.put(AccessPath.INCLUDE_META_QUERY_PARAMETER, Boolean.toString(includeMeta)); + queryParams.put(InstancePath.INCLUDE_META_QUERY_PARAMETER, Boolean.toString(includeMeta)); } } private void addIncludeAllMeta(Map queryParams) throws UnsupportedEncodingException{ if(allMeta) { - queryParams.put(AccessPath.INCLUDE_META_IN_ALL_INSTANCES_QUERY_PARAMETER, Boolean.toString(allMeta)); + queryParams.put(InstancePath.INCLUDE_META_IN_ALL_INSTANCES_QUERY_PARAMETER, Boolean.toString(allMeta)); } } 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()); + queryParams.put(InstancePath.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()); + queryParams.put(InstancePath.LIMIT_QUERY_PARAMETER, limit.toString()); } } protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() { - + @Override public List renew() throws ResourceRegistryException { - return getContextsFromServer(); + return getAllContextFromServer(true, 0, BaseRequestInfo.UNBOUNDED_LIMIT); } - + }; @Override @@ -186,16 +198,22 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re * @return All Contexts read from server * @throws ResourceRegistryException */ - public List getContextsFromServer() throws ResourceRegistryException { + public List getAllContextFromServer() throws ResourceRegistryException { + return getAllContextFromServer(includeMeta, offset, limit); + } + + protected List getAllContextFromServer(boolean includeMeta, Integer offset, Integer limit) throws ResourceRegistryException { try { logger.info("Going to read all {}s", Context.NAME); GXHTTPStringRequest gxHTTPStringRequest = getGXHTTPStringRequest(); gxHTTPStringRequest.header(ACCEPT_HTTP_HEADER_KEY, GXConnection.APPLICATION_JSON_CHARSET_UTF_8); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART); - + Map parameters = new HashMap<>(); - addIncludeMeta(parameters); + addIncludeMeta(parameters, includeMeta); + addOffset(parameters, offset); + addLimit(parameters, limit); gxHTTPStringRequest.queryParams(parameters); HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();