X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=esr-mgr%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Fwrapper%2FThirdpatySdncWrapper.java;h=0dfd45a7fc42a3f15650b0939ffdf6fe4f972cfa;hb=22a43294c389a413b7d8d372a6d267ea054b4e22;hp=e5f9966f5c32401ca88fd45e0cf1d6bb91ff2425;hpb=dd5fda2be4276ac66536853fe664db4f2f798e7c;p=aai%2Fesr-server.git diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java index e5f9966..0dfd45a 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java @@ -37,6 +37,7 @@ public class ThirdpatySdncWrapper { private static ThirdpatySdncWrapper thirdpatySdncWrapper; private static final Logger LOG = LoggerFactory.getLogger(ThirdpatySdncWrapper.class); + private static ThirdpartySdncManagerUtil thirdpartySdncManagerUtil = new ThirdpartySdncManagerUtil(); /** * get ThirdpatySdncWrapper instance. @@ -52,7 +53,7 @@ public class ThirdpatySdncWrapper { public Response registerThirdpartySdnc(ThirdpartySdncRegisterInfo thirdpartySdnc) { CommonRegisterResponse result = new CommonRegisterResponse(); EsrThirdpartySdncDetail esrSdncDetail = new EsrThirdpartySdncDetail(); - esrSdncDetail = ThirdpartySdncManagerUtil.sdncRegisterInfo2EsrSdnc(thirdpartySdnc); + esrSdncDetail = thirdpartySdncManagerUtil.sdncRegisterInfo2EsrSdnc(thirdpartySdnc); String sdncId = esrSdncDetail.getThirdpartySdncId(); try { ExternalSystemProxy.registerSdnc(sdncId, esrSdncDetail); @@ -72,7 +73,7 @@ public class ThirdpatySdncWrapper { EsrThirdpartySdncDetail originalEsrSdncDetail = new EsrThirdpartySdncDetail(); EsrSystemInfo originalEsrSystemInfo = new EsrSystemInfo(); originalEsrSdncDetail = queryEsrThirdpartySdncDetail(sdncId); - esrSdncDetail = ThirdpartySdncManagerUtil.sdncRegisterInfo2EsrSdnc(thirdpartySdnc); + esrSdncDetail = thirdpartySdncManagerUtil.sdncRegisterInfo2EsrSdnc(thirdpartySdnc); String resourceVersion = originalEsrSdncDetail.getResourceVersion(); esrSdncDetail.setResourceVersion(resourceVersion); esrSdncDetail.setThirdpartySdncId(sdncId); @@ -119,8 +120,23 @@ public class ThirdpatySdncWrapper { } public Response delThirdpartySdnc(String thirdpartySdncId) { - //TODO - return Response.noContent().build(); + EsrThirdpartySdncDetail thirdpartySdncDetail = new EsrThirdpartySdncDetail(); + thirdpartySdncDetail = queryEsrThirdpartySdncDetail(thirdpartySdncId); + String resourceVersion = thirdpartySdncDetail.getResourceVersion(); + if (resourceVersion != null) { + try { + ExternalSystemProxy.deleteThirdpartySdnc(thirdpartySdncId, resourceVersion); + return Response.ok().build(); + } catch (Exception e) { + e.printStackTrace(); + LOG.error("Delete VNFM from A&AI failed! thirdparty SDNC ID: " + thirdpartySdncId + "resouce-version:" + + resourceVersion, e.getMessage()); + return Response.noContent().build(); + } + } else { + LOG.error("resouce-version is null ! Can not delete resouce from A&AI. "); + return Response.serverError().build(); + } } private ThirdpartySdncRegisterInfo querySdncDetail(String sdncId) { @@ -130,7 +146,7 @@ public class ThirdpatySdncWrapper { String esrSdncStr = ExternalSystemProxy.queryThirdpartySdncDetail(sdncId); LOG.info("Response from AAI by query thirdparty SDNC: " + esrSdncStr); esrSdncDetail = new Gson().fromJson(esrSdncStr, EsrThirdpartySdncDetail.class); - sdncRegisterInfo = ThirdpartySdncManagerUtil.esrSdnc2SdncRegisterInfo(esrSdncDetail); + sdncRegisterInfo = thirdpartySdncManagerUtil.esrSdnc2SdncRegisterInfo(esrSdncDetail); return sdncRegisterInfo; } catch (Exception e) { e.printStackTrace();