diff options
author | 2018-05-11 10:38:48 +0800 | |
---|---|---|
committer | 2018-05-11 10:38:56 +0800 | |
commit | 8ee24f0293cd54c4b8e20ed058909ce9e537c7db (patch) | |
tree | a5d8498f11c0f82d07dbe08ba50a8a1fcb214a95 | |
parent | ffbc1024dd6be539a4a1e28750fe5098ae726371 (diff) |
Fix service create request for so api
Change-Id: I557432a1661a979aa2584b2d2955e4cabc7d5fad
Issue-ID: USECASEUI-115
Signed-off-by: zhangab <zhanganbing@chinamobile.com>
21 files changed, 307 insertions, 49 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInput.java b/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInput.java index 0e25e0de..37399d97 100644 --- a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInput.java +++ b/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInput.java @@ -38,9 +38,11 @@ public class ServiceTemplateInput { private String category; private String subcategory; - + + private String customizationUuid; + private List<TemplateInput> inputs; - + private List<ServiceTemplateInput> nestedTemplates; public ServiceTemplateInput( @@ -52,6 +54,7 @@ public class ServiceTemplateInput { String description, String category, String subcategory, + String customizationUuid, List<TemplateInput> inputs) { this.invariantUUID = invariantUUID; this.uuid = uuid; @@ -61,6 +64,7 @@ public class ServiceTemplateInput { this.description = description; this.category = category; this.subcategory = subcategory; + this.customizationUuid = customizationUuid; this.inputs = inputs; this.nestedTemplates = new ArrayList<>(); } @@ -96,8 +100,12 @@ public class ServiceTemplateInput { public String getSubcategory() { return subcategory; } + + public String getCustomizationUuid() { + return customizationUuid; + } - public List<TemplateInput> getInputs() { + public List<TemplateInput> getInputs() { return inputs; } @@ -134,13 +142,14 @@ public class ServiceTemplateInput { Objects.equals(description, that.description) && Objects.equals(category, that.category) && Objects.equals(subcategory, that.subcategory) && + Objects.equals(customizationUuid, that.customizationUuid) && Objects.equals(inputs, that.inputs) && Objects.equals(nestedTemplates, that.nestedTemplates); } @Override public int hashCode() { - return Objects.hash(invariantUUID, uuid, name, type, version, description, category, subcategory, inputs, nestedTemplates); + return Objects.hash(invariantUUID, uuid, name, type, version, description, category, subcategory,customizationUuid, inputs, nestedTemplates); } @Override @@ -154,6 +163,7 @@ public class ServiceTemplateInput { .add("description", description) .add("category", category) .add("subcategory", subcategory) + .add("customizationUuid", customizationUuid) .add("inputs", inputs) .add("nestedTemplates", nestedTemplates) .toString(); diff --git a/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java b/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java index 9a818e4e..472f5406 100755 --- a/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java +++ b/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java @@ -1,4 +1,4 @@ -/*
+/**
* Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,5 +21,6 @@ public final class Constant public static final String DATE_FORMAT= "yyyy-MM-dd HH:mm:ss";
+ public static final String RegEX_DATE_FORMAT = "[^0-9-:]";
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java index e900365d..715a2acd 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java @@ -15,19 +15,25 @@ */ package org.onap.usecaseui.server.controller.lcm; +import java.util.List; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + import org.onap.usecaseui.server.service.lcm.ServiceInstanceService; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance; +import org.onap.usecaseui.server.util.UuiCommonUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.util.List; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; @Controller @org.springframework.context.annotation.Configuration @@ -52,7 +58,43 @@ public class ServiceInstanceController { "list service instances with [customerId=%s, serviceType=%s]", customerId, serviceType)); - return serviceInstanceService.listServiceInstances(customerId, serviceType); } + @ResponseBody + @RequestMapping(value = {"/uui-lcm/getServiceInstanceById"}, method = RequestMethod.GET , produces = "application/json") + public String getServiceInstanceById(HttpServletRequest request){ + String customerId = request.getParameter("customerId"); + String serviceType = request.getParameter("serviceType"); + String serviceId = request.getParameter("serviceId"); + JSONArray result = new JSONArray(); + String servicesString=serviceInstanceService.getRelationShipData(customerId, serviceType, serviceId); + if(!UuiCommonUtil.isNotNullOrEmpty(servicesString)){ + return result.toString(); + } + JSONObject services = JSONObject.parseObject(servicesString); + JSONArray relations =JSONObject.parseArray(JSONObject.parseObject(services.getString("relationship-list")).getString("relationship")); + for (int i = 0; i < relations.size(); i++) { + JSONObject relation = JSONObject.parseObject(relations.getString(i)); + JSONArray relationShipData = JSONObject.parseArray(relation.getString("relationship-data")); + for (int j = 0; j < relationShipData.size(); j++) { + JSONObject res = new JSONObject(); + JSONObject data = JSONObject.parseObject(relationShipData.getString(j)); + String relationshipKey=data.getString("relationship-key"); + String netWorkServiceId=data.getString("relationship-value"); + if("service-instance.service-instance-id".equals(relationshipKey)){ + JSONObject netWorkSerSring=JSONObject.parseObject(serviceInstanceService.getRelationShipData(customerId, serviceType, netWorkServiceId)); + if("NetworkService".equals(netWorkSerSring.get("service-type"))){ + res.put("netWorkServiceId", netWorkSerSring.get("service-instance-id")); + res.put("netWorkServiceName", netWorkSerSring.get("service-instance-name")); + res.put("scaleType",""); + res.put("aspectId",""); + res.put("numberOfSteps",""); + res.put("scalingDirection",""); + result.add(res); + } + } + } + } + return result.toString() ; + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java index 5c620cfa..cb919a3d 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java @@ -18,6 +18,7 @@ package org.onap.usecaseui.server.controller.lcm; import org.onap.usecaseui.server.service.lcm.ServiceLcmService; import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation; +import org.onap.usecaseui.server.service.lcm.domain.so.bean.SaveOrUpdateOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,7 +78,7 @@ public class ServiceLcmController { */ @ResponseBody @RequestMapping(value = {"/uui-lcm/services/scaleServices/{serviceId}"}, method = RequestMethod.POST , produces = "application/json") - public DeleteOperationRsp scaleServices(@PathVariable(value = "serviceId") String serviceId, HttpServletRequest request){ + public SaveOrUpdateOperationRsp scaleServices(@PathVariable(value = "serviceId") String serviceId, HttpServletRequest request){ return serviceLcmService.scaleService(serviceId, request); } @@ -95,7 +96,7 @@ public class ServiceLcmController { */ @ResponseBody @RequestMapping(value = {"/uui-lcm/services/updateService/{serviceId}"}, method = RequestMethod.PUT , produces = "application/json") - public DeleteOperationRsp updateServices(@PathVariable(value = "serviceId") String serviceId, HttpServletRequest request){ - return serviceLcmService.scaleService(serviceId, request); + public SaveOrUpdateOperationRsp updateServices(@PathVariable(value = "serviceId") String serviceId, HttpServletRequest request){ + return serviceLcmService.updateService(serviceId, request); } } diff --git a/server/src/main/java/org/onap/usecaseui/server/dao/UsecaseuiDataSource.java b/server/src/main/java/org/onap/usecaseui/server/dao/UsecaseuiDataSource.java index 475adc01..57160301 100644 --- a/server/src/main/java/org/onap/usecaseui/server/dao/UsecaseuiDataSource.java +++ b/server/src/main/java/org/onap/usecaseui/server/dao/UsecaseuiDataSource.java @@ -1,4 +1,4 @@ -/* +/** * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java b/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java index b47b2dfd..bb78503e 100755 --- a/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java +++ b/server/src/main/java/org/onap/usecaseui/server/hibernate/HibernateConfiguration.java @@ -1,4 +1,4 @@ -/*
+/**
* Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/InitializationService.java b/server/src/main/java/org/onap/usecaseui/server/service/InitializationService.java index 330d1424..488c07e4 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/InitializationService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/InitializationService.java @@ -1,4 +1,4 @@ -/* +/** * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/InitializationServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/InitializationServiceImpl.java index adc1ffe9..c4af8ddc 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/impl/InitializationServiceImpl.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/InitializationServiceImpl.java @@ -1,4 +1,4 @@ -/* +/** * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java index 1775211c..49fa8e32 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceInstanceService.java @@ -22,4 +22,6 @@ import java.util.List; public interface ServiceInstanceService { List<ServiceInstance> listServiceInstances(String customerId, String serviceType); + + String getRelationShipData(String customerId, String serviceType,String serviceId ); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceLcmService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceLcmService.java index f2d993af..f69a33e9 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceLcmService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceLcmService.java @@ -17,6 +17,7 @@ package org.onap.usecaseui.server.service.lcm; import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation; +import org.onap.usecaseui.server.service.lcm.domain.so.bean.SaveOrUpdateOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation; import javax.servlet.http.HttpServletRequest; @@ -29,7 +30,7 @@ public interface ServiceLcmService { DeleteOperationRsp terminateService(String serviceId, HttpServletRequest request); - DeleteOperationRsp scaleService(String serviceId,HttpServletRequest request); + SaveOrUpdateOperationRsp scaleService(String serviceId,HttpServletRequest request); - DeleteOperationRsp updateService(String serviceId,HttpServletRequest request); + SaveOrUpdateOperationRsp updateService(String serviceId,HttpServletRequest request); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java index d1ea6815..267efcef 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java @@ -16,6 +16,8 @@ package org.onap.usecaseui.server.service.lcm.domain.aai; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.*; + +import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Headers; @@ -71,4 +73,13 @@ public interface AAIService { }) @GET("/api/aai-externalSystem/v11/esr-thirdparty-sdnc-list") Call<SDNCControllerRsp> listSdncControllers(); + + @Headers({ + "X-TransactionId: 7777", + "X-FromAppId: uui", + "Authorization: Basic QUFJOkFBSQ==", + "Accept: application/json" + }) + @GET("/api/aai-business/v11/customers/customer/{customerId}/service-subscriptions/service-subscription/{service-type}/service-instances/service-instance/{serviceId}") + Call<ResponseBody> getAAIServiceInstance(@Path("customerId") String customerId,@Path("service-type") String seviceType,@Path("serviceId") String serviceId); } 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 fc414524..e4ea5b56 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 @@ -18,6 +18,7 @@ package org.onap.usecaseui.server.service.lcm.domain.so; import okhttp3.RequestBody; import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation; +import org.onap.usecaseui.server.service.lcm.domain.so.bean.SaveOrUpdateOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation; import retrofit2.Call; import retrofit2.http.*; @@ -51,12 +52,12 @@ public interface SOService { "Accept: application/json" }) @POST("/ecomp/mso/infra/e2eServiceInstances/v3/{serviceId}/scale") - Call<DeleteOperationRsp> scaleService(@Path("serviceId") String serviceId, @Body RequestBody body); + Call<SaveOrUpdateOperationRsp> scaleService(@Path("serviceId") String serviceId, @Body RequestBody body); @Headers({ "Authorization: Basic SW5mcmFQb3J0YWxDbGllbnQ6cGFzc3dvcmQxJA==", "Accept: application/json" }) @PUT("/ecomp/mso/infra/e2eServiceInstances/v3/{serviceId}") - Call<DeleteOperationRsp> updateService(@Path("serviceId") String serviceId, @Body RequestBody body); + Call<SaveOrUpdateOperationRsp> updateService(@Path("serviceId") String serviceId, @Body RequestBody body); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/SaveOrUpdateOperationRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/SaveOrUpdateOperationRsp.java new file mode 100644 index 00000000..ed718e66 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/so/bean/SaveOrUpdateOperationRsp.java @@ -0,0 +1,32 @@ +/** + * Copyright 2016-2017 CMCC Corporation. + * + * 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.usecaseui.server.service.lcm.domain.so.bean; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown=true) +public class SaveOrUpdateOperationRsp { + + private String operationId; + + public String getOperationId() { + return operationId; + } + + public void setOperationId(String operationId) { + this.operationId = operationId; + } +} diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java index ff430a5c..8cd7ab5e 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java @@ -25,6 +25,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; + +import okhttp3.ResponseBody; import retrofit2.Response; import java.io.IOException; @@ -63,4 +65,21 @@ public class DefaultServiceInstanceService implements ServiceInstanceService { throw new AAIException("AAI is not available.", e); } } + + @Override + public String getRelationShipData(String customerId, String serviceType, String serviceId) { + try { + Response<ResponseBody> response = aaiService.getAAIServiceInstance(customerId, serviceType,serviceId).execute(); + if (response.isSuccessful()) { + String result=new String(response.body().bytes()); + return result; + } else { + logger.info(String.format("Can not get service instances[code=%s, message=%s]", response.code(), response.message())); + return ""; + } + } catch (IOException e) { + logger.error("list services instances occur exception"); + throw new AAIException("AAI is not available.", e); + } + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java index 6fc85b3b..1e9895de 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceLcmService.java @@ -15,25 +15,28 @@ */ package org.onap.usecaseui.server.service.lcm.impl; -import okhttp3.RequestBody; +import static org.onap.usecaseui.server.util.RestfulServices.create; +import static org.onap.usecaseui.server.util.RestfulServices.extractBody; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; + import org.onap.usecaseui.server.service.lcm.ServiceLcmService; import org.onap.usecaseui.server.service.lcm.domain.so.SOService; import org.onap.usecaseui.server.service.lcm.domain.so.bean.DeleteOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.OperationProgressInformation; +import org.onap.usecaseui.server.service.lcm.domain.so.bean.SaveOrUpdateOperationRsp; import org.onap.usecaseui.server.service.lcm.domain.so.bean.ServiceOperation; import org.onap.usecaseui.server.service.lcm.domain.so.exceptions.SOException; +import org.onap.usecaseui.server.util.UuiCommonUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; -import retrofit2.Response; -import javax.servlet.http.HttpServletRequest; -import java.io.IOException; -import java.util.Collections; - -import static org.onap.usecaseui.server.util.RestfulServices.create; -import static org.onap.usecaseui.server.util.RestfulServices.extractBody; +import okhttp3.RequestBody; +import retrofit2.Response; @Service("ServiceLcmService") @org.springframework.context.annotation.Configuration @@ -55,15 +58,17 @@ public class DefaultServiceLcmService implements ServiceLcmService { @Override public ServiceOperation instantiateService(HttpServletRequest request) { try { - RequestBody requestBody = extractBody(request); + logger.info("so instantiate is starting"); + RequestBody requestBody = extractBody(request); Response<ServiceOperation> response = soService.instantiateService(requestBody).execute(); + logger.info("so instantiate has finished"); if (response.isSuccessful()) { return response.body(); } else { - logger.info(String.format("Can not instantiate service[code=%s, message=%s]", response.code(), response.message())); + logger.error(String.format("Can not instantiate service[code=%s, message=%s]", response.code(), response.message())); throw new SOException("SO instantiate service failed!"); } - } catch (IOException e) { + } catch (Exception e) { throw new SOException("SO Service is not available!", e); } } @@ -75,7 +80,7 @@ public class DefaultServiceLcmService implements ServiceLcmService { if (response.isSuccessful()) { return response.body(); } else { - logger.info(String.format("Can not query operation process[code=%s, message=%s]", response.code(), response.message())); + logger.error(String.format("Can not query operation process[code=%s, message=%s]", response.code(), response.message())); throw new SOException("SO query operation process failed!"); } } catch (IOException e) { @@ -86,12 +91,14 @@ public class DefaultServiceLcmService implements ServiceLcmService { @Override public DeleteOperationRsp terminateService(String serviceId, HttpServletRequest request) { try { + logger.info("so terminate is starting"); RequestBody requestBody = extractBody(request); Response<DeleteOperationRsp> response = soService.terminateService(serviceId, requestBody).execute(); + logger.info("so terminate has finished"); if (response.isSuccessful()) { return response.body(); } else { - logger.info(String.format("Can not terminate service[code=%s, message=%s]", response.code(), response.message())); + logger.error(String.format("Can not terminate service[code=%s, message=%s]", response.code(), response.message())); throw new SOException("SO terminate service failed!"); } } catch (IOException e) { @@ -100,14 +107,16 @@ public class DefaultServiceLcmService implements ServiceLcmService { } @Override - public DeleteOperationRsp scaleService(String serviceId, HttpServletRequest request) { + public SaveOrUpdateOperationRsp scaleService(String serviceId, HttpServletRequest request) { try { + logger.info("so scale is finished"); RequestBody requestBody = extractBody(request); - Response<DeleteOperationRsp> response = soService.scaleService(serviceId,requestBody).execute(); + Response<SaveOrUpdateOperationRsp> response = soService.scaleService(serviceId,requestBody).execute(); + logger.info("so scale has finished"); if(response.isSuccessful()){ return response.body(); }else{ - logger.info(String.format("Can not terminate service[code=%s, message=%s]", response.code(), response.message())); + logger.error(String.format("Can not scaleService service[code=%s, message=%s]", response.code(), response.message())); throw new SOException("SO terminate service failed!"); } } catch (IOException e) { @@ -116,14 +125,16 @@ public class DefaultServiceLcmService implements ServiceLcmService { } @Override - public DeleteOperationRsp updateService(String serviceId, HttpServletRequest request) { + public SaveOrUpdateOperationRsp updateService(String serviceId, HttpServletRequest request) { try { + logger.info("so update is starting"); RequestBody requestBody = extractBody(request); - Response<DeleteOperationRsp> response = soService.updateService(serviceId,requestBody).execute(); + Response<SaveOrUpdateOperationRsp> response = soService.updateService(serviceId,requestBody).execute(); + logger.info("so update has finished"); if(response.isSuccessful()){ return response.body(); }else{ - logger.info(String.format("Can not terminate service[code=%s, message=%s]", response.code(), response.message())); + logger.error(String.format("Can not updateService service[code=%s, message=%s]", response.code(), response.message())); throw new SOException("SO terminate service failed!"); } } catch (IOException e) { 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 1b4cd33e..d78a8533 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 @@ -289,6 +289,7 @@ public class DefaultServiceTemplateService implements ServiceTemplateService { String description = tosca.getMetaData().getValue("description"); String category = tosca.getMetaData().getValue("category"); String subcategory = tosca.getMetaData().getValue("subcategory"); + String customizationUuid = tosca.getMetaData().getValue("customizationUuid"); if(subcategory == null) { subcategory = ""; } @@ -301,6 +302,7 @@ public class DefaultServiceTemplateService implements ServiceTemplateService { description, category, subcategory, + customizationUuid, new ArrayList<>()); } @@ -316,6 +318,7 @@ public class DefaultServiceTemplateService implements ServiceTemplateService { String description = nodeTemplate.getMetaData().getValue("description"); String category = nodeTemplate.getMetaData().getValue("category"); String subcategory = nodeTemplate.getMetaData().getValue("subcategory"); + String customizationUuid = nodeTemplate.getMetaData().getValue("customizationUuid"); if(subcategory == null) { subcategory = ""; } @@ -328,6 +331,7 @@ public class DefaultServiceTemplateService implements ServiceTemplateService { description, category, subcategory, + customizationUuid, new ArrayList<>()); } diff --git a/server/src/main/java/org/onap/usecaseui/server/util/ResponseUtil.java b/server/src/main/java/org/onap/usecaseui/server/util/ResponseUtil.java index 8e2f39cb..9891bcf7 100644 --- a/server/src/main/java/org/onap/usecaseui/server/util/ResponseUtil.java +++ b/server/src/main/java/org/onap/usecaseui/server/util/ResponseUtil.java @@ -1,4 +1,4 @@ -/* +/** * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); 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 2d013ddf..6441d0ef 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,17 +15,23 @@ */ package org.onap.usecaseui.server.util; -import okhttp3.RequestBody; -import okhttp3.MediaType; -import retrofit2.Retrofit; -import retrofit2.converter.jackson.JacksonConverterFactory; +import java.io.IOException; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; -import java.io.IOException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import okhttp3.MediaType; +import okhttp3.RequestBody; +import retrofit2.Retrofit; +import retrofit2.converter.jackson.JacksonConverterFactory; public class RestfulServices { + private static final Logger logger = LoggerFactory.getLogger(RestfulServices.class); + public static <T> T create(String baseUrl, Class<T> clazz) { Retrofit retrofit = new Retrofit.Builder() .baseUrl(baseUrl) @@ -58,6 +64,7 @@ public class RestfulServices { 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); }finally { if (inStream != null) { diff --git a/server/src/main/java/org/onap/usecaseui/server/util/UuiCommonUtil.java b/server/src/main/java/org/onap/usecaseui/server/util/UuiCommonUtil.java new file mode 100644 index 00000000..f9a1e814 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/util/UuiCommonUtil.java @@ -0,0 +1,116 @@ +/** + * Copyright 2016-2017 CMCC Corporation. + * + * 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.usecaseui.server.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.lang.reflect.Array; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; + +import javax.servlet.http.HttpServletRequest; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UuiCommonUtil { + + + private static final Logger logger = LoggerFactory.getLogger(UuiCommonUtil.class); + /** + * + * getUUID + * + * @Auther YYY + * @Date 2018/4/26 + * @Title: getUUID + * @Description: + * @return + */ + public static String getUUID() { + UUID uuid = UUID.randomUUID(); + String str = uuid.toString(); + return str.substring(0, 8) + str.substring(9, 13) + + str.substring(14, 18) + str.substring(19, 23) + + str.substring(24); + } + + /** + * + * isNotNullOrEmpty + * + * @Auther YYY + * @Date 2018/5/4 + * @Title: isNotNullOrEmpty + * @Description: + * @param obj + * @return + */ + public static boolean isNotNullOrEmpty(Object obj) { + if(null == obj) { + return false; + } + if(obj instanceof Collection) { + if (((Collection)obj).size() == 0) { + return false; + } + } else if (obj instanceof String) { + if (((String)obj).trim().equals("")) { + return false; + } + } else if (obj instanceof Map) { + if (((Map)obj).size() == 0) { + return false; + } + } else if (obj.getClass().isArray()) { + if(Array.getLength(obj) == 0) { + return false; + } + } else if (obj instanceof StringBuffer) { + if (((StringBuffer)obj).length() == 0) { + return false; + } + } + return true; + } + + /** + * + * OutRequestBody + * + * @Auther YYY + * @Date 2018/5/9 + * @Title: OutRequestBody + * @Description: + * @param request + * @return + */ + public static String OutRequestBody(HttpServletRequest request){ + BufferedReader br; + String str, wholeStr = ""; + try { + br = request.getReader(); + while((str = br.readLine()) != null){ + wholeStr += str; + } + } catch (IOException e) { + logger.error("exception occurred while performing UuiCommonUtil OutRequestBody.Details:"+ e.getMessage()); + e.printStackTrace(); + } + return wholeStr; + } +} diff --git a/server/src/test/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInputTest.java b/server/src/test/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInputTest.java index 0d2d95db..2c93ee7f 100644 --- a/server/src/test/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInputTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInputTest.java @@ -34,7 +34,7 @@ public class ServiceTemplateInputTest { @Test public void testGetServiceTemplateInput() throws Exception { List<TemplateInput> inputs = new ArrayList<>(); - ServiceTemplateInput sti = new ServiceTemplateInput("invariantUUID", "uuid", "name", "type", "version", "description", "category", "subcategory", inputs); + ServiceTemplateInput sti = new ServiceTemplateInput("invariantUUID", "uuid", "name", "type", "version", "description", "category", "subcategory","", inputs); sti.getInvariantUUID(); sti.getUuid(); sti.getName(); @@ -53,7 +53,7 @@ public class ServiceTemplateInputTest { public void testSetServiceTemplateInput() throws Exception { List<TemplateInput> tis = new ArrayList<>(); TemplateInput ti = new TemplateInput("name", "type", "description", "isRequired", "defaultValue"); - ServiceTemplateInput sti = new ServiceTemplateInput("invariantUUID", "uuid", "name", "type", "version", "description", "category", "subcategory", tis); + ServiceTemplateInput sti = new ServiceTemplateInput("invariantUUID", "uuid", "name", "type", "version", "description", "category", "subcategory","", tis); sti.addNestedTemplate(sti); sti.addInputs(tis); sti.addInput(ti); 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 250c6980..ac0d2694 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 @@ -123,10 +123,10 @@ public class DefaultServiceTemplateServiceTest { private ServiceTemplateInput expectedServiceInputs(String uuid, String nodeUUID) { ServiceTemplateInput e2eServiceTemplateInput = new ServiceTemplateInput( - uuid, uuid, "VoLTE", "service","", "VoLTE", "service", "", Collections.EMPTY_LIST); + uuid, uuid, "VoLTE", "service","", "VoLTE", "service", "","", Collections.EMPTY_LIST); TemplateInput templateInput = new TemplateInput("field_name","field_type", "field_description", "true", "field_default"); ServiceTemplateInput nodeTemplateInput = new ServiceTemplateInput( - nodeUUID, nodeUUID, "", "", "","", "service", "", Collections.singletonList(templateInput)); + nodeUUID, nodeUUID, "", "", "","", "service", "","", Collections.singletonList(templateInput)); // e2eServiceTemplateInput.addNestedTemplate(nodeTemplateInput); return e2eServiceTemplateInput; } |