hierarchicalMode and includeContextsInHeader are now instance based

This commit is contained in:
Luca Frosini 2022-07-21 17:08:24 +02:00
parent e9d110e5a1
commit f711e95e7e
2 changed files with 39 additions and 6 deletions

View File

@ -34,6 +34,15 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaV
*/
public interface ResourceRegistryPublisher {
public boolean isHierarchicalMode();
public void setHierarchicalMode(boolean hierarchicalMode);
public boolean isIncludeContextsInHeader();
public void setIncludeContextsInHeader(boolean includeContextsInHeader);
public List<Context> getAllContext() throws ResourceRegistryException;
public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException;

View File

@ -56,6 +56,30 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
protected final String address;
protected boolean hierarchicalMode;
protected boolean includeContextsInHeader;
@Override
public boolean isHierarchicalMode() {
return hierarchicalMode;
}
@Override
public void setHierarchicalMode(boolean hierarchicalMode) {
this.hierarchicalMode = hierarchicalMode;
}
@Override
public boolean isIncludeContextsInHeader() {
return includeContextsInHeader;
}
@Override
public void setIncludeContextsInHeader(boolean includeContextsInHeader) {
this.includeContextsInHeader = includeContextsInHeader;
}
private GXHTTPStringRequest includeAdditionalQueryParameters(GXHTTPStringRequest gxHTTPStringRequest)
throws UnsupportedEncodingException {
return includeAdditionalQueryParameters(gxHTTPStringRequest, null);
@ -69,22 +93,22 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
private GXHTTPStringRequest checkHierarchicalMode(GXHTTPStringRequest gxHTTPStringRequest,
Map<String, String> queryParams) throws UnsupportedEncodingException {
if (ResourceRegistryPublisherFactory.isHierarchicalMode()) {
if (queryParams == null) {
if(hierarchicalMode) {
if(queryParams==null) {
queryParams = new HashMap<>();
}
queryParams.put(AccessPath.HIERARCHICAL_MODE_QUERY_PARAMETER, Boolean.toString(true));
queryParams.put(AccessPath.HIERARCHICAL_MODE_QUERY_PARAMETER, Boolean.toString(hierarchicalMode));
}
return gxHTTPStringRequest.queryParams(queryParams);
}
private GXHTTPStringRequest checkIncludeContextsInInstanceHeader(GXHTTPStringRequest gxHTTPStringRequest,
Map<String, String> queryParams) throws UnsupportedEncodingException {
if (ResourceRegistryPublisherFactory.includeContextsInInstanceHeader()) {
if (queryParams == null) {
if(includeContextsInHeader) {
if(queryParams==null) {
queryParams = new HashMap<>();
}
queryParams.put(AccessPath.INCLUDE_CONTEXTS_IN_HEADER_QUERY_PARAMETER, Boolean.toString(true));
queryParams.put(AccessPath.INCLUDE_CONTEXTS_IN_HEADER_QUERY_PARAMETER, Boolean.toString(includeContextsInHeader));
}
return gxHTTPStringRequest.queryParams(queryParams);
}