From 5c957b25d2eabe6d5c6fbbda6c6dcc50f11c07c3 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Wed, 6 Mar 2019 13:47:27 +0000 Subject: [PATCH 1/2] Adding connection close to http4 endpoints --- .../connector/derivative/DerivativeConnector.java | 4 ++-- .../alpaca/indexing/fcrepo/FcrepoIndexer.java | 10 +++++----- .../indexing/triplestore/TriplestoreIndexer.java | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/islandora-connector-derivative/src/main/java/ca/islandora/alpaca/connector/derivative/DerivativeConnector.java b/islandora-connector-derivative/src/main/java/ca/islandora/alpaca/connector/derivative/DerivativeConnector.java index 1527d313..13bdb089 100644 --- a/islandora-connector-derivative/src/main/java/ca/islandora/alpaca/connector/derivative/DerivativeConnector.java +++ b/islandora-connector-derivative/src/main/java/ca/islandora/alpaca/connector/derivative/DerivativeConnector.java @@ -63,13 +63,13 @@ public void configure() { .setHeader("X-Islandora-Args", simple("${exchangeProperty.event.attachment.content.args}")) .setHeader("Apix-Ldp-Resource", simple("${exchangeProperty.event.attachment.content.sourceUri}")) .setBody(simple("${null}")) - .to("{{derivative.service.url}}") + .to("{{derivative.service.url}}?connectionClose=true") // PUT the media. .removeHeaders("*", "Authorization", "Content-Type") .setHeader("Content-Location", simple("${exchangeProperty.event.attachment.content.fileUploadUri}")) .setHeader(Exchange.HTTP_METHOD, constant("PUT")) - .toD("${exchangeProperty.event.attachment.content.destinationUri}"); + .toD("${exchangeProperty.event.attachment.content.destinationUri}?connectionClose=true"); } } diff --git a/islandora-indexing-fcrepo/src/main/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexer.java b/islandora-indexing-fcrepo/src/main/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexer.java index 14be670c..18adc7a1 100644 --- a/islandora-indexing-fcrepo/src/main/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexer.java +++ b/islandora-indexing-fcrepo/src/main/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexer.java @@ -137,7 +137,7 @@ public void configure() { .setBody(simple("${null}")) // Pass it to milliner. - .toD(getMillinerBaseUrl() + "node/${exchangeProperty.uuid}"); + .toD(getMillinerBaseUrl() + "node/${exchangeProperty.uuid}?connectionClose=true"); from("{{node.delete.stream}}") .routeId("FcrepoIndexerDeleteNode") @@ -164,7 +164,7 @@ public void configure() { .setBody(simple("${null}")) // Remove the file from Gemini. - .toD(getMillinerBaseUrl() + "node/${exchangeProperty.uuid}"); + .toD(getMillinerBaseUrl() + "node/${exchangeProperty.uuid}?connectionClose=true"); from("{{media.stream}}") .routeId("FcrepoIndexerMedia") @@ -184,7 +184,7 @@ public void configure() { .setBody(simple("${null}")) // Pass it to milliner. - .toD(getMillinerBaseUrl() + "media/${exchangeProperty.sourceField}"); + .toD(getMillinerBaseUrl() + "media/${exchangeProperty.sourceField}?connectionClose=true"); from("{{file.stream}}") .routeId("FcrepoIndexerFile") @@ -207,7 +207,7 @@ public void configure() { ) // Index the file in Gemini. - .toD(getGeminiBaseUrl() + "${exchangeProperty.uuid}"); + .toD(getGeminiBaseUrl() + "${exchangeProperty.uuid}?connectionClose=true"); from("{{file.delete.stream}}") .routeId("FcrepoIndexerFileDelete") @@ -225,7 +225,7 @@ public void configure() { .setBody(simple("${null}")) // Remove the file from Gemini. - .toD(getGeminiBaseUrl() + "${exchangeProperty.uuid}"); + .toD(getGeminiBaseUrl() + "${exchangeProperty.uuid}?connectionClose=true"); } } diff --git a/islandora-indexing-triplestore/src/main/java/ca/islandora/alpaca/indexing/triplestore/TriplestoreIndexer.java b/islandora-indexing-triplestore/src/main/java/ca/islandora/alpaca/indexing/triplestore/TriplestoreIndexer.java index 495cfc49..315268fb 100644 --- a/islandora-indexing-triplestore/src/main/java/ca/islandora/alpaca/indexing/triplestore/TriplestoreIndexer.java +++ b/islandora-indexing-triplestore/src/main/java/ca/islandora/alpaca/indexing/triplestore/TriplestoreIndexer.java @@ -59,11 +59,11 @@ public void configure() { .removeHeaders("*", "Authorization") .setHeader(Exchange.HTTP_METHOD, constant("GET")) .setBody(simple("${null}")) - .toD("${exchangeProperty.url}") + .toD("${exchangeProperty.url}&connectionClose=true") .setHeader(FCREPO_URI, simple("${exchangeProperty.url}")) .process(new SparqlUpdateProcessor()) .log(INFO, LOGGER, "Indexing ${exchangeProperty.url} in triplestore") - .to("{{triplestore.baseUrl}}"); + .to("{{triplestore.baseUrl}}?connectionClose=true"); from("{{delete.stream}}") .routeId("IslandoraTriplestoreIndexerDelete") @@ -71,7 +71,7 @@ public void configure() { .setHeader(FCREPO_URI, simple("${exchangeProperty.url}")) .process(new SparqlDeleteProcessor()) .log(INFO, LOGGER, "Deleting ${exchangeProperty.url} in triplestore") - .to("{{triplestore.baseUrl}}"); + .to("{{triplestore.baseUrl}}?connectionClose=true"); // Extracts the JSONLD URL from the event message and stores it on the exchange. from("direct:parse.url") From 27f53d4e2614f81641c4831f63b8aebe4babdc7d Mon Sep 17 00:00:00 2001 From: dannylamb Date: Wed, 6 Mar 2019 23:33:31 -0400 Subject: [PATCH 2/2] tests --- .../derivative/DerivativeConnectorTest.java | 4 ++-- .../indexing/fcrepo/FcrepoIndexerTest.java | 18 +++++++++++++----- .../triplestore/TriplestoreIndexerTest.java | 8 +++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/islandora-connector-derivative/src/test/java/ca/islandora/alpaca/connector/derivative/DerivativeConnectorTest.java b/islandora-connector-derivative/src/test/java/ca/islandora/alpaca/connector/derivative/DerivativeConnectorTest.java index d27da8aa..50094f16 100644 --- a/islandora-connector-derivative/src/test/java/ca/islandora/alpaca/connector/derivative/DerivativeConnectorTest.java +++ b/islandora-connector-derivative/src/test/java/ca/islandora/alpaca/connector/derivative/DerivativeConnectorTest.java @@ -66,7 +66,7 @@ public void configure() throws Exception { replaceFromWith("direct:start"); // Rig Drupal REST endpoint to return canned jsonld - interceptSendToEndpoint("http://example.org/derivative/convert") + interceptSendToEndpoint("http://example.org/derivative/convert?connectionClose=true") .skipSendToOriginalEndpoint() .process(exchange -> { exchange.getIn().removeHeaders("*", "Authorization"); @@ -74,7 +74,7 @@ public void configure() throws Exception { exchange.getIn().setBody("SOME DERIVATIVE", String.class); }); - mockEndpointsAndSkip("http://localhost:8000/node/2/media/image/3"); + mockEndpointsAndSkip("http://localhost:8000/node/2/media/image/3?connectionClose=true"); } }); context.start(); diff --git a/islandora-indexing-fcrepo/src/test/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexerTest.java b/islandora-indexing-fcrepo/src/test/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexerTest.java index 8633a0d2..bbcad6c3 100644 --- a/islandora-indexing-fcrepo/src/test/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexerTest.java +++ b/islandora-indexing-fcrepo/src/test/java/ca/islandora/alpaca/indexing/fcrepo/FcrepoIndexerTest.java @@ -59,7 +59,9 @@ public void testNode() throws Exception { @Override public void configure() throws Exception { replaceFromWith("direct:start"); - mockEndpointsAndSkip("http://localhost:8000/milliner/node/72358916-51e9-4712-b756-4b0404c91b1d"); + mockEndpointsAndSkip( + "http://localhost:8000/milliner/node/72358916-51e9-4712-b756-4b0404c91b1d?connectionClose=true" + ); } }); context.start(); @@ -92,7 +94,9 @@ public void testNodeDelete() throws Exception { @Override public void configure() throws Exception { replaceFromWith("direct:start"); - mockEndpointsAndSkip("http://localhost:8000/milliner/node/72358916-51e9-4712-b756-4b0404c91b1d"); + mockEndpointsAndSkip( + "http://localhost:8000/milliner/node/72358916-51e9-4712-b756-4b0404c91b1d?connectionClose=true" + ); } }); context.start(); @@ -124,7 +128,9 @@ public void testFile() throws Exception { @Override public void configure() throws Exception { replaceFromWith("direct:start"); - mockEndpointsAndSkip("http://localhost:8000/gemini/148dfe8f-9711-4263-97e7-3ef3fb15864f"); + mockEndpointsAndSkip( + "http://localhost:8000/gemini/148dfe8f-9711-4263-97e7-3ef3fb15864f?connectionClose=true" + ); } }); context.start(); @@ -161,7 +167,9 @@ public void testFileDelet() throws Exception { @Override public void configure() throws Exception { replaceFromWith("direct:start"); - mockEndpointsAndSkip("http://localhost:8000/gemini/148dfe8f-9711-4263-97e7-3ef3fb15864f"); + mockEndpointsAndSkip( + "http://localhost:8000/gemini/148dfe8f-9711-4263-97e7-3ef3fb15864f?connectionClose=true" + ); } }); context.start(); @@ -193,7 +201,7 @@ public void testMedia() throws Exception { @Override public void configure() throws Exception { replaceFromWith("direct:start"); - mockEndpointsAndSkip("http://localhost:8000/milliner/media/field_media_image"); + mockEndpointsAndSkip("http://localhost:8000/milliner/media/field_media_image?connectionClose=true"); } }); context.start(); diff --git a/islandora-indexing-triplestore/src/test/java/ca/islandora/alpaca/indexing/triplestore/TriplestoreIndexerTest.java b/islandora-indexing-triplestore/src/test/java/ca/islandora/alpaca/indexing/triplestore/TriplestoreIndexerTest.java index faa9eead..5f0df530 100644 --- a/islandora-indexing-triplestore/src/test/java/ca/islandora/alpaca/indexing/triplestore/TriplestoreIndexerTest.java +++ b/islandora-indexing-triplestore/src/test/java/ca/islandora/alpaca/indexing/triplestore/TriplestoreIndexerTest.java @@ -131,7 +131,7 @@ public void configure() throws Exception { replaceFromWith("direct:start"); // Rig Drupal REST endpoint to return canned jsonld - interceptSendToEndpoint("http://localhost:8000/node/1?_format=jsonld") + interceptSendToEndpoint("http://localhost:8000/node/1?_format=jsonld&connectionClose=true") .skipSendToOriginalEndpoint() .process(exchange -> { exchange.getIn().removeHeaders("*"); @@ -141,7 +141,9 @@ public void configure() throws Exception { String.class); }); - mockEndpointsAndSkip("http://localhost:8080/bigdata/namespace/islandora/sparql"); + mockEndpointsAndSkip( + "http://localhost:8080/bigdata/namespace/islandora/sparql?connectionClose=true" + ); } }); context.start(); @@ -181,7 +183,7 @@ public void testDelete() throws Exception { @Override public void configure() throws Exception { replaceFromWith("direct:start"); - mockEndpointsAndSkip("http://localhost:8080/bigdata/namespace/islandora/sparql"); + mockEndpointsAndSkip("http://localhost:8080/bigdata/namespace/islandora/sparql?connectionClose=true"); } }); context.start();