summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-requests-db
diff options
context:
space:
mode:
authorBoslet, Cory <cory.boslet@att.com>2019-12-09 08:49:08 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-12-09 08:49:09 -0500
commit4b23ea7fbe55fadd119a3534a578aa86e664ebd9 (patch)
treec3c8de23e686946863b6bac89d7f1da5dabbaed1 /mso-api-handlers/mso-requests-db
parentb9765b97e0fd8a99c5b27263638eb05483f14e29 (diff)
refactor fallouthandler
Created a new update method to allow accessibility from groovy Ignore test that do not function in groovy. Fixed typo and bug in request db client class Fixed failing junits for falloouthandler Add the request factory to the rest template so that patch works updated check payload keyword to check response Issue-ID: SO-2555 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Iebfea31b659a02069bd6c59c09f025fdc6a99843
Diffstat (limited to 'mso-api-handlers/mso-requests-db')
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
index 655ae60f47..334eb73da4 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
@@ -371,6 +371,41 @@ public class RequestsDbClient {
String.class);
}
+ public InfraActiveRequests getInfraActiveRequests(String requestId, String basicAuth, String host) {
+ RestTemplate template = new RestTemplate();
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(HttpHeaders.AUTHORIZATION, basicAuth);
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ URI uri = getUri(host + "/infraActiveRequests/" + requestId);
+ try {
+ InfraActiveRequests infraActiveRequests = template
+ .exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), InfraActiveRequests.class).getBody();
+ if (infraActiveRequests != null) {
+ infraActiveRequests.setRequestId(requestId);
+ }
+ return infraActiveRequests;
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ return null;
+ }
+ throw e;
+ }
+ }
+
+ public void updateInfraActiveRequests(InfraActiveRequests request, String basicAuth, String host) {
+ RestTemplate template = new RestTemplate();
+ template.getInterceptors().add(new SOSpringClientFilter());
+ template.getInterceptors().add(new SpringClientPayloadFilter());
+ HttpHeaders headers = new HttpHeaders();
+ headers.set(HttpHeaders.AUTHORIZATION, basicAuth);
+ headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+ URI uri = getUri(host + "/infraActiveRequests/" + request.getRequestId());
+ HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers);
+ template.put(uri, entity);
+ }
+
protected URI getUri(String uri) {
return URI.create(uri);
}