Realize query thirdparty sdnc detail API 17/13017/1
authorlizi00164331 <li.zi30@zte.com.cn>
Mon, 18 Sep 2017 07:14:04 +0000 (15:14 +0800)
committerlizi00164331 <li.zi30@zte.com.cn>
Mon, 18 Sep 2017 07:14:04 +0000 (15:14 +0800)
Change-Id: I3bd27d083cb6243c91039648ea0fb158c81ea8e5
Issue-ID: AAI-316
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java
esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java

index cebab2c..eda2eb2 100644 (file)
@@ -61,4 +61,8 @@ public class ExternalSystemProxy {
     registerVnfmServiceproxy.registerThirdpartySdnc(transactionId, fromAppId, authorization, thirdpartySdncId,
         esrSdncDetail);
   }
+  
+  public static String queryThirdpartySdncDetail(String thirdpartySdncId) throws Exception{
+    return externalSystemproxy.queryThirdpartySdncDetail(transactionId, fromAppId, authorization, thirdpartySdncId);
+  }
 }
index 9bc61ad..f9246f7 100644 (file)
@@ -27,6 +27,8 @@ import org.onap.aai.esr.util.ThirdpartySdncManagerUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.gson.Gson;
+
 public class ThirdpatySdncWrapper {
 
   private static ThirdpatySdncWrapper thirdpatySdncWrapper;
@@ -73,12 +75,32 @@ public class ThirdpatySdncWrapper {
   
   public Response queryThirdpartySdncById(String thirdpartySdncId) {
     ThirdpartySdncRegisterInfo thirdpartySdnc = new ThirdpartySdncRegisterInfo();
-    //TODO
-    return Response.ok(thirdpartySdnc).build();
+    thirdpartySdnc = querySdncDetail(thirdpartySdncId);
+    if(thirdpartySdnc != null) {
+      return Response.ok(thirdpartySdnc).build();
+    } else {
+      return Response.serverError().build();
+    }
   }
   
   public Response delThirdpartySdnc(String thirdpartySdncId) {
     //TODO
     return Response.noContent().build();
   }
+  
+  private ThirdpartySdncRegisterInfo querySdncDetail(String sdncId) {
+    ThirdpartySdncRegisterInfo sdncRegisterInfo = new ThirdpartySdncRegisterInfo();
+    EsrThirdpartySdncDetail esrSdncDetail = new EsrThirdpartySdncDetail();
+    try {
+      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);
+      return sdncRegisterInfo;
+    } catch (Exception e) {
+      e.printStackTrace();
+      LOG.error("Query VNFM detail failed! thirdpaty SDNC ID: " + sdncId, e.getMessage());
+      return null;
+    }
+  }
 }