From fe7a75e390c55436ed249d32627d78a105e4018b Mon Sep 17 00:00:00 2001 From: Jonas Bulcke <127748878+jobulcke@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:02:10 +0200 Subject: [PATCH] fix: same request is sent twice (#610) --- docs/_includes/ldio-core/rdf-writer.md | 13 ++++++++++--- docs/_ldio/ldio-outputs/ldio-http-out.md | 4 +++- .../ldes/ldio/LdioHttpOut.java | 16 +++++++++------- .../ldes/ldio/LdioLdesClientConnectorApi.java | 1 - 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/docs/_includes/ldio-core/rdf-writer.md b/docs/_includes/ldio-core/rdf-writer.md index 84090a7fa..8fc378bfa 100644 --- a/docs/_includes/ldio-core/rdf-writer.md +++ b/docs/_includes/ldio-core/rdf-writer.md @@ -1,12 +1,14 @@ -### Additional RDF Writer Properties +### RDF Writer Properties | Property | Description | Required | Default | Supported values | Example | |:------------------------|:-----------------------------------------------------------------|:---------|:------------|:------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------| | rdf-writer.content-type | Target content type. | No | text/turtle | Any type supported by [Apache Jena](https://jena.apache.org/documentation/io/rdf-input.html#determining-the-rdf-syntax) | application/ld+json | | rdf-writer.frame | Additional JSON-LD Frame to format the outputted JSON-LD Object. | No | N/A | Any valid JSON Object that describes a JSON-LD Frame | See https://www.w3.org/TR/json-ld11-framing/#sample-library-frame | -### RDF Writer Example +
+ Example RDF Writer config +
Format as N-Quads: ```yaml @@ -32,4 +34,9 @@ Format as JSON-LD with given frame: } } } -``` \ No newline at end of file +``` +
+ + +
+ diff --git a/docs/_ldio/ldio-outputs/ldio-http-out.md b/docs/_ldio/ldio-outputs/ldio-http-out.md index ecf9400da..97ddbb0b2 100644 --- a/docs/_ldio/ldio-outputs/ldio-http-out.md +++ b/docs/_ldio/ldio-outputs/ldio-http-out.md @@ -16,4 +16,6 @@ The LDIO HTTP Out is a basic Http Client that will send the given Linked Data mo |:-----------|:----------------------|:---------|:-------------|:----------------------------|:------------------------------------------------------| | endpoint | Target url. | Yes | N/A | http://example.com/endpoint | HTTP and HTTPS urls | -{% include ldio-core/rdf-writer.md %} \ No newline at end of file +{% include ldio-core/rdf-writer.md %} + +{% include ldio-core/http-requester.md %} \ No newline at end of file diff --git a/ldi-orchestrator/ldio-connectors/ldio-http-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpOut.java b/ldi-orchestrator/ldio-connectors/ldio-http-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpOut.java index 0af1be338..0acf57f06 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-http-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpOut.java +++ b/ldi-orchestrator/ldio-connectors/ldio-http-out/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioHttpOut.java @@ -41,13 +41,15 @@ public void accept(Model linkedDataModel) { final String contentType = rdfWriterProperties.getLang().getHeaderString(); final RequestHeader requestHeader = new RequestHeader(HttpHeaders.CONTENT_TYPE, contentType); final PostRequest request = new PostRequest(targetURL, new RequestHeaders(List.of(requestHeader)), output.toByteArray()); - Response response = requestExecutor.execute(request); - if (response.isSuccess()) { - log.debug("{} {} {}", request.getMethod(), request.getUrl(), response.getHttpStatus()); - } else { - log.atError().log("Failed to post model. The request url was {}. " + - "The http response obtained from the server has code {} and body \"{}\".", - response.getRequestedUrl(), response.getHttpStatus(), response.getBodyAsString().orElse(null)); + synchronized (requestExecutor) { + Response response = requestExecutor.execute(request); + if (response.isSuccess()) { + log.debug("{} {} {}", request.getMethod(), request.getUrl(), response.getHttpStatus()); + } else { + log.atError().log("Failed to post model. The request url was {}. " + + "The http response obtained from the server has code {} and body \"{}\".", + response.getRequestedUrl(), response.getHttpStatus(), response.getBodyAsString().orElse(null)); + } } } } diff --git a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java index ba061866b..feeb37f2c 100644 --- a/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java +++ b/ldi-orchestrator/ldio-connectors/ldio-ldes-client-connector/src/main/java/be/vlaanderen/informatievlaanderen/ldes/ldio/LdioLdesClientConnectorApi.java @@ -10,7 +10,6 @@ public class LdioLdesClientConnectorApi { private final TokenService tokenService; private final LdioLdesClient ldesClient; - @SuppressWarnings("java:S107") public LdioLdesClientConnectorApi(TransferService transferService, TokenService tokenService, LdioLdesClient ldesClient) { this.transferService = transferService; this.tokenService = tokenService;