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;
private static ThirdpatySdncWrapper thirdpatySdncWrapper;
private static final Logger LOG = LoggerFactory.getLogger(ThirdpatySdncWrapper.class);
+ private static ThirdpartySdncManagerUtil thirdpartySdncManagerUtil = new ThirdpartySdncManagerUtil();
/**
* get ThirdpatySdncWrapper instance.
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());
}
}
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);
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());
}
}
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) {
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());
}
}
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;
}