summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.aai/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors/actor.aai/src/main')
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java39
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java36
2 files changed, 60 insertions, 15 deletions
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
index 613b6689d..5b4aa0527 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
@@ -21,8 +21,11 @@
package org.onap.policy.controlloop.actor.aai;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture;
import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import lombok.Getter;
@@ -54,6 +57,7 @@ public class AaiCustomQueryOperation extends HttpOperation<String> {
public static final String RESOURCE_LINK = "resource-link";
public static final String RESULT_DATA = "result-data";
+ // TODO make this configurable
private static final String PREFIX = "/aai/v16";
@Getter
@@ -89,21 +93,38 @@ public class AaiCustomQueryOperation extends HttpOperation<String> {
@Override
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
- Map<String, String> request = makeRequest();
+ final Map<String, String> request = makeRequest();
+ Map<String, Object> headers = makeHeaders();
- Entity<Map<String, String>> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
+ StringBuilder str = new StringBuilder(getClient().getBaseUrl());
- Map<String, Object> headers = makeHeaders();
+ String path = getPath();
+ WebTarget web = getClient().getWebTarget().path(path);
+ str.append(path);
+
+ web = addQuery(web, str, "?", "format", "resource");
+
+ Builder webldr = web.request();
+ for (Entry<String, Object> header : headers.entrySet()) {
+ webldr.header(header.getKey(), header.getValue());
+ }
- headers.put("Accept", MediaType.APPLICATION_JSON);
- String url = makeUrl();
+ String url = str.toString();
logMessage(EventType.OUT, CommInfrastructure.REST, url, request);
- // @formatter:off
- return handleResponse(outcome, url,
- callback -> getClient().put(callback, makePath(), entity, headers));
- // @formatter:on
+ Entity<Map<String, String>> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
+
+ return handleResponse(outcome, url, callback -> webldr.async().put(entity, callback));
+ }
+
+ private WebTarget addQuery(WebTarget web, StringBuilder str, String separator, String name, String value) {
+ str.append(separator);
+ str.append(name);
+ str.append('=');
+ str.append(value);
+
+ return web.queryParam(name, value);
}
/**
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java
index 408c1a0b1..4c4124189 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java
@@ -21,8 +21,11 @@
package org.onap.policy.controlloop.actor.aai;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.onap.policy.aai.AaiConstants;
@@ -92,14 +95,35 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> {
Map<String, Object> headers = makeHeaders();
headers.put("Accept", MediaType.APPLICATION_JSON);
- String url = makeUrl();
+
+ StringBuilder str = new StringBuilder(getClient().getBaseUrl());
+
+ String path = getPath();
+ WebTarget web = getClient().getWebTarget().path(path);
+ str.append(path);
+
+ web = addQuery(web, str, "?", "search-node-type", "vserver");
+ web = addQuery(web, str, "&", "filter", "vserver-name:EQUALS:" + params.getTargetEntity());
+
+ Builder webldr = web.request();
+ for (Entry<String, Object> header : headers.entrySet()) {
+ webldr.header(header.getKey(), header.getValue());
+ }
+
+ String url = str.toString();
logMessage(EventType.OUT, CommInfrastructure.REST, url, null);
- // @formatter:off
- return handleResponse(outcome, url,
- callback -> getClient().get(callback, makePath(), headers));
- // @formatter:on
+ return handleResponse(outcome, url, callback -> webldr.async().get(callback));
+ }
+
+ private WebTarget addQuery(WebTarget web, StringBuilder str, String separator, String name, String value) {
+ str.append(separator);
+ str.append(name);
+ str.append('=');
+ str.append(value);
+
+ return web.queryParam(name, value);
}
@Override
@@ -109,7 +133,7 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> {
@Override
public String makePath() {
- return (getPath() + "/" + params.getTargetEntity());
+ return (getPath() + params.getTargetEntity());
}
/**