EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit 61293120 authored by Lubomir Dolezal's avatar Lubomir Dolezal
Browse files

Merge branch 'registrar-fixes' into 'staging'

Registrar fixes

See merge request !48
parents 6da4569f 63053a23
No related branches found
No related tags found
2 merge requests!49Production release 1.1.1,!48Registrar fixes
......@@ -32,11 +32,11 @@ class ReportingPostHandler:
<BROWSE_AVAILABILITY_DATETIME>{availability_time}</BROWSE_AVAILABILITY_DATETIME>
<URL>
<Service>WCS</Service>
<URL>{wms_capabilities_url}</URL>
<URL>{wcs_capabilities_url}</URL>
</URL>
<URL>
<Service>WMS</Service>
<URL>{wcs_capabilities_url}</URL>
<URL>{wms_capabilities_url}</URL>
</URL>
</DataAccessItem>
""".format(
......
import re
import logging
import importlib
from .source import get_source
from .scheme import get_scheme
......@@ -23,22 +22,27 @@ def register_file(config: dict, path: str, replace: bool=False):
for pre_handler in get_pre_handlers(config):
pre_handler(config, path, context)
for backend in get_backends(config, path):
if backend.exists(source, context):
if replace:
logger.info(f"Replacing '{path}'.")
backend.register(source, context, replace=True)
try:
for backend in get_backends(config, path):
if backend.exists(source, context):
if replace:
logger.info(f"Replacing '{path}'.")
backend.register(source, context, replace=True)
else:
raise RegistrationError(f'Object {context} is already registered')
else:
raise RegistrationError(f'Object {context} is already registered')
else:
logger.info(f"Registering '{path}'.")
backend.register(source, context, replace=False)
logger.info(f"Registering '{path}'.")
backend.register(source, context, replace=False)
except Exception as e:
for error_handler in get_error_handlers(config):
error_handler(config, path, context, e)
raise
else:
for post_handler in get_post_handlers(config):
post_handler(config, path, context)
for post_handler in get_post_handlers(config):
post_handler(config, path, context)
logger.info(f"Successfully {'replaced' if replace else 'registered'} '{path}'")
return context
logger.info(f"Successfully {'replaced' if replace else 'registered'} '{path}'")
return context
def _get_handlers(config, name):
......@@ -61,3 +65,7 @@ def get_pre_handlers(config):
def get_post_handlers(config):
return _get_handlers(config, 'post_handlers')
def get_error_handlers(config):
return _get_handlers(config, 'error_handlers')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment