summaryrefslogtreecommitdiffstats
path: root/esr-mgr
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-09-25 11:41:51 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-09-25 11:41:51 +0800
commit3dadf002d8aac39501700204b951b24f706c8b9e (patch)
tree655db49d156ccde50e1a6df3445317cca6b4af53 /esr-mgr
parent679a70ca3200b0acd9980bf0f1f1f0c0b236a62e (diff)
Change the Exception deal ways for sdnc manager.
Change-Id: I6cd6da374d87d973e1ae9d546a824e573ec0ddf9 Issue-ID: AAI-282 Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr')
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java63
1 files changed, 25 insertions, 38 deletions
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 0aa21da..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
@@ -24,6 +24,8 @@ import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncList;
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.slf4j.Logger;
@@ -57,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());
}
}
@@ -84,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());
}
}
@@ -99,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(sdncList).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(thirdpartySdnc).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.serverError().build();
- }
- } else {
- LOG.error("resouce-version is null ! Can not delete resouce from A&AI. ");
- return Response.serverError().build();
+ 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());
}
}
@@ -146,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());
}
}
@@ -172,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;
}