summaryrefslogtreecommitdiffstats
path: root/esr-mgr/src
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-09-25 11:29:49 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-09-25 11:29:49 +0800
commit679a70ca3200b0acd9980bf0f1f1f0c0b236a62e (patch)
tree5362af6b849256e7f42d7f9485d8fee50c688e82 /esr-mgr/src
parent83c6e0c5f6214af24efc124ed6cf840e6ad59cc4 (diff)
Fix the exception deal way of Ems manager.
Change-Id: I9908b88a8fbc969e7029e5a4d3aed54783bfd352 Issue-ID: AAI-282 Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr/src')
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/IVimManage.java4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java59
2 files changed, 28 insertions, 35 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/IVimManage.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/IVimManage.java
index 33ecd91..0e5784e 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/IVimManage.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/IVimManage.java
@@ -22,6 +22,8 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import org.onap.aai.esr.exception.ExtsysException;
+
@Path("/")
public interface IVimManage {
@POST
@@ -29,6 +31,6 @@ public interface IVimManage {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public void updateVIM(@PathParam("cloud_owner") String cloud_owner,
- @PathParam("cloud_region_id") String cloud_region_id, Tenant tenant) throws Exception;
+ @PathParam("cloud_region_id") String cloud_region_id, Tenant tenant) throws ExtsysException;
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java
index 6436bf8..e1ab970 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java
@@ -20,6 +20,8 @@ import java.util.ArrayList;
import javax.ws.rs.core.Response;
import org.onap.aai.esr.entity.rest.EmsRegisterInfo;
+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.EmsManagerUtil;
import org.onap.aai.esr.entity.aai.EsrEmsDetail;
@@ -56,10 +58,9 @@ public class EmsManagerWrapper {
ExternalSystemProxy.registerEms(emsId, esrEmsDetail);
result.setId(emsId);
return Response.ok(result).build();
- } catch (Exception e) {
- e.printStackTrace();
- LOG.error("Register EMS failed !" + e.getMessage());
- return Response.serverError().build();
+ } catch (ExtsysException e) {
+ LOG.error("Register EMS failed !", e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
}
@@ -71,10 +72,9 @@ public class EmsManagerWrapper {
ExternalSystemProxy.registerEms(emsId, esrEmsDetail);
result.setId(emsId);
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());
}
}
@@ -87,15 +87,14 @@ public class EmsManagerWrapper {
LOG.info("Response from AAI by query EMS list: " + esrEms);
emsList = getEmsDetailList(esrEms);
return Response.ok(emsList).build();
- } catch (Exception e) {
- e.printStackTrace();
- LOG.error("Query EMS list failed !");
+ } catch (ExtsysException e) {
+ LOG.error("Query EMS list failed !", e);
return Response.ok(emsList).build();
}
}
public Response queryEmsById(String emsId) {
- EmsRegisterInfo ems = new EmsRegisterInfo();
+ EmsRegisterInfo ems;
ems = queryEmsDetail(emsId);
if (ems != null) {
return Response.ok(ems).build();
@@ -108,22 +107,17 @@ public class EmsManagerWrapper {
EsrEmsDetail esrEmsDetail = new EsrEmsDetail();
esrEmsDetail = queryEsrEmsDetail(emsId);
String resourceVersion = esrEmsDetail.getResourceVersion();
- if (resourceVersion != null) {
- try {
- ExternalSystemProxy.deleteEms(emsId, resourceVersion);
- return Response.noContent().build();
- } catch (Exception e) {
- e.printStackTrace();
- LOG.error("Delete EMS from A&AI failed! EMS ID: " + emsId + "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.deleteEms(emsId, resourceVersion);
+ return Response.noContent().build();
+ } catch (ExtsysException e) {
+ LOG.error(
+ "Delete EMS from A&AI failed! EMS ID: " + emsId + "resouce-version:" + resourceVersion,
+ e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
}
-
+
private EmsRegisterInfo queryEmsDetail(String emsId) {
EmsRegisterInfo emsRegisterInfo = new EmsRegisterInfo();
EsrEmsDetail esrEmsDetail = new EsrEmsDetail();
@@ -132,12 +126,10 @@ public class EmsManagerWrapper {
LOG.info("Response from AAI by query EMS: " + esrEmsStr);
esrEmsDetail = new Gson().fromJson(esrEmsStr, EsrEmsDetail.class);
emsRegisterInfo = emsManagerUtil.EsrEms2EmsRegisterInfo(esrEmsDetail);
- return emsRegisterInfo;
- } catch (Exception e) {
- e.printStackTrace();
- LOG.error("Query EMS detail failed! EMS ID: " + emsId, e.getMessage());
- return null;
+ } catch (ExtsysException e) {
+ LOG.error("Query EMS detail failed! EMS ID: " + emsId, e);
}
+ return emsRegisterInfo;
}
private ArrayList<EmsRegisterInfo> getEmsDetailList(EsrEmsList esrEms) {
@@ -159,9 +151,8 @@ public class EmsManagerWrapper {
String esrEmsStr = ExternalSystemProxy.queryEmsDetail(emsId);
LOG.info("Response from AAI by query EMS: " + esrEmsStr);
esrEmsDetail = new Gson().fromJson(esrEmsStr, EsrEmsDetail.class);
- } catch (Exception e) {
- e.printStackTrace();
- LOG.error("Query EMS detail failed! EMS ID: " + emsId, e.getMessage());
+ } catch (ExtsysException e) {
+ LOG.error("Query EMS detail failed! EMS ID: " + emsId, e);
}
return esrEmsDetail;
}