From 71870a575f65f1c0a984fcd15533b73cc176d68d Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Wed, 12 Feb 2020 17:21:28 +0800 Subject: Modify requestDbClient to add methods for OrchestrationTask Issue-ID: SO-2368 Add methods to handle OrchestrationTask Change-Id: I4595c5a1099977e5dba259bfbf77d666b1db699c Signed-off-by: Harry Huang --- .../so/db/request/client/RequestsDbClient.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'mso-api-handlers/mso-requests-db/src/main/java/org/onap') 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 334eb73da4..7b642ab831 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 @@ -45,6 +45,7 @@ import org.onap.so.db.request.beans.SiteStatus; import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus; import org.onap.so.db.request.beans.WatchdogDistributionStatus; import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup; +import org.onap.so.db.request.beans.OrchestrationTask; import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; import org.springframework.beans.factory.annotation.Autowired; @@ -119,6 +120,8 @@ public class RequestsDbClient { private String getInProgressVolumeGroupsAndVfModules = "/infraActiveRequests/getInProgressVolumeGroupsAndVfModules"; + private String orchestrationTasksURI = "/orchestrationTask"; + private static final String findBySoRequestIdAndGroupIdAndName = "/requestProcessingData/search/findOneBySoRequestIdAndGroupingIdAndName"; @@ -156,6 +159,7 @@ public class RequestsDbClient { findAllByOperationalEnvIdAndRequestIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findAllByOperationalEnvIdAndRequestIdURI; findOneByRequestId = endpoint + findOneByRequestId; + orchestrationTasksURI = endpoint + orchestrationTasksURI; } protected String getEndpoint() { @@ -520,6 +524,40 @@ public class RequestsDbClient { .getBody(); } + public List getAllOrchestrationTasks() { + String url = UriBuilder.fromUri(getUri(orchestrationTasksURI)).build().toString(); + HttpEntity entity = getHttpEntity(); + return restTemplate + .exchange(url, HttpMethod.GET, entity, new ParameterizedTypeReference>() {}) + .getBody(); + } + + public OrchestrationTask getOrchestrationTask(String taskId) { + String url = UriBuilder.fromUri(getUri(orchestrationTasksURI + "/" + taskId)).build().toString(); + HttpEntity entity = getHttpEntity(); + return restTemplate.exchange(url, HttpMethod.GET, entity, OrchestrationTask.class).getBody(); + } + + public OrchestrationTask createOrchestrationTask(OrchestrationTask orchestrationTask) { + String url = UriBuilder.fromUri(getUri(orchestrationTasksURI + "/")).build().toString(); + HttpHeaders headers = getHttpHeaders(); + HttpEntity entity = new HttpEntity<>(orchestrationTask, headers); + return restTemplate.exchange(url, HttpMethod.POST, entity, OrchestrationTask.class).getBody(); + } + + public OrchestrationTask updateOrchestrationTask(String taskId, OrchestrationTask orchestrationTask) { + String url = getUri(orchestrationTasksURI + "/" + taskId).toString(); + HttpHeaders headers = getHttpHeaders(); + HttpEntity entity = new HttpEntity<>(orchestrationTask, headers); + return restTemplate.exchange(url, HttpMethod.PUT, entity, OrchestrationTask.class).getBody(); + } + + public void deleteOrchestrationTask(String taskId) { + String url = getUri(orchestrationTasksURI + "/" + taskId).toString(); + HttpEntity entity = getHttpEntity(); + restTemplate.exchange(url, HttpMethod.DELETE, entity, Void.class).getBody(); + } + @Component static class ClassURLMapper { private static final Map classURLMap = new HashMap<>(); -- cgit 1.2.3-korg