diff options
author | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-18 19:49:29 +0800 |
---|---|---|
committer | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-18 19:49:29 +0800 |
commit | 48df9cda482edd36130777549ac42ee88f048af3 (patch) | |
tree | 7713883bd5571465af05833c5381e450f85038c0 | |
parent | fbc14fb126199394da2ccc459460e69672772c1c (diff) |
Realize the update EMS API.
Change-Id: If8ad34360d9d0ea9213db33b0008931d3def293f
Issue-ID: AAI-323
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
-rw-r--r-- | esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java | 2 | ||||
-rw-r--r-- | esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java | 48 |
2 files changed, 46 insertions, 4 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java b/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java index 7897eb2..ba51f43 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/resource/EmsManager.java @@ -124,7 +124,7 @@ public class EmsManager { public Response updateEms(@ApiParam(value = "ems", required = true) EmsRegisterInfo ems, @ApiParam(value = "ems id", required = true) @PathParam("emsId") String emsId) { LOGGER.info("start update ems .id:" + emsId + " info:" + ExtsysUtil.objectToString(ems)); - return RestResponseUtil.getSuccessResponse(new EmsRegisterInfo()); + return EmsManagerWrapper.getInstance().updateEms(ems, emsId); } /** 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 f3ae511..36f7963 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 @@ -24,6 +24,7 @@ import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy; import org.onap.aai.esr.util.EmsManagerUtil; import org.onap.aai.esr.entity.aai.EsrEmsDetail; import org.onap.aai.esr.entity.aai.EsrEmsList; +import org.onap.aai.esr.entity.aai.EsrSystemInfo; import org.onap.aai.esr.entity.rest.CommonRegisterResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,9 +62,19 @@ public class EmsManagerWrapper { } } - public Response updateEms(EmsRegisterInfo ems) { - //TODO - return Response.ok().build(); + public Response updateEms(EmsRegisterInfo emsRegisterInfo, String emsId) { + CommonRegisterResponse result = new CommonRegisterResponse(); + EsrEmsDetail esrEmsDetail = new EsrEmsDetail(); + esrEmsDetail = getNewEsrEmsDetail(emsRegisterInfo, emsId); + try { + 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(); + } } public Response queryEmsList() { @@ -153,4 +164,35 @@ public class EmsManagerWrapper { } return esrEmsDetail; } + + private EsrEmsDetail getNewEsrEmsDetail(EmsRegisterInfo emsRegisterInfo, String emsId) { + EsrEmsDetail esrEmsDetail = new EsrEmsDetail(); + ArrayList<EsrSystemInfo> newEsrSysInfoList = new ArrayList<EsrSystemInfo>(); + EsrSystemInfo newEsrSystemInfo = new EsrSystemInfo(); + EsrEmsDetail oriEsrEmsDetail = new EsrEmsDetail(); + ArrayList<EsrSystemInfo> oriEsrSysInfoList = new ArrayList<EsrSystemInfo>(); + EsrSystemInfo originalEsrSystemInfo = new EsrSystemInfo(); + + oriEsrEmsDetail = queryEsrEmsDetail(emsId); + esrEmsDetail = EmsManagerUtil.emsRegisterInfo2EsrEms(emsRegisterInfo); + String emsResourceVersion = oriEsrEmsDetail.getResourceVersion(); + esrEmsDetail.setResourceVersion(emsResourceVersion); + esrEmsDetail.setEmsId(emsId); + newEsrSysInfoList = esrEmsDetail.getEsrSystemInfoList().getEsrSystemInfo(); + oriEsrSysInfoList = oriEsrEmsDetail.getEsrSystemInfoList().getEsrSystemInfo(); + for (int i = 0; i < oriEsrSysInfoList.size(); i++) { + originalEsrSystemInfo = oriEsrSysInfoList.get(i); + for (int j = 0; j < newEsrSysInfoList.size(); j++) { + newEsrSystemInfo = newEsrSysInfoList.get(j); + if (originalEsrSystemInfo.getSystemType().equals(newEsrSystemInfo.getSystemType())) { + esrEmsDetail.getEsrSystemInfoList().getEsrSystemInfo().get(j) + .setResouceVersion(originalEsrSystemInfo.getResouceVersion()); + esrEmsDetail.getEsrSystemInfoList().getEsrSystemInfo().get(j) + .setEsrSystemInfoId(originalEsrSystemInfo.getEsrSystemInfoId()); + break; + } + } + } + return esrEmsDetail; + } } |