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=9e6f3f8061d60c811e92d071413866901fabf2ce;hpb=979f0fa70cbe576f8eed5e56db467b261a1919cf;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 9e6f3f8..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; @@ -59,10 +59,9 @@ public class ThirdpatySdncWrapper { 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()); } } @@ -86,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()); } } @@ -101,41 +99,29 @@ 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.ok().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) { EsrThirdpartySdncDetail thirdpartySdncDetail = new EsrThirdpartySdncDetail(); thirdpartySdncDetail = queryEsrThirdpartySdncDetail(thirdpartySdncId); String resourceVersion = thirdpartySdncDetail.getResourceVersion(); - if (resourceVersion != null) { - try { - ExternalSystemProxy.deleteThirdpartySdnc(thirdpartySdncId, resourceVersion); - return Response.noContent().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. "); + 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()); } } @@ -148,10 +134,9 @@ public class ThirdpatySdncWrapper { esrSdncDetail = new Gson().fromJson(esrSdncStr, EsrThirdpartySdncDetail.class); 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()); } } @@ -174,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; }