Realize the update thirdparty SDNC API 31/13031/1
authorlizi00164331 <li.zi30@zte.com.cn>
Mon, 18 Sep 2017 07:54:33 +0000 (15:54 +0800)
committerlizi00164331 <li.zi30@zte.com.cn>
Mon, 18 Sep 2017 07:54:33 +0000 (15:54 +0800)
Change-Id: Iea0e31d678a6cc17de319254b9c18484410a9505
Issue-ID: AAI-318
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
esr-mgr/src/main/java/org/onap/aai/esr/resource/ThirdpatySdncManager.java
esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java
esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java

index 18fd5d9..8c5f5f7 100644 (file)
@@ -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);
   }
   
   /**
index 20b8eab..e5f9966 100644 (file)
@@ -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;
+  }
+  
 }
index 016e525..d75760c 100644 (file)
@@ -112,7 +112,7 @@ public class VnfmManagerWrapper {
     if (vnfm != null) {
       return Response.ok(vnfm).build();
     } else {
-      return Response.serverError().build();
+      return Response.ok().build();
     }
   }