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
## [v4.5.0-SNAPSHOT]
- Added support for paginated results [#24648]
## [v4.4.0]
- Migrated code to reorganized E/R format [#24992]

View File

@ -9,7 +9,7 @@
<groupId>org.gcube.information-system</groupId>
<artifactId>resource-registry-publisher</artifactId>
<version>4.4.0</version>
<version>4.5.0-SNAPSHOT</version>
<name>Resource Registry Publisher</name>
<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.relations.ConsistsOf;
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.AvailableInAnotherContextException;
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 ContextCache getContextCache();
/**
* Use {@link #getContexts()} instead
* @return an array containing all contexts definition

View File

@ -129,6 +129,18 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re
}
}
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() {
@Override
@ -216,6 +228,11 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re
return contextCache.getContexts();
}
@Override
public ContextCache getContextCache() {
return contextCache;
}
/**
* It reads the context from server.
* The cache used for contexts is bypassed and not updated.
@ -312,6 +329,8 @@ public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements Re
gxHTTPStringRequest.path(type);
Map<String,String> parameters = new HashMap<>();
addOffset(parameters);
addLimit(parameters);
parameters.put(InstancePath.POLYMORPHIC_QUERY_PARAMETER, polymorphic.toString());
includeAdditionalQueryParameters(gxHTTPStringRequest, parameters);