hierarchicalMode and includeContextsInHeader are now instance based
This commit is contained in:
parent
e9d110e5a1
commit
f711e95e7e
|
@ -34,6 +34,15 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaV
|
||||||
*/
|
*/
|
||||||
public interface ResourceRegistryPublisher {
|
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 List<Context> getAllContext() throws ResourceRegistryException;
|
||||||
|
|
||||||
public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException;
|
public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException;
|
||||||
|
|
|
@ -56,6 +56,30 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
|
|
||||||
protected final String address;
|
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)
|
private GXHTTPStringRequest includeAdditionalQueryParameters(GXHTTPStringRequest gxHTTPStringRequest)
|
||||||
throws UnsupportedEncodingException {
|
throws UnsupportedEncodingException {
|
||||||
return includeAdditionalQueryParameters(gxHTTPStringRequest, null);
|
return includeAdditionalQueryParameters(gxHTTPStringRequest, null);
|
||||||
|
@ -69,22 +93,22 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
|
|
||||||
private GXHTTPStringRequest checkHierarchicalMode(GXHTTPStringRequest gxHTTPStringRequest,
|
private GXHTTPStringRequest checkHierarchicalMode(GXHTTPStringRequest gxHTTPStringRequest,
|
||||||
Map<String, String> queryParams) throws UnsupportedEncodingException {
|
Map<String, String> queryParams) throws UnsupportedEncodingException {
|
||||||
if (ResourceRegistryPublisherFactory.isHierarchicalMode()) {
|
if(hierarchicalMode) {
|
||||||
if (queryParams == null) {
|
if(queryParams==null) {
|
||||||
queryParams = new HashMap<>();
|
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);
|
return gxHTTPStringRequest.queryParams(queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GXHTTPStringRequest checkIncludeContextsInInstanceHeader(GXHTTPStringRequest gxHTTPStringRequest,
|
private GXHTTPStringRequest checkIncludeContextsInInstanceHeader(GXHTTPStringRequest gxHTTPStringRequest,
|
||||||
Map<String, String> queryParams) throws UnsupportedEncodingException {
|
Map<String, String> queryParams) throws UnsupportedEncodingException {
|
||||||
if (ResourceRegistryPublisherFactory.includeContextsInInstanceHeader()) {
|
if(includeContextsInHeader) {
|
||||||
if (queryParams == null) {
|
if(queryParams==null) {
|
||||||
queryParams = new HashMap<>();
|
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);
|
return gxHTTPStringRequest.queryParams(queryParams);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue