Realize the API to get complex object ID. 45/33545/1
authorLiZi <li.zi30@zte.com.cn>
Thu, 1 Mar 2018 07:11:56 +0000 (02:11 -0500)
committerLiZi <li.zi30@zte.com.cn>
Thu, 1 Mar 2018 07:13:30 +0000 (02:13 -0500)
Change-Id: Ie70a1352fbdd490b0b4e6ac05ea14fbfa38b9678
Issue-ID: AAI-826
Signed-off-by: LiZi <li.zi30@zte.com.cn>
esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/Complex.java [new file with mode: 0644]
esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/ComplexList.java [new file with mode: 0644]
esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java
esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java

diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/Complex.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/Complex.java
new file mode 100644 (file)
index 0000000..0a543bb
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2018 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 Complex implements Serializable {
+    public static final long serialVersionUID = 1L;
+    
+    @SerializedName("physical-location-id")
+    private String physicalLocationId;
+
+    public String getPhysicalLocationId() {
+        return physicalLocationId;
+    }
+
+    public void setPhysicalLocationId(String physicalLocationId) {
+        this.physicalLocationId = physicalLocationId;
+    }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/ComplexList.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/ComplexList.java
new file mode 100644 (file)
index 0000000..d8cd678
--- /dev/null
@@ -0,0 +1,36 @@
+/**
+ * Copyright 2018 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.List;
+import com.google.gson.annotations.SerializedName;
+
+public class ComplexList implements Serializable {
+    public static final long serialVersionUID = 1L;
+
+    @SerializedName("complex")
+    private List<Complex> complex;
+
+    public List<Complex> getComplex() {
+        return complex;
+    }
+
+    public void setComplex(List<Complex> complex) {
+        this.complex = complex;
+    }
+    
+}
index a145288..bcfedb3 100644 (file)
@@ -72,4 +72,12 @@ public class CloudRegionProxy {
             throw new ExtsysException("Delete cloud region from A&AI failed.", e);
         }
     }
             throw new ExtsysException("Delete cloud region from A&AI failed.", e);
         }
     }
+    
+    public String qureyComplexes() throws ExtsysException {
+        try {
+            return adapterServiceproxy.queryComplexList(transactionId, fromAppId, authorization);
+        } catch (Exception e) {
+            throw new ExtsysException("Query complexes from A&AI failed.", e);
+        }
+    }
 }
 }
index a122c47..b3adcbf 100644 (file)
@@ -1,5 +1,5 @@
 /**
 /**
- * Copyright 2016-2017 ZTE Corporation.
+ * Copyright 2016-2018 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -140,4 +140,19 @@ public class VimManager {
         LOGGER.info("start add vim" + " info:" + extsysUtil.objectToString(vim));
         return VimManagerWrapper.getInstance().registerVim(vim);
     }
         LOGGER.info("start add vim" + " info:" + extsysUtil.objectToString(vim));
         return VimManagerWrapper.getInstance().registerVim(vim);
     }
+    
+    @GET
+    @Path("/complexes")
+    @ApiOperation(value = "get  all complexes ")
+    @Produces(MediaType.APPLICATION_JSON)
+    @ApiResponses(value = {
+            @ApiResponse(code = HttpStatus.NOT_FOUND_404, message = "microservice not found", response = String.class),
+            @ApiResponse(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE_415,
+                    message = "Unprocessable MicroServiceInfo Entity ", response = String.class),
+            @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
+                    response = String.class)})
+    @Timed
+    public Response queryComplexList() {
+        return VimManagerWrapper.getInstance().queryComplexes();
+    }
 }
 }
index bc7e872..7545b01 100644 (file)
@@ -1,5 +1,5 @@
 /**
 /**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2018 ZTE Corporation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import java.util.List;
 import javax.ws.rs.core.Response;
 import org.onap.aai.esr.entity.aai.CloudRegionDetail;
 import org.onap.aai.esr.entity.aai.CloudRegionList;
 import javax.ws.rs.core.Response;
 import org.onap.aai.esr.entity.aai.CloudRegionDetail;
 import org.onap.aai.esr.entity.aai.CloudRegionList;
+import org.onap.aai.esr.entity.aai.ComplexList;
 import org.onap.aai.esr.entity.aai.EsrSystemInfo;
 import org.onap.aai.esr.entity.rest.VimRegisterInfo;
 import org.onap.aai.esr.entity.rest.VimRegisterResponse;
 import org.onap.aai.esr.entity.aai.EsrSystemInfo;
 import org.onap.aai.esr.entity.rest.VimRegisterInfo;
 import org.onap.aai.esr.entity.rest.VimRegisterResponse;
@@ -214,4 +215,20 @@ public class VimManagerWrapper {
         }
         return cloudRegionDetail;
     }
         }
         return cloudRegionDetail;
     }
+
+    public Response queryComplexes() {
+        ComplexList complexList = new ComplexList();
+        List<String> complexId = new ArrayList<>();
+        try {
+            String complexesString = cloudRegionProxy.qureyComplexes();
+            LOG.info("The complex query result is: " + complexesString);
+            complexList = new Gson().fromJson(complexesString, ComplexList.class);
+            for (int i=0; i<complexList.getComplex().size(); i++) {
+                complexId.add(complexList.getComplex().get(i).getPhysicalLocationId());
+            }
+        } catch (ExtsysException e) {
+            LOG.error("Query vim details by ID failed !", e);
+        }
+        return Response.ok(complexId).build();
+    }
 }
 }