aboutsummaryrefslogtreecommitdiffstats
path: root/graph-inventory
diff options
context:
space:
mode:
Diffstat (limited to 'graph-inventory')
-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
-rw-r--r--graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java5
-rw-r--r--graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java17
7 files changed, 54 insertions, 33 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();
diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java
index 36fc1db57c..68858de9a4 100644
--- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java
+++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIDSLQueryClientTest.java
@@ -1,7 +1,8 @@
package org.onap.aaiclient.client.aai;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.net.URISyntaxException;
+import org.javatuples.Pair;
import org.junit.Test;
public class AAIDSLQueryClientTest {
@@ -12,6 +13,6 @@ public class AAIDSLQueryClientTest {
public void verifyHeadersTest() throws URISyntaxException {
AAIDSLQueryClient client = new AAIDSLQueryClient();
- assertEquals("V2", client.getClient().getAdditionalHeaders().get("X-DslApiVersion"));
+ assertTrue(client.getClient().getAdditionalHeaders().get("ALL").contains(Pair.with("X-DslApiVersion", "V2")));
}
}
diff --git a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java
index d0f7847726..9b34095a23 100644
--- a/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java
+++ b/graph-inventory/aai-client/src/test/java/org/onap/aaiclient/client/aai/AAIRestClientTest.java
@@ -43,8 +43,9 @@ import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
-import java.util.HashMap;
+import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.Response;
+import org.javatuples.Pair;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -75,7 +76,7 @@ public class AAIRestClientTest {
@Test
public void failPatchOnComplexObject() throws URISyntaxException {
- AAIRestClient client = new AAIRestClient(props, new URI(""), new HashMap<String, String>());
+ AAIRestClient client = new AAIRestClient(props, new URI(""), new MultivaluedHashMap<>());
this.thrown.expect(GraphInventoryPatchDepthExceededException.class);
this.thrown.expectMessage(containsString("Object exceeds allowed depth for update action"));
client.patch(
@@ -84,7 +85,7 @@ public class AAIRestClientTest {
@Test
public void verifyPatchValidation() throws URISyntaxException {
- AAIRestClient client = new AAIRestClient(props, new URI(""), new HashMap<String, String>());
+ AAIRestClient client = new AAIRestClient(props, new URI(""), new MultivaluedHashMap<>());
AAIRestClient spy = spy(client);
GraphInventoryPatchConverter patchValidatorMock = mock(GraphInventoryPatchConverter.class);
doReturn(patchValidatorMock).when(spy).getPatchConverter();
@@ -97,11 +98,13 @@ public class AAIRestClientTest {
@Test
public void verifyAdditionalHeadersTest() throws URISyntaxException {
AAIRestClient client = new AAIRestClient(new DefaultAAIPropertiesImpl(wireMockRule.port()), new URI("/test"),
- ImmutableMap.of("test", "value"));
+ new MultivaluedHashMap<String, Pair<String, String>>(
+ ImmutableMap.of("ALL", Pair.with("test", "value"), "GET", Pair.with("get test", "value"))));
wireMockRule.stubFor(get(urlPathEqualTo("/test")).willReturn(aResponse().withStatus(200)));
client.get();
wireMockRule.verify(getRequestedFor(urlPathEqualTo("/test")).withHeader("X-FromAppId", equalTo("MSO"))
- .withHeader("X-TransactionId", matching(".*")).withHeader("test", equalTo("value")));
+ .withHeader("X-TransactionId", matching(".*")).withHeader("test", equalTo("value"))
+ .withHeader("get test", equalTo("value")));
}
@@ -145,7 +148,7 @@ public class AAIRestClientTest {
}
};
- RestClient client = new AAIRestClient(props, new URI("/cached"), new HashMap<String, String>());
+ RestClient client = new AAIRestClient(props, new URI("/cached"), new MultivaluedHashMap<>());
Response response = client.get();
@@ -199,7 +202,7 @@ public class AAIRestClientTest {
};
- RestClient client = new AAIRestClient(props, new URI("/cached/1"), new HashMap<String, String>());
+ RestClient client = new AAIRestClient(props, new URI("/cached/1"), new MultivaluedHashMap<>());
Response response = client.get();