return packageDistributionService.deleteVfPackage(casrId);
}
+ @RequestMapping(value = {"/uui-lcm/fetchNsTemplateData}"}, method = RequestMethod.GET , produces = "application/json")
+ public String fetchNsTemplateData(HttpServletRequest request){
+ return packageDistributionService.fetchNsTemplateData(request);
+ }
+
+ @RequestMapping(value = {"/uui-lcm/listNsTemplates}"}, method = RequestMethod.GET , produces = "application/json")
+ public String listNsTemplates(){
+ return packageDistributionService.listNsTemplates();
+ }
+
@RequestMapping(value = {"/uui-lcm/ns-packages}"}, method = RequestMethod.GET , produces = "application/json")
public String getNsPackages(){
return packageDistributionService.getNetworkServicePackages();
*/
package org.onap.usecaseui.server.controller.lcm;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
@Controller
@org.springframework.context.annotation.Configuration
@ResponseBody
@RequestMapping(value = {"/uui-lcm/service-instances"}, method = RequestMethod.GET , produces = "application/json")
- public List<ServiceInstance> listServiceInstances(HttpServletRequest request){
+ public List<String> listServiceInstances(HttpServletRequest request){
+ List<String> result = new ArrayList<String>();
String customerId = request.getParameter("customerId");
String serviceType = request.getParameter("serviceType");
- List<ServiceInstance> list =serviceInstanceService.listServiceInstances(customerId, serviceType);
- if(list.size()>0){
- for(ServiceInstance serviceInstance:list){
- ServiceBean serviceBean = serviceLcmService.getServiceBeanByServiceInStanceId(serviceInstance.getServiceInstanceId());
- if(UuiCommonUtil.isNotNullOrEmpty(serviceBean)){
- serviceInstance.setServiceDomain(serviceBean.getServiceDomain());
- }
- }
- }
- System.out.println(list);
- return list;
+ List<String> serviceInstances =serviceInstanceService.listServiceInstances(customerId, serviceType);
+ return result;
}
@ResponseBody
@RequestMapping(value = {"/uui-lcm/getServiceInstanceById"}, method = RequestMethod.GET , produces = "application/json")
}
return result.toString() ;
}
+
+ private void parseServiceInstance(List<String> list){
+ ObjectMapper mapper = new ObjectMapper();
+ for(String serviceInstance:list){
+ try {
+ JsonNode node = mapper.readTree(serviceInstance);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
}
Job deleteVfPackage(String csarId);
+ String listNsTemplates();
+
+ String fetchNsTemplateData(HttpServletRequest request);
+
String getVnfPackages();
String getNetworkServicePackages();
*/
package org.onap.usecaseui.server.service.lcm;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance;
-
import java.util.List;
public interface ServiceInstanceService {
- List<ServiceInstance> listServiceInstances(String customerId, String serviceType);
+ List<String> listServiceInstances(String customerId, String serviceType);
String getRelationShipData(String customerId, String serviceType,String serviceId );
}
public class ServiceInstanceRsp {
- private List<ServiceInstance> serviceInstances;
+ private List<String> serviceInstances;
@JsonProperty("service-instance")
- public List<ServiceInstance> getServiceInstances() {
+ public List<String> getServiceInstances() {
return serviceInstances;
}
@JsonProperty("service-instance")
- public void setServiceInstances(List<ServiceInstance> serviceInstances) {
+ public void setServiceInstances(List<String> serviceInstances) {
this.serviceInstances = serviceInstances;
}
}
@DELETE("/api/catalog/v1/vnfpackages/{csarId}")
Call<Job> deleteVnfPackage(@Path("csarId") String csarId);
+ @GET("/api/catalog/v1/nspackages")
+ Call<ResponseBody> listNsTemplates();
+
+ @GET("/api/catalog/v1/parsernsd")
+ Call<ResponseBody> fetchNsTemplateData(@Body RequestBody body);
+
@GET("/api/nslcm/v1/ns")
Call<ResponseBody> getNetworkServiceInfo();
return result;
}
+
+ @Override
+ public String listNsTemplates() {
+
+ String result="";
+ try {
+ logger.info("vfc listNsTemplates is starting!");
+ Response<ResponseBody> response = this.vfcService.listNsTemplates().execute();
+ logger.info("vfc listNsTemplates has finished!");
+ if (response.isSuccessful()) {
+ result=new String(response.body().bytes());
+ } else {
+ logger.info(String.format("Can not get listNsTemplates[code=%s, message=%s]", response.code(), response.message()));
+ result=Constant.CONSTANT_FAILED;;
+ }
+ } catch (IOException e) {
+ logger.error("listNsTemplates occur exception:"+e);
+ result=Constant.CONSTANT_FAILED;;
+ }
+ return result;
+
+ }
+
+ @Override
+ public String fetchNsTemplateData(HttpServletRequest request) {
+ String result = "";
+ try {
+ logger.info("aai fetchNsTemplateData is starting");
+ RequestBody requestBody = extractBody(request);
+ Response<ResponseBody> response = vfcService.fetchNsTemplateData(requestBody).execute();
+ logger.info("aai fetchNsTemplateData has finished");
+ if (response.isSuccessful()) {
+ result=new String(response.body().bytes());
+ } else {
+ result=Constant.CONSTANT_FAILED;
+ logger.error(String.format("Can not fetchNsTemplateData[code=%s, message=%s]", response.code(), response.message()));
+ }
+ } catch (Exception e) {
+ result=Constant.CONSTANT_FAILED;
+ logger.error("fetchNsTemplateData occur exception:"+e);
+ }
+ return result;
+ }
}
}
@Override
- public List<ServiceInstance> listServiceInstances(String customerId, String serviceType) {
+ public List<String> listServiceInstances(String customerId, String serviceType) {
try {
Response<ServiceInstanceRsp> response = aaiService.listServiceInstances(customerId, serviceType).execute();
if (response.isSuccessful()) {
AAIService aaiService = mock(AAIService.class);
String customerId = "1";
String serviceType = "service";
- List<ServiceInstance> instances = Collections.singletonList(new ServiceInstance("1","service","1","VoLTE","e2eservice","abc","vim1"));
+ List<String> instances = Collections.singletonList("{\"service-instance-id\":\"35e88f8e-473f-4d88-92f8-6739a42baa23\",\"service-instance-name\":\"SDWANVPNInfra1\",\"service-type\":\"E2E Service\",\"service-role\":\"E2E Service\",\"model-invariant-id\":\"88dcb2f0-085b-4548-8b93-0882e37d25d8\",\"model-version-id\":\"462f84e5-f0e5-44c5-ab95-38fb4bf77064\",\"resource-version\":\"1535687551051\",\"input-parameters\":\"{\\n \\\"service\\\":{\\n \\\"name\\\":\\\"SDWANVPNInfra\\\",\\n \\\"description\\\":\\\"SDWANVPNInfra\\\",\\n \\\"serviceInvariantUuid\\\":\\\"88dcb2f0-085b-4548-8b93-0882e37d25d8\\\",\\n \\\"serviceUuid\\\":\\\"462f84e5-f0e5-44c5-ab95-38fb4bf77064\\\",\\n \\\"globalSubscriberId\\\":\\\"Demonstration\\\",\\n \\\"serviceType\\\":\\\"CCVPN\\\",\\n \\\"parameters\\\":{\\n \\\"locationConstraints\\\":[\\n\\n ],\\n \\\"resources\\\":[\\n {\\n \\\"resourceName\\\":\\\"SDWANConnectivity 0\\\",\\n \\\"resourceInvariantUuid\\\":\\\"f99a9a23-c88e-44ff-a4dc-22b88675d278\\\",\\n \\\"resourceUuid\\\":\\\"7baa7742-3a13-4288-8330-868015adc340\\\",\\n \\\"resourceCustomizationUuid\\\":\\\"94ec574b-2306-4cbd-8214-09662b040f73\\\",\\n \\\"parameters\\\":{\\n \\\"locationConstraints\\\":[\\n\\n ],\\n \\\"resources\\\":[\\n\\n ],\\n \\\"requestInputs\\\":{\\n\\n }\\n }\\n },\\n {\\n \\\"resourceName\\\":\\\"SPPartnerVF 0\\\",\\n \\\"resourceInvariantUuid\\\":\\\"072f9238-15b0-4bc5-a5f5-f18548739470\\\",\\n \\\"resourceUuid\\\":\\\"81b9430b-8abe-45d6-8bf9-f41a8f5c735f\\\",\\n \\\"resourceCustomizationUuid\\\":\\\"a7baba5d-6ac3-42b5-b47d-070841303ab1\\\",\\n \\\"parameters\\\":{\\n \\\"locationConstraints\\\":[\\n\\n ],\\n \\\"resources\\\":[\\n\\n ],\\n \\\"requestInputs\\\":{\\n\\n }\\n }\\n }\\n ],\\n \\\"requestInputs\\\":{\\n \\\"sdwanconnectivity0_name\\\":\\\"CMCCVPN\\\",\\n \\\"sdwanconnectivity0_topology\\\":\\\"hub-spoke\\\"\\n }\\n }\\n }\\n}\",\"relationship-list\":{\"relationship\":[{\"related-to\":\"sdwan-vpn\",\"relationship-label\":\"org.onap.relationships.inventory.PartOf\",\"related-link\":\"/aai/v13/network/sdwan-vpns/sdwan-vpn/4efe6dff-acfc-4d13-a3fd-1177d3c08e89\",\"relationship-data\":[{\"relationship-key\":\"sdwan-vpn.sdwan-vpn-id\",\"relationship-value\":\"4efe6dff-acfc-4d13-a3fd-1177d3c08e89\"}],\"related-to-property\":[{\"property-key\":\"sdwan-vpn.sdwan-vpn-name\",\"property-value\":\"vdfvpn\"}]},{\"related-to\":\"sp-partner\",\"relationship-label\":\"org.onap.relationships.inventory.PartOf\",\"related-link\":\"/aai/v13/business/sp-partners/sp-partner/1b9c677d-fddf-4b70-938b-925a7fa57d00\",\"relationship-data\":[{\"relationship-key\":\"sp-partner.sp-partner-id\",\"relationship-value\":\"1b9c677d-fddf-4b70-938b-925a7fa57d00\"}],\"related-to-property\":[{\"property-key\":\"sp-partner.sp-partner-id\",\"property-value\":\"1b9c677d-fddf-4b70-938b-925a7fa57d00\"}]},{\"related-to\":\"allotted-resource\",\"relationship-label\":\"org.onap.relationships.inventory.Uses\",\"related-link\":\"/aai/v13/business/customers/customer/Democcy/service-subscriptions/service-subscription/CCVPN/service-instances/service-instance/189b87a5-72fe-4197-a307-6929c3831f81/allotted-resources/allotted-resource/2214feec-1aef-4890-abba-f8f3a906935f\",\"relationship-data\":[{\"relationship-key\":\"customer.global-customer-id\",\"relationship-value\":\"Democcy\"},{\"relationship-key\":\"service-subscription.service-type\",\"relationship-value\":\"CCVPN\"},{\"relationship-key\":\"service-instance.service-instance-id\",\"relationship-value\":\"189b87a5-72fe-4197-a307-6929c3831f81\"},{\"relationship-key\":\"allotted-resource.id\",\"relationship-value\":\"2214feec-1aef-4890-abba-f8f3a906935f\"}],\"related-to-property\":[{\"property-key\":\"allotted-resource.description\",\"property-value\":\"2214feec-1aef-4890-abba-f8f3a906935f\"},{\"property-key\":\"allotted-resource.allotted-resource-name\",\"property-value\":\"sdwan ar\"}]},{\"related-to\":\"allotted-resource\",\"relationship-label\":\"org.onap.relationships.inventory.Uses\",\"related-link\":\"/aai/v13/business/customers/customer/Democcy/service-subscriptions/service-subscription/CCVPN/service-instances/service-instance/089b87a5-72fe-4197-a307-6929c3831f80/allotted-resources/allotted-resource/1114feec-1aef-4890-abba-f8f3a906935f\",\"relationship-data\":[{\"relationship-key\":\"customer.global-customer-id\",\"relationship-value\":\"Democcy\"},{\"relationship-key\":\"service-subscription.service-type\",\"relationship-value\":\"CCVPN\"},{\"relationship-key\":\"service-instance.service-instance-id\",\"relationship-value\":\"089b87a5-72fe-4197-a307-6929c3831f80\"},{\"relationship-key\":\"allotted-resource.id\",\"relationship-value\":\"1114feec-1aef-4890-abba-f8f3a906935f\"}],\"related-to-property\":[{\"property-key\":\"allotted-resource.description\",\"property-value\":\"1114feec-1aef-4890-abba-f8f3a906935f\"},{\"property-key\":\"allotted-resource.allotted-resource-name\",\"property-value\":\"sdwan ar\"}]}]}}");
ServiceInstanceRsp rsp = new ServiceInstanceRsp();
rsp.setServiceInstances(instances);
when(aaiService.listServiceInstances(customerId, serviceType)).thenReturn(successfulCall(rsp));
when(aaiService.listServiceInstances(customerId, serviceType)).thenReturn(emptyBodyCall());
ServiceInstanceService service = new DefaultServiceInstanceService(aaiService);
- List<ServiceInstance> serviceInstances = service.listServiceInstances(customerId, serviceType);
+ List<String> serviceInstances = service.listServiceInstances(customerId, serviceType);
Assert.assertTrue("service instances should be empty.", serviceInstances.isEmpty());
}