From 8f5e361483e985a25c2d48cea5ada4e6de9e60d0 Mon Sep 17 00:00:00 2001
From: lizi00164331
Date: Mon, 18 Sep 2017 15:16:51 +0800
Subject: [PATCH] Realize query thirdparty sdnc list API.
Change-Id: I241134d56f0aa495546c8987d038c986ed6b7468
Issue-ID: AAI-317
Signed-off-by: lizi00164331
---
.../onap/aai/esr/entity/aai/EsrThirdpartySdnc.java | 68 ++++++++++++++++++++++
.../aai/esr/entity/aai/EsrThirdpartySdncList.java | 37 ++++++++++++
.../externalservice/aai/ExternalSystemProxy.java | 4 ++
.../onap/aai/esr/wrapper/ThirdpatySdncWrapper.java | 30 +++++++++-
4 files changed, 136 insertions(+), 3 deletions(-)
create mode 100644 esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdnc.java
create mode 100644 esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncList.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
index 0000000..89e1ffd
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdnc.java
@@ -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
index 0000000..8340e31
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncList.java
@@ -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;
+
+ public ArrayList getEsrThirdpartySdnc() {
+ return esrThirdpartySdnc;
+ }
+
+ public void setEsrThirdpartySdnc(ArrayList esrThirdpartySdnc) {
+ this.esrThirdpartySdnc = esrThirdpartySdnc;
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java
index eda2eb2..01d8ac3 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java
@@ -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);
+ }
}
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 f9246f7..20b8eab 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
@@ -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 thirdpartySdncList = new ArrayList();
- return Response.ok(thirdpartySdncList).build();
+ ArrayList sdncList = new ArrayList();
+ 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 getSdncDetailList(EsrThirdpartySdncList esrThirdPartySdnc) {
+ ArrayList sdncInfoList = new ArrayList();
+ 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;
+ }
}
--
2.16.6