diff --git a/.python-stubs/auth_access.py b/.python-stubs/auth_access.py new file mode 100644 index 0000000000000000000000000000000000000000..27db7c351eb559518505db9e2c5763ea4c5c1319 --- /dev/null +++ b/.python-stubs/auth_access.py @@ -0,0 +1,11 @@ +import requests + +auth = requests.post("http://localhost/api/auth/realms/dbrepo/protocol/openid-connect/token", data={ + "username": "foo", + "password": "bar", + "grant_type": "password", + "client_id": "dbrepo-client", + "scope": "openid", + "client_secret": "MUwRc7yfXSJwX8AdRMWaQC3Nep1VjwgG" +}) +print(auth.json()["access_token"]) diff --git a/.python-stubs/auth_refresh.py b/.python-stubs/auth_refresh.py new file mode 100644 index 0000000000000000000000000000000000000000..8375ed4999061e7bf9acfdbcd4ef5dd8a727550f --- /dev/null +++ b/.python-stubs/auth_refresh.py @@ -0,0 +1,9 @@ +import requests + +auth = requests.post("http://localhost/api/auth/realms/dbrepo/protocol/openid-connect/token", data={ + "grant_type": "refresh_token", + "client_id": "dbrepo-client", + "client_secret": "MUwRc7yfXSJwX8AdRMWaQC3Nep1VjwgG", + "refresh_token": "THE_REFRESH_TOKEN" +}) +print(auth.json()["access_token"]) diff --git a/.python-stubs/publish_oauth2.py b/.python-stubs/publish_oauth2.py index 7d299f6644ba676cba66ec58badafe93d364741b..e67920773544aa31039aff29ee8b34de6ce6e576 100644 --- a/.python-stubs/publish_oauth2.py +++ b/.python-stubs/publish_oauth2.py @@ -1,21 +1,12 @@ -#!/bin/env python3 -import os - import pika -from dotenv import load_dotenv - -load_dotenv() - -if __name__ == "__main__": - token = os.getenv("TOKEN") - credentials = pika.credentials.PlainCredentials("", token) - parameters = pika.ConnectionParameters('localhost', 5672, '/', credentials) - connection = pika.BlockingConnection(parameters) - channel = connection.channel() - channel.queue_declare(queue='test', durable=True) - channel.basic_publish(exchange='', - routing_key='test', - body=b'Hello World!') - print(" [x] Sent 'Hello World!'") - connection.close() +credentials = pika.credentials.PlainCredentials("", "THE_ACCESS_TOKEN") +parameters = pika.ConnectionParameters('localhost', 5672, '/', credentials) +connection = pika.BlockingConnection(parameters) +channel = connection.channel() +channel.queue_declare(queue='test', durable=True) +channel.basic_publish(exchange='', + routing_key='test', + body=b'Hello World!') +print(" [x] Sent 'Hello World!'") +connection.close() diff --git a/.python-stubs/publish_plain.py b/.python-stubs/publish_plain.py new file mode 100644 index 0000000000000000000000000000000000000000..71b7f3811b0c179d6645dbabdb05005fe08f1afc --- /dev/null +++ b/.python-stubs/publish_plain.py @@ -0,0 +1,12 @@ +import pika + +credentials = pika.credentials.PlainCredentials("foo", "bar") +parameters = pika.ConnectionParameters('localhost', 5672, '/', credentials) +connection = pika.BlockingConnection(parameters) +channel = connection.channel() +channel.queue_declare(queue='test', durable=True) +channel.basic_publish(exchange='', + routing_key='test', + body=b'Hello World!') +print(" [x] Sent 'Hello World!'") +connection.close() diff --git a/.python-stubs/requirements.txt b/.python-stubs/requirements.txt index 80bcf81cb1962c64ff592312ea7b69e847084335..4053c0f69310255281766257eb440fd937b9a453 100644 --- a/.python-stubs/requirements.txt +++ b/.python-stubs/requirements.txt @@ -1,2 +1,3 @@ pika==1.3.1 -python-dotenv==1.0.0 \ No newline at end of file +python-dotenv==1.0.0 +requests==2.28.2 \ No newline at end of file diff --git a/dbrepo-broker-service/rabbitmq.conf b/dbrepo-broker-service/rabbitmq.conf index 34180dba38fe02a3eecaf36f9c63f7a4c72fc258..6b93149a71c2ee79baa1151ca186be7e4a9a7254 100644 --- a/dbrepo-broker-service/rabbitmq.conf +++ b/dbrepo-broker-service/rabbitmq.conf @@ -11,4 +11,4 @@ default_permissions.write = .* listeners.tcp.1 = 0.0.0.0:5672 # logging -log.file.level = warning \ No newline at end of file +log.file.level = warning diff --git a/dbrepo-metadata-service/rest-service/src/main/resources/application-docker.yml b/dbrepo-metadata-service/rest-service/src/main/resources/application-docker.yml deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/dbrepo-metadata-service/rest-service/src/main/resources/application-local.yml b/dbrepo-metadata-service/rest-service/src/main/resources/application-local.yml index fc3b8e3fb5df0de4a4f8e4d3959072ef598f5cbe..b5529e2975fa93116d76ac5200cf2011f71d74b7 100644 --- a/dbrepo-metadata-service/rest-service/src/main/resources/application-local.yml +++ b/dbrepo-metadata-service/rest-service/src/main/resources/application-local.yml @@ -20,6 +20,10 @@ spring: time_zone: UTC application: name: metadata-service + rabbitmq: + host: localhost + username: fda + password: fda cloud: loadbalancer.ribbon.enabled: false management.endpoints.web.exposure.include: health,info,prometheus diff --git a/dbrepo-metadata-service/services/src/main/java/at/tuwien/config/GatewayConfig.java b/dbrepo-metadata-service/services/src/main/java/at/tuwien/config/GatewayConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..4ab06fdf85d62394aaf1877a61b680233f870e6e --- /dev/null +++ b/dbrepo-metadata-service/services/src/main/java/at/tuwien/config/GatewayConfig.java @@ -0,0 +1,33 @@ +package at.tuwien.config; + +import lombok.Getter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.support.BasicAuthenticationInterceptor; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.DefaultUriBuilderFactory; + +@Getter +@Configuration +public class GatewayConfig { + + @Value("${fda.gateway.endpoint}") + private String gatewayEndpoint; + + @Value("${spring.rabbitmq.username}") + private String brokerUsername; + + @Value("${spring.rabbitmq.password}") + private String brokerPassword; + + @Bean("brokerRestTemplate") + public RestTemplate brokerRestTemplate() { + final RestTemplate restTemplate = new RestTemplate(); + restTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory(gatewayEndpoint)); + restTemplate.getInterceptors() + .add(new BasicAuthenticationInterceptor(brokerUsername, brokerPassword)); + return restTemplate; + } + +} diff --git a/dbrepo-semantics-service/Dockerfile b/dbrepo-semantics-service/Dockerfile index f1ccca7952c06126215e5141ce9693850ce94216..64a5a2844ba315cd331b97048a9989656493c071 100644 --- a/dbrepo-semantics-service/Dockerfile +++ b/dbrepo-semantics-service/Dockerfile @@ -28,7 +28,8 @@ HEALTHCHECK --interval=10s --timeout=5s --retries=12 CMD service_ready EXPOSE $PORT_APP -COPY ./us-yml/ ./us-yml/ +COPY ./us-yml ./us-yml +COPY ./ontologies ./ontologies COPY ./*.py ./ ENTRYPOINT [ "python", "-u", "./pywsgi.py" ] diff --git a/dbrepo-semantics-service/validate.py b/dbrepo-semantics-service/validate.py index 9ea0fa9c05f250db007e9af978dcf7521fa9b51a..50bba920abfa130f79b95778ec1f1b75127fe32e 100644 --- a/dbrepo-semantics-service/validate.py +++ b/dbrepo-semantics-service/validate.py @@ -8,15 +8,13 @@ Created on Thu Dec 2 23:31:39 2021 import rdflib import requests as rq -rdf = rq.get('http://www.ontology-of-units-of-measure.org/resource/om-2', headers={'Accept': 'application/rdf+xml'}) -rdf.raise_for_status() - -g = rdflib.Graph() -g.namespace_manager.bind('om', 'http://www.ontology-of-units-of-measure.org/resource/om-2/') -g.parse(data=rdf.text, format='xml') +# ontology of measure +u = rdflib.Graph() +u.namespace_manager.bind('om', 'http://www.ontology-of-units-of-measure.org/resource/om-2/') +u.namespace_manager.bind('schema', 'http://schema.org/') +u.parse('ontologies/om-2.rdf', format='xml') om = rdflib.Namespace('http://www.ontology-of-units-of-measure.org/resource/om-2/') -rdf_schema = rdflib.Namespace('http://www.w3.org/2000/01/rdf-schema#') # rdf = rq.get('http://qudt.org/2.1/vocab/unit', headers={'Accept': 'text/turtle'}) @@ -33,9 +31,9 @@ def validator(value): # input str tmp = str(om) + value t_uri = rdflib.term.URIRef(tmp) - if next(g.triples((t_uri, None, om.Unit)), _exhausted) is _exhausted and next( - g.triples((t_uri, None, om.PrefixedUnit)), _exhausted) is _exhausted and next( - g.triples((t_uri, None, None)), _exhausted) is _exhausted: + if next(u.triples((t_uri, None, om.Unit)), _exhausted) is _exhausted and next( + u.triples((t_uri, None, om.PrefixedUnit)), _exhausted) is _exhausted and next( + u.triples((t_uri, None, None)), _exhausted) is _exhausted: return False else: return True diff --git a/dbrepo-ui/Dockerfile b/dbrepo-ui/Dockerfile index bc7cd4d45674387f3ca32cb535e2cb42350c7c15..6fa3d4acf93c3259eb12274b4421c0939949babd 100644 --- a/dbrepo-ui/Dockerfile +++ b/dbrepo-ui/Dockerfile @@ -28,6 +28,7 @@ COPY ./api ./api COPY ./components ./components COPY ./lang ./lang COPY ./layouts ./layouts +COPY ./locales ./locales COPY ./pages ./pages COPY ./plugins ./plugins COPY ./server-middleware ./server-middleware