diff options
10 files changed, 525 insertions, 5 deletions
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 index 00000000..46673ee6 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/OrchestratorController.java @@ -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 index 00000000..b953eea4 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/OrchestratorService.java @@ -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(); +} diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java index e11e8bde..1e898c06 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java @@ -16,11 +16,7 @@ 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; @@ -51,6 +47,24 @@ public interface AAIService { "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", + "Authorization: Basic QUFJOkFBSQ==", + "Accept: application/json" + }) // @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances") @GET("/api/aai-business/v13/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances") Call<ResponseBody> listServiceInstances(@Path("global-customer-id") String customerId, @Path("service-type") String serviceType); 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 index 00000000..55ce3767 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAIEsrNfvo.java @@ -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 index 00000000..0181f8f0 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAIOrchestratorRsp.java @@ -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 index 00000000..9652dd36 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAISingleOrchestratorRsp.java @@ -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 index 00000000..4ba05cf9 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/EsrSystemInfo.java @@ -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 index 00000000..51ae5804 --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/EsrSystemInfoList.java @@ -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 index 00000000..32a7c32b --- /dev/null +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultOrchestratorService.java @@ -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 index 00000000..d679a53f --- /dev/null +++ b/server/src/test/java/org/onap/usecaseui/server/controller/lcm/OrchestratorControllerTest.java @@ -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(); + } +} |