Misc fixes 2020 09 23 (#540)
* fix OACov output headers, safeguard coverage plugin loading * fix ref, add query debug logging * normalize mimetypes
This commit is contained in:
+17
-9
@@ -511,9 +511,18 @@ class API:
|
||||
})
|
||||
if dataset is not None:
|
||||
LOGGER.debug('Creating extended coverage metadata')
|
||||
p = load_plugin('provider', get_provider_by_type(
|
||||
self.config['resources'][dataset]['providers'],
|
||||
'coverage'))
|
||||
try:
|
||||
p = load_plugin('provider', get_provider_by_type(
|
||||
self.config['resources'][dataset]['providers'],
|
||||
'coverage'))
|
||||
except ProviderConnectionError:
|
||||
exception = {
|
||||
'code': 'NoApplicableCode',
|
||||
'description': 'connection error (check logs)'
|
||||
}
|
||||
LOGGER.error(exception)
|
||||
return headers_, 500, to_json(exception,
|
||||
self.pretty_print)
|
||||
|
||||
collection['crs'] = [p.crs]
|
||||
collection['domainset'] = p.get_coverage_domainset()
|
||||
@@ -1341,10 +1350,10 @@ class API:
|
||||
mt = collection_def['format']['name']
|
||||
|
||||
if format_ == mt:
|
||||
headers_['Content-type'] = mt
|
||||
headers_['Content-Type'] = collection_def['format']['mimetype']
|
||||
return headers_, 200, data
|
||||
elif format_ == 'json':
|
||||
headers_['Content-type'] = 'application/prs.coverage+json'
|
||||
headers_['Content-Type'] = 'application/prs.coverage+json'
|
||||
return headers_, 200, to_json(data, self.pretty_print)
|
||||
else:
|
||||
exception = {
|
||||
@@ -1411,7 +1420,7 @@ class API:
|
||||
data['title'] = self.config['resources'][dataset]['title']
|
||||
content = render_j2_template(self.config, 'domainset.html',
|
||||
data)
|
||||
headers_['Content-type'] = 'text/html'
|
||||
headers_['Content-Type'] = 'text/html'
|
||||
return headers_, 200, content
|
||||
else:
|
||||
exception = {
|
||||
@@ -1471,14 +1480,13 @@ class API:
|
||||
return headers_, 500, to_json(exception, self.pretty_print)
|
||||
|
||||
if format_ == 'json':
|
||||
return ({'Content-type': 'application/json'},
|
||||
200, to_json(data, self.pretty_print))
|
||||
return (headers_, 200, to_json(data, self.pretty_print))
|
||||
elif format_ == 'html':
|
||||
data['id'] = dataset
|
||||
data['title'] = self.config['resources'][dataset]['title']
|
||||
content = render_j2_template(self.config, 'rangetype.html',
|
||||
data)
|
||||
headers_['Content-type'] = 'text/html'
|
||||
headers_['Content-Type'] = 'text/html'
|
||||
return headers_, 200, content
|
||||
else:
|
||||
exception = {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
# =================================================================
|
||||
|
||||
from collections import OrderedDict
|
||||
import json
|
||||
import logging
|
||||
|
||||
from elasticsearch import Elasticsearch, exceptions, helpers
|
||||
@@ -190,7 +191,7 @@ class ElasticsearchProvider(BaseProvider):
|
||||
filter_.append({'match': {time_field: datetime}})
|
||||
|
||||
LOGGER.debug(filter_)
|
||||
query['query']['bool']['filter'].append(filter_)
|
||||
query['query']['bool']['filter'].append(*filter_)
|
||||
|
||||
if properties:
|
||||
LOGGER.debug('processing properties')
|
||||
@@ -238,6 +239,7 @@ class ElasticsearchProvider(BaseProvider):
|
||||
query['_source']['includes'].append('geometry')
|
||||
try:
|
||||
LOGGER.debug('querying Elasticsearch')
|
||||
LOGGER.debug(json.dumps(query, indent=4))
|
||||
|
||||
LOGGER.debug('Setting ES paging zero-based')
|
||||
if startindex > 0:
|
||||
|
||||
Reference in New Issue
Block a user