diff options
author | 2017-09-18 15:54:33 +0800 | |
---|---|---|
committer | 2017-09-18 15:54:33 +0800 | |
commit | dd5fda2be4276ac66536853fe664db4f2f798e7c (patch) | |
tree | 20b4efe66d08fb7d962d08f17d68f9345e07c5b5 /esr-mgr | |
parent | 8f5e361483e985a25c2d48cea5ada4e6de9e60d0 (diff) |
Realize the update thirdparty SDNC API
Change-Id: Iea0e31d678a6cc17de319254b9c18484410a9505
Issue-ID: AAI-318
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr')
3 files changed, 44 insertions, 6 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpatySdncManager.java b/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpatySdncManager.java index 18fd5d9..8c5f5f7 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpatySdncManager.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpatySdncManager.java @@ -123,7 +123,7 @@ public class ThirdpatySdncManager { public Response updateThirdpartySdnc(@ApiParam(value = "thirdpartySdnc", required = true) ThirdpartySdncRegisterInfo thirdPartySdnc, @ApiParam(value = "sdnc id", required = true) @PathParam("thirdPartySdncId") String thirdPartySdncId) { LOGGER.info("start update sdnc .id:" + thirdPartySdncId + " info:" + ExtsysUtil.objectToString(thirdPartySdnc)); - return ThirdpatySdncWrapper.getInstance().updateThirdpartySdnc(thirdPartySdnc); + return ThirdpatySdncWrapper.getInstance().updateThirdpartySdnc(thirdPartySdnc, thirdPartySdncId); } /** 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 20b8eab..e5f9966 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 @@ -19,12 +19,15 @@ import java.util.ArrayList; 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.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; @@ -63,9 +66,30 @@ public class ThirdpatySdncWrapper { } - public Response updateThirdpartySdnc(ThirdpartySdncRegisterInfo thirdpartySdnc) { - //TODO - return Response.ok().build(); + public Response updateThirdpartySdnc(ThirdpartySdncRegisterInfo thirdpartySdnc, String sdncId) { + CommonRegisterResponse result = new CommonRegisterResponse(); + EsrThirdpartySdncDetail esrSdncDetail = new EsrThirdpartySdncDetail(); + EsrThirdpartySdncDetail originalEsrSdncDetail = new EsrThirdpartySdncDetail(); + EsrSystemInfo originalEsrSystemInfo = new EsrSystemInfo(); + originalEsrSdncDetail = queryEsrThirdpartySdncDetail(sdncId); + esrSdncDetail = ThirdpartySdncManagerUtil.sdncRegisterInfo2EsrSdnc(thirdpartySdnc); + String resourceVersion = originalEsrSdncDetail.getResourceVersion(); + esrSdncDetail.setResourceVersion(resourceVersion); + esrSdncDetail.setThirdpartySdncId(sdncId); + originalEsrSystemInfo = originalEsrSdncDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0); + esrSdncDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0) + .setEsrSystemInfoId(originalEsrSystemInfo.getEsrSystemInfoId()); + esrSdncDetail.getEsrSystemInfoList().getEsrSystemInfo().get(0) + .setResouceVersion(originalEsrSystemInfo.getResouceVersion()); + try { + 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(); + } } public Response queryThirdpartySdncList() { @@ -90,7 +114,7 @@ public class ThirdpatySdncWrapper { if(thirdpartySdnc != null) { return Response.ok(thirdpartySdnc).build(); } else { - return Response.serverError().build(); + return Response.ok().build(); } } @@ -127,4 +151,18 @@ public class ThirdpatySdncWrapper { } return sdncInfoList; } + + private EsrThirdpartySdncDetail queryEsrThirdpartySdncDetail (String sdncId) { + EsrThirdpartySdncDetail esrSdncDetail = new EsrThirdpartySdncDetail(); + try { + 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()); + } + return esrSdncDetail; + } + } diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java index 016e525..d75760c 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java @@ -112,7 +112,7 @@ public class VnfmManagerWrapper { if (vnfm != null) { return Response.ok(vnfm).build(); } else { - return Response.serverError().build(); + return Response.ok().build(); } } |