From 3c5b947c75b7366a475ea8f735bc33167c78498b Mon Sep 17 00:00:00 2001 From: Arnav Garg Date: Fri, 31 Aug 2018 19:15:29 +0530 Subject: [PATCH 1/3] Update Plugin.py When the query API was entered in the following form as shown below on CKAN, the result was not displayed 1) /v1/queryContext 2) /v1/contextEntities Orion can handle both uppercase and lowercase letters(queryContext, contextEntities), but NGSI view can handle in lowercase letters only. NGSI view compares API names in all lowercase letters(querycontext, contextentities). Also,in else part of function "setup_template_variables" - self.get_proxified_ngsi_url(data_dict) is called only in the case of different-domain and does not works properly in case of same-domain. --- ckanext/right_time_context/plugin.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ckanext/right_time_context/plugin.py b/ckanext/right_time_context/plugin.py index 5f36c55..6e2647a 100644 --- a/ckanext/right_time_context/plugin.py +++ b/ckanext/right_time_context/plugin.py @@ -39,7 +39,7 @@ def check_query(resource): - parsedurl = resource['url'] + parsedurl = resource['url'].lower() return parsedurl.find('/v2/entities') != -1 or parsedurl.find('/v1/querycontext') != -1 or parsedurl.find('/v1/contextentities/') != -1 @@ -140,8 +140,7 @@ def setup_template_variables(self, context, data_dict): view_enable = [False, details] url = '' else: - if not same_domain: - url = self.get_proxified_ngsi_url(data_dict) + url = self.get_proxified_ngsi_url(data_dict) if resource['auth_type'] != 'none' and not p.toolkit.c.user: details = "

In order to see this resource properly, you need to be logged in.


" From 77cdd2b7d50485ed864528c0a868e13b9fd99c0f Mon Sep 17 00:00:00 2001 From: Arnav Garg Date: Fri, 31 Aug 2018 19:17:35 +0530 Subject: [PATCH 2/3] Updated controller.py When the query API was entered in the following form as shown below on CKAN, the result was not displayed 1) /v1/queryContext 2) /v1/contextEntities Orion can handle both uppercase and lowercase letters(queryContext, contextEntities), but NGSI view can handle in lowercase letters only. NGSI view compares API names in all lowercase letters(querycontext, contextentities). --- ckanext/right_time_context/controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/right_time_context/controller.py b/ckanext/right_time_context/controller.py index 2958d66..a599316 100644 --- a/ckanext/right_time_context/controller.py +++ b/ckanext/right_time_context/controller.py @@ -42,7 +42,7 @@ class ProxyNGSIController(base.BaseController): def _proxy_query_resource(self, resource, parsed_url, headers, verify=True): - if parsed_url.path.find('/v1/queryContext') != -1: + if parsed_url.path.lower().find('/v1/querycontext') != -1: if resource.get("payload", "").strip() == "": details = 'Please add a payload to complete the query.' base.abort(409, detail=details) From 94e7b7aaed0c79ef3d616aeedee1ee9d303eaf2d Mon Sep 17 00:00:00 2001 From: Arnav Garg Date: Fri, 31 Aug 2018 19:19:34 +0530 Subject: [PATCH 3/3] updated resource_form.html When the query API was entered in the following form as shown below on CKAN, the result was not displayed 1) /v1/queryContext 2) /v1/contextEntities Orion can handle both uppercase and lowercase letters(queryContext, contextEntities), but NGSI view can handle in lowercase letters only. NGSI view compares API names in all lowercase letters(querycontext, contextentities). --- .../templates/package/snippets/resource_form.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/right_time_context/templates/package/snippets/resource_form.html b/ckanext/right_time_context/templates/package/snippets/resource_form.html index 37e0983..b93fa48 100644 --- a/ckanext/right_time_context/templates/package/snippets/resource_form.html +++ b/ckanext/right_time_context/templates/package/snippets/resource_form.html @@ -142,7 +142,7 @@ } } - if (url.pathname.indexOf('/v1/queryContext') !== -1) { + if (url.pathname.toLowerCase().indexOf('/v1/querycontext') !== -1) { $('.ngsiview-v1').removeClass('hidden'); } else { $('.ngsiview-v1').addClass('hidden');