Realize query thirdparty sdnc list API. 19/13019/1
authorlizi00164331 <li.zi30@zte.com.cn>
Mon, 18 Sep 2017 07:16:51 +0000 (15:16 +0800)
committerlizi00164331 <li.zi30@zte.com.cn>
Mon, 18 Sep 2017 07:16:51 +0000 (15:16 +0800)
Change-Id: I241134d56f0aa495546c8987d038c986ed6b7468
Issue-ID: AAI-317
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdnc.java [new file with mode: 0644]
esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncList.java [new file with mode: 0644]
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

diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdnc.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdnc.java
new file mode 100644 (file)
index 0000000..89e1ffd
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.aai.esr.entity.aai;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class EsrThirdpartySdnc implements Serializable {
+public static final long serialVersionUID = 1L;
+  
+  @SerializedName("thirdparty-sdnc-id")
+  private String thirdpartySdncId;
+  
+  @SerializedName("location")
+  private String location;
+
+  @SerializedName("product-name")
+  private String productName;
+  
+  @SerializedName("resource-version")
+  private String resourceVersion;
+
+  public String getThirdpartySdncId() {
+    return thirdpartySdncId;
+  }
+
+  public void setThirdpartySdncId(String thirdpartySdncId) {
+    this.thirdpartySdncId = thirdpartySdncId;
+  }
+
+  public String getLocation() {
+    return location;
+  }
+
+  public void setLocation(String location) {
+    this.location = location;
+  }
+
+  public String getProductName() {
+    return productName;
+  }
+
+  public void setProductName(String productName) {
+    this.productName = productName;
+  }
+
+  public String getResourceVersion() {
+    return resourceVersion;
+  }
+
+  public void setResourceVersion(String resourceVersion) {
+    this.resourceVersion = resourceVersion;
+  }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncList.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncList.java
new file mode 100644 (file)
index 0000000..8340e31
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.aai.esr.entity.aai;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+import com.google.gson.annotations.SerializedName;
+
+public class EsrThirdpartySdncList implements Serializable {
+
+  public static final long serialVersionUID = 1L;
+  
+  @SerializedName("esr-thirdparty-sdnc")
+  private ArrayList<EsrThirdpartySdnc> esrThirdpartySdnc;
+
+  public ArrayList<EsrThirdpartySdnc> getEsrThirdpartySdnc() {
+    return esrThirdpartySdnc;
+  }
+
+  public void setEsrThirdpartySdnc(ArrayList<EsrThirdpartySdnc> esrThirdpartySdnc) {
+    this.esrThirdpartySdnc = esrThirdpartySdnc;
+  }
+}
index eda2eb2..01d8ac3 100644 (file)
@@ -65,4 +65,8 @@ public class ExternalSystemProxy {
   public static String queryThirdpartySdncDetail(String thirdpartySdncId) throws Exception{
     return externalSystemproxy.queryThirdpartySdncDetail(transactionId, fromAppId, authorization, thirdpartySdncId);
   }
+  
+  public static String querySdncList() throws Exception {
+    return externalSystemproxy.queryThirdpartySdncList(transactionId, fromAppId, authorization);
+  }
 }
index f9246f7..20b8eab 100644 (file)
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import javax.ws.rs.core.Response;
 
 import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
+import org.onap.aai.esr.entity.aai.EsrThirdpartySdncList;
 import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
 import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
 import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
@@ -68,9 +69,19 @@ public class ThirdpatySdncWrapper {
   }
   
   public Response queryThirdpartySdncList() {
-    //TODO
-    ArrayList<ThirdpartySdncRegisterInfo> thirdpartySdncList = new ArrayList<ThirdpartySdncRegisterInfo>();
-    return Response.ok(thirdpartySdncList).build();
+    ArrayList<ThirdpartySdncRegisterInfo> sdncList = new ArrayList<ThirdpartySdncRegisterInfo>();
+    EsrThirdpartySdncList esrSdnc = new EsrThirdpartySdncList();
+    try {
+      String esrSdncStr = ExternalSystemProxy.querySdncList();
+      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();
+    }
   }
   
   public Response queryThirdpartySdncById(String thirdpartySdncId) {
@@ -103,4 +114,17 @@ public class ThirdpatySdncWrapper {
       return null;
     }
   }
+  
+  private ArrayList<ThirdpartySdncRegisterInfo> getSdncDetailList(EsrThirdpartySdncList esrThirdPartySdnc) {
+    ArrayList<ThirdpartySdncRegisterInfo> sdncInfoList = new ArrayList<ThirdpartySdncRegisterInfo>();
+    ThirdpartySdncRegisterInfo sdncInfo = new ThirdpartySdncRegisterInfo();
+    for (int i = 0; i < esrThirdPartySdnc.getEsrThirdpartySdnc().size(); i++) {
+      String sdncId = esrThirdPartySdnc.getEsrThirdpartySdnc().get(i).getThirdpartySdncId();
+      sdncInfo = querySdncDetail(sdncId);
+      if (sdncInfo != null) {
+        sdncInfoList.add(sdncInfo);
+      }
+    }
+    return sdncInfoList;
+  }
 }