summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrenealr <reneal.rogers@amdocs.com>2018-11-07 12:05:07 -0500
committerrenealr <reneal.rogers@amdocs.com>2018-11-07 12:05:39 -0500
commitefc67e7a519560ff3e26de18f2f973d884bfbfc7 (patch)
tree5ad75f057c911041f144b604e765bae87c9913de
parentf3dbccd386d36df1936d3a3ea6a6a5daa9262214 (diff)
fix bulk api to support secure rest calls to an ES
implement client authorization when performing bulk request to a secure ES update content type support by ES Issue-ID: AAI-1883 Change-Id: I72bd3af0af4680b55fd74c6e7fbd77990fa0ee5b Signed-off-by: renealr <reneal.rogers@amdocs.com>
-rw-r--r--src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java b/src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java
index 6087488..716814b 100644
--- a/src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java
+++ b/src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java
@@ -53,6 +53,7 @@ import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriBuilder;
import org.eclipse.jetty.http.HttpStatus;
@@ -127,6 +128,7 @@ public class ElasticSearchHttpController implements DocumentStoreInterface {
"{\"index\":{\"_index\":\"%s\",\"_type\":\"%s\",\"_id\":\"%s\", \"_version\":\"%s\"}}\n";
private static final String BULK_DELETE_TEMPLATE =
"{ \"delete\": { \"_index\": \"%s\", \"_type\": \"%s\", \"_id\": \"%s\", \"_version\":\"%s\"}}\n";
+ public final static String APPLICATION_XND_JSON_TYPE = new MediaType("application", "x-ndjson").toString();
private final ElasticSearchConfig config;
@@ -501,7 +503,10 @@ public class ElasticSearchHttpController implements DocumentStoreInterface {
conn = (HttpURLConnection) buildUrl(createUriBuilder("_bulk")).openConnection();
conn.setRequestMethod(HttpMethod.PUT);
conn.setDoOutput(true);
- conn.setRequestProperty(CONTENT_TYPE, APPLICATION_FORM_URLENCODED);
+ conn.setRequestProperty(CONTENT_TYPE, APPLICATION_XND_JSON_TYPE);
+ if(config.useAuth()){
+ conn.setRequestProperty("Authorization", config.getAuthValue());
+ }
conn.setRequestProperty("Connection", "Close");
} catch (IOException e) {