summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-09-18 17:38:07 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-09-18 17:38:07 +0800
commitc62f4b64bdd6a26cd8d78406e4bcf8ab907384a1 (patch)
tree416ceb49b752b6875d7236c69c9f2f5ab619fe77
parent191a050af372f6eebee33a16a1b501a66aab950f (diff)
Realize the query EMS list API.
Change-Id: I151c71919245d6af21b9ad63a153ef2331860b98 Issue-ID: AAI-322 Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEms.java47
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEmsList.java37
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfm.java2
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java30
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java1
6 files changed, 116 insertions, 5 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEms.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEms.java
new file mode 100644
index 0000000..d50af6b
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEms.java
@@ -0,0 +1,47 @@
+/**
+ * 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 EsrEms implements Serializable {
+
+public static final long serialVersionUID = 1L;
+
+ @SerializedName("ems-id")
+ private String emsId;
+
+ @SerializedName("resource-version")
+ private String resourceVersion;
+
+ public String getEmsId() {
+ return emsId;
+ }
+
+ public void setEmsId(String emsId) {
+ this.emsId = emsId;
+ }
+
+ 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/EsrEmsList.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEmsList.java
new file mode 100644
index 0000000..e14da46
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrEmsList.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 EsrEmsList implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("esr-ems")
+ private ArrayList<EsrEms> esrEms;
+
+ public ArrayList<EsrEms> getEsrEms() {
+ return esrEms;
+ }
+
+ public void setEsrEms(ArrayList<EsrEms> esrEms) {
+ this.esrEms = esrEms;
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfm.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfm.java
index f0b8bb8..73fbc8c 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfm.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfm.java
@@ -19,7 +19,7 @@ import java.io.Serializable;
import com.google.gson.annotations.SerializedName;
-public class EsrVnfm implements Serializable {
+public class EsrVnfm implements Serializable {
public static final long serialVersionUID = 1L;
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 bc7b58e..e2ebfef 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
@@ -86,4 +86,8 @@ public class ExternalSystemProxy {
public static String queryEmsDetail(String emsId) throws Exception {
return externalSystemproxy.queryEMSDetail(transactionId, fromAppId, authorization, emsId);
}
+
+ public static String queryEmsList() throws Exception {
+ return externalSystemproxy.queryEMSList(transactionId, fromAppId, authorization);
+ }
}
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 ac85b0a..9d13165 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
@@ -23,6 +23,7 @@ import org.onap.aai.esr.entity.rest.EmsRegisterInfo;
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.rest.CommonRegisterResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,9 +67,19 @@ public class EmsManagerWrapper {
}
public Response queryEmsList() {
- //TODO
ArrayList<EmsRegisterInfo> emsList = new ArrayList<EmsRegisterInfo>();
- return Response.ok(emsList).build();
+ EsrEmsList esrEms = new EsrEmsList();
+ try {
+ String esrEmsStr = ExternalSystemProxy.queryEmsList();
+ esrEms = new Gson().fromJson(esrEmsStr, EsrEmsList.class);
+ LOG.info("Response from AAI by query EMS list: " + esrEms);
+ emsList = getEmsDetailList(esrEms);
+ return Response.ok(emsList).build();
+ } catch (Exception e) {
+ e.printStackTrace();
+ LOG.error("Query EMS list failed !");
+ return Response.serverError().build();
+ }
}
public Response queryEmsById(String emsId) {
@@ -97,8 +108,21 @@ public class EmsManagerWrapper {
return emsRegisterInfo;
} catch (Exception e) {
e.printStackTrace();
- LOG.error("Query VNFM detail failed! EMS ID: " + emsId, e.getMessage());
+ LOG.error("Query EMS detail failed! EMS ID: " + emsId, e.getMessage());
return null;
}
}
+
+ private ArrayList<EmsRegisterInfo> getEmsDetailList(EsrEmsList esrEms) {
+ ArrayList<EmsRegisterInfo> emsInfoList = new ArrayList<EmsRegisterInfo>();
+ EmsRegisterInfo emsInfo = new EmsRegisterInfo();
+ for (int i = 0; i < esrEms.getEsrEms().size(); i++) {
+ String emsId = esrEms.getEsrEms().get(i).getEmsId();
+ emsInfo = queryEmsDetail(emsId);
+ if (emsInfo != null) {
+ emsInfoList.add(emsInfo);
+ }
+ }
+ return emsInfoList;
+ }
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
index d75760c..d1b3b77 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
@@ -103,7 +103,6 @@ public class VnfmManagerWrapper {
LOG.error("Query VNFM list failed !");
return Response.serverError().build();
}
-
}
public Response queryVnfmById(String vnfmId) {