From 960fda8db5fee3c75c260a5e791daff662d7e7d6 Mon Sep 17 00:00:00 2001 From: NicolasLaplaud Date: Mon, 23 Apr 2018 12:02:37 +0200 Subject: Fix Missing requestDetails wrapper in SO payload - Add MSOPayload class to wrap RequestDetail json in the SO Request - Manage the new wrapper in SoClient and SOTaskProcessor Change-Id: Ia7843ea24375321aaab98b624538814fdff1262e Issue-ID: EXTAPI-67 Signed-off-by: NicolasLaplaud --- .../org/onap/nbi/apis/serviceorder/SoClient.java | 20 +++++------ .../serviceorder/model/consumer/MSOPayload.java | 40 ++++++++++++++++++++++ .../serviceorder/workflow/SOTaskProcessor.java | 25 ++++---------- 3 files changed, 55 insertions(+), 30 deletions(-) create mode 100644 src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/MSOPayload.java (limited to 'src') diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java b/src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java index c3e41f4..5f10d63 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/SoClient.java @@ -18,17 +18,13 @@ package org.onap.nbi.apis.serviceorder; import org.onap.nbi.OnapComponentsUrlPaths; import org.onap.nbi.apis.serviceorder.model.consumer.CreateServiceInstanceResponse; import org.onap.nbi.apis.serviceorder.model.consumer.GetRequestStatusResponse; -import org.onap.nbi.apis.serviceorder.model.consumer.RequestDetails; +import org.onap.nbi.apis.serviceorder.model.consumer.MSOPayload; import org.onap.nbi.exceptions.BackendFunctionalException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; +import org.springframework.http.*; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @@ -57,15 +53,15 @@ public class SoClient { private static final Logger LOGGER = LoggerFactory.getLogger(SoClient.class); - public ResponseEntity callCreateServiceInstance(RequestDetails requestDetails) { + public ResponseEntity callCreateServiceInstance(MSOPayload msoPayload) { if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Calling SO CreateServiceInstance with requestDetails : " + requestDetails.toString()); + LOGGER.debug("Calling SO CreateServiceInstance with msoPayload : " + msoPayload.toString()); } String url = soHostname + OnapComponentsUrlPaths.MSO_CREATE_SERVICE_INSTANCE_PATH; - HttpEntity requestDetailEntity = new HttpEntity<>(requestDetails, buildRequestHeader()); + HttpEntity requestDetailEntity = new HttpEntity<>(msoPayload, buildRequestHeader()); try { ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, @@ -80,16 +76,16 @@ public class SoClient { } } - public ResponseEntity callDeleteServiceInstance(RequestDetails requestDetails, + public ResponseEntity callDeleteServiceInstance(MSOPayload msoPayload, String serviceId) { if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Calling SO DeleteServiceInstance with requestDetails : " + requestDetails.toString()); + LOGGER.debug("Calling SO DeleteServiceInstance with msoPayload : " + msoPayload.toString()); } String url = soHostname + OnapComponentsUrlPaths.MSO_DELETE_REQUEST_STATUS_PATH + serviceId; - HttpEntity requestDetailEntity = new HttpEntity<>(requestDetails, buildRequestHeader()); + HttpEntity requestDetailEntity = new HttpEntity<>(msoPayload, buildRequestHeader()); try { ResponseEntity response = restTemplate.exchange(url, HttpMethod.DELETE, diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/MSOPayload.java b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/MSOPayload.java new file mode 100644 index 0000000..76415c3 --- /dev/null +++ b/src/main/java/org/onap/nbi/apis/serviceorder/model/consumer/MSOPayload.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2018 Orange + * + * 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. + */ +package org.onap.nbi.apis.serviceorder.model.consumer; + +public class MSOPayload { + + private RequestDetails requestDetails; + + public MSOPayload(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + + public RequestDetails getRequestDetails() { + return requestDetails; + } + + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + + @Override + public String toString() { + return "MSOPayload{" + + "requestDetails=" + requestDetails + + '}'; + } +} diff --git a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java index 84a198c..71f1320 100644 --- a/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java +++ b/src/main/java/org/onap/nbi/apis/serviceorder/workflow/SOTaskProcessor.java @@ -13,27 +13,12 @@ */ package org.onap.nbi.apis.serviceorder.workflow; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; import org.onap.nbi.apis.serviceorder.SoClient; import org.onap.nbi.apis.serviceorder.model.ServiceCharacteristic; import org.onap.nbi.apis.serviceorder.model.ServiceOrder; import org.onap.nbi.apis.serviceorder.model.ServiceOrderItem; import org.onap.nbi.apis.serviceorder.model.StateType; -import org.onap.nbi.apis.serviceorder.model.consumer.CloudConfiguration; -import org.onap.nbi.apis.serviceorder.model.consumer.CreateServiceInstanceResponse; -import org.onap.nbi.apis.serviceorder.model.consumer.GetRequestStatusResponse; -import org.onap.nbi.apis.serviceorder.model.consumer.ModelInfo; -import org.onap.nbi.apis.serviceorder.model.consumer.RequestDetails; -import org.onap.nbi.apis.serviceorder.model.consumer.RequestInfo; -import org.onap.nbi.apis.serviceorder.model.consumer.RequestParameters; -import org.onap.nbi.apis.serviceorder.model.consumer.RequestState; -import org.onap.nbi.apis.serviceorder.model.consumer.SubscriberInfo; -import org.onap.nbi.apis.serviceorder.model.consumer.UserParams; +import org.onap.nbi.apis.serviceorder.model.consumer.*; import org.onap.nbi.apis.serviceorder.model.orchestrator.ExecutionTask; import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfo; import org.onap.nbi.apis.serviceorder.model.orchestrator.ServiceOrderInfoJson; @@ -49,6 +34,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.io.IOException; +import java.util.*; + @Service public class SOTaskProcessor { @@ -147,14 +135,15 @@ public class SOTaskProcessor { RequestDetails requestDetails = buildSoRequest(serviceOrderItem, serviceOrderInfo.getServiceOrderItemInfos().get(serviceOrderItem.getId()).getCatalogResponse(), serviceOrderInfo.getSubscriberInfo()); + MSOPayload msoPayload = new MSOPayload(requestDetails); ResponseEntity response = null; switch (serviceOrderItem.getAction()) { case ADD: - response = soClient.callCreateServiceInstance(requestDetails); + response = soClient.callCreateServiceInstance(msoPayload); break; case DELETE: - response = soClient.callDeleteServiceInstance(requestDetails, serviceOrderItem.getService().getId()); + response = soClient.callDeleteServiceInstance(msoPayload, serviceOrderItem.getService().getId()); break; default: break; -- cgit 1.2.3-korg