From 5df6c19a24330f79abb65ef8e49e8d34c4235ff9 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 5 May 2023 12:12:30 +0200 Subject: [PATCH] Added missing query parameters to request --- .../client/ResourceRegistryClientImpl.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java index 73b8b11..4c41e54 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java @@ -221,6 +221,12 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { 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 getAllContextFromServer() throws ResourceRegistryException { try { 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.CONTEXTS_PATH_PART); + Map parameters = new HashMap<>(); + addIncludeMeta(parameters); + addIncludeAllMeta(parameters); + gxHTTPStringRequest.queryParams(parameters); + HttpURLConnection httpURLConnection = gxHTTPStringRequest.get(); String ret = HTTPUtility.getResponse(String.class, httpURLConnection); @@ -253,6 +264,18 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { 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 { try { 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(uuid); + Map parameters = new HashMap<>(); + addIncludeMeta(parameters); + addIncludeAllMeta(parameters); + gxHTTPStringRequest.queryParams(parameters); + HttpURLConnection httpURLConnection = gxHTTPStringRequest.get(); Context context = HTTPUtility.getResponse(Context.class, httpURLConnection); @@ -400,6 +428,8 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { gxHTTPStringRequest.path(typeName); Map parameters = new HashMap<>(); + addIncludeMeta(parameters); + addIncludeAllMeta(parameters); parameters.put(TypePath.POLYMORPHIC_QUERY_PARAMETER, polymorphic.toString()); gxHTTPStringRequest.queryParams(parameters); @@ -853,6 +883,11 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { gxHTTPStringRequest.path(AccessPath.ACCESS_PATH_PART); gxHTTPStringRequest.path(QueryTemplatePath.QUERY_TEMPLATES_PATH_PART); + Map parameters = new HashMap<>(); + addIncludeMeta(parameters); + addIncludeAllMeta(parameters); + gxHTTPStringRequest.queryParams(parameters); + HttpURLConnection httpURLConnection = gxHTTPStringRequest.get(); 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(queryTemplateName); + Map parameters = new HashMap<>(); + addIncludeMeta(parameters); + addIncludeAllMeta(parameters); + gxHTTPStringRequest.queryParams(parameters); + HttpURLConnection httpURLConnection = gxHTTPStringRequest.get(); 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(name); + includeAdditionalQueryParameters(gxHTTPStringRequest); + HttpURLConnection httpURLConnection = gxHTTPStringRequest.post(params); 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.QUERY_PATH_PART); + includeAdditionalQueryParameters(gxHTTPStringRequest); + HttpURLConnection httpURLConnection = gxHTTPStringRequest.post(query); String c = HTTPUtility.getResponse(String.class, httpURLConnection);