|
| 1 | +## |
| 2 | +## © Copyright 2021- IBM Inc. All rights reserved |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | +## |
| 5 | + |
| 6 | + |
| 7 | +################################################################################################# |
| 8 | + |
| 9 | +# ENI/RELM application |
| 10 | + |
| 11 | +# |
| 12 | +# This is a skeleton implementation for ENI/RELM - just enough to support finding a project |
| 13 | +# |
| 14 | + |
| 15 | +################################################################################################# |
| 16 | + |
| 17 | +import logging |
| 18 | + |
| 19 | +import requests |
| 20 | +import lxml.etree as ET |
| 21 | +import tqdm |
| 22 | + |
| 23 | +from . import _app |
| 24 | +from . import _project |
| 25 | +from . import _typesystem |
| 26 | +from . import oslcqueryapi |
| 27 | +from . import rdfxml |
| 28 | +from . import server |
| 29 | +from . import utils |
| 30 | + |
| 31 | +logger = logging.getLogger(__name__) |
| 32 | + |
| 33 | +################################################################################################# |
| 34 | + |
| 35 | +class _RELMProject(_project._Project): |
| 36 | + def __init__(self, name, project_uri, app, is_optin=False, singlemode=False,defaultinit=False): |
| 37 | + super().__init__(name, project_uri, app, is_optin,singlemode, defaultinit=defaultinit) |
| 38 | + self.hooks = [] |
| 39 | + self._components = None # will become a dict keyed on component uri |
| 40 | + self._configurations = None # keyed on the config name |
| 41 | + self.default_query_resource = 'oslc_config:Configuration' |
| 42 | + |
| 43 | + |
| 44 | +################################################################################################# |
| 45 | + |
| 46 | +#@utils.mixinomatic |
| 47 | +class RELMApp(_app._App): |
| 48 | + domain = 'relm' |
| 49 | + project_class = _RELMProject |
| 50 | + supports_configs = False |
| 51 | + supports_components = False |
| 52 | + supports_reportable_rest = False |
| 53 | + |
| 54 | + relprefixes = ( |
| 55 | + ) |
| 56 | + |
| 57 | +# identifier_name = 'Short ID' |
| 58 | +# identifier_uri = 'Identifier' |
| 59 | + |
| 60 | + def __init__(self, server, contextroot, jts=None): |
| 61 | + super().__init__(server, contextroot, jts=jts) |
| 62 | + |
| 63 | + self.rootservices_xml = self.execute_get_xml(self.reluri('rootservices')) |
| 64 | +# self.serviceproviders = 'gc:globalConfigServiceProviders' |
| 65 | +# self.default_query_resource = 'oslc_config:Configuration' |
| 66 | + # register some app-specific namespaces |
| 67 | + for prefix,reluri in self.relprefixes: |
| 68 | + rdfxml.addprefix(prefix,self.baseurl+reluri) |
| 69 | + self.hooks = [] |
| 70 | + |
| 71 | + def _get_headers(self, headers=None): |
| 72 | + result = super()._get_headers() |
| 73 | + result['net.jazz.jfs.owning-context'] = self.baseurl |
| 74 | + if headers: |
| 75 | + result.update(headers) |
| 76 | + return result |
| 77 | + |
0 commit comments