Added missing query parameters to request

This commit is contained in:
Luca Frosini 2023-05-05 12:12:30 +02:00
parent c933cc3f85
commit 5df6c19a24
1 changed files with 44 additions and 0 deletions

View File

@ -221,6 +221,12 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
contextCache.setContextCacheRenewal(contextCacheRenewal); 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 { public List<Context> getAllContextFromServer() throws ResourceRegistryException {
try { try {
logger.info("Going to read all {}s", Context.NAME); logger.info("Going to read all {}s", Context.NAME);
@ -229,6 +235,11 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
gxHTTPStringRequest.path(AccessPath.CONTEXTS_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(); HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
String ret = HTTPUtility.getResponse(String.class, httpURLConnection); String ret = HTTPUtility.getResponse(String.class, httpURLConnection);
@ -253,6 +264,18 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
return contextCache.getContexts(); return contextCache.getContexts();
} }
/**
* 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 { protected Context getContextFromServer(String uuid) throws ContextNotFoundException, ResourceRegistryException {
try { try {
logger.info("Going to get current {} ", Context.NAME); logger.info("Going to get current {} ", Context.NAME);
@ -262,6 +285,11 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART); gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
gxHTTPStringRequest.path(uuid); gxHTTPStringRequest.path(uuid);
Map<String,String> parameters = new HashMap<>();
addIncludeMeta(parameters);
addIncludeAllMeta(parameters);
gxHTTPStringRequest.queryParams(parameters);
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get(); HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
Context context = HTTPUtility.getResponse(Context.class, httpURLConnection); Context context = HTTPUtility.getResponse(Context.class, httpURLConnection);
@ -400,6 +428,8 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
gxHTTPStringRequest.path(typeName); gxHTTPStringRequest.path(typeName);
Map<String,String> parameters = new HashMap<>(); Map<String,String> parameters = new HashMap<>();
addIncludeMeta(parameters);
addIncludeAllMeta(parameters);
parameters.put(TypePath.POLYMORPHIC_QUERY_PARAMETER, polymorphic.toString()); parameters.put(TypePath.POLYMORPHIC_QUERY_PARAMETER, polymorphic.toString());
gxHTTPStringRequest.queryParams(parameters); gxHTTPStringRequest.queryParams(parameters);
@ -853,6 +883,11 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
gxHTTPStringRequest.path(QueryTemplatePath.QUERY_TEMPLATES_PATH_PART); gxHTTPStringRequest.path(QueryTemplatePath.QUERY_TEMPLATES_PATH_PART);
Map<String,String> parameters = new HashMap<>();
addIncludeMeta(parameters);
addIncludeAllMeta(parameters);
gxHTTPStringRequest.queryParams(parameters);
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get(); HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
String all = HTTPUtility.getResponse(String.class, httpURLConnection); String all = HTTPUtility.getResponse(String.class, httpURLConnection);
@ -929,6 +964,11 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
gxHTTPStringRequest.path(QueryTemplatePath.QUERY_TEMPLATES_PATH_PART); gxHTTPStringRequest.path(QueryTemplatePath.QUERY_TEMPLATES_PATH_PART);
gxHTTPStringRequest.path(queryTemplateName); gxHTTPStringRequest.path(queryTemplateName);
Map<String,String> parameters = new HashMap<>();
addIncludeMeta(parameters);
addIncludeAllMeta(parameters);
gxHTTPStringRequest.queryParams(parameters);
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get(); HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
String c = HTTPUtility.getResponse(String.class, httpURLConnection); String c = HTTPUtility.getResponse(String.class, httpURLConnection);
@ -987,6 +1027,8 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
gxHTTPStringRequest.path(QueryTemplatePath.QUERY_TEMPLATES_PATH_PART); gxHTTPStringRequest.path(QueryTemplatePath.QUERY_TEMPLATES_PATH_PART);
gxHTTPStringRequest.path(name); gxHTTPStringRequest.path(name);
includeAdditionalQueryParameters(gxHTTPStringRequest);
HttpURLConnection httpURLConnection = gxHTTPStringRequest.post(params); HttpURLConnection httpURLConnection = gxHTTPStringRequest.post(params);
String c = HTTPUtility.getResponse(String.class, httpURLConnection); String c = HTTPUtility.getResponse(String.class, httpURLConnection);
@ -1031,6 +1073,8 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART);
gxHTTPStringRequest.path(AccessPath.QUERY_PATH_PART); gxHTTPStringRequest.path(AccessPath.QUERY_PATH_PART);
includeAdditionalQueryParameters(gxHTTPStringRequest);
HttpURLConnection httpURLConnection = gxHTTPStringRequest.post(query); HttpURLConnection httpURLConnection = gxHTTPStringRequest.post(query);
String c = HTTPUtility.getResponse(String.class, httpURLConnection); String c = HTTPUtility.getResponse(String.class, httpURLConnection);