Added missing query parameters to requests
This commit is contained in:
parent
6b8b2e780a
commit
64ec6c94d5
|
@ -133,7 +133,6 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
this.allMeta = allMeta;
|
||||
}
|
||||
|
||||
|
||||
private void addOptionalQueryParameters(Map<String,String> queryParams) throws UnsupportedEncodingException {
|
||||
addHierarchicalMode(queryParams);
|
||||
addIncludeContexts(queryParams);
|
||||
|
@ -208,6 +207,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
public ResourceRegistryPublisherImpl(String address, boolean sharedContextCache) {
|
||||
this.address = address;
|
||||
this.headers = new HashMap<>();
|
||||
this.hierarchicalMode = false;
|
||||
this.includeContexts = false;
|
||||
this.includeMeta = false;
|
||||
this.allMeta = false;
|
||||
if(sharedContextCache) {
|
||||
contextCache = ContextCache.getInstance();
|
||||
}else {
|
||||
|
@ -216,6 +219,12 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
contextCache.setContextCacheRenewal(contextCacheRenewal);
|
||||
}
|
||||
|
||||
/**
|
||||
* It reads all the contexts from server.
|
||||
* The cache used for contexts is bypassed and not updated.
|
||||
* @return All Contexts read from server
|
||||
* @throws ResourceRegistryException
|
||||
*/
|
||||
public List<Context> getAllContextFromServer() throws ResourceRegistryException {
|
||||
try {
|
||||
logger.info("Going to read all {}s", Context.NAME);
|
||||
|
@ -224,6 +233,11 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
|
||||
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
|
||||
|
||||
Map<String,String> parameters = new HashMap<>();
|
||||
addIncludeMeta(parameters);
|
||||
addIncludeAllMeta(parameters);
|
||||
gxHTTPStringRequest.queryParams(parameters);
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||
String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||
|
||||
|
@ -248,15 +262,32 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
return contextCache.getContexts();
|
||||
}
|
||||
|
||||
protected Context getContextFromServer(String id) throws ContextNotFoundException, ResourceRegistryException {
|
||||
/**
|
||||
* It reads the context from server.
|
||||
* The cache used for contexts is bypassed and not updated.
|
||||
* @param uuid
|
||||
* @return the Contexts read from server
|
||||
* @throws ContextNotFoundException
|
||||
* @throws ResourceRegistryException
|
||||
*/
|
||||
public Context getContextFromServer(UUID uuid) throws ContextNotFoundException, ResourceRegistryException {
|
||||
return getContextFromServer(uuid.toString());
|
||||
}
|
||||
|
||||
protected Context getContextFromServer(String uuid) throws ContextNotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
logger.info("Going to get current {} ", 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);
|
||||
gxHTTPStringRequest.path(id);
|
||||
gxHTTPStringRequest.path(uuid);
|
||||
|
||||
Map<String,String> parameters = new HashMap<>();
|
||||
addIncludeMeta(parameters);
|
||||
addIncludeAllMeta(parameters);
|
||||
gxHTTPStringRequest.queryParams(parameters);
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
|
||||
Context context = HTTPUtility.getResponse(Context.class, httpURLConnection);
|
||||
|
||||
|
@ -357,7 +388,12 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
gxHTTPStringRequest.path(type);
|
||||
gxHTTPStringRequest.path(uuid.toString());
|
||||
|
||||
includeAdditionalQueryParameters(gxHTTPStringRequest);
|
||||
Map<String,String> parameters = new HashMap<>();
|
||||
addIncludeContexts(parameters);
|
||||
addIncludeMeta(parameters);
|
||||
addIncludeAllMeta(parameters);
|
||||
gxHTTPStringRequest.queryParams(parameters);
|
||||
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.put(json);
|
||||
String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||
|
@ -595,7 +631,11 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
gxHTTPStringRequest.path(type);
|
||||
gxHTTPStringRequest.path(uuid.toString());
|
||||
|
||||
includeAdditionalQueryParameters(gxHTTPStringRequest);
|
||||
Map<String,String> parameters = new HashMap<>();
|
||||
addIncludeContexts(parameters);
|
||||
addIncludeMeta(parameters);
|
||||
addIncludeAllMeta(parameters);
|
||||
gxHTTPStringRequest.queryParams(parameters);
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.put(json);
|
||||
String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||
|
@ -870,7 +910,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
Boolean forceAddToContext = getCurrentContextUUID().compareTo(contextUUID)==0;
|
||||
queryParams.put(SharingPath.FORCE_ADD_TO_CONTEXT_QUERY_PARAMETER, forceAddToContext.toString());
|
||||
|
||||
includeAdditionalQueryParameters(gxHTTPStringRequest, queryParams);
|
||||
addIncludeMeta(queryParams);
|
||||
addIncludeAllMeta(queryParams);
|
||||
addIncludeContexts(queryParams);
|
||||
gxHTTPStringRequest.queryParams(queryParams);
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.post();
|
||||
String jsonArray = HTTPUtility.getResponse(String.class, httpURLConnection);
|
||||
|
@ -936,7 +979,10 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
queryParams.put(SharingPath.OPERATION_QUERY_PARAMETER, SharingOperation.REMOVE.name());
|
||||
queryParams.put(SharingPath.DRY_RUN_QUERY_QUERY_PARAMETER, dryRun.toString());
|
||||
|
||||
includeAdditionalQueryParameters(gxHTTPStringRequest, queryParams);
|
||||
addIncludeMeta(queryParams);
|
||||
addIncludeAllMeta(queryParams);
|
||||
addIncludeContexts(queryParams);
|
||||
gxHTTPStringRequest.queryParams(queryParams);
|
||||
|
||||
|
||||
HttpURLConnection httpURLConnection = gxHTTPStringRequest.post();
|
||||
|
|
Loading…
Reference in New Issue