add files for sotn business 79/64979/1
authorguochuyicmri <guochuyi@chinamobile.com>
Thu, 6 Sep 2018 10:45:01 +0000 (18:45 +0800)
committerguochuyicmri <guochuyi@chinamobile.com>
Thu, 6 Sep 2018 10:45:20 +0000 (18:45 +0800)
Change-Id: Ic4512fd9ede7eba344613838562cf0d8de498268
Issue-ID: USECASEUI-141
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
server/src/main/java/org/onap/usecaseui/server/bean/sotn/NetWorkResource.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/bean/sotn/NetWorkResourceRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/bean/sotn/Pinterface.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/bean/sotn/PinterfaceRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/bean/sotn/Pnf.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/bean/sotn/Pnfs.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/constant/Constant.java
server/src/main/java/org/onap/usecaseui/server/controller/sotn/SotnController.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java
server/src/main/java/org/onap/usecaseui/server/service/sotn/SOTNService.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/sotn/impl/SOTNServiceImpl.java [new file with mode: 0644]

diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/sotn/NetWorkResource.java b/server/src/main/java/org/onap/usecaseui/server/bean/sotn/NetWorkResource.java
new file mode 100644 (file)
index 0000000..0af6640
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.bean.sotn;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class NetWorkResource {
+       
+       private String networkId;
+       
+       private List<Pnf> pnfs;
+       
+       private List<Pinterface> tps;
+
+       public NetWorkResource(String networkId, List<Pnf> pnfs, List<Pinterface> tps) {
+               this.networkId = networkId;
+               this.pnfs = pnfs;
+               this.tps = tps;
+       }
+
+       public NetWorkResource() {
+       }
+
+       public String getNetworkId() {
+               return networkId;
+       }
+
+       public void setNetworkId(String networkId) {
+               this.networkId = networkId;
+       }
+
+       public List<Pnf> getPnfs() {
+               return pnfs;
+       }
+
+       public void setPnfs(List<Pnf> pnfs) {
+               this.pnfs = pnfs;
+       }
+
+       public List<Pinterface> getTps() {
+               return tps;
+       }
+
+       public void setTps(List<Pinterface> tps) {
+               this.tps = tps;
+       }
+       
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/sotn/NetWorkResourceRsp.java b/server/src/main/java/org/onap/usecaseui/server/bean/sotn/NetWorkResourceRsp.java
new file mode 100644 (file)
index 0000000..592c078
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.bean.sotn;
+
+import java.util.List;
+
+public class NetWorkResourceRsp {
+       
+    private List<NetWorkResource> netWorkResources;
+    
+    public void setNetWorkResourceSkins(List<NetWorkResource> netWorkResources) {
+        this.netWorkResources = netWorkResources;
+    }
+    
+       public List<NetWorkResource> getNetWorkResources() {
+               return netWorkResources;
+       }
+    
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/sotn/Pinterface.java b/server/src/main/java/org/onap/usecaseui/server/bean/sotn/Pinterface.java
new file mode 100644 (file)
index 0000000..bd49aa5
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.bean.sotn;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class Pinterface {
+       
+       private String interfaceName;
+       
+       public Pinterface() {
+       }
+
+       @JsonCreator
+       public Pinterface(@JsonProperty("interface-name") String interfaceName) {
+               this.interfaceName = interfaceName;
+       }
+       
+       @JsonProperty("interface-name")
+       public String getInterfaceName() {
+               return interfaceName;
+       }
+       
+       @JsonProperty("interface-name")
+       public void setInterfaceName(String interfaceName) {
+               this.interfaceName = interfaceName;
+       }
+       
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/sotn/PinterfaceRsp.java b/server/src/main/java/org/onap/usecaseui/server/bean/sotn/PinterfaceRsp.java
new file mode 100644 (file)
index 0000000..636fe70
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.bean.sotn;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class PinterfaceRsp {
+       
+       private List<Pinterface> pinterfaces;
+       
+       
+       public PinterfaceRsp() {
+       }
+       
+       @JsonCreator
+       public PinterfaceRsp(@JsonProperty("p-interface")List<Pinterface> pinterfaces) {
+               this.pinterfaces = pinterfaces;
+       }
+       
+       @JsonProperty("p-interface")
+       public List<Pinterface> getPinterfaces() {
+               return pinterfaces;
+       }
+       
+       @JsonProperty("p-interface")
+       public void setPinterfaces(List<Pinterface> pinterfaces) {
+               this.pinterfaces = pinterfaces;
+       }
+       
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/sotn/Pnf.java b/server/src/main/java/org/onap/usecaseui/server/bean/sotn/Pnf.java
new file mode 100644 (file)
index 0000000..702fd92
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.bean.sotn;
+
+public class Pnf {
+       
+       private String pnfName;
+       
+       public Pnf( String pnfName) {
+               this.pnfName = pnfName;
+       }
+
+       public Pnf() {
+       }
+
+       public String getPnfName() {
+               return pnfName;
+       }
+
+       public void setPnfName(String pnfName) {
+               this.pnfName = pnfName;
+       }
+       
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/sotn/Pnfs.java b/server/src/main/java/org/onap/usecaseui/server/bean/sotn/Pnfs.java
new file mode 100644 (file)
index 0000000..7231257
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.bean.sotn;
+
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class Pnfs {
+       
+       private List<Pnf> pnfs;
+       
+       @JsonCreator
+       public Pnfs(@JsonProperty("pnf") List<Pnf> pnfs) {
+               this.pnfs = pnfs;
+       }
+       
+       @JsonProperty("pnf")
+       public List<Pnf> getPnfs() {
+               return pnfs;
+       }
+       
+       @JsonProperty("pnf")
+       public void setPnfs(List<Pnf> pnfs) {
+               this.pnfs = pnfs;
+       }
+       
+}
index ef65476..b2c79b5 100755 (executable)
@@ -28,4 +28,8 @@ public final class Constant
     public static final String RegEX_DATE_FORMAT = "[^0-9-:]";\r
     \r
     public static Map<String,ServiceTemplateInput> netWorkMap  = new HashMap<String,ServiceTemplateInput>();\r
+    \r
+    public static final String CONSTANT_SUCCESS="SUCCESS";\r
+    \r
+    public static final String CONSTANT_FAILED="FAILED";\r
 }\r
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/sotn/SotnController.java b/server/src/main/java/org/onap/usecaseui/server/controller/sotn/SotnController.java
new file mode 100644 (file)
index 0000000..9b24eb7
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.controller.sotn;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
+import org.onap.usecaseui.server.bean.sotn.NetWorkResource;
+import org.onap.usecaseui.server.bean.sotn.Pinterface;
+import org.onap.usecaseui.server.bean.sotn.Pnf;
+import org.onap.usecaseui.server.service.sotn.SOTNService;
+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 com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@Controller
+@RequestMapping("/uui-sotn")
+public class SotnController {
+       
+       @Resource(name="SOTNService")
+       public SOTNService sotnService;
+
+       public SOTNService getSotnService() {
+               return sotnService;
+       }
+
+       public void setSotnService(SOTNService sotnService) {
+               this.sotnService = sotnService;
+       }
+       
+    @ResponseBody
+    @RequestMapping(value = {"/getNetWorkResources"}, method = RequestMethod.GET , produces = "application/json")
+       public List<NetWorkResource> getNetWorkResources(){
+       List<NetWorkResource> result = new ArrayList<NetWorkResource>();
+       String json  = sotnService.getNetWorkResources();
+       createJson(json,result);
+       for(NetWorkResource networks:result){
+               List<Pinterface> pinterfaces = new ArrayList<Pinterface>();
+               List<Pnf> pnfs = networks.getPnfs();
+               for(Pnf pnf :pnfs){
+                       List<Pinterface> tps= sotnService.getPinterfaceByPnfName(pnf.getPnfName());
+                       pinterfaces.addAll(tps);
+               }
+               networks.setTps(pinterfaces);
+       }
+               return result;
+       }
+    
+    @ResponseBody
+    @RequestMapping(value = {"/getPinterfaceByPnfName/{pnfName}"}, method = RequestMethod.GET , produces = "application/json")
+    public List<Pinterface>  getPinterfaceByPnfName(@PathVariable(value="pnfName") String pnfName){
+       return sotnService.getPinterfaceByPnfName(pnfName);
+    }
+    
+    @ResponseBody
+    @RequestMapping(value = {"/getLogicalLinks"}, method = RequestMethod.GET , produces = "application/json")
+    public String getLogicalLinks(){
+       return sotnService.getLogicalLinks();
+    }
+    
+    @ResponseBody
+    @RequestMapping(value = {"/createTopoNetwork/{networkId}"}, method = RequestMethod.PUT , produces = "application/json")
+    public String createTopoNetwork(HttpServletRequest request,@PathVariable(value="networkId") String networkId){
+       return sotnService.createTopoNetwork(request,networkId);
+    }
+    
+    @ResponseBody
+    @RequestMapping(value = {"/pnf/{pnfName}/p-interfaces/p-interface/{tp-id}/createTerminationPoint"}, method = RequestMethod.PUT , produces = "application/json")
+    public String createTerminationPoint(HttpServletRequest request,@PathVariable(value="pnfName") String pnfName,@PathVariable(value="tp-id") String tpId){
+       return sotnService.createTerminationPoint(request,pnfName,tpId);
+    }
+    
+    @ResponseBody
+    @RequestMapping(value = {"/createLink/{linkName}"}, method = RequestMethod.PUT , produces = "application/json")
+    public String createLink(HttpServletRequest request,@PathVariable(value="linkName") String linkName){
+       return sotnService.createLink(request, linkName);
+    }
+    
+    @ResponseBody
+    @RequestMapping(value = {"/createPnf/{pnfName}"}, method = RequestMethod.PUT , produces = "application/json")
+    public String createPnf(HttpServletRequest request,@PathVariable(value="pnfName") String pnfName){
+       return sotnService.createPnf(request, pnfName);
+    }
+    
+    @ResponseBody
+    @RequestMapping(value = {"/deleteLink/{linkName}"}, method = RequestMethod.DELETE , produces = "application/json")
+    public String deleteLink(@PathVariable(value="linkName") String linkName){
+       return sotnService.deleteLink(linkName);
+    }
+    
+    @ResponseBody
+    @RequestMapping(value = {"/getServiceInstanceInfo"}, method = RequestMethod.GET , produces = "application/json")
+    public String getServiceInstanceInfo(HttpServletRequest request){
+        String customerId = request.getParameter("customerId");
+        String serviceType = request.getParameter("serviceType");
+        String serviceId = request.getParameter("serviceId");
+       return sotnService.serviceInstanceInfo(customerId, serviceType, serviceId);
+    }
+    
+    @ResponseBody
+    @RequestMapping(value = {"/getServiceInstanceList"}, method = RequestMethod.GET , produces = "application/json")
+    public String getServiceInstanceList(HttpServletRequest request){
+        String customerId = request.getParameter("customerId");
+        String serviceType = request.getParameter("serviceType");
+       return sotnService.getServiceInstances(customerId, serviceType);
+    }
+    
+    private void createJson(String json,List<NetWorkResource> list){
+
+       ObjectMapper mapper = new ObjectMapper();
+       
+       try {
+                       JsonNode node = mapper.readTree(json);
+                       JsonNode netNode = node.get("network-resource");
+                       for(int i=0;i<netNode.size();i++){
+                               NetWorkResource netResource = new NetWorkResource();
+                               List<Pnf> pnfs = new ArrayList<Pnf>();
+                               String networkId=netNode.get(i).get("network-id").toString();
+                               netResource.setNetworkId(networkId);
+                               String relationJson = netNode.get(i).get("relationship-list").toString();
+                               JsonNode relationNode = mapper.readTree(relationJson);
+                               
+                               JsonNode shipNode = relationNode.get("relationship");
+                               for(int j=0;j<shipNode.size();j++){
+                                       Pnf pnf = new Pnf();
+                                       JsonNode shipDataNode = shipNode.get(j).get("relationship-data");
+                                       String shipDataValue = shipDataNode.get(0).get("relationship-value").toString();
+                                       pnf.setPnfName(shipDataValue);
+                                       pnfs.add(pnf);
+                               }
+                               netResource.setPnfs(pnfs);
+                               list.add(netResource);
+                       }
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+    }
+}
index 267efce..cdfe11e 100644 (file)
  */
 package org.onap.usecaseui.server.service.lcm.domain.aai;
 
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.*;
+import org.onap.usecaseui.server.bean.sotn.PinterfaceRsp;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomerRsp;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCControllerRsp;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstanceRsp;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceSubscriptionRsp;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfoRsp;
 
+import okhttp3.RequestBody;
 import okhttp3.ResponseBody;
 import retrofit2.Call;
+import retrofit2.http.Body;
+import retrofit2.http.DELETE;
 import retrofit2.http.GET;
 import retrofit2.http.Headers;
+import retrofit2.http.PUT;
 import retrofit2.http.Path;
+import retrofit2.http.Query;
 
 public interface AAIService {
 
@@ -82,4 +92,94 @@ public interface AAIService {
        })
        @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);
+    
+    @Headers({
+        "X-TransactionId: 7777",
+        "X-FromAppId: uui",
+        "Authorization: Basic QUFJOkFBSQ==",
+        "Accept: application/json"
+    })
+       @GET("/api/aai-business/v13/network/network-resources")
+       Call<ResponseBody> listNetWorkResources();
+    
+    @Headers({
+        "X-TransactionId: 7777",
+        "X-FromAppId: uui",
+        "Authorization: Basic QUFJOkFBSQ==",
+        "Accept: application/json"
+    })
+       @GET("/api/aai-business/v13/network/pnfs/pnf/{pnfName}/p-interfaces")
+       Call<PinterfaceRsp> getPinterfaceByPnfName(@Path("pnfName") String pnfName);
+    
+    @Headers({
+        "X-TransactionId: 7777",
+        "X-FromAppId: uui",
+        "Authorization: Basic QUFJOkFBSQ==",
+        "Accept: application/json"
+    })
+       @GET("/api/aai-business/v13/network/logical-links")
+       Call<ResponseBody> getLogicalLinks();
+    
+    @Headers({
+        "X-TransactionId: 7777",
+        "X-FromAppId: uui",
+        "Authorization: Basic QUFJOkFBSQ==",
+        "Accept: application/json"
+    })
+    @PUT("/api/aai-business/v13/network/network-resources/network-resource/{networkId}")
+    Call<ResponseBody> createTopoNetwork(@Body RequestBody body,@Path("networkId") String networkId);
+    
+    @Headers({
+        "X-TransactionId: 7777",
+        "X-FromAppId: uui",
+        "Authorization: Basic QUFJOkFBSQ==",
+        "Accept: application/json"
+    })
+    @PUT("/api/aai-business/v13/network/pnfs/pnf/{pnfName}/p-interfaces/p-interface/{tp-id}")
+    Call<ResponseBody> createTerminationPoint(@Body RequestBody body,@Path("pnfName") String pnfName,@Path("tp-id") String tpId);
+    
+    @Headers({
+        "X-TransactionId: 7777",
+        "X-FromAppId: uui",
+        "Authorization: Basic QUFJOkFBSQ==",
+        "Accept: application/json"
+    })
+    @PUT("/api/aai-business/v13/network/pnfs/pnf/{pnfname}")
+    Call<ResponseBody> createPnf(@Body RequestBody body,@Path("pnfname") String pnfname);
+    
+    @Headers({
+       "X-TransactionId: 7777",
+       "X-FromAppId: uui",
+       "Authorization: Basic QUFJOkFBSQ==",
+       "Accept: application/json"
+    })
+    @PUT("/api/aai-business/v13/network/logical-links/logical-link/{linkName}")
+    Call<ResponseBody> createLink(@Body RequestBody body,@Path("linkName") String linkName);
+    
+    @Headers({
+        "X-TransactionId: 7777",
+        "X-FromAppId: uui",
+        "Authorization: Basic QUFJOkFBSQ==",
+        "Accept: application/json"
+    })
+    @DELETE("/api/aai-business/v13/network/logical-links/logical-link/{linkName}")
+    Call<ResponseBody> deleteLink(@Path("linkName") String linkName);
+    
+    @Headers({
+        "X-TransactionId: 7777",
+        "X-FromAppId: uui",
+        "Authorization: Basic QUFJOkFBSQ==",
+        "Accept: application/json"
+    })
+    @GET("/api/aai-business/v13/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}")
+    Call<ResponseBody> getServiceInstances(@Path("global-customer-id}") String customerId,@Path("service-type}") String serviceType);
+    
+    @Headers({
+        "X-TransactionId: 7777",
+        "X-FromAppId: uui",
+        "Authorization: Basic QUFJOkFBSQ==",
+        "Accept: application/json"
+    })
+    @GET("/api/aai-business/v13/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances")
+    Call<ResponseBody> serviceInstaneInfo(@Path("global-customer-id}") String globalCustomerId,@Path("service-type") String serviceType,@Query("service-instance-id") String serviceInstanceId);
 }
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/sotn/SOTNService.java b/server/src/main/java/org/onap/usecaseui/server/service/sotn/SOTNService.java
new file mode 100644 (file)
index 0000000..36262e3
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.service.sotn;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.onap.usecaseui.server.bean.sotn.Pinterface;
+
+public interface SOTNService {
+       
+       public String getNetWorkResources();
+       
+       public List<Pinterface>  getPinterfaceByPnfName(String pnfName);
+       
+       public String getLogicalLinks();
+       
+       public String createTopoNetwork(HttpServletRequest request,String networkId);
+       
+       public String createTerminationPoint(HttpServletRequest request,String pnfName,String tpId);
+       
+       public String createLink(HttpServletRequest request,String linkName);
+       
+       public String createPnf(HttpServletRequest request,String pnfName);
+       
+       public String deleteLink(String linkName);
+       
+       public String getServiceInstances(String customerId,String serviceType);
+       
+       public String serviceInstanceInfo(String customerId,String serviceType,String serviceInstanceId);
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/sotn/impl/SOTNServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/sotn/impl/SOTNServiceImpl.java
new file mode 100644 (file)
index 0000000..c39b651
--- /dev/null
@@ -0,0 +1,266 @@
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. 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.
+ */
+package org.onap.usecaseui.server.service.sotn.impl;
+
+import static org.onap.usecaseui.server.util.RestfulServices.extractBody;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.onap.usecaseui.server.bean.sotn.Pinterface;
+import org.onap.usecaseui.server.bean.sotn.PinterfaceRsp;
+import org.onap.usecaseui.server.constant.Constant;
+import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
+import org.onap.usecaseui.server.service.lcm.domain.so.exceptions.SOException;
+import org.onap.usecaseui.server.service.sotn.SOTNService;
+import org.onap.usecaseui.server.util.RestfulServices;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Service;
+
+import okhttp3.RequestBody;
+import okhttp3.ResponseBody;
+import retrofit2.Response;
+
+@Service("SOTNService")
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class SOTNServiceImpl implements SOTNService{
+       
+    private static final Logger logger = LoggerFactory.getLogger(SOTNServiceImpl.class);
+
+    private AAIService aaiService;
+
+    public SOTNServiceImpl() {
+        this(RestfulServices.create(AAIService.class));
+    }
+
+    public SOTNServiceImpl(AAIService aaiService) {
+       this.aaiService = aaiService;
+       }
+
+       @Override
+       public String getNetWorkResources() {
+        try {
+               logger.info("aai getNetWorkResources is starting!");
+            Response<ResponseBody> response = this.aaiService.listNetWorkResources().execute();
+            logger.info("aai getNetWorkResources has finished!");
+            if (response.isSuccessful()) {
+               String result=new String(response.body().bytes());
+                return result;
+            } else {
+                logger.info(String.format("Can not get getNetWorkResources[code=%s, message=%s]", response.code(), response.message()));
+                return "";
+            }
+        } catch (IOException e) {
+            logger.error("getNetWorkResources occur exception:"+e);
+            throw new AAIException("AAI is not available.", e);
+        }
+       }
+
+       @Override
+       public List<Pinterface> getPinterfaceByPnfName(String pnfName) {
+        try {
+               logger.info("aai getPinterfaceByPnfName is starting!");
+            Response<PinterfaceRsp> response = this.aaiService.getPinterfaceByPnfName(pnfName).execute();
+            logger.info("aai getPinterfaceByPnfName has finished!");
+            if (response.isSuccessful()) {
+                return response.body().getPinterfaces();
+            } else {
+                logger.info(String.format("Can not get getPinterfaceByPnfName[code=%s, message=%s]", response.code(), response.message()));
+                return Collections.emptyList();
+            }
+        } catch (IOException e) {
+            logger.error("getPinterfaceByPnfName occur exception:"+e);
+            throw new AAIException("AAI is not available.", e);
+        }
+       }
+
+       @Override
+       public String getLogicalLinks() {
+        try {
+               logger.info("aai getLogicalLinks is starting!");
+            Response<ResponseBody> response = this.aaiService.getLogicalLinks().execute();
+            logger.info("aai getLogicalLinks has finished!");
+            if (response.isSuccessful()) {
+               String result=new String(response.body().bytes());
+                return result;
+            } else {
+                logger.info(String.format("Can not get getLogicalLinks[code=%s, message=%s]", response.code(), response.message()));
+                return "";
+            }
+        } catch (IOException e) {
+            logger.error("getLogicalLinks occur exception:"+e);
+            throw new AAIException("AAI is not available.", e);
+        }
+       }
+
+       @Override
+       public String createTopoNetwork(HttpServletRequest request,String networkId) {
+               String result = "";
+        try {
+               logger.info("aai createTopoNetwork is starting");
+               RequestBody requestBody = extractBody(request);
+            Response<ResponseBody> response = aaiService.createTopoNetwork(requestBody,networkId).execute();
+                       logger.info("aai createTopoNetwork has finished");
+            if (response.isSuccessful()) {
+               result=Constant.CONSTANT_SUCCESS;
+            } else {
+               result=Constant.CONSTANT_FAILED;
+                logger.error(String.format("Can not createTopoNetwork[code=%s, message=%s]", response.code(), response.message()));
+                throw new SOException("aai createTopoNetwork failed!");
+            }
+        } catch (Exception e) {
+               result=Constant.CONSTANT_FAILED;
+               logger.error("createTopoNetwork occur exception:"+e);
+            throw new SOException("aai createTopoNetwork is not available!", e);
+        }
+        return result;
+       }
+
+       @Override
+       public String createTerminationPoint(HttpServletRequest request,String pnfName,String tpId) {
+               String result = "";
+        try {
+               logger.info("aai createTerminationPoint is starting");
+               RequestBody requestBody = extractBody(request);
+            Response<ResponseBody> response = aaiService.createTerminationPoint(requestBody,pnfName,tpId).execute();
+                       logger.info("aai createTerminationPoint has finished");
+            if (response.isSuccessful()) {
+               result=Constant.CONSTANT_SUCCESS;
+            } else {
+               result=Constant.CONSTANT_FAILED;
+                logger.error(String.format("Can not createTerminationPoint[code=%s, message=%s]", response.code(), response.message()));
+                throw new SOException("aai createTerminationPoint failed!");
+            }
+        } catch (Exception e) {
+               result=Constant.CONSTANT_FAILED;
+               logger.error("createTerminationPoint occur exception:"+e);
+            throw new SOException("aai createTerminationPoint is not available!", e);
+        }
+        return result;
+       }
+
+       @Override
+       public String createLink(HttpServletRequest request,String linkName) {
+               String result = "";
+        try {
+               logger.info("aai createLink is starting");
+               RequestBody requestBody = extractBody(request);
+            Response<ResponseBody> response = aaiService.createLink(requestBody,linkName).execute();
+                       logger.info("aai createLink has finished");
+            if (response.isSuccessful()) {
+               result=Constant.CONSTANT_SUCCESS;
+            } else {
+               result=Constant.CONSTANT_FAILED;
+                logger.error(String.format("Can not createLink[code=%s, message=%s]", response.code(), response.message()));
+                throw new SOException("aai createLink failed!");
+            }
+        } catch (Exception e) {
+               result="FAILED";
+               logger.error("createLink occur exception:"+e);
+            throw new SOException("aai createLink is not available!", e);
+        }
+        return result;
+       }
+       
+       @Override
+       public String createPnf(HttpServletRequest request,String pnfName) {
+               String result = "";
+        try {
+               logger.info("aai createPnf is starting");
+               RequestBody requestBody = extractBody(request);
+            Response<ResponseBody> response = aaiService.createPnf(requestBody,pnfName).execute();
+                       logger.info("aai createPnf has finished");
+            if (response.isSuccessful()) {
+               result=Constant.CONSTANT_SUCCESS;
+            } else {
+               result=Constant.CONSTANT_FAILED;
+                logger.error(String.format("Can not createPnf[code=%s, message=%s]", response.code(), response.message()));
+                throw new SOException("aai createPnf failed!");
+            }
+        } catch (Exception e) {
+               result=Constant.CONSTANT_FAILED;
+               logger.error("createPnf occur exception:"+e);
+        }
+        return result;
+       }
+       
+       @Override
+       public String deleteLink(String linkName) {
+               String result = "";
+        try {
+               logger.info("aai deleteLink is starting");
+            Response<ResponseBody> response = aaiService.deleteLink(linkName).execute();
+                       logger.info("aai deleteLink has finished");
+            if (response.isSuccessful()) {
+               result=Constant.CONSTANT_SUCCESS;
+            } else {
+               result=Constant.CONSTANT_FAILED;
+                logger.error(String.format("Can not deleteLink[code=%s, message=%s]", response.code(), response.message()));
+                throw new SOException("aai deleteLink failed!");
+            }
+        } catch (Exception e) {
+               result=Constant.CONSTANT_FAILED;
+               logger.error("deleteLink occur exception:"+e);
+            throw new SOException("aai deleteLink is not available!", e);
+        }
+        return result;
+       }
+
+       @Override
+       public String getServiceInstances(String customerId, String serviceType) {
+        try {
+               logger.info("aai getServiceInstances is starting");
+            Response<ResponseBody> response = aaiService.getServiceInstances(customerId, serviceType).execute();
+                       logger.info("aai getServiceInstances has finished");
+            if (response.isSuccessful()) {
+               String result=new String(response.body().bytes());
+                return result;
+            } else {
+                logger.error(String.format("Can not getServiceInstances[code=%s, message=%s]", response.code(), response.message()));
+                throw new SOException("aai getServiceInstances failed!");
+            }
+        } catch (Exception e) {
+               logger.error("getServiceInstances occur exception:"+e);
+            throw new SOException("aai getServiceInstances is not available!", e);
+        }
+       }
+
+       @Override
+       public String serviceInstanceInfo(String customerId, String serviceType, String serviceInstanceId) {
+        try {
+               logger.info("aai serviceInstanceInfo is starting");
+            Response<ResponseBody> response = aaiService.serviceInstaneInfo(customerId, serviceType, serviceInstanceId).execute();
+                       logger.info("aai serviceInstanceInfo has finished");
+            if (response.isSuccessful()) {
+               String result=new String(response.body().bytes());
+                return result;
+            } else {
+                logger.error(String.format("Can not serviceInstanceInfo[code=%s, message=%s]", response.code(), response.message()));
+                throw new SOException("aai serviceInstanceInfo failed!");
+            }
+        } catch (Exception e) {
+               logger.error("serviceInstanceInfo occur exception:"+e);
+            throw new SOException("aai serviceInstanceInfo is not available!", e);
+        }
+       }
+}