summaryrefslogtreecommitdiffstats
path: root/esr-mgr/src
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-09-22 19:32:35 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-09-22 20:40:50 +0800
commit6011cbc9b4031f3ce25a82ccb1c0fedf4a2bf57a (patch)
tree1e25b3129dfc75d3211e548cedcd9fef75982f44 /esr-mgr/src
parentf98c32ab879722dfce8c1c72b3dedc6291722a0e (diff)
Change the exception throw way for VIM register.
Change-Id: I8d67a08793a8d19bb12d0bd2cdbcc1300495abbe Issue-ID: AAI-371 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/exception/ExceptionUtil.java34
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/exception/ExtsysException.java9
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java41
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimManagerProxy.java9
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/EmsManagerUtil.java6
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysUtil.java6
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java5
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java3
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java82
10 files changed, 119 insertions, 80 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExceptionUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExceptionUtil.java
new file mode 100644
index 0000000..57ad6f2
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExceptionUtil.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.aai.esr.exception;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+public class ExceptionUtil {
+
+ private static final int EXCEPTION_CODE = 498;
+
+ private ExceptionUtil() {
+
+ }
+
+ public static WebApplicationException buildExceptionResponse(String message) {
+ Response response = Response.status(EXCEPTION_CODE).entity(message).type(MediaType.TEXT_PLAIN).build();
+ return new WebApplicationException(response);
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExtsysException.java b/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExtsysException.java
index acfa459..9561934 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExtsysException.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/exception/ExtsysException.java
@@ -41,8 +41,11 @@ public class ExtsysException extends Exception {
super();
}
- public ExtsysException(String errorCode, String errorMsg) {
- this.errorCode = errorCode;
- this.errorMsg = errorMsg;
+ public ExtsysException(String msg, Exception e) {
+ super(msg, e);
+ }
+
+ public ExtsysException(String msg) {
+ super(msg);
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
index 8ff14d0..57e6920 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
@@ -18,6 +18,7 @@ package org.onap.aai.esr.externalservice.aai;
import org.glassfish.jersey.client.ClientConfig;
import org.onap.aai.esr.common.MsbConfig;
import org.onap.aai.esr.entity.aai.CloudRegionDetail;
+import org.onap.aai.esr.exception.ExtsysException;
import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
@@ -35,26 +36,42 @@ public class CloudRegionProxy {
}
public void registerVim(String cloudOwner, String cloudRegionId,
- CloudRegionDetail cloudRegion) throws Exception {
+ CloudRegionDetail cloudRegion) throws ExtsysException {
ClientConfig config = new ClientConfig(new VimRegisterProvider());
ICloudRegion registerVimServiceproxy = ConsumerFactory
.createConsumer(MsbConfig.getCloudInfrastructureAddr(), config, ICloudRegion.class);
- registerVimServiceproxy.registerVIMService(transactionId, fromAppId, authorization, cloudOwner,
- cloudRegionId, cloudRegion);
+ try {
+ registerVimServiceproxy.registerVIMService(transactionId, fromAppId, authorization, cloudOwner,
+ cloudRegionId, cloudRegion);
+ } catch (Exception e) {
+ throw new ExtsysException("PUT cloud region to A&AI failed.", e);
+ }
}
- public String queryVimDetail(String cloud_owner, String cloud_region_id) throws Exception {
- return adapterServiceproxy.queryVIMDetail(transactionId, fromAppId, authorization, cloud_owner,
- cloud_region_id);
+ public String queryVimDetail(String cloud_owner, String cloud_region_id) throws ExtsysException {
+ try {
+ return adapterServiceproxy.queryVIMDetail(transactionId, fromAppId, authorization, cloud_owner,
+ cloud_region_id);
+ } catch (Exception e) {
+ throw new ExtsysException("Query cloud region detail from A&AI failed.", e);
+ }
}
- public String qureyVimList() throws Exception {
- return adapterServiceproxy.queryVIMList(transactionId, fromAppId, authorization);
+ public String qureyVimList() throws ExtsysException {
+ try {
+ return adapterServiceproxy.queryVIMList(transactionId, fromAppId, authorization);
+ } catch (Exception e) {
+ throw new ExtsysException("Query cloud region list from A&AI failed.", e);
+ }
}
- public void deleteVim(String cloud_owner, String cloud_region_id, String resourceVersion)
- throws Exception {
- adapterServiceproxy.deleteVim(transactionId, fromAppId, authorization, cloud_owner,
- cloud_region_id, resourceVersion);
+ public void deleteVim(String cloud_owner, String cloud_region_id, String resourceVersion) throws ExtsysException
+ {
+ try {
+ adapterServiceproxy.deleteVim(transactionId, fromAppId, authorization, cloud_owner,
+ cloud_region_id, resourceVersion);
+ } catch (Exception e) {
+ throw new ExtsysException("Delete cloud region from A&AI failed.", e);
+ }
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimManagerProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimManagerProxy.java
index 3a485b2..0c5d678 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimManagerProxy.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimManagerProxy.java
@@ -17,16 +17,21 @@ package org.onap.aai.esr.externalservice.cloud;
import org.glassfish.jersey.client.ClientConfig;
import org.onap.aai.esr.common.MsbConfig;
+import org.onap.aai.esr.exception.ExtsysException;
import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
public class VimManagerProxy {
public static void updateVim(String cloudOwner, String cloudRegionId,
- Tenant tenant) throws Exception {
+ Tenant tenant) throws ExtsysException {
ClientConfig config = new ClientConfig(new VimUpdateProvider());
IVimManage updateVimServiceproxy = ConsumerFactory
.createConsumer(MsbConfig.getCloudInfrastructureAddr(), config, IVimManage.class);
- updateVimServiceproxy.updateVIM(cloudOwner, cloudRegionId, tenant);
+ try {
+ updateVimServiceproxy.updateVIM(cloudOwner, cloudRegionId, tenant);
+ } catch (Exception e) {
+ throw new ExtsysException("Update cloud region to A&AI by Multi-Cloud failed.", e);
+ }
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/EmsManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/EmsManagerUtil.java
index 238683d..76f9681 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/util/EmsManagerUtil.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/EmsManagerUtil.java
@@ -29,7 +29,7 @@ public class EmsManagerUtil {
public EsrEmsDetail emsRegisterInfo2EsrEms(EmsRegisterInfo emsRegisterInfo) {
EsrEmsDetail esrEms = new EsrEmsDetail();
- esrEms.setEmsId(ExtsysUtil.generateId());
+ esrEms.setEmsId(extsysUtil.generateId());
ArrayList<EsrSystemInfo> authInfos = new ArrayList<EsrSystemInfo>();
authInfos = getAuthInfosFromRegisterData(emsRegisterInfo);
esrEms.setEsrSystemInfoList(extsysUtil.getEsrSystemInfoListFromAuthInfoList(authInfos));
@@ -65,7 +65,7 @@ public class EmsManagerUtil {
authInfo.setPassword(ftpAddr.getPassword());
authInfo.setRemotePath(ftpAddr.getRemotepath());
authInfo.setPassive(ftpAddr.getPassive());
- authInfo.setEsrSystemInfoId(ExtsysUtil.generateId());
+ authInfo.setEsrSystemInfoId(extsysUtil.generateId());
authInfo.setSystemType(systemType);
authInfo.setSystemName(emsRegisterInfo.getName());
authInfo.setVendor(emsRegisterInfo.getVendor());
@@ -77,7 +77,7 @@ public class EmsManagerUtil {
EsrSystemInfo authInfo = new EsrSystemInfo();
AlarmAddr alarmAddr = new AlarmAddr();
alarmAddr = emsRegisterInfo.getAlarmAddr();
- authInfo.setEsrSystemInfoId(ExtsysUtil.generateId());
+ authInfo.setEsrSystemInfoId(extsysUtil.generateId());
authInfo.setIpAddress(alarmAddr.getIp());
authInfo.setPort(alarmAddr.getPort());
authInfo.setUserName(alarmAddr.getUser());
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysUtil.java
index 2e1649f..834c9d5 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysUtil.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/ExtsysUtil.java
@@ -17,18 +17,14 @@ package org.onap.aai.esr.util;
import com.google.gson.Gson;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
-
import java.util.ArrayList;
import java.util.UUID;
-
import org.onap.aai.esr.entity.aai.EsrSystemInfo;
import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
public class ExtsysUtil {
- public static String generateId() {
+ public String generateId() {
return UUID.randomUUID().toString();
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java
index a2d1e1a..d0f61ca 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/ThirdpartySdncManagerUtil.java
@@ -24,10 +24,11 @@ import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
public class ThirdpartySdncManagerUtil {
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
public EsrThirdpartySdncDetail sdncRegisterInfo2EsrSdnc(ThirdpartySdncRegisterInfo sdncRegisterInfo) {
EsrThirdpartySdncDetail esrThirdpartySdnc = new EsrThirdpartySdncDetail();
- sdncRegisterInfo.setThirdpartySdncId(ExtsysUtil.generateId());
+ sdncRegisterInfo.setThirdpartySdncId(extsysUtil.generateId());
esrThirdpartySdnc.setThirdpartySdncId(sdncRegisterInfo.getThirdpartySdncId());
esrThirdpartySdnc.setLocation(sdncRegisterInfo.getLocation());
esrThirdpartySdnc.setProductName(sdncRegisterInfo.getProductName());
@@ -39,7 +40,7 @@ public class ThirdpartySdncManagerUtil {
EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
ArrayList<EsrSystemInfo> esrSystemInfo = new ArrayList<EsrSystemInfo>();
EsrSystemInfo authInfo = new EsrSystemInfo();
- authInfo.setEsrSystemInfoId(ExtsysUtil.generateId());
+ authInfo.setEsrSystemInfoId(extsysUtil.generateId());
authInfo.setVersion(sdncRegisterInfo.getVersion());
authInfo.setSystemName(sdncRegisterInfo.getName());
authInfo.setServiceUrl(sdncRegisterInfo.getUrl());
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java
index 2670866..1fc68a9 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java
@@ -25,7 +25,6 @@ import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
import org.onap.aai.esr.entity.rest.VimAuthInfo;
import org.onap.aai.esr.entity.rest.VimRegisterInfo;
-
public class VimManagerUtil {
private static ExtsysUtil extsysUtil = new ExtsysUtil();
@@ -60,7 +59,7 @@ public class VimManagerUtil {
esrSystemInfoObj.setServiceUrl(vimAuthInfo.getAuthUrl());
esrSystemInfoObj.setSslCassert(vimAuthInfo.getSslCacert());
esrSystemInfoObj.setSslInsecure(vimAuthInfo.getSslInsecure());
- esrSystemInfoObj.setEsrSystemInfoId(ExtsysUtil.generateId());
+ esrSystemInfoObj.setEsrSystemInfoId(extsysUtil.generateId());
esrSystemInfoObj.setSystemType(SystemType.VIM.toString());
// esrSystemInfoObj.setSystemStatus(SystemStatus.normal.toString());
return esrSystemInfoObj;
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java
index c3833b9..f1f33a7 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java
@@ -30,7 +30,7 @@ public class VnfmManagerUtil {
EsrSystemInfo authInfo = new EsrSystemInfo();
esrVnfm.setCertificateUrl(vnfmRegisterInfo.getCertificateUrl());
esrVnfm.setVimId(vnfmRegisterInfo.getVimId());
- esrVnfm.setVnfmId(ExtsysUtil.generateId());
+ esrVnfm.setVnfmId(extsysUtil.generateId());
authInfo = getAuthInfoFromVnfmRegisterInfo(vnfmRegisterInfo);
esrSystemInfo = extsysUtil.getEsrSystemInfoListFromAuthInfo(authInfo);
esrVnfm.setEsrSystemInfoList(esrSystemInfo);
@@ -43,7 +43,7 @@ public class VnfmManagerUtil {
*/
private EsrSystemInfo getAuthInfoFromVnfmRegisterInfo(VnfmRegisterInfo vnfmRegisterInfo) {
EsrSystemInfo authInfo = new EsrSystemInfo();
- authInfo.setEsrSystemInfoId(ExtsysUtil.generateId());
+ authInfo.setEsrSystemInfoId(extsysUtil.generateId());
authInfo.setSystemName(vnfmRegisterInfo.getName());
authInfo.setType(vnfmRegisterInfo.getType());
authInfo.setVendor(vnfmRegisterInfo.getVendor());
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
index d7f4f77..ae975ac 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
@@ -17,7 +17,6 @@ package org.onap.aai.esr.wrapper;
import java.util.ArrayList;
-import javax.inject.Inject;
import javax.ws.rs.core.Response;
import org.onap.aai.esr.entity.aai.CloudRegionDetail;
@@ -25,6 +24,8 @@ import org.onap.aai.esr.entity.aai.CloudRegionList;
import org.onap.aai.esr.entity.aai.EsrSystemInfo;
import org.onap.aai.esr.entity.rest.VimRegisterInfo;
import org.onap.aai.esr.entity.rest.VimRegisterResponse;
+import org.onap.aai.esr.exception.ExceptionUtil;
+import org.onap.aai.esr.exception.ExtsysException;
import org.onap.aai.esr.externalservice.aai.CloudRegionProxy;
import org.onap.aai.esr.externalservice.cloud.Tenant;
import org.onap.aai.esr.externalservice.cloud.VimManagerProxy;
@@ -35,20 +36,16 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
-
public class VimManagerWrapper {
private static VimManagerWrapper vimManagerWrapper;
private static final Logger LOG = LoggerFactory.getLogger(VimManagerWrapper.class);
- @Inject
- private VimManagerUtil vimManagerUtil;
+ private static VimManagerUtil vimManagerUtil = new VimManagerUtil();
- @Inject
- private CloudRegionProxy cloudRegionProxy;
+ private static CloudRegionProxy cloudRegionProxy = new CloudRegionProxy();
- @Inject
- private ExtsysUtil extsysUtil;
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
/**
* get VimManagerWrapper instance.
@@ -79,15 +76,14 @@ public class VimManagerWrapper {
tenant.setDefaultTenant(cloudRegion.getEsrSystemInfoList().getEsrSystemInfo().get(0).getDefaultTenant());
try {
VimManagerProxy.updateVim(cloudOwner, cloudRegionId, tenant);
- } catch (Exception e) {
- e.printStackTrace();
- LOG.error("Update VIM by Multi-cloud failed !" + e.getMessage());
+ } catch (ExtsysException e) {
+ LOG.error("Update VIM by Multi-cloud failed !", e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
return Response.ok(result).build();
- } catch (Exception error) {
- error.printStackTrace();
- LOG.error("Register VIM failed !" + error.getMessage());
- return Response.serverError().build();
+ } catch (ExtsysException error) {
+ LOG.error("Register VIM failed !", error);
+ throw ExceptionUtil.buildExceptionResponse(error.getMessage());
}
}
@@ -102,10 +98,9 @@ public class VimManagerWrapper {
result.setCloudOwner(cloudOwner);
result.setCloudRegionId(cloudRegionId);
return Response.ok(result).build();
- } catch (Exception e) {
- e.printStackTrace();
- LOG.error("Update VIM failed !" + e.getMessage());
- return Response.serverError().build();
+ } catch (ExtsysException e) {
+ LOG.error("Update VIM failed !", e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
}
@@ -117,9 +112,8 @@ public class VimManagerWrapper {
cloudRegionList = new Gson().fromJson(aaiVimList, CloudRegionList.class);
vimRegisterInfos = getVimDetailList(cloudRegionList);
return Response.ok(vimRegisterInfos).build();
- } catch (Exception error) {
- error.printStackTrace();
- LOG.error("Query vim list details failed !" + error.getMessage());
+ } catch (ExtsysException error) {
+ LOG.error("Query vim list details failed !", error);
return Response.ok(vimRegisterInfos).build();
}
@@ -134,8 +128,8 @@ public class VimManagerWrapper {
cloudRegionDetail = new Gson().fromJson(cloudRegionstr, CloudRegionDetail.class);
vim = vimManagerUtil.cloudRegion2VimRegisterInfo(cloudRegionDetail);
return Response.ok(vim).build();
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (ExtsysException e) {
+ LOG.error("Query vim details by ID failed !", e);
return Response.ok(vim).build();
}
@@ -161,10 +155,9 @@ public class VimManagerWrapper {
String cloudRegionstr = cloudRegionProxy.queryVimDetail(cloudOwner, cloudRegionId);
cloudRegionDetail = new Gson().fromJson(cloudRegionstr, CloudRegionDetail.class);
registeredVimInfo = vimManagerUtil.cloudRegion2VimRegisterInfo(cloudRegionDetail);
- } catch (Exception error) {
- error.printStackTrace();
+ } catch (ExtsysException error) {
LOG.error("query VIM detail failed ! cloud-owner = " + cloudOwner + ", cloud-region-id = "
- + cloudRegionId + error.getMessage());
+ + cloudRegionId, error);
}
return registeredVimInfo;
}
@@ -175,10 +168,9 @@ public class VimManagerWrapper {
String cloudRegionstr = cloudRegionProxy.queryVimDetail(cloudOwner, cloudRegionId);
cloudRegionDetail = new Gson().fromJson(cloudRegionstr, CloudRegionDetail.class);
return cloudRegionDetail;
- } catch (Exception error) {
- error.printStackTrace();
+ } catch (ExtsysException error) {
LOG.error("query VIM detail failed ! cloud-owner = " + cloudOwner + ", cloud-region-id = "
- + cloudRegionId + error.getMessage());
+ + cloudRegionId, error);
return null;
}
}
@@ -205,34 +197,26 @@ public class VimManagerWrapper {
CloudRegionDetail cloudRegionDetail = new CloudRegionDetail();
cloudRegionDetail = queryCloudRegionDetail(cloudOwner, cloudRegionId);
String resourceVersion = cloudRegionDetail.getResourceVersion();
- if (resourceVersion != null) {
- try {
- cloudRegionProxy.deleteVim(cloudOwner, cloudRegionId, resourceVersion);
- return Response.noContent().build();
- } catch (Exception e) {
- e.printStackTrace();
- LOG.error(
- "Delete cloud region from A&AI failed! cloud-owner = " + cloudOwner
- + ", cloud-region-id = " + cloudRegionId + "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 {
+ cloudRegionProxy.deleteVim(cloudOwner, cloudRegionId, resourceVersion);
+ return Response.noContent().build();
+ } catch (ExtsysException e) {
+ LOG.error("Delete cloud region from A&AI failed! cloud-owner = " + cloudOwner
+ + ", cloud-region-id = " + cloudRegionId + "resouce-version:" + resourceVersion, e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
}
-
+
private CloudRegionDetail queryCloudRegionDetail (String cloudOwner, String cloudRegionId) {
CloudRegionDetail cloudRegionDetail = new CloudRegionDetail();
try {
String cloudRegionStr = cloudRegionProxy.queryVimDetail(cloudOwner, cloudRegionId);
LOG.info("Response from AAI by query cloud region: " + cloudRegionStr);
cloudRegionDetail = new Gson().fromJson(cloudRegionStr, CloudRegionDetail.class);
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (ExtsysException e) {
LOG.error("Query EMS detail failed! cloud-owner = " + cloudOwner
- + ", cloud-region-id = " + cloudRegionId , e.getMessage());
+ + ", cloud-region-id = " + cloudRegionId , e);
+ throw ExceptionUtil.buildExceptionResponse(e.getMessage());
}
return cloudRegionDetail;
}