Added support for paginated results

This commit is contained in:
luca.frosini 2023-11-09 18:29:16 +01:00
parent 3670c234a4
commit 88ef977959
4 changed files with 28 additions and 1 deletions

View File

@ -2,6 +2,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for Resource Registry Publisher # Changelog for Resource Registry Publisher
## [v4.5.0-SNAPSHOT]
- Added support for paginated results [#24648]
## [v4.4.0] ## [v4.4.0]
- Migrated code to reorganized E/R format [#24992] - Migrated code to reorganized E/R format [#24992]

View File

@ -9,7 +9,7 @@
<groupId>org.gcube.information-system</groupId> <groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-publisher</artifactId> <artifactId>resource-registry-publisher</artifactId>
<version>4.4.0</version> <version>4.5.0-SNAPSHOT</version>
<name>Resource Registry Publisher</name> <name>Resource Registry Publisher</name>
<description>Resource Registry Publisher is a library designed to interact with Resource Registry Instances APIs</description> <description>Resource Registry Publisher is a library designed to interact with Resource Registry Instances APIs</description>

View File

@ -10,6 +10,7 @@ import org.gcube.informationsystem.model.reference.entities.Facet;
import org.gcube.informationsystem.model.reference.entities.Resource; import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf; import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo; import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException; import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
@ -51,6 +52,8 @@ public interface ResourceRegistryPublisher extends RequestInfo {
public void addHeader(String name, String value); public void addHeader(String name, String value);
public ContextCache getContextCache();
/** /**
* Use {@link #getContexts()} instead * Use {@link #getContexts()} instead
* @return an array containing all contexts definition * @return an array containing all contexts definition

View File

@ -128,6 +128,18 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re
queryParams.put(AccessPath.INCLUDE_META_IN_ALL_INSTANCES_QUERY_PARAMETER, Boolean.toString(allMeta)); queryParams.put(AccessPath.INCLUDE_META_IN_ALL_INSTANCES_QUERY_PARAMETER, Boolean.toString(allMeta));
} }
} }
private void addOffset(Map<String,String> queryParams) throws UnsupportedEncodingException{
if(offset!=null) {
queryParams.put(AccessPath.OFFSET_QUERY_PARAMETER, offset.toString());
}
}
private void addLimit(Map<String,String> queryParams) throws UnsupportedEncodingException{
if(limit!=null) {
queryParams.put(AccessPath.LIMIT_QUERY_PARAMETER, limit.toString());
}
}
protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() { protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
@ -215,6 +227,11 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re
public List<Context> getContexts() throws ResourceRegistryException { public List<Context> getContexts() throws ResourceRegistryException {
return contextCache.getContexts(); return contextCache.getContexts();
} }
@Override
public ContextCache getContextCache() {
return contextCache;
}
/** /**
* It reads the context from server. * It reads the context from server.
@ -312,6 +329,8 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re
gxHTTPStringRequest.path(type); gxHTTPStringRequest.path(type);
Map<String,String> parameters = new HashMap<>(); Map<String,String> parameters = new HashMap<>();
addOffset(parameters);
addLimit(parameters);
parameters.put(InstancePath.POLYMORPHIC_QUERY_PARAMETER, polymorphic.toString()); parameters.put(InstancePath.POLYMORPHIC_QUERY_PARAMETER, polymorphic.toString());
includeAdditionalQueryParameters(gxHTTPStringRequest, parameters); includeAdditionalQueryParameters(gxHTTPStringRequest, parameters);