diff options
author | zhangab <zhanganbing@chinamobile.com> | 2019-02-01 17:48:53 +0800 |
---|---|---|
committer | zhangab <zhanganbing@chinamobile.com> | 2019-02-01 17:48:54 +0800 |
commit | 1e30f1c34d8c624eff70af9be0f80ed5f3941d98 (patch) | |
tree | 97978282d82c5236609a9d38e6bbf3384d62d025 | |
parent | 235406a6f36f06b59cfce5f4592506725838768e (diff) |
Fix request body partially missing bugcasablanca
Change-Id: Ifa0e14fd3d037b822751364c7caf4df868158513
Issue-ID: USECASEUI-210
Signed-off-by: zhangab <zhanganbing@chinamobile.com>
5 files changed, 46 insertions, 36 deletions
diff --git a/server/pom.xml b/server/pom.xml index 0817d8ef..d6a6cb05 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -205,9 +205,9 @@ <version>1.2.23</version> </dependency> <dependency> - <groupId>org.openecomp.sdc.jtosca</groupId> - <artifactId>jtosca</artifactId> - <version>1.1.1</version> + <groupId>org.onap.sdc.sdc-tosca</groupId> + <artifactId>sdc-tosca</artifactId> + <version>1.4.63</version> </dependency> <dependency> diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/SOService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/SOService.java index 323329b6..494647ac 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/SOService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/SOService.java @@ -29,14 +29,14 @@ public interface SOService { "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==", "Accept: application/json" }) - @POST("/api/so-serviceInstances/v5") + @POST("/api/so-serviceInstances/v3") Call<ServiceOperation> instantiateService(@Body RequestBody body); @Headers({ "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==", "Accept: application/json" }) - @GET("/api/so-serviceInstances/v5/{serviceId}/operations/{operationId}") + @GET("/api/so-serviceInstances/v3/{serviceId}/operations/{operationId}") Call<OperationProgressInformation> queryOperationProgress(@Path("serviceId") String serviceId, @Path("operationId") String operationId); @Headers({ @@ -44,20 +44,20 @@ public interface SOService { "Accept: application/json" }) // @DELETE("/ecomp/mso/infra/e2eServiceInstances/v3/{serviceId}") - @HTTP(method="DELETE", path="/api/so-serviceInstances/v5/{serviceId}", hasBody = true) + @HTTP(method="DELETE", path="/api/so-serviceInstances/v3/{serviceId}", hasBody = true) Call<DeleteOperationRsp> terminateService(@Path("serviceId") String serviceId, @Body RequestBody body); @Headers({ "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==", "Accept: application/json" }) - @POST("/api/so-serviceInstances/v5/{serviceId}/scale") + @POST("/api/so-serviceInstances/v3/{serviceId}/scale") Call<SaveOrUpdateOperationRsp> scaleService(@Path("serviceId") String serviceId, @Body RequestBody body); @Headers({ "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==", "Accept: application/json" }) - @PUT("/api/so-serviceInstances/v5/{serviceId}") + @PUT("/api/so-serviceInstances/v3/{serviceId}") Call<SaveOrUpdateOperationRsp> updateService(@Path("serviceId") String serviceId, @Body RequestBody body); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java index 9aba5cca..1a12c497 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java @@ -17,6 +17,11 @@ package org.onap.usecaseui.server.service.lcm.impl; import com.google.common.io.Files; import okhttp3.ResponseBody; +import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.Property; +import org.onap.sdc.toscaparser.api.ToscaTemplate; +import org.onap.sdc.toscaparser.api.common.JToscaException; +import org.onap.sdc.toscaparser.api.parameters.Input; import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput; import org.onap.usecaseui.server.bean.lcm.TemplateInput; import org.onap.usecaseui.server.constant.Constant; @@ -32,11 +37,6 @@ import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate; import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException; import org.onap.usecaseui.server.util.RestfulServices; import org.onap.usecaseui.server.util.UuiCommonUtil; -import org.openecomp.sdc.toscaparser.api.NodeTemplate; -import org.openecomp.sdc.toscaparser.api.Property; -import org.openecomp.sdc.toscaparser.api.ToscaTemplate; -import org.openecomp.sdc.toscaparser.api.common.JToscaException; -import org.openecomp.sdc.toscaparser.api.parameters.Input; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.EnableAspectJAutoProxy; diff --git a/server/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java b/server/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java index 6441d0ef..4b332a19 100644 --- a/server/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java +++ b/server/src/main/java/org/onap/usecaseui/server/util/RestfulServices.java @@ -15,7 +15,9 @@ */ package org.onap.usecaseui.server.util; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; @@ -23,6 +25,7 @@ import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import okhttp3.MediaType; import okhttp3.RequestBody; import retrofit2.Retrofit; @@ -58,14 +61,17 @@ public class RestfulServices { } public static RequestBody extractBody(HttpServletRequest request) throws IOException { - int len = request.getContentLength(); ServletInputStream inStream = null; + StringBuilder sb = new StringBuilder(); try { inStream = request.getInputStream(); - byte[] buffer = new byte[len]; - inStream.read(buffer, 0, len); - logger.info("The request body content is: "+new String(buffer)); - return RequestBody.create(MediaType.parse("application/json"), buffer); + BufferedReader reader = new BufferedReader(new InputStreamReader(inStream)); + String line = ""; + while((line=reader.readLine())!=null){ + sb.append(line); + } + logger.info("The request body content is: "+sb.toString()); + return RequestBody.create(MediaType.parse("application/json"),sb.toString()); }finally { if (inStream != null) { inStream.close(); diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java index 0534838a..a61a0579 100644 --- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java @@ -15,12 +15,32 @@ */ package org.onap.usecaseui.server.service.lcm.impl; +import static org.hamcrest.Matchers.equalTo; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.CATEGORY_E2E_SERVICE; +import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.DISTRIBUTION_STATUS_DISTRIBUTED; +import static org.onap.usecaseui.server.util.CallStub.emptyBodyCall; +import static org.onap.usecaseui.server.util.CallStub.failedCall; +import static org.onap.usecaseui.server.util.CallStub.successfulCall; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.onap.sdc.toscaparser.api.NodeTemplate; +import org.onap.sdc.toscaparser.api.ToscaTemplate; +import org.onap.sdc.toscaparser.api.common.JToscaException; +import org.onap.sdc.toscaparser.api.elements.Metadata; +import org.onap.sdc.toscaparser.api.parameters.Input; import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput; import org.onap.usecaseui.server.bean.lcm.TemplateInput; -import org.onap.usecaseui.server.service.impl.AlarmsInformationServiceImpl; import org.onap.usecaseui.server.service.lcm.ServiceTemplateService; import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCController; @@ -31,24 +51,8 @@ import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException; import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate; import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException; -import org.openecomp.sdc.toscaparser.api.NodeTemplate; -import org.openecomp.sdc.toscaparser.api.ToscaTemplate; -import org.openecomp.sdc.toscaparser.api.common.JToscaException; -import org.openecomp.sdc.toscaparser.api.elements.Metadata; -import org.openecomp.sdc.toscaparser.api.parameters.Input; -import retrofit2.Call; -import java.io.IOException; -import java.util.*; - -import static org.hamcrest.Matchers.equalTo; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.CATEGORY_E2E_SERVICE; -import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.DISTRIBUTION_STATUS_DISTRIBUTED; -import static org.onap.usecaseui.server.util.CallStub.emptyBodyCall; -import static org.onap.usecaseui.server.util.CallStub.failedCall; -import static org.onap.usecaseui.server.util.CallStub.successfulCall; +import retrofit2.Call; public class DefaultServiceTemplateServiceTest { |