diff --git a/CHANGELOG.md b/CHANGELOG.md index 780f51e2..188e2269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Alfred API - Changelog +* [ALFREDAPI-563](https://xenitsupport.jira.com/browse/ALFREDAPI-563) Fix @GetMapping(value = "/v1/nodes/{space}/{store}/{guid}/content") Content-Type + ## 6.0.0 (2024-08-22) From this version onward Dynamic Extensions for integration-testing is replaced by [remote-junit](https://github.com/ruediste/remote-junit) diff --git a/alfred-api-integrationtests-client/alfresco/src/main/java/eu/xenit/alfred/api/rest/v1/tests/NodeContentTest.java b/alfred-api-integrationtests-client/alfresco/src/main/java/eu/xenit/alfred/api/rest/v1/tests/NodeContentTest.java index 1b21dcab..46b6bb09 100644 --- a/alfred-api-integrationtests-client/alfresco/src/main/java/eu/xenit/alfred/api/rest/v1/tests/NodeContentTest.java +++ b/alfred-api-integrationtests-client/alfresco/src/main/java/eu/xenit/alfred/api/rest/v1/tests/NodeContentTest.java @@ -79,6 +79,31 @@ public void testSetNodeContent() { } }, false, true); assertEquals("This is the content", content); + + String contentHeader = transactionService.getRetryingTransactionHelper() + .doInTransaction(() -> { + ContentInputStream c = ns.getContent(nodeRef); + return c.getMimetype(); + }, false, true); + assertEquals("text/plain", contentHeader); + + // Test the Content-Header of the set file via GET method. + transactionService.getRetryingTransactionHelper() + .doInTransaction(() -> { + HttpGet httpGet = new HttpGet(url); + + try (CloseableHttpResponse response = httpclient.execute(httpGet)) { + assertEquals(200, response.getStatusLine().getStatusCode()); + InputStream inputStream = response.getEntity().getContent(); + assertEquals("This is the content", + IOUtils.toString(inputStream, Charset.defaultCharset())); + ContentInputStream c = ns.getContent(nodeRef); + assertEquals("text/plain", + c.getMimetype()); + inputStream.close(); + } + return null; + }, false, true); } @Test diff --git a/alfred-api-rest/src/main/java/eu/xenit/alfred/api/rest/v1/nodes/NodesWebscript1.java b/alfred-api-rest/src/main/java/eu/xenit/alfred/api/rest/v1/nodes/NodesWebscript1.java index 3aa7595f..054fcfb3 100644 --- a/alfred-api-rest/src/main/java/eu/xenit/alfred/api/rest/v1/nodes/NodesWebscript1.java +++ b/alfred-api-rest/src/main/java/eu/xenit/alfred/api/rest/v1/nodes/NodesWebscript1.java @@ -509,6 +509,7 @@ public ResponseEntity getContent(@PathVariable String space, @PathVariable St return writeNotFoundResponse(nodeRef); } return ResponseEntity.ok() + .header("Content-Type", contentInputStream.getMimetype()) .body(new InputStreamResource(contentInputStream.getInputStream())); }