add sdnc controller para. 69/19969/1
authorLuji7 <lu.ji3@zte.com.cn>
Sun, 22 Oct 2017 08:10:21 +0000 (16:10 +0800)
committerLuji7 <lu.ji3@zte.com.cn>
Sun, 22 Oct 2017 08:10:28 +0000 (16:10 +0800)
Change-Id: I1d9bb257f674837a5083242cb05497320de57cbf
Issue-id: USECASEUI-53
Signed-off-by: Luji7 <lu.ji3@zte.com.cn>
server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInput.java
server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceTemplateService.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCController.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCControllerRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java

index 91a3eb0..0e25e0d 100644 (file)
@@ -117,6 +117,10 @@ public class ServiceTemplateInput {
         this.inputs.add(input);
     }
 
+    public void setType(String type) {
+        this.type = type;
+    }
+
     @Override
     public boolean equals(Object o) {
         if (this == o) return true;
index bbe25b7..9683eab 100644 (file)
@@ -17,6 +17,7 @@ package org.onap.usecaseui.server.controller.lcm;
 
 import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
 import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCController;
 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
 import org.slf4j.Logger;
@@ -59,4 +60,10 @@ public class ServiceTemplateController {
     public List<VimInfo> getLocations(){
         return serviceTemplateService.listVim();
     }
+
+    @ResponseBody
+    @RequestMapping(value = {"/uui-lcm/sdnc-controllers/"}, method = RequestMethod.GET , produces = "application/json")
+    public List<SDNCController> getSDNCControllers(){
+        return serviceTemplateService.listSDNCControllers();
+    }
 }
index c2607d4..d14774f 100644 (file)
@@ -16,6 +16,7 @@
 package org.onap.usecaseui.server.service.lcm;
 
 import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCController;
 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
 
@@ -28,4 +29,6 @@ public interface ServiceTemplateService {
     ServiceTemplateInput fetchServiceTemplateInput(String uuid, String toscaModelPath);
 
     List<VimInfo> listVim();
+
+    List<SDNCController> listSDNCControllers();
 }
\ No newline at end of file
index df1e076..d1ea681 100644 (file)
@@ -21,8 +21,6 @@ import retrofit2.http.GET;
 import retrofit2.http.Headers;
 import retrofit2.http.Path;
 
-import java.util.List;
-
 public interface AAIService {
 
     @Headers({
@@ -64,4 +62,13 @@ public interface AAIService {
 //    @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions")
     @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions")
     Call<ServiceSubscriptionRsp> listServiceSubscriptions(@Path("global-customer-id") String customerId);
+
+    @Headers({
+            "X-TransactionId: 7777",
+            "X-FromAppId: uui",
+            "Authorization: Basic QUFJOkFBSQ==",
+            "Accept: application/json"
+    })
+    @GET("/api/aai-externalSystem/v11/esr-thirdparty-sdnc-list")
+    Call<SDNCControllerRsp> listSdncControllers();
 }
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCController.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCController.java
new file mode 100644 (file)
index 0000000..b73cd40
--- /dev/null
@@ -0,0 +1,47 @@
+/**
+ * Copyright 2016-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.usecaseui.server.service.lcm.domain.aai.bean;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class SDNCController {
+
+    private String sdncId;
+
+    private String location;
+
+    @JsonProperty("thirdparty-sdnc-id")
+    public String getSdncId() {
+        return sdncId;
+    }
+
+    @JsonProperty("thirdparty-sdnc-id")
+    public void setSdncId(String sdncId) {
+        this.sdncId = sdncId;
+    }
+
+    @JsonProperty("location")
+    public String getLocation() {
+        return location;
+    }
+
+    @JsonProperty("location")
+    public void setLocation(String location) {
+        this.location = location;
+    }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCControllerRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/SDNCControllerRsp.java
new file mode 100644 (file)
index 0000000..3ceb3e7
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2016-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.usecaseui.server.service.lcm.domain.aai.bean;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class SDNCControllerRsp {
+
+    private List<SDNCController> esrThirdpartySdncList;
+
+    @JsonProperty("esr-thirdparty-sdnc-list")
+    public List<SDNCController> getEsrThirdpartySdncList() {
+        return esrThirdpartySdncList;
+    }
+
+    @JsonProperty("esr-thirdparty-sdnc-list")
+    public void setEsrThirdpartySdncList(List<SDNCController> esrThirdpartySdncList) {
+        this.esrThirdpartySdncList = esrThirdpartySdncList;
+    }
+}
index 92973e7..7d50a17 100644 (file)
@@ -21,6 +21,8 @@ import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
 import org.onap.usecaseui.server.bean.lcm.TemplateInput;
 import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCController;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCControllerRsp;
 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfoRsp;
 import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
@@ -132,6 +134,7 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
         List<TemplateInput> serviceInputs = getServiceInputs(inputsMap.values());
         serviceTemplateInput.addInputs(serviceInputs);
         if (isVF) {
+            serviceTemplateInput.setType("VF");
             appendLocationParameters(serviceTemplateInput, tosca);
             appendSdnControllerParameter(serviceTemplateInput);
         }
@@ -141,12 +144,13 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
     private void appendLocationParameters(ServiceTemplateInput serviceTemplateInput, ToscaTemplate tosca) {
         for (NodeTemplate nodeTemplate : tosca.getNodeTemplates()) {
             String type = nodeTemplate.getMetaData().getValue("type");
+            String uuid = nodeTemplate.getMetaData().getValue("UUID");
             if ("VF".equals(type)) {
                 serviceTemplateInput.addInput(
                         new TemplateInput(
-                                nodeTemplate.getName() + "_location",
+                                uuid,
                                 "vf_location",
-                                "location for the service",
+                                "location for the service " + uuid,
                                 "true",
                                 ""
                         )
@@ -339,4 +343,20 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
             throw new AAIException("AAI is not available.", e);
         }
     }
+
+    @Override
+    public List<SDNCController> listSDNCControllers() {
+        try {
+            Response<SDNCControllerRsp> response = aaiService.listSdncControllers().execute();
+            if (response.isSuccessful()) {
+                return response.body().getEsrThirdpartySdncList();
+            } else {
+                logger.info(String.format("Can not get sdnc controllers[code=%s, message=%s]", response.code(), response.message()));
+                return Collections.emptyList();
+            }
+        } catch (IOException e) {
+            logger.error("Visit AAI occur exception");
+            throw new AAIException("AAI is not available.", e);
+        }
+    }
 }