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=fd7dc438735b8c3c9a060728631900bab03bf537;hb=3ca84f4c73c5996a2cc5d4372d70f1e7bce5cf0f;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..fd7dc43 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 @@ -22,12 +22,12 @@ import javax.ws.rs.core.Response; import org.onap.aai.esr.entity.aai.EsrSystemInfo; import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail; import org.onap.aai.esr.entity.aai.EsrThirdpartySdncList; -import org.onap.aai.esr.entity.aai.EsrVnfmDetail; import org.onap.aai.esr.entity.rest.CommonRegisterResponse; import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo; +import org.onap.aai.esr.exception.ExceptionUtil; +import org.onap.aai.esr.exception.ExtsysException; import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy; import org.onap.aai.esr.util.ThirdpartySdncManagerUtil; -import org.onap.aai.esr.util.VnfmManagerUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -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,16 +53,15 @@ 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); result.setId(sdncId); return Response.ok(result).build(); - } catch (Exception e) { - e.printStackTrace(); - LOG.error("Register thirdParty SDNC failed !" + e.getMessage()); - return Response.serverError().build(); + } catch (ExtsysException e) { + LOG.error("Register thirdParty SDNC failed !" , e); + throw ExceptionUtil.buildExceptionResponse(e.getMessage()); } } @@ -72,7 +72,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); @@ -85,10 +85,9 @@ public class ThirdpatySdncWrapper { ExternalSystemProxy.registerSdnc(sdncId, esrSdncDetail); result.setId(sdncId); return Response.ok(result).build(); - } catch (Exception e) { - e.printStackTrace(); - LOG.error("Update VNFM failed !" + e.getMessage()); - return Response.serverError().build(); + } catch (ExtsysException e) { + LOG.error("Update VNFM failed !" , e); + throw ExceptionUtil.buildExceptionResponse(e.getMessage()); } } @@ -100,27 +99,30 @@ public class ThirdpatySdncWrapper { esrSdnc = new Gson().fromJson(esrSdncStr, EsrThirdpartySdncList.class); LOG.info("Response from AAI by query thirdparty SDNC list: " + esrSdnc); sdncList = getSdncDetailList(esrSdnc); - return Response.ok(sdncList).build(); - } catch (Exception e) { - e.printStackTrace(); - LOG.error("Query thirdparty SDNC list failed !"); - return Response.serverError().build(); + } catch (ExtsysException e) { + LOG.error("Query thirdparty SDNC list failed !", e); } + return Response.ok(sdncList).build(); } public Response queryThirdpartySdncById(String thirdpartySdncId) { ThirdpartySdncRegisterInfo thirdpartySdnc = new ThirdpartySdncRegisterInfo(); thirdpartySdnc = querySdncDetail(thirdpartySdncId); - if(thirdpartySdnc != null) { - return Response.ok(thirdpartySdnc).build(); - } else { - return Response.ok().build(); - } + return Response.ok(thirdpartySdnc).build(); } public Response delThirdpartySdnc(String thirdpartySdncId) { - //TODO - return Response.noContent().build(); + EsrThirdpartySdncDetail thirdpartySdncDetail = new EsrThirdpartySdncDetail(); + thirdpartySdncDetail = queryEsrThirdpartySdncDetail(thirdpartySdncId); + String resourceVersion = thirdpartySdncDetail.getResourceVersion(); + try { + ExternalSystemProxy.deleteThirdpartySdnc(thirdpartySdncId, resourceVersion); + return Response.noContent().build(); + } catch (ExtsysException e) { + LOG.error("Delete VNFM from A&AI failed! thirdparty SDNC ID: " + thirdpartySdncId + + "resouce-version:" + resourceVersion, e); + throw ExceptionUtil.buildExceptionResponse(e.getMessage()); + } } private ThirdpartySdncRegisterInfo querySdncDetail(String sdncId) { @@ -130,12 +132,11 @@ 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(); - LOG.error("Query VNFM detail failed! thirdpaty SDNC ID: " + sdncId, e.getMessage()); - return null; + } catch (ExtsysException e) { + LOG.error("Query VNFM detail failed! thirdpaty SDNC ID: " + sdncId, e); + throw ExceptionUtil.buildExceptionResponse(e.getMessage()); } } @@ -158,9 +159,9 @@ public class ThirdpatySdncWrapper { String esrThirdpartySdncStr = ExternalSystemProxy.queryThirdpartySdncDetail(sdncId); LOG.info("Response from AAI by query thirdparty SDNC: " + esrThirdpartySdncStr); esrSdncDetail = new Gson().fromJson(esrThirdpartySdncStr, EsrThirdpartySdncDetail.class); - } catch (Exception e) { - e.printStackTrace(); - LOG.error("Query VNFM detail failed! VNFM ID: " + sdncId, e.getMessage()); + } catch (ExtsysException e) { + LOG.error("Query VNFM detail failed! VNFM ID: " + sdncId, e); + throw ExceptionUtil.buildExceptionResponse(e.getMessage()); } return esrSdncDetail; }