Add uui-lcm/orchestrators API to UUI Server 25/82925/1
authorBharath Thiruveedula <bharath.thiruveedula@verizon.com>
Thu, 21 Mar 2019 12:42:32 +0000 (18:12 +0530)
committerBharath Thiruveedula <bharath.thiruveedula@verizon.com>
Thu, 21 Mar 2019 12:44:11 +0000 (18:14 +0530)
Change-Id: I3f3c638cd01921e0aeaa8d55423d89f83d0f7337
Signed-off-by: Bharath Thiruveedula <bharath.thiruveedula@verizon.com>
Issue-ID: USECASEUI-243
Depends-on: I71601180d47fe3de71ddbc07a4c54db7b398f520

server/src/main/java/org/onap/usecaseui/server/controller/lcm/OrchestratorController.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/OrchestratorService.java [new file with mode: 0644]
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/AAIEsrNfvo.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAIOrchestratorRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAISingleOrchestratorRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/EsrSystemInfo.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/EsrSystemInfoList.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultOrchestratorService.java [new file with mode: 0644]
server/src/test/java/org/onap/usecaseui/server/controller/lcm/OrchestratorControllerTest.java [new file with mode: 0644]

diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/OrchestratorController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/OrchestratorController.java
new file mode 100644 (file)
index 0000000..46673ee
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2019  Verizon. All Rights Reserved.
+ *
+ * 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.controller.lcm;
+
+import org.onap.usecaseui.server.service.lcm.OrchestratorService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIEsrNfvo;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Controller
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class OrchestratorController {
+
+    @Resource(name="OrchestratorService")
+    private OrchestratorService  orchestratorService;
+
+    public void setOrchestratorService(OrchestratorService orchestratorService) {
+        this.orchestratorService = orchestratorService;
+    }
+
+    @ResponseBody
+    @RequestMapping(value = {"/uui-lcm/orchestrators"}, method = RequestMethod.GET , produces = "application/json")
+    public List<AAIEsrNfvo> getOrchestrators(){
+        return orchestratorService.listOrchestrator();
+    }
+
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/OrchestratorService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/OrchestratorService.java
new file mode 100644 (file)
index 0000000..b953eea
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Copyright (C) 2019 Verizon. All Rights Reserved.
+ *
+ * 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;
+
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIEsrNfvo;
+
+import java.util.List;
+
+public interface OrchestratorService {
+    List<AAIEsrNfvo> listOrchestrator();
+}
index e11e8bd..1e898c0 100644 (file)
 package org.onap.usecaseui.server.service.lcm.domain.aai;
 
 import org.onap.usecaseui.server.bean.sotn.PinterfaceRsp;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomerRsp;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.SDNCControllerRsp;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstanceRsp;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceSubscriptionRsp;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfoRsp;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.*;
 
 import okhttp3.RequestBody;
 import okhttp3.ResponseBody;
@@ -45,6 +41,24 @@ public interface AAIService {
     @GET("/api/aai-business/v11/customers")
     Call<AAICustomerRsp> listCustomer();
 
+    @Headers({
+            "X-TransactionId: 7777",
+            "X-FromAppId: uui",
+            "Authorization: Basic QUFJOkFBSQ==",
+            "Accept: application/json"
+    })
+    @GET("/api/aai-externalSystem/v16/esr-nfvo-list")
+    Call<AAIOrchestratorRsp> listOrchestrator();
+
+    @Headers({
+            "X-TransactionId: 7777",
+            "X-FromAppId: uui",
+            "Authorization: Basic QUFJOkFBSQ==",
+            "Accept: application/json"
+    })
+    @GET("/api/aai-externalSystem/v16/esr-nfvo-list/esr-nfvo/{nfvo-id}?depth=all")
+    Call<AAISingleOrchestratorRsp> getOrchestrator(@Path("nfvo-id") String nfvoId);
+
     @Headers({
             "X-TransactionId: 7777",
             "X-FromAppId: uui",
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAIEsrNfvo.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAIEsrNfvo.java
new file mode 100644 (file)
index 0000000..55ce376
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * Copyright (C) 2019 Verizon. All Rights Reserved
+ *
+ * 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.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+public class AAIEsrNfvo {
+
+    private String nfvoId;
+
+    private String apiRoot;
+
+    private String resourceVersion;
+
+    private String name;
+
+    @JsonCreator
+    public AAIEsrNfvo(
+        @JsonProperty("nfvo-id") String nfvoId,
+        @JsonProperty("api-root") String apiRoot,
+        @JsonProperty("resource-version") String resourceVersion,
+        @JsonProperty("name") String name) {
+        this.nfvoId = nfvoId;
+        this.apiRoot = apiRoot;
+        this.resourceVersion = resourceVersion;
+        this.name = name;
+    }
+
+    @JsonProperty("nfvo-id")
+    public String getNfvoId() {
+        return nfvoId;
+    }
+
+    @JsonProperty("api-root")
+    public String getApiRoot() {
+        return apiRoot;
+    }
+
+    @JsonProperty("resource-version")
+    public String getResourceVersion() {
+        return resourceVersion;
+    }
+
+    @JsonProperty("name")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAIOrchestratorRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAIOrchestratorRsp.java
new file mode 100644 (file)
index 0000000..0181f8f
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2019 Verizon. All Rights Reserved.
+ *
+ * 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 AAIOrchestratorRsp {
+
+    @JsonProperty("esr-nfvo")
+    private List<AAIEsrNfvo> esrNfvo;
+
+    public List<AAIEsrNfvo> getEsrNfvo() {
+        return esrNfvo;
+    }
+
+    public void setEsrNfvo(@JsonProperty("esr-nfvo") List<AAIEsrNfvo> esrNfvo) {
+        this.esrNfvo = esrNfvo;
+    }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAISingleOrchestratorRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAISingleOrchestratorRsp.java
new file mode 100644 (file)
index 0000000..9652dd3
--- /dev/null
@@ -0,0 +1,60 @@
+/**
+ * Copyright (C) 2019 Verizon. All Rights Reserved.
+ *
+ * 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;
+
+
+public class AAISingleOrchestratorRsp {
+
+    @JsonProperty("nfvo-id")
+    private String nfvoId;
+
+    @JsonProperty("resource-version")
+    private String resourceVersion;
+
+    @JsonProperty("esr-system-info-list")
+    private EsrSystemInfoList esrSystemInfoList;
+
+    public String getNfvoId() {
+        return nfvoId;
+    }
+
+    public void setNfvoId(String nfvoId) {
+        this.nfvoId = nfvoId;
+    }
+
+    public String getResourceVersion() {
+        return resourceVersion;
+    }
+
+    public void setResourceVersion(String resourceVersion) {
+        this.resourceVersion = resourceVersion;
+    }
+
+    public EsrSystemInfoList getEsrSystemInfoList() {
+        return esrSystemInfoList;
+    }
+
+    public void setEsrSystemInfo(EsrSystemInfoList esrSystemInfoList) {
+        this.esrSystemInfoList = esrSystemInfoList;
+    }
+
+
+
+
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/EsrSystemInfo.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/EsrSystemInfo.java
new file mode 100644 (file)
index 0000000..4ba05cf
--- /dev/null
@@ -0,0 +1,123 @@
+/**
+ * Copyright (C) 2019 Verizon. All Rights Reserved.
+ *
+ * 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 org.immutables.value.internal.$processor$.meta.$JacksonMirrors;
+
+public class EsrSystemInfo {
+
+    @JsonProperty("esr-system-info-id")
+    private String esrSystemInfoId;
+
+    @JsonProperty("system-name")
+    private String systemName;
+
+    @JsonProperty("vendor")
+    private String vendor;
+
+    @JsonProperty("version")
+    private String version;
+
+    @JsonProperty("service-url")
+    private String serviceUrl;
+
+    @JsonProperty("user-name")
+    private String userName;
+
+    @JsonProperty("password")
+    private String password;
+
+    @JsonProperty("system-type")
+    private String systemType;
+
+    @JsonProperty("resource-version")
+    private String resourceVersion;
+
+    public String getEsrSystemInfoId() {
+        return esrSystemInfoId;
+    }
+
+    public void setEsrSystemInfoId(String esrSystemInfoId) {
+        this.esrSystemInfoId = esrSystemInfoId;
+    }
+
+    public String getSystemName() {
+        return systemName;
+    }
+
+    public void setSystemName(String systemName) {
+        this.systemName = systemName;
+    }
+
+    public String getVendor() {
+        return vendor;
+    }
+
+    public void setVendor(String vendor) {
+        this.vendor = vendor;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    public String getServiceUrl() {
+        return serviceUrl;
+    }
+
+    public void setServiceUrl(String serviceUrl) {
+        this.serviceUrl = serviceUrl;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getSystemType() {
+        return systemType;
+    }
+
+    public void setSystemType(String systemType) {
+        this.systemType = systemType;
+    }
+
+    public String getResourceVersion() {
+        return resourceVersion;
+    }
+
+    public void setResourceVersion(String resourceVersion) {
+        this.resourceVersion = resourceVersion;
+    }
+
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/EsrSystemInfoList.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/EsrSystemInfoList.java
new file mode 100644 (file)
index 0000000..51ae580
--- /dev/null
@@ -0,0 +1,36 @@
+/**
+ * Copyright (C) 2019 Verizon. All Rights Reserved.
+ *
+ * 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 EsrSystemInfoList {
+
+    public List<EsrSystemInfo> getEsrSystemInfo() {
+        return esrSystemInfo;
+    }
+
+    public void setEsrSystemInfo(List<EsrSystemInfo> esrSystemInfo) {
+        this.esrSystemInfo = esrSystemInfo;
+    }
+
+    @JsonProperty("esr-system-info")
+    private List<EsrSystemInfo> esrSystemInfo;
+
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultOrchestratorService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultOrchestratorService.java
new file mode 100644 (file)
index 0000000..32a7c32
--- /dev/null
@@ -0,0 +1,78 @@
+/**
+ * Copyright (C) 2019 Verizon. All Rights Reserved.
+ *
+ * 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.impl;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.onap.usecaseui.server.service.lcm.OrchestratorService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.*;
+import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
+import org.onap.usecaseui.server.util.RestfulServices;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.stereotype.Service;
+
+import retrofit2.Response;
+
+@Service("OrchestratorService")
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+public class DefaultOrchestratorService implements OrchestratorService {
+
+    private static final Logger logger = LoggerFactory.getLogger(DefaultOrchestratorService.class);
+
+    private AAIService aaiService;
+
+    public DefaultOrchestratorService() {
+        this(RestfulServices.create(AAIService.class));
+    }
+
+    public DefaultOrchestratorService(AAIService aaiService) {
+        this.aaiService = aaiService;
+    }
+
+    @Override
+    public List<AAIEsrNfvo> listOrchestrator() {
+        try {
+            Response<AAIOrchestratorRsp> response = this.aaiService.listOrchestrator().execute();
+            if (response.isSuccessful()) {
+                List<AAIEsrNfvo> nfvoList = response.body().getEsrNfvo();
+                for(AAIEsrNfvo nfvo: nfvoList){
+                    String nfvoId = nfvo.getNfvoId();
+                    Response<AAISingleOrchestratorRsp> response_orch =
+                        this.aaiService.getOrchestrator(nfvoId).execute();
+                    EsrSystemInfoList esrSystemInfoList = response_orch.body().getEsrSystemInfoList();
+                    List<EsrSystemInfo> esrSystemInfo = esrSystemInfoList.getEsrSystemInfo();
+                    nfvo.setName(esrSystemInfo.get(0).getSystemName());
+
+                }
+                return nfvoList;
+            } else {
+                logger.info(String.format("Can not get orchestrators[code=%s, message=%s]", response.code(), response.message()));
+                return Collections.emptyList();
+            }
+        } catch (IOException e) {
+            logger.error("list orchestrators occur exception");
+            throw new AAIException("AAI is not available.", e);
+        }
+    }
+
+}
diff --git a/server/src/test/java/org/onap/usecaseui/server/controller/lcm/OrchestratorControllerTest.java b/server/src/test/java/org/onap/usecaseui/server/controller/lcm/OrchestratorControllerTest.java
new file mode 100644 (file)
index 0000000..d679a53
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * Copyright (C) 2019 Verizon. All Rights Reserved
+ *
+ * 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.controller.lcm;
+
+import org.junit.Test;
+import org.onap.usecaseui.server.service.lcm.OrchestratorService;
+
+import static org.mockito.Mockito.*;
+
+public class OrchestratorControllerTest {
+
+    @Test
+    public void testGetOrchestrators() {
+        OrchestratorService orchestratorService = mock(OrchestratorService.class);
+        OrchestratorController controller = new OrchestratorController();
+        controller.setOrchestratorService(orchestratorService);
+
+        controller.getOrchestrators();
+
+        verify(orchestratorService, times(1)).listOrchestrator();
+    }
+}