summaryrefslogtreecommitdiffstats
path: root/graph-inventory/aai-client/src/main
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@att.com>2021-01-28 13:12:40 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2021-02-01 17:45:32 -0500
commitdd89e148932ba0acbfc6ceb4b229b001b6b8dd33 (patch)
treee377fce20812d390a07eab5d12665fe3e1903a1f /graph-inventory/aai-client/src/main
parentb8b0464aa8a05a345115264084b08229f35c8413 (diff)
allow RestClient to configure custom headers
allow RestClient to configure custom headers always load the first implementation on the classpath Issue-ID: SO-3495 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I9c433cdaed33a7db6182af259421676c088a1fae
Diffstat (limited to 'graph-inventory/aai-client/src/main')
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java13
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java9
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java24
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java14
-rw-r--r--graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java5
5 files changed, 41 insertions, 24 deletions
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java
index 1f747e6c8c..fc5ef86e56 100644
--- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIClient.java
@@ -21,10 +21,11 @@
package org.onap.aaiclient.client.aai;
import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
import javax.ws.rs.NotFoundException;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriBuilder;
+import org.javatuples.Pair;
import org.onap.aaiclient.client.graphinventory.GraphInventoryClient;
import org.onap.aaiclient.client.graphinventory.exceptions.GraphInventoryUriComputationException;
import org.onap.so.client.RestClient;
@@ -38,19 +39,19 @@ public class AAIClient extends GraphInventoryClient {
protected AAIVersion version;
protected AAIClient() {
- super(AAIProperties.class, new HashMap<String, String>());
+ super(AAIProperties.class, new MultivaluedHashMap<>());
}
protected AAIClient(AAIVersion version) {
- super(AAIProperties.class, new HashMap<String, String>());
+ super(AAIProperties.class, new MultivaluedHashMap<>());
this.version = version;
}
- protected AAIClient(Map<String, String> additionalHeaders) {
+ protected AAIClient(MultivaluedMap<String, Pair<String, String>> additionalHeaders) {
super(AAIProperties.class, additionalHeaders);
}
- protected AAIClient(AAIVersion version, Map<String, String> additionalHeaders) {
+ protected AAIClient(AAIVersion version, MultivaluedMap<String, Pair<String, String>> additionalHeaders) {
super(AAIProperties.class, additionalHeaders);
this.version = version;
}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java
index 8b8707e533..d894a0fa0d 100644
--- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIDSLQueryClient.java
@@ -20,6 +20,8 @@
package org.onap.aaiclient.client.aai;
+import javax.ws.rs.core.MultivaluedHashMap;
+import org.javatuples.Pair;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.aai.entities.uri.AAIFluentTypeReverseLookup;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
@@ -33,11 +35,14 @@ public class AAIDSLQueryClient
extends GraphInventoryQueryClient<AAIDSLQueryClient, DSLQuery, AAIResultWrapper, AAIObjectType> {
public AAIDSLQueryClient() {
- super(new AAIClient(ImmutableMap.of("X-DslApiVersion", "V2")));
+ super(new AAIClient(new MultivaluedHashMap<String, Pair<String, String>>(
+ ImmutableMap.of("ALL", Pair.with("X-DslApiVersion", "V2")))));
+
}
public AAIDSLQueryClient(AAIVersion version) {
- super(new AAIClient(version, ImmutableMap.of("X-DslApiVersion", "V2")));
+ super(new AAIClient(version, new MultivaluedHashMap<String, Pair<String, String>>(
+ ImmutableMap.of("ALL", Pair.with("X-DslApiVersion", "V2")))));
}
@Override
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java
index 0f69b0cc8f..df124efe9a 100644
--- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIRestClient.java
@@ -21,8 +21,9 @@
package org.onap.aaiclient.client.aai;
import java.net.URI;
-import java.util.Map;
import java.util.Optional;
+import javax.ws.rs.core.MultivaluedMap;
+import org.javatuples.Pair;
import org.onap.aaiclient.client.graphinventory.GraphInventoryPatchConverter;
import org.onap.aaiclient.client.graphinventory.GraphInventoryRestClient;
import org.onap.logging.filter.base.ONAPComponents;
@@ -31,9 +32,10 @@ import org.onap.so.client.ResponseExceptionMapper;
public class AAIRestClient extends GraphInventoryRestClient {
private final AAIProperties aaiProperties;
- private final Map<String, String> additionalHeaders;
+ private final MultivaluedMap<String, Pair<String, String>> additionalHeaders;
- protected AAIRestClient(AAIProperties props, URI uri, Map<String, String> additionalHeaders) {
+ protected AAIRestClient(AAIProperties props, URI uri,
+ MultivaluedMap<String, Pair<String, String>> additionalHeaders) {
super(props, uri);
this.aaiProperties = props;
this.additionalHeaders = additionalHeaders;
@@ -45,16 +47,24 @@ public class AAIRestClient extends GraphInventoryRestClient {
}
@Override
- protected void initializeHeaderMap(Map<String, String> headerMap) {
- headerMap.put("X-FromAppId", aaiProperties.getSystemName());
- headerMap.put("X-TransactionId", requestId);
- headerMap.putAll(additionalHeaders);
+ protected void initializeHeaderMap(MultivaluedMap<String, Pair<String, String>> headerMap) {
+ headerMap.add("ALL", Pair.with("X-FromAppId", aaiProperties.getSystemName()));
+ headerMap.add("ALL", Pair.with("X-TransactionId", requestId));
+ additionalHeaders.forEach((k, v) -> {
+ headerMap.addAll(k, v);
+ });
String auth = aaiProperties.getAuth();
String key = aaiProperties.getKey();
if (auth != null && !auth.isEmpty() && key != null && !key.isEmpty()) {
addBasicAuthHeader(auth, key);
}
+
+ if (!aaiProperties.additionalHeaders().isEmpty()) {
+ aaiProperties.additionalHeaders().forEach((k, v) -> {
+ headerMap.addAll(k, v);
+ });
+ }
}
@Override
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java
index f8f977d117..af875fa274 100644
--- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryClient.java
@@ -21,22 +21,22 @@
package org.onap.aaiclient.client.graphinventory;
import java.net.URI;
-import java.util.Map;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import org.javatuples.Pair;
import org.onap.aaiclient.client.graphinventory.entities.uri.GraphInventoryUri;
import org.onap.aaiclient.client.graphinventory.entities.uri.HttpAwareUri;
import org.onap.so.client.RestClient;
import org.onap.so.client.RestProperties;
import org.onap.so.client.RestPropertiesLoader;
-import com.google.common.collect.ImmutableMap;
public abstract class GraphInventoryClient {
private RestProperties props;
- protected final Map<String, String> additionalHeaders;
+ protected final MultivaluedMap<String, Pair<String, String>> additionalHeaders;
protected GraphInventoryClient(Class<? extends RestProperties> propertiesClass,
- Map<String, String> additionalHeaders) {
-
+ MultivaluedMap<String, Pair<String, String>> additionalHeaders) {
RestProperties props = RestPropertiesLoader.getInstance().getNewImpl(propertiesClass);
this.props = props;
this.additionalHeaders = additionalHeaders;
@@ -70,7 +70,7 @@ public abstract class GraphInventoryClient {
public abstract String getGraphDBName();
- public Map<String, String> getAdditionalHeaders() {
- return ImmutableMap.copyOf(this.additionalHeaders);
+ public MultivaluedMap<String, Pair<String, String>> getAdditionalHeaders() {
+ return new MultivaluedHashMap<>(this.additionalHeaders);
}
}
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java
index c22f2f5f8e..6ccd1a2cab 100644
--- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java
+++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/graphinventory/GraphInventoryRestClient.java
@@ -21,10 +21,11 @@
package org.onap.aaiclient.client.graphinventory;
import java.net.URI;
-import java.util.Map;
import java.util.Optional;
import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
+import org.javatuples.Pair;
import org.onap.aaiclient.client.CacheControlFeature;
import org.onap.aaiclient.client.FlushCache;
import org.onap.logging.filter.base.ONAPComponentsList;
@@ -65,7 +66,7 @@ public abstract class GraphInventoryRestClient extends RestClientSSL {
public abstract ONAPComponentsList getTargetEntity();
@Override
- protected abstract void initializeHeaderMap(Map<String, String> headerMap);
+ protected abstract void initializeHeaderMap(MultivaluedMap<String, Pair<String, String>> headerMap);
@Override
protected abstract Optional<ResponseExceptionMapper> addResponseExceptionMapper();