Skip to content

Commit

Permalink
fix: same request is sent twice (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
jobulcke authored Apr 24, 2024
1 parent 9bc74ed commit fe7a75e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
13 changes: 10 additions & 3 deletions docs/_includes/ldio-core/rdf-writer.md
Original file line number Diff line number Diff line change
@@ -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
<details>
<summary>Example RDF Writer config</summary>

<div markdown="1">
Format as N-Quads:

```yaml
Expand All @@ -32,4 +34,9 @@ Format as JSON-LD with given frame:
}
}
}
```
```
</div>
</details>
4 changes: 3 additions & 1 deletion docs/_ldio/ldio-outputs/ldio-http-out.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
{% include ldio-core/rdf-writer.md %}

{% include ldio-core/http-requester.md %}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fe7a75e

Please sign in to comment.