aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguochuyicmri <guochuyi@chinamobile.com>2019-04-02 17:56:37 +0800
committerguochuyicmri <guochuyi@chinamobile.com>2019-04-02 17:56:47 +0800
commit81c25b176b3c7e5206bf7d059e79d6cd00f9850e (patch)
treec74701ddc8183545adc9d107e29db14b92ba2300
parenta29a7bebca92aee498f60aca9c2476dcf81e6010 (diff)
Add backend Code for customer/serviceType management UI page
Change-Id: Ie1937cf1983c420231a8f4fb6ec5cba131f09d5a Issue-ID: USECASEUI-213 Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
-rw-r--r--server/pom.xml2
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java43
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java18
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java101
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java145
5 files changed, 286 insertions, 23 deletions
diff --git a/server/pom.xml b/server/pom.xml
index 6d575bba..5ef9f200 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -35,7 +35,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<hibernate.version>5.3.6.Final</hibernate.version>
- <spring.version>4.3.15.RELEASE</spring.version>
+ <spring.version>4.3.4.RELEASE</spring.version>
<javax.persistence.version>1.0.2</javax.persistence.version>
<common.csv.version>1.4</common.csv.version>
<jackson.version>2.9.0</jackson.version>
diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java
index 9d332e7b..22bda7e4 100644
--- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java
+++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java
@@ -23,9 +23,14 @@ 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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import com.alibaba.fastjson.JSONObject;
+
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+
import java.util.List;
@Controller
@@ -45,10 +50,46 @@ public class CustomerController {
public List<AAICustomer> getCustomers(){
return customerService.listCustomer();
}
-
+
+ @ResponseBody
+ @RequestMapping(value={"/uui-lcm/customers/{customerId}"},method = RequestMethod.PUT,produces="application/json")
+ public JSONObject createOrUpdateCustomer(HttpServletRequest request,@PathVariable String customerId){
+ return customerService.createOrUpdateCustomer(request, customerId);
+ }
+
+ @ResponseBody
+ @RequestMapping(value={"/uui-lcm/customers/{customerId}"},method = RequestMethod.GET,produces="application/json")
+ public JSONObject getCustomerById(@PathVariable String customerId){
+ return customerService.getCustomerById(customerId);
+ }
+
+ @ResponseBody
+ @RequestMapping(value={"/uui-lcm/customers"},method = RequestMethod.DELETE,produces="application/json")
+ public JSONObject deleteCustomer(@RequestParam String customerId,@RequestParam String resourceVersion){
+ return customerService.deleteCustomer(customerId,resourceVersion);
+ }
+
@ResponseBody
@RequestMapping(value = {"/uui-lcm/customers/{customerId}/service-subscriptions"}, method = RequestMethod.GET , produces = "application/json")
public List<AAIServiceSubscription> getServiceSubscriptions(@PathVariable(value="customerId") String customerId){
return customerService.listServiceSubscriptions(customerId);
}
+
+ @ResponseBody
+ @RequestMapping(value={"/uui-lcm/customers/{customerId}/service-subscriptions/{serviceType}"},method = RequestMethod.PUT,produces="application/json")
+ public JSONObject createOrUpdateServiceType(HttpServletRequest request,@PathVariable String serviceType){
+ return customerService.createOrUpdateServiceType(request, serviceType);
+ }
+
+ @ResponseBody
+ @RequestMapping(value={"/uui-lcm/customers/{customerId}/service-subscriptions/{serviceType}"},method = RequestMethod.DELETE,produces="application/json")
+ public JSONObject deleteServiceType(@PathVariable String customerId,@PathVariable String serviceType,@RequestParam String resourceVersion){
+ return customerService.deleteServiceType(customerId,serviceType,resourceVersion);
+ }
+
+ @ResponseBody
+ @RequestMapping(value={"/uui-lcm/customers/{customerId}/service-subscriptions/{serviceType}"},method = RequestMethod.GET,produces="application/json")
+ public JSONObject getServiceTypeById(@PathVariable String customerId,@PathVariable String serviceType){
+ return customerService.getServiceTypeById(customerId,serviceType);
+ }
}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java
index 0bd3f323..2e906550 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java
@@ -18,9 +18,27 @@ package org.onap.usecaseui.server.service.lcm;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription;
+import com.alibaba.fastjson.JSONObject;
+
import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+
public interface CustomerService {
+
List<AAICustomer> listCustomer();
+
+ JSONObject createOrUpdateCustomer(HttpServletRequest request,String customerId);
+
+ JSONObject deleteCustomer(String customerId,String resourceVersion);
+
+ JSONObject getCustomerById(String customerId);
+
List<AAIServiceSubscription> listServiceSubscriptions(String customerId);
+
+ JSONObject createOrUpdateServiceType(HttpServletRequest request,String serviceType);
+
+ JSONObject deleteServiceType(String customerId,String serviceType,String resourceVersion);
+
+ JSONObject getServiceTypeById(String customerId,String serviceType);
}
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 1e898c06..58ce2cb5 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,7 +16,15 @@
package org.onap.usecaseui.server.service.lcm.domain.aai;
import org.onap.usecaseui.server.bean.sotn.PinterfaceRsp;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.*;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomerRsp;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIOrchestratorRsp;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAISingleOrchestratorRsp;
+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;
@@ -38,27 +46,54 @@ public interface AAIService {
"Accept: application/json"
})
// @GET("/api/aai-business/v11/customers")
- @GET("/api/aai-business/v11/customers")
+ @GET("/api/aai-business/v13/customers")
Call<AAICustomerRsp> listCustomer();
-
+
@Headers({
- "X-TransactionId: 7777",
- "X-FromAppId: uui",
- "Authorization: Basic QUFJOkFBSQ==",
- "Accept: application/json"
+ "X-TransactionId: 7777",
+ "X-FromAppId: uui",
+ "Authorization: Basic QUFJOkFBSQ==",
+ "Accept: application/json"
+ })
+ @GET("/api/aai-externalSystem/v16/esr-nfvo-list")
+ Call<AAIOrchestratorRsp> listOrchestrator();
+
+ @Headers({
+ "X-TransactionId: 7777",
+ "X-FromAppId: uui",
+ "Authorization: Basic QUFJOkFBSQ==",
+ "Accept: application/json"
+ })
+ @GET("/api/aai-externalSystem/v16/esr-nfvo-list/esr-nfvo/{nfvo-id}?depth=all")
+ Call<AAISingleOrchestratorRsp> getOrchestrator(@Path("nfvo-id") String nfvoId);
+
+ @Headers({
+ "X-TransactionId: 7777",
+ "X-FromAppId: uui",
+ "Authorization: Basic QUFJOkFBSQ==",
+ "Accept: application/json"
})
- @GET("/api/aai-externalSystem/v16/esr-nfvo-list")
- Call<AAIOrchestratorRsp> listOrchestrator();
-
+ @PUT("/api/aai-business/v13/customers/customer/{global-customer-id}")
+ Call<ResponseBody> createOrUpdateCustomer(@Path("global-customer-id") String customerId,@Body RequestBody body);
+
@Headers({
- "X-TransactionId: 7777",
- "X-FromAppId: uui",
- "Authorization: Basic QUFJOkFBSQ==",
- "Accept: application/json"
+ "X-TransactionId: 7777",
+ "X-FromAppId: uui",
+ "Authorization: Basic QUFJOkFBSQ==",
+ "Accept: application/json"
})
- @GET("/api/aai-externalSystem/v16/esr-nfvo-list/esr-nfvo/{nfvo-id}?depth=all")
- Call<AAISingleOrchestratorRsp> getOrchestrator(@Path("nfvo-id") String nfvoId);
-
+ @DELETE("/api/aai-business/v13//customers/customer/{global-customer-id}")
+ Call<ResponseBody> deleteCustomer(@Path("global-customer-id") String customerId,@Query("resource-version") String resourceVersion);
+
+ @Headers({
+ "X-TransactionId: 7777",
+ "X-FromAppId: uui",
+ "Authorization: Basic QUFJOkFBSQ==",
+ "Accept: application/json"
+ })
+ @GET("/api/aai-business/v13//customers/customer/{global-customer-id}")
+ Call<AAICustomer> getCustomerById(@Path("global-customer-id") String customerId);
+
@Headers({
"X-TransactionId: 7777",
"X-FromAppId: uui",
@@ -88,7 +123,37 @@ public interface AAIService {
// @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions")
@GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions")
Call<ServiceSubscriptionRsp> listServiceSubscriptions(@Path("global-customer-id") String customerId);
-
+
+ @Headers({
+ "X-TransactionId: 7777",
+ "X-FromAppId: uui",
+ "Authorization: Basic QUFJOkFBSQ==",
+ "Accept: application/json"
+ })
+ //@GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions")
+ @PUT("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}")
+ Call<ResponseBody> createOrUpdateServiceType(@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/v11/customers/customer/{global-customer-id}/service-subscriptions")
+ @PUT("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}")
+ Call<ResponseBody> deleteServiceType(@Path("global-customer-id") String customerId,@Path("service-type") String serviceType,@Query("resource-version") String resourceVersion);
+
+ @Headers({
+ "X-TransactionId: 7777",
+ "X-FromAppId: uui",
+ "Authorization: Basic QUFJOkFBSQ==",
+ "Accept: application/json"
+ })
+ //@GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions")
+ @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}")
+ Call<AAIServiceSubscription> getServiceTypeById(@Path("global-customer-id") String customerId,@Path("service-type") String serviceType);
+
@Headers({
"X-TransactionId: 7777",
"X-FromAppId: uui",
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java
index 972dbedc..d75d101a 100644
--- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java
@@ -27,12 +27,21 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Service;
+
+import com.alibaba.fastjson.JSONObject;
+
+import okhttp3.RequestBody;
+import okhttp3.ResponseBody;
import retrofit2.Response;
+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;
+
@Service("CustomerService")
@org.springframework.context.annotation.Configuration
@EnableAspectJAutoProxy
@@ -65,11 +74,76 @@ public class DefaultCustomerService implements CustomerService {
throw new AAIException("AAI is not available.", e);
}
}
-
+
+ @Override
+ public JSONObject createOrUpdateCustomer(HttpServletRequest request,String customerId){
+ JSONObject result = new JSONObject();
+ try {
+ logger.info("aai createOrUpdateCustomer is starting!");
+ RequestBody requestBody = extractBody(request);
+ Response<ResponseBody> response = this.aaiService.createOrUpdateCustomer(customerId,requestBody).execute();
+ logger.info("aai createOrUpdateCustomer is finished!");
+ if(response.isSuccessful()){
+ result.put("status", "SUCCESS");
+ }else{
+ result.put("status", "FAILED");
+ result.put("errorMessage",String.format("Can not get createOrUpdateCustomer[code=%s, message=%s]", response.code(), response.message()));
+ }
+ } catch (IOException e) {
+ result.put("status", "FAILED");
+ result.put("errorMessage","createOrUpdateCustomer occur exception:"+e.getMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public JSONObject getCustomerById(String customerId){
+ JSONObject result = new JSONObject();
+ try {
+ logger.info("aai getCustomerById is starting!");
+ Response<AAICustomer> response = this.aaiService.getCustomerById(customerId).execute();
+ logger.info("aai getCustomerById is finished!");
+ if(response.isSuccessful()){
+ result.put("status", "SUCCESS");
+ result.put("result",response.body());
+ }else{
+ result.put("status", "FAILED");
+ result.put("errorMessage",String.format("Can not get getCustomerById[code=%s, message=%s]", response.code(), response.message()));
+ }
+ } catch (IOException e) {
+ result.put("status", "FAILED");
+ result.put("errorMessage","getCustomerById occur exception:"+e.getMessage());
+ }
+ return result;
+ }
+
@Override
- public List<AAIServiceSubscription> listServiceSubscriptions(String customerId) {
+ public JSONObject deleteCustomer(String customerId,String resourceVersion){
+ JSONObject result = new JSONObject();
+ try {
+ logger.info("aai deleteCustomer is starting!");
+ Response<ResponseBody> response = this.aaiService.deleteCustomer(customerId,resourceVersion).execute();
+ logger.info("aai deleteCustomer is finished!");
+ if(response.isSuccessful()){
+ result.put("status", "SUCCESS");
+ }else{
+ result.put("status", "FAILED");
+ result.put("errorMessage",String.format("Can not get deleteCustomer[code=%s, message=%s]", response.code(), response.message()));
+ }
+ } catch (IOException e) {
+ result.put("status", "FAILED");
+ if(e.getMessage().contains("204")){
+ result.put("status", "SUCCESS");
+ }
+ result.put("errorMessage","deleteCustomer occur exception:"+e.getMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public List<AAIServiceSubscription> listServiceSubscriptions(String serviceType) {
try {
- Response<ServiceSubscriptionRsp> response = this.aaiService.listServiceSubscriptions(customerId).execute();
+ Response<ServiceSubscriptionRsp> response = this.aaiService.listServiceSubscriptions(serviceType).execute();
if (response.isSuccessful()) {
return response.body().getServiceSubscriptions();
} else {
@@ -81,4 +155,69 @@ public class DefaultCustomerService implements CustomerService {
throw new AAIException("AAI is not available.", e);
}
}
+
+ @Override
+ public JSONObject createOrUpdateServiceType(HttpServletRequest request,String serviceType){
+ JSONObject result = new JSONObject();
+ try {
+ logger.info("aai createOrUpdateServiceType is starting!");
+ RequestBody requestBody = extractBody(request);
+ Response<ResponseBody> response = this.aaiService.createOrUpdateCustomer(serviceType,requestBody).execute();
+ logger.info("aai createOrUpdateServiceType is finished!");
+ if(response.isSuccessful()){
+ result.put("status", "SUCCESS");
+ }else{
+ result.put("status", "FAILED");
+ result.put("errorMessage",String.format("Can not get createOrUpdateServiceType[code=%s, message=%s]", response.code(), response.message()));
+ }
+ } catch (IOException e) {
+ result.put("status", "FAILED");
+ result.put("errorMessage","createOrUpdateServiceType occur exception:"+e.getMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public JSONObject deleteServiceType(String customerId,String serviceType,String resourceVersion){
+ JSONObject result = new JSONObject();
+ try {
+ logger.info("aai deleteServiceType is starting!");
+ Response<ResponseBody> response = this.aaiService.deleteServiceType(customerId,serviceType,resourceVersion).execute();
+ logger.info("aai deleteServiceType is finished!");
+ if(response.isSuccessful()){
+ result.put("status", "SUCCESS");
+ }else{
+ result.put("status", "FAILED");
+ result.put("errorMessage",String.format("Can not get deleteServiceType[code=%s, message=%s]", response.code(), response.message()));
+ }
+ } catch (IOException e) {
+ result.put("status", "FAILED");
+ if(e.getMessage().contains("204")){
+ result.put("status", "SUCCESS");
+ }
+ result.put("errorMessage","deleteServiceType occur exception:"+e.getMessage());
+ }
+ return result;
+ }
+
+ @Override
+ public JSONObject getServiceTypeById(String customerId,String serviceType){
+ JSONObject result = new JSONObject();
+ try {
+ logger.info("aai getServiceTypeById is starting!");
+ Response<AAIServiceSubscription> response = this.aaiService.getServiceTypeById(customerId,serviceType).execute();
+ logger.info("aai getServiceTypeById is finished!");
+ if(response.isSuccessful()){
+ result.put("status", "SUCCESS");
+ result.put("result",response.body());
+ }else{
+ result.put("status", "FAILED");
+ result.put("errorMessage",String.format("Can not get getServiceTypeById[code=%s, message=%s]", response.code(), response.message()));
+ }
+ } catch (IOException e) {
+ result.put("status", "FAILED");
+ result.put("errorMessage","getServiceTypeById occur exception:"+e.getMessage());
+ }
+ return result;
+ }
}