diff options
author | guochuyicmri <guochuyi@chinamobile.com> | 2018-09-07 17:27:46 +0800 |
---|---|---|
committer | guochuyicmri <guochuyi@chinamobile.com> | 2018-09-07 17:28:10 +0800 |
commit | 9473ec7749ca0a1f9412b20e39019b1e3f599250 (patch) | |
tree | 01997faa46e46d1042867ea3efb1fc4efe1c5d30 | |
parent | ff1cfcf59881838fe6a0f7ea3839ea9dc7fb4093 (diff) |
modify sotn business
Change-Id: I1fedabd1e5be8c9bd6be52375d0eb769a4d594bf
Issue-ID: USECASEUI-142
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
5 files changed, 135 insertions, 15 deletions
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 index 9b24eb7a..9ed5b655 100644 --- 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 @@ -55,6 +55,9 @@ public class SotnController { public List<NetWorkResource> getNetWorkResources(){ List<NetWorkResource> result = new ArrayList<NetWorkResource>(); String json = sotnService.getNetWorkResources(); + if("FAILED".equals(json)){ + return result; + } createJson(json,result); for(NetWorkResource networks:result){ List<Pinterface> pinterfaces = new ArrayList<Pinterface>(); @@ -81,6 +84,24 @@ public class SotnController { } @ResponseBody + @RequestMapping(value = {"/getSpecificLogicalLink/{linkName}"}, method = RequestMethod.GET , produces = "application/json") + public String getSpecificLogicalLink(@PathVariable(value="linkName") String linkName){ + return sotnService.getSpecificLogicalLink(linkName); + } + + @ResponseBody + @RequestMapping(value = {"/getHostUrl/{aaiId}"}, method = RequestMethod.GET , produces = "application/json") + public String getHostUrl(@PathVariable(value="aaiId") String aaiId){ + return sotnService.getHostUrl(aaiId); + } + + @ResponseBody + @RequestMapping(value = {"/createHostUrl/{aaiId}"}, method = RequestMethod.PUT , produces = "application/json") + public String createHostUrl(HttpServletRequest request,@PathVariable(value="aaiId") String aaiId){ + return sotnService.createTopoNetwork(request,aaiId); + } + + @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); 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 cdfe11ec..0b21696f 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 @@ -121,6 +121,15 @@ public interface AAIService { Call<ResponseBody> getLogicalLinks(); @Headers({ + "X-TransactionId: 7777", + "X-FromAppId: uui", + "Authorization: Basic QUFJOkFBSQ==", + "Accept: application/json" + }) + @GET("/aai/v14/network/logical-links") + Call<ResponseBody> getSpecificLogicalLink(@Query("link-name") String linkName); + + @Headers({ "X-TransactionId: 7777", "X-FromAppId: uui", "Authorization: Basic QUFJOkFBSQ==", @@ -130,6 +139,24 @@ public interface AAIService { 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/ext-aai-networks/ext-aai-network/{aai-id}") + Call<ResponseBody> createHostUrl(@Body RequestBody body,@Path("aai-id") String aaiId); + + @Headers({ + "X-TransactionId: 7777", + "X-FromAppId: uui", + "Authorization: Basic QUFJOkFBSQ==", + "Accept: application/json" + }) + @GET("/api/aai-business/v13/network/ext-aai-networks/ext-aai-network/{aai-id}/esr-system-info") + Call<ResponseBody> getHostUrl(@Path("aai-id") String aaiId); + + @Headers({ "X-TransactionId: 7777", "X-FromAppId: uui", "Authorization: Basic QUFJOkFBSQ==", 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 index 36262e32..c24b62c2 100644 --- 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 @@ -29,6 +29,12 @@ public interface SOTNService { public String getLogicalLinks(); + public String getSpecificLogicalLink(String linkName); + + public String getHostUrl(String aaiId); + + public String createHostUrl(HttpServletRequest request,String aaiId); + public String createTopoNetwork(HttpServletRequest request,String networkId); public String createTerminationPoint(HttpServletRequest request,String pnfName,String tpId); 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 index c39b651a..890d2556 100644 --- 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 @@ -59,21 +59,22 @@ public class SOTNServiceImpl implements SOTNService{ @Override public String getNetWorkResources() { + String result=""; 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; + result=new String(response.body().bytes()); } else { logger.info(String.format("Can not get getNetWorkResources[code=%s, message=%s]", response.code(), response.message())); - return ""; + result = Constant.CONSTANT_FAILED; } } catch (IOException e) { logger.error("getNetWorkResources occur exception:"+e); - throw new AAIException("AAI is not available.", e); + result = Constant.CONSTANT_FAILED;; } + return result; } @Override @@ -96,23 +97,87 @@ public class SOTNServiceImpl implements SOTNService{ @Override public String getLogicalLinks() { + String result=""; 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; + result=new String(response.body().bytes()); } else { logger.info(String.format("Can not get getLogicalLinks[code=%s, message=%s]", response.code(), response.message())); - return ""; + result=Constant.CONSTANT_FAILED;; } } catch (IOException e) { logger.error("getLogicalLinks occur exception:"+e); - throw new AAIException("AAI is not available.", e); + result=Constant.CONSTANT_FAILED;; } + return result; } - + + @Override + public String getSpecificLogicalLink(String linkName) { + String result=""; + try { + logger.info("aai getSpecificLogicalLink is starting!"); + Response<ResponseBody> response = this.aaiService.getSpecificLogicalLink(linkName).execute(); + logger.info("aai getSpecificLogicalLink has finished!"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + logger.info(String.format("Can not get getSpecificLogicalLink[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED; + } + } catch (IOException e) { + logger.error("getSpecificLogicalLink occur exception:"+e); + result=Constant.CONSTANT_FAILED; + } + return result; + } + + @Override + public String getHostUrl(String aaiId) { + String result=""; + try { + logger.info("aai getHostUrl is starting!"); + Response<ResponseBody> response = this.aaiService.getHostUrl(aaiId).execute(); + logger.info("aai getHostUrl has finished!"); + if (response.isSuccessful()) { + result=new String(response.body().bytes()); + } else { + logger.info(String.format("Can not get getHostUrl[code=%s, message=%s]", response.code(), response.message())); + result=Constant.CONSTANT_FAILED; + } + } catch (IOException e) { + logger.error("getHostUrl occur exception:"+e); + result=Constant.CONSTANT_FAILED;; + } + return result; + } + + @Override + public String createHostUrl(HttpServletRequest request,String aaiId) { + String result = ""; + try { + logger.info("aai createHostUrl is starting"); + RequestBody requestBody = extractBody(request); + Response<ResponseBody> response = aaiService.createHostUrl(requestBody,aaiId).execute(); + logger.info("aai createHostUrl has finished"); + if (response.isSuccessful()) { + result=Constant.CONSTANT_SUCCESS; + } else { + result=Constant.CONSTANT_FAILED; + logger.error(String.format("Can not createHostUrl[code=%s, message=%s]", response.code(), response.message())); + throw new SOException("aai createHostUrl failed!"); + } + } catch (Exception e) { + result=Constant.CONSTANT_FAILED; + logger.error("createHostUrl occur exception:"+e); + throw new SOException("aai createHostUrl is not available!", e); + } + return result; + } + @Override public String createTopoNetwork(HttpServletRequest request,String networkId) { String result = ""; @@ -228,21 +293,22 @@ public class SOTNServiceImpl implements SOTNService{ @Override public String getServiceInstances(String customerId, String serviceType) { + String result=""; 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; + result=new String(response.body().bytes()); } else { logger.error(String.format("Can not getServiceInstances[code=%s, message=%s]", response.code(), response.message())); - throw new SOException("aai getServiceInstances failed!"); + result= Constant.CONSTANT_FAILED; } } catch (Exception e) { logger.error("getServiceInstances occur exception:"+e); - throw new SOException("aai getServiceInstances is not available!", e); + result= Constant.CONSTANT_FAILED; } + return result; } @Override diff --git a/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java b/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java index 3ecaee28..78b58b61 100644 --- a/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java +++ b/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java @@ -129,10 +129,10 @@ public class DmaapSubscriber implements Runnable { public void run() { try { initConfig(); - while (isActive) { + while (isActive) {/* subscribe(alarmTopic); subscribe(performanceTopic); - } + */} } catch (Exception e) { logger.error("subscribe raise error :" + e.getCause()); } |