aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-04-29 13:35:51 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-29 13:35:51 +0000
commit81c1466f6657d41dc01b5271b18430875fd2e3f9 (patch)
tree47c5fd0479bbc0d2a318162ecfa75e529a27fb74 /mso-api-handlers
parent702ab6907b58bfac82a17c52ecdc70ef4084ef6f (diff)
parenta10606e383ce6c872cb7c95fe1d5e65565827813 (diff)
Merge "Store Cloud Request in Database"
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java36
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java98
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json62
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql15
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql17
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/CloudApiRequests.java138
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java19
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java4
8 files changed, 300 insertions, 89 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index 34dcd4b0c4..1bbe858859 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -35,12 +35,14 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.http.HttpStatus;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandler.common.ResponseBuilder;
@@ -53,6 +55,7 @@ import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.exceptions.ValidationException;
import org.onap.so.logger.ErrorCode;
import org.onap.so.logger.MessageEnum;
+import org.onap.so.serviceinstancebeans.CloudRequestData;
import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
import org.onap.so.serviceinstancebeans.InstanceReferences;
@@ -65,6 +68,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -92,7 +97,9 @@ public class OrchestrationRequests {
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response getOrchestrationRequest(@PathParam("requestId") String requestId,
- @PathParam("version") String version) throws ApiException {
+ @PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest)
+ throws ApiException {
+
String apiVersion = version.substring(1);
GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse();
@@ -135,7 +142,7 @@ public class OrchestrationRequests {
throw validateException;
}
- Request request = mapInfraActiveRequestToRequest(infraActiveRequest);
+ Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest);
if (!requestProcessingData.isEmpty()) {
request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData));
}
@@ -150,8 +157,8 @@ public class OrchestrationRequests {
@ApiOperation(value = "Find Orchestrated Requests for a URI Information", response = Response.class)
@Produces(MediaType.APPLICATION_JSON)
@Transactional
- public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version)
- throws ApiException {
+ public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version,
+ @QueryParam("includeCloudRequest") boolean includeCloudRequest) throws ApiException {
long startTime = System.currentTimeMillis();
@@ -188,7 +195,7 @@ public class OrchestrationRequests {
List<RequestProcessingData> requestProcessingData =
requestsDbClient.getRequestProcessingDataBySoRequestId(infraActive.getRequestId());
RequestList requestList = new RequestList();
- Request request = mapInfraActiveRequestToRequest(infraActive);
+ Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest);
if (!requestProcessingData.isEmpty()) {
request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData));
}
@@ -286,8 +293,8 @@ public class OrchestrationRequests {
return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build();
}
- private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar) throws ApiException {
-
+ private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest)
+ throws ApiException {
String requestBody = iar.getRequestBody();
Request request = new Request();
@@ -329,8 +336,6 @@ public class OrchestrationRequests {
if (iar.getInstanceGroupName() != null)
ir.setInstanceGroupName(iar.getInstanceGroupName());
-
-
request.setInstanceReferences(ir);
RequestDetails requestDetails = null;
@@ -410,8 +415,19 @@ public class OrchestrationRequests {
status.setPercentProgress(iar.getProgress().intValue());
}
- request.setRequestStatus(status);
+ if (iar.getCloudApiRequests() != null && !iar.getCloudApiRequests().isEmpty() && includeCloudRequest) {
+ iar.getCloudApiRequests().stream().forEach(cloudRequest -> {
+ try {
+ request.getCloudRequestData()
+ .add(new CloudRequestData(mapper.readValue(cloudRequest.getRequestBody(), Object.class),
+ cloudRequest.getCloudIdentifier()));
+ } catch (Exception e) {
+ logger.error("Error reading Cloud Request", e);
+ }
+ });
+ }
+ request.setRequestStatus(status);
return request;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index 321ea3ac7d..c678fab03e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -48,6 +48,7 @@ import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.exceptions.ValidationException;
+import org.onap.so.serviceinstancebeans.CloudRequestData;
import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
import org.onap.so.serviceinstancebeans.Request;
@@ -64,6 +65,7 @@ import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public class OrchestrationRequestsTest extends BaseTest {
@@ -149,13 +151,24 @@ public class OrchestrationRequestsTest extends BaseTest {
}
@Test
- public void testGetOrchestrationRequestRequestDetails() throws Exception {
- setupTestGetOrchestrationRequestRequestDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
+ public void testGetOrchestrationRequestWithOpenstackDetails() throws Exception {
+ setupTestGetOrchestrationRequestOpenstackDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
// Test request with modelInfo request body
GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
Request request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
+ List<CloudRequestData> cloudRequestData = new ArrayList<>();
+ CloudRequestData cloudData = new CloudRequestData();
+ cloudData.setCloudIdentifier("heatstackName/123123");
+ ObjectMapper mapper = new ObjectMapper();
+ Object reqData = mapper.readValue(
+ "{\r\n \"test\": \"00032ab7-3fb3-42e5-965d-8ea592502016\",\r\n \"test2\": \"deleteInstance\",\r\n \"test3\": \"COMPLETE\",\r\n \"test4\": \"Vf Module has been deleted successfully.\",\r\n \"test5\": 100\r\n}",
+ Object.class);
+ cloudData.setCloudRequest(reqData);
+ cloudRequestData.add(cloudData);
+ request.setCloudRequestData(cloudRequestData);
testResponse.setRequest(request);
+
String testRequestId = request.getRequestId();
HttpHeaders headers = new HttpHeaders();
@@ -163,15 +176,17 @@ public class OrchestrationRequestsTest extends BaseTest {
headers.set("Content-Type", MediaType.APPLICATION_JSON);
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
+ "/onap/so/infra/orchestrationRequests/v7/" + testRequestId + "?includeCloudRequest=true"));
ResponseEntity<GetOrchestrationResponse> response =
restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
+ System.out.println("Response :" + response.getBody().toString());
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
.ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
+
assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
@@ -323,70 +338,7 @@ public class OrchestrationRequestsTest extends BaseTest {
// properly called to update.
}
- @Ignore // What is this testing?
- @Test
- public void testGetOrchestrationRequestRequestDetailsWhiteSpace() throws Exception {
- InfraActiveRequests requests = new InfraActiveRequests();
- requests.setAction("create");
- requests.setRequestBody(" ");
- requests.setRequestId("requestId");
- requests.setRequestScope("service");
- requests.setRequestType("createInstance");
- ObjectMapper mapper = new ObjectMapper();
- String json = mapper.writeValueAsString(requests);
-
- requestsDbClient.save(requests);
- HttpHeaders headers = new HttpHeaders();
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
-
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
-
- ResponseEntity<GetOrchestrationResponse> response =
- restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
- }
-
- @Ignore // What is this testing?
- @Test
- public void testGetOrchestrationRequestRequestDetailsAlaCarte() throws IOException {
- InfraActiveRequests requests = new InfraActiveRequests();
-
- String requestJSON = new String(
- Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/AlaCarteRequest.json")));
-
- requests.setAction("create");
- requests.setRequestBody(requestJSON);
- requests.setRequestId("requestId");
- requests.setRequestScope("service");
- requests.setRequestType("createInstance");
- // iar.save(requests);
- HttpHeaders headers = new HttpHeaders();
- headers.set("Accept", MediaType.APPLICATION_JSON);
- headers.set("Content-Type", MediaType.APPLICATION_JSON);
- HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
- UriComponentsBuilder builder = UriComponentsBuilder
- .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
-
- ResponseEntity<GetOrchestrationResponse> response =
- restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
- assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
- assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
- assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
- assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
- assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
- }
@Test
public void mapRequestProcessingDataTest() throws JsonParseException, JsonMappingException, IOException {
@@ -461,6 +413,15 @@ public class OrchestrationRequestsTest extends BaseTest {
.withStatus(HttpStatus.SC_OK)));
}
+
+ private void setupTestGetOrchestrationRequestOpenstackDetails(String requestId, String status) throws Exception {
+ wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse()
+ .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(new String(Files.readAllBytes(Paths
+ .get("src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json"))))
+ .withStatus(HttpStatus.SC_OK)));
+ }
+
private void setupTestUnlockOrchestrationRequest(String requestId, String status) {
wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId)))
.willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
@@ -473,7 +434,6 @@ public class OrchestrationRequestsTest extends BaseTest {
private void setupTestUnlockOrchestrationRequest_invalid_Json() {
wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(INVALID_REQUEST_ID))).willReturn(aResponse()
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
-
}
private void setupTestUnlockOrchestrationRequest_Valid_Status(String requestID, String status) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json
new file mode 100644
index 0000000000..41d7e4d706
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json
@@ -0,0 +1,62 @@
+{
+ "clientRequestId": "00032ab7-3fb3-42e5-965d-8ea592502016",
+ "action": "deleteInstance",
+ "requestStatus": "COMPLETE",
+ "statusMessage": "Vf Module has been deleted successfully.",
+ "progress": 100,
+ "startTime": "2016-12-22T13:29:54.000+0000",
+ "endTime": "2016-12-22T13:30:28.000+0000",
+ "source": "VID",
+ "vnfId": "b92f60c8-8de3-46c1-8dc1-e4390ac2b005",
+ "vnfName": null,
+ "vnfType": null,
+ "serviceType": null,
+ "aicNodeClli": null,
+ "tenantId": "6accefef3cb442ff9e644d589fb04107",
+ "provStatus": null,
+ "vnfParams": null,
+ "vnfOutputs": null,
+ "requestBody": "{\"modelInfo\":{\"modelType\":\"vfModule\",\"modelName\":\"test::base::module-0\"},\"requestInfo\":{\"source\":\"VID\"},\"cloudConfiguration\":{\"tenantId\":\"6accefef3cb442ff9e644d589fb04107\",\"lcpCloudRegionId\":\"n6\"}}",
+ "responseBody": null,
+ "lastModifiedBy": "BPMN",
+ "modifyTime": "2016-12-22T13:30:28.000+0000",
+ "requestType": null,
+ "volumeGroupId": null,
+ "volumeGroupName": null,
+ "vfModuleId": "c7d527b1-7a91-49fd-b97d-1c8c0f4a7992",
+ "vfModuleName": null,
+ "vfModuleModelName": "test::base::module-0",
+ "aaiServiceId": null,
+ "aicCloudRegion": "n6",
+ "callBackUrl": null,
+ "correlator": null,
+ "serviceInstanceId": "e3b5744d-2ad1-4cdd-8390-c999a38829bc",
+ "serviceInstanceName": null,
+ "requestScope": "vfModule",
+ "requestAction": "deleteInstance",
+ "networkId": null,
+ "networkName": null,
+ "networkType": null,
+ "requestorId": null,
+ "configurationId": null,
+ "configurationName": null,
+ "operationalEnvId": null,
+ "operationalEnvName": null,
+ "cloudApiRequests":[
+ {
+ "id": 1,
+ "cloudIdentifier": "heatstackName/123123",
+ "requestBody":"{\r\n \"test\": \"00032ab7-3fb3-42e5-965d-8ea592502016\",\r\n \"test2\": \"deleteInstance\",\r\n \"test3\": \"COMPLETE\",\r\n \"test4\": \"Vf Module has been deleted successfully.\",\r\n \"test5\": 100\r\n}",
+ "created": "2016-12-22T13:29:54.000+0000"
+ }
+ ],
+ "requestURI": "00032ab7-3fb3-42e5-965d-8ea592502017",
+ "_links": {
+ "self": {
+ "href": "http://localhost:8087/infraActiveRequests/00032ab7-3fb3-42e5-965d-8ea592502017"
+ },
+ "infraActiveRequests": {
+ "href": "http://localhost:8087/infraActiveRequests/00032ab7-3fb3-42e5-965d-8ea592502017"
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
index 765740e864..c2eb21b18e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
@@ -1463,6 +1463,16 @@ create table if not exists model (
FOREIGN KEY (`RECIPE`) REFERENCES `model_recipe` (`MODEL_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+CREATE TABLE IF NOT EXISTS `requestdb`.`cloud_api_requests` (
+`ID` INT(13) NOT NULL AUTO_INCREMENT,
+`REQUEST_BODY` LONGTEXT NOT NULL,
+`CLOUD_IDENTIFIER` VARCHAR(200) NULL,
+`SO_REQUEST_ID` VARCHAR(45) NOT NULL,
+`CREATE_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (`ID`),
+INDEX `fk_cloud_api_requests__so_request_id_idx` (`SO_REQUEST_ID` ASC))
+ENGINE = InnoDB DEFAULT CHARSET=latin1;
+
CREATE TABLE IF NOT EXISTS `workflow` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`ARTIFACT_UUID` varchar(200) NOT NULL,
@@ -1480,8 +1490,3 @@ CREATE TABLE IF NOT EXISTS `workflow` (
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_workflow` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`SOURCE`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
-
-
-
-
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
index 2bd9936b3a..65372b7b48 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-requests-db-repositories/src/test/resources/schema.sql
@@ -1,5 +1,5 @@
-create table ACTIVATE_OPERATIONAL_ENV_SERVICE_MODEL_DISTRIBUTION_STATUS (
+create table IF NOT EXISTS ACTIVATE_OPERATIONAL_ENV_SERVICE_MODEL_DISTRIBUTION_STATUS (
REQUEST_ID varchar(255) not null,
OPERATIONAL_ENV_ID varchar(255) not null,
SERVICE_MODEL_VERSION_ID varchar(255) not null,
@@ -13,7 +13,7 @@ create table ACTIVATE_OPERATIONAL_ENV_SERVICE_MODEL_DISTRIBUTION_STATUS (
primary key (REQUEST_ID,OPERATIONAL_ENV_ID, SERVICE_MODEL_VERSION_ID)
);
-create table OPERATION_STATUS (
+create table IF NOT EXISTS OPERATION_STATUS (
SERVICE_ID varchar(255) not null,
OPERATION_ID varchar(255) not null,
SERVICE_NAME varchar(255),
@@ -46,7 +46,7 @@ INSERT INTO PUBLIC.OPERATION_STATUS(SERVICE_ID, OPERATION_ID, OPERATION_TYPE, US
primary key (SERVICE_ID,OPERATION_ID,RESOURCE_TEMPLATE_UUID)
);
-CREATE CACHED TABLE PUBLIC.INFRA_ACTIVE_REQUESTS(
+CREATE TABLE IF NOT EXISTS PUBLIC.INFRA_ACTIVE_REQUESTS(
REQUEST_ID VARCHAR NOT NULL SELECTIVITY 100,
CLIENT_REQUEST_ID VARCHAR SELECTIVITY 6,
ACTION VARCHAR SELECTIVITY 1,
@@ -168,6 +168,17 @@ CREATE CACHED TABLE PUBLIC.ARCHIVED_INFRA_REQUESTS(
REQUEST_URL VARCHAR SELECTIVITY 1
);
+CREATE TABLE IF NOT EXISTS cloud_api_requests(
+`ID` INT(13) NOT NULL AUTO_INCREMENT,
+`REQUEST_BODY` LONGTEXT NOT NULL,
+`CLOUD_IDENTIFIER` VARCHAR(200) NULL,
+`SO_REQUEST_ID` VARCHAR(45) NOT NULL,
+`CREATE_TIME` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+PRIMARY KEY (`ID`),
+CONSTRAINT fk_cloud_api_req_infra_requests
+ FOREIGN KEY (SO_REQUEST_ID)
+ REFERENCES infra_active_requests (REQUEST_ID));
+
CREATE CACHED TABLE PUBLIC.SITE_STATUS(
SITE_NAME VARCHAR NOT NULL,
STATUS VARCHAR,
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/CloudApiRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/CloudApiRequests.java
new file mode 100644
index 0000000000..690d0ffbaf
--- /dev/null
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/CloudApiRequests.java
@@ -0,0 +1,138 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+
+package org.onap.so.db.request.beans;
+
+import java.io.Serializable;
+import java.util.Date;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.openpojo.business.annotation.BusinessKey;
+
+
+@Entity
+@JsonInclude(Include.NON_NULL)
+@Table(name = "cloud_api_requests")
+public class CloudApiRequests implements Serializable {
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 4686890103198488984L;
+
+ @JsonIgnore
+ @Id
+ @BusinessKey
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "ID")
+ private Integer id;
+
+
+ @Column(name = "SO_REQUEST_ID")
+ private String requestId;
+
+ public String getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(String requestId) {
+ this.requestId = requestId;
+ }
+
+ @Column(name = "CLOUD_IDENTIFIER")
+ private String cloudIdentifier;
+
+ @Column(name = "REQUEST_BODY", columnDefinition = "LONGTEXT")
+ private String requestBody;
+
+ @Column(name = "CREATE_TIME", insertable = false, updatable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date created = null;
+
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof CloudApiRequests)) {
+ return false;
+ }
+ CloudApiRequests castOther = (CloudApiRequests) other;
+ return new EqualsBuilder().append(id, castOther.id).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(id).toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("id", id).append("cloudIdentifier", cloudIdentifier)
+ .append("requestBody", requestBody).append("created", created).toString();
+ }
+
+ @PrePersist
+ protected void createdAt() {
+ this.created = new Date();
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getCloudIdentifier() {
+ return cloudIdentifier;
+ }
+
+ public void setCloudIdentifier(String cloudIdentifier) {
+ this.cloudIdentifier = cloudIdentifier;
+ }
+
+
+ public String getRequestBody() {
+ return requestBody;
+ }
+
+ public void setRequestBody(String requestBody) {
+ this.requestBody = requestBody;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
index a1010a349c..7c58c6171e 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
@@ -23,10 +23,15 @@ package org.onap.so.db.request.beans;
import java.net.URI;
import java.sql.Timestamp;
import java.util.Date;
+import java.util.List;
import java.util.Objects;
+import javax.persistence.CascadeType;
import javax.persistence.Column;
+import javax.persistence.FetchType;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
import javax.persistence.MappedSuperclass;
+import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
@@ -34,6 +39,7 @@ import javax.persistence.TemporalType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.onap.so.requestsdb.TimestampXMLAdapter;
+import uk.co.blackpepper.bowman.annotation.LinkedResource;
import uk.co.blackpepper.bowman.annotation.ResourceId;
@MappedSuperclass
@@ -147,6 +153,10 @@ public abstract class InfraRequests implements java.io.Serializable {
@Column(name = "REQUEST_URL", length = 500)
private String requestUrl;
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ @JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID")
+ private List<CloudApiRequests> cloudApiRequests;
+
@ResourceId
public URI getRequestURI() {
return URI.create(this.requestId);
@@ -458,6 +468,15 @@ public abstract class InfraRequests implements java.io.Serializable {
return requestAction;
}
+ @LinkedResource
+ public List<CloudApiRequests> getCloudApiRequests() {
+ return cloudApiRequests;
+ }
+
+ public void setCloudApiRequests(List<CloudApiRequests> cloudApiRequests) {
+ this.cloudApiRequests = cloudApiRequests;
+ }
+
public void setRequestAction(String requestAction) {
this.requestAction = requestAction;
}
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 f2ff6fac00..103410701c 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
@@ -72,10 +72,10 @@ public class RequestsDbClient {
private static final String SERVICE_MODEL_VERSION_ID = "SERVICE_MODEL_VERSION_ID";
- @Value("${mso.adapters.requestDb.endpoint}")
+ @Value("${mso.adapters.requestDb.endpoint:#{null}}")
protected String endpoint;
- @Value("${mso.adapters.requestDb.auth}")
+ @Value("${mso.adapters.requestDb.auth:#{null}}")
private String msoAdaptersAuth;
private String getOrchestrationFilterURI = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive/";