--- /dev/null
+/**
+ * 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;
+ }
+}
--- /dev/null
+/**
+ * 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;
+ }
+}
import com.google.gson.annotations.SerializedName;
-public class EsrVnfm implements Serializable {
+public class EsrVnfm implements Serializable {
public static final long serialVersionUID = 1L;
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);
+ }
}
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;
}
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) {
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;
+ }
}
LOG.error("Query VNFM list failed !");
return Response.serverError().build();
}
-
}
public Response queryVnfmById(String vnfmId) {