diff options
author | Luji7 <lu.ji3@zte.com.cn> | 2017-10-12 18:50:06 +0800 |
---|---|---|
committer | Luji7 <lu.ji3@zte.com.cn> | 2017-10-12 18:50:14 +0800 |
commit | eea68ef0cf77f6ce36f1c0244cec6aa2ff8e3296 (patch) | |
tree | 70c2a76d257fb9f06a84df617279b22995ed37ed | |
parent | 92d643ebff691603d2a1fe3eb03f102d09a9f479 (diff) |
Fix create service request body wrong.
Change-Id: I504610ec7df46a453c666643750c5ed7e296b959
Issue-id: USECASEUI-36
Signed-off-by: Luji7 <lu.ji3@zte.com.cn>
18 files changed, 176 insertions, 135 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInput.java b/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInput.java index becc3238..73ce014b 100644 --- a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInput.java +++ b/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInput.java @@ -17,6 +17,7 @@ package org.onap.usecaseui.server.bean.lcm; import com.google.common.base.MoreObjects; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -30,6 +31,8 @@ public class ServiceTemplateInput { private String type; + private String version; + private String description; private String category; @@ -38,11 +41,14 @@ public class ServiceTemplateInput { private List<TemplateInput> inputs; + private List<ServiceTemplateInput> nestedTemplates; + public ServiceTemplateInput( String invariantUUID, String uuid, String name, String type, + String version, String description, String category, String subcategory, @@ -51,10 +57,12 @@ public class ServiceTemplateInput { this.uuid = uuid; this.name = name; this.type = type; + this.version = version; this.description = description; this.category = category; this.subcategory = subcategory; this.inputs = inputs; + this.nestedTemplates = new ArrayList<>(); } public String getInvariantUUID() { @@ -73,6 +81,10 @@ public class ServiceTemplateInput { return type; } + public String getVersion() { + return version; + } + public String getDescription() { return description; } @@ -89,6 +101,14 @@ public class ServiceTemplateInput { return inputs; } + public List<ServiceTemplateInput> getNestedTemplates() { + return nestedTemplates; + } + + public void addNestedTemplate(ServiceTemplateInput template) { + this.nestedTemplates.add(template); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -98,15 +118,17 @@ public class ServiceTemplateInput { Objects.equals(uuid, that.uuid) && Objects.equals(name, that.name) && Objects.equals(type, that.type) && + Objects.equals(version, that.version) && Objects.equals(description, that.description) && Objects.equals(category, that.category) && Objects.equals(subcategory, that.subcategory) && - Objects.equals(inputs, that.inputs); + Objects.equals(inputs, that.inputs) && + Objects.equals(nestedTemplates, that.nestedTemplates); } @Override public int hashCode() { - return Objects.hash(invariantUUID, uuid, name, type, description, category, subcategory, inputs); + return Objects.hash(invariantUUID, uuid, name, type, version, description, category, subcategory, inputs, nestedTemplates); } @Override @@ -116,10 +138,12 @@ public class ServiceTemplateInput { .add("uuid", uuid) .add("name", name) .add("type", type) + .add("version", version) .add("description", description) .add("category", category) .add("subcategory", subcategory) .add("inputs", inputs) + .add("nestedTemplates", nestedTemplates) .toString(); } } diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInputRsp.java b/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInputRsp.java deleted file mode 100644 index 4a707d0c..00000000 --- a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplateInputRsp.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * 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.bean.lcm; - -import com.google.common.base.MoreObjects; -import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo; - -import java.util.List; -import java.util.Objects; - -public class ServiceTemplateInputRsp { - - private List<ServiceTemplateInput> serviceTemplateInput; - - private List<VimInfo> vimInfos; - - public ServiceTemplateInputRsp(List<ServiceTemplateInput> serviceTemplateInput, List<VimInfo> vimInfos) { - this.serviceTemplateInput = serviceTemplateInput; - this.vimInfos = vimInfos; - } - - public List<ServiceTemplateInput> getServiceTemplateInput() { - return serviceTemplateInput; - } - - public List<VimInfo> getVimInfos() { - return vimInfos; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ServiceTemplateInputRsp that = (ServiceTemplateInputRsp) o; - return Objects.equals(serviceTemplateInput, that.serviceTemplateInput) && - Objects.equals(vimInfos, that.vimInfos); - } - - @Override - public int hashCode() { - return Objects.hash(serviceTemplateInput, vimInfos); - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("serviceTemplateInput", serviceTemplateInput) - .add("vimInfos", vimInfos) - .toString(); - } -} diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/VfNsPackageInfo.java b/server/src/main/java/org/onap/usecaseui/server/bean/lcm/VfNsPackageInfo.java index 0e8ef960..1c41ca96 100644 --- a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/VfNsPackageInfo.java +++ b/server/src/main/java/org/onap/usecaseui/server/bean/lcm/VfNsPackageInfo.java @@ -15,7 +15,6 @@ */ package org.onap.usecaseui.server.bean.lcm; -import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.Vnf; @@ -28,12 +27,9 @@ public class VfNsPackageInfo { private List<Vnf> vnfPackages; - private List<VimInfo> vimInfos; - - public VfNsPackageInfo(List<SDCServiceTemplate> nsPackage, List<Vnf> vnfPackages, List<VimInfo> vimInfos) { + public VfNsPackageInfo(List<SDCServiceTemplate> nsPackage, List<Vnf> vnfPackages) { this.nsPackage = nsPackage; this.vnfPackages = vnfPackages; - this.vimInfos = vimInfos; } public List<SDCServiceTemplate> getNsPackage() { @@ -44,22 +40,17 @@ public class VfNsPackageInfo { return vnfPackages; } - public List<VimInfo> getVimInfos() { - return vimInfos; - } - @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; VfNsPackageInfo that = (VfNsPackageInfo) o; return Objects.equals(nsPackage, that.nsPackage) && - Objects.equals(vnfPackages, that.vnfPackages) && - Objects.equals(vimInfos, that.vimInfos); + Objects.equals(vnfPackages, that.vnfPackages); } @Override public int hashCode() { - return Objects.hash(nsPackage, vnfPackages, vimInfos); + return Objects.hash(nsPackage, vnfPackages); } } diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java index 3d51bde0..ae6fb2fe 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/CustomerController.java @@ -17,8 +17,10 @@ package org.onap.usecaseui.server.controller.lcm; import org.onap.usecaseui.server.service.lcm.CustomerService; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer; +import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription; 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; @@ -39,8 +41,14 @@ public class CustomerController { } @ResponseBody - @RequestMapping(value = {"/lcm/customers"}, method = RequestMethod.GET , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/customers"}, method = RequestMethod.GET , produces = "application/json") public List<AAICustomer> getCustomers(){ return customerService.listCustomer(); } + + @ResponseBody + @RequestMapping(value = {"/onapapi/uui-lcm/v1/customers/{customerId}/service-subscriptions"}, method = RequestMethod.GET , produces = "application/json") + public List<AAIServiceSubscription> getServiceSubscriptions(@PathVariable(value="customerId") String customerId){ + return customerService.listServiceSubscriptions(customerId); + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java index 7014b2b6..ccdd308b 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/PackageDistributionController.java @@ -44,25 +44,25 @@ public class PackageDistributionController { } @ResponseBody - @RequestMapping(value = {"/lcm/vf-ns-packages"}, method = RequestMethod.GET , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/vf-ns-packages"}, method = RequestMethod.GET , produces = "application/json") public VfNsPackageInfo retrievePackageInfo(){ return packageDistributionService.retrievePackageInfo(); } @ResponseBody - @RequestMapping(value = {"/lcm/ns-packages"}, method = RequestMethod.POST , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/ns-packages"}, method = RequestMethod.POST , produces = "application/json") public DistributionResult distributeNsPackage(@RequestBody Csar csar){ return packageDistributionService.postNsPackage(csar); } @ResponseBody - @RequestMapping(value = {"/lcm/vf-packages"}, method = RequestMethod.POST , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/vf-packages"}, method = RequestMethod.POST , produces = "application/json") public Job distributeVfPackage(@RequestBody Csar csar){ return packageDistributionService.postVfPackage(csar); } @ResponseBody - @RequestMapping(value = {"/lcm/jobs/{jobId}"}, method = RequestMethod.POST , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/jobs/{jobId}"}, method = RequestMethod.POST , produces = "application/json") public JobStatus getJobStatus(@PathVariable(value="jobId") String jobId){ return packageDistributionService.getJobStatus(jobId); } diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java index 350652c4..21464dc4 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceInstanceController.java @@ -44,7 +44,7 @@ public class ServiceInstanceController { } @ResponseBody - @RequestMapping(value = {"/lcm/service-instances"}, method = RequestMethod.GET , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/service-instances"}, method = RequestMethod.GET , produces = "application/json") public List<ServiceInstance> listServiceInstances(HttpServletRequest request){ String customerId = request.getParameter("customerId"); String serviceType = request.getParameter("serviceType"); diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java index ded536f6..13ef5d55 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceLcmController.java @@ -42,19 +42,19 @@ public class ServiceLcmController { } @ResponseBody - @RequestMapping(value = {"/lcm/services"}, method = RequestMethod.POST , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/services/"}, method = RequestMethod.POST , produces = "application/json") public ServiceOperation instantiateService(@RequestBody ServiceInstantiationRequest request){ return serviceLcmService.instantiateService(request); } @ResponseBody - @RequestMapping(value = {"/lcm/services/{serviceId}/operations/{operationId}"}, method = RequestMethod.GET , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/services/{serviceId}/operations/{operationId}"}, method = RequestMethod.GET , produces = "application/json") public OperationProgressInformation queryOperationProgress(@PathVariable(value="serviceId") String serviceId, @PathVariable(value="operationId") String operationId){ return serviceLcmService.queryOperationProgress(serviceId, operationId); } @ResponseBody - @RequestMapping(value = {"/lcm/services/{serviceId}"}, method = RequestMethod.DELETE , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/services/{serviceId}"}, method = RequestMethod.DELETE , produces = "application/json") public ServiceOperation terminateService(@PathVariable(value = "serviceId") String serviceId){ return serviceLcmService.terminateService(serviceId); } diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java index 96c463bc..f64612a5 100644 --- a/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/lcm/ServiceTemplateController.java @@ -15,8 +15,9 @@ */ package org.onap.usecaseui.server.controller.lcm; -import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInputRsp; +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.VimInfo; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,14 +43,20 @@ public class ServiceTemplateController { } @ResponseBody - @RequestMapping(value = {"/lcm/service-templates"}, method = RequestMethod.GET , produces = "application/json") + @RequestMapping(value = {"/onapapi/uui-lcm/v1/service-templates"}, method = RequestMethod.GET , produces = "application/json") public List<SDCServiceTemplate> getServiceTemplates(){ return serviceTemplateService.listDistributedServiceTemplate(); } @ResponseBody - @RequestMapping(value = {"/lcm/service-templates/service-template/{uuid}"}, method = RequestMethod.GET , produces = "application/json") - public ServiceTemplateInputRsp getServiceTemplateInput(@PathVariable("uuid") String uuid, @RequestParam("toscaModelPath") String toscaModelPath){ + @RequestMapping(value = {"/onapapi/uui-lcm/v1/service-templates/{uuid}"}, method = RequestMethod.GET , produces = "application/json") + public ServiceTemplateInput getServiceTemplateInput(@PathVariable("uuid") String uuid, @RequestParam("toscaModelPath") String toscaModelPath){ return serviceTemplateService.fetchServiceTemplateInput(uuid, toscaModelPath); } + + @ResponseBody + @RequestMapping(value = {"/onapapi/uui-lcm/v1/locations/"}, method = RequestMethod.GET , produces = "application/json") + public List<VimInfo> getLocations(){ + return serviceTemplateService.listVim(); + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java index 9c659469..0bd3f323 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/CustomerService.java @@ -16,9 +16,11 @@ package org.onap.usecaseui.server.service.lcm; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer; +import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription; import java.util.List; public interface CustomerService { List<AAICustomer> listCustomer(); + List<AAIServiceSubscription> listServiceSubscriptions(String customerId); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceTemplateService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceTemplateService.java index 22479e61..c2607d4c 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceTemplateService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/ServiceTemplateService.java @@ -15,7 +15,8 @@ */ package org.onap.usecaseui.server.service.lcm; -import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInputRsp; +import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput; +import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate; import java.util.List; @@ -24,5 +25,7 @@ public interface ServiceTemplateService { List<SDCServiceTemplate> listDistributedServiceTemplate(); - ServiceTemplateInputRsp fetchServiceTemplateInput(String uuid, String toscaModelPath); + ServiceTemplateInput fetchServiceTemplateInput(String uuid, String toscaModelPath); + + List<VimInfo> listVim(); }
\ No newline at end of file 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 fc83f4f0..ff5ffc7f 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,6 +16,7 @@ package org.onap.usecaseui.server.service.lcm.domain.aai; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer; +import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo; import retrofit2.Call; @@ -50,4 +51,12 @@ public interface AAIService { }) @GET("/cloud-infrastructure/cloud-regions") Call<List<VimInfo>> listVimInfo(); + + @Headers({ + "X-TransactionId: 7777", + "X-FromAppId: uui", + "Authorization: QUFJOkFBSQ==" + }) + @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions") + Call<List<AAIServiceSubscription>> listServiceSubscriptions(@Path("global-customer-id") String customerId); } diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplate.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAIServiceSubscription.java index bc23ac76..e79c02b9 100644 --- a/server/src/main/java/org/onap/usecaseui/server/bean/lcm/ServiceTemplate.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAIServiceSubscription.java @@ -13,7 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onap.usecaseui.server.bean.lcm; +package org.onap.usecaseui.server.service.lcm.domain.aai.bean; -public class ServiceTemplate { +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class AAIServiceSubscription { + + private String serviceType; + + @JsonCreator + public AAIServiceSubscription(@JsonProperty("service-type") String serviceType) { + this.serviceType = serviceType; + } + + @JsonProperty("service-type") + public String getServiceType() { + return serviceType; + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/SDCServiceTemplate.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/SDCServiceTemplate.java index 9a686bcb..52b516d1 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/SDCServiceTemplate.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/sdc/bean/SDCServiceTemplate.java @@ -28,6 +28,8 @@ public class SDCServiceTemplate { private String name; + private String version; + private String toscaModelURL; private String category; @@ -37,11 +39,13 @@ public class SDCServiceTemplate { @JsonProperty String uuid, @JsonProperty String invariantUUID, @JsonProperty String name, + @JsonProperty String version, @JsonProperty String toscaModelURL, @JsonProperty String category) { this.uuid = uuid; this.invariantUUID = invariantUUID; this.name = name; + this.version = version; this.toscaModelURL = toscaModelURL; this.category = category; } @@ -58,6 +62,10 @@ public class SDCServiceTemplate { return name; } + public String getVersion() { + return version; + } + public String getToscaModelURL() { return toscaModelURL; } @@ -74,12 +82,13 @@ public class SDCServiceTemplate { return Objects.equals(uuid, that.uuid) && Objects.equals(invariantUUID, that.invariantUUID) && Objects.equals(name, that.name) && + Objects.equals(version, that.version) && Objects.equals(toscaModelURL, that.toscaModelURL) && Objects.equals(category, that.category); } @Override public int hashCode() { - return Objects.hash(uuid, invariantUUID, name, toscaModelURL, category); + return Objects.hash(uuid, invariantUUID, name, version, toscaModelURL, category); } } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java index 9332dcf7..9ece03e6 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java @@ -18,6 +18,7 @@ package org.onap.usecaseui.server.service.lcm.impl; import org.onap.usecaseui.server.service.lcm.CustomerService; import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService; import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer; +import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription; import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException; import org.onap.usecaseui.server.util.RestfulServices; import org.slf4j.Logger; @@ -54,4 +55,14 @@ public class DefaultCustomerService implements CustomerService { throw new AAIException("AAI is not available.", e); } } + + @Override + public List<AAIServiceSubscription> listServiceSubscriptions(String customerId) { + try { + return this.aaiService.listServiceSubscriptions(customerId).execute().body(); + } catch (IOException e) { + logger.error("list customers occur exception"); + throw new AAIException("AAI is not available.", e); + } + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java index e4a08b8a..9650cf69 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionService.java @@ -17,8 +17,6 @@ package org.onap.usecaseui.server.service.lcm.impl; import org.onap.usecaseui.server.bean.lcm.VfNsPackageInfo; import org.onap.usecaseui.server.service.lcm.PackageDistributionService; -import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService; -import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo; import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.Vnf; @@ -45,17 +43,14 @@ public class DefaultPackageDistributionService implements PackageDistributionSer private SDCCatalogService sdcCatalogService; - private AAIService aaiService; - private VfcService vfcService; public DefaultPackageDistributionService() { - this(create(SDCCatalogService.class), create(AAIService.class), create(VfcService.class)); + this(create(SDCCatalogService.class), create(VfcService.class)); } - public DefaultPackageDistributionService(SDCCatalogService sdcCatalogService, AAIService aaiService, VfcService vfcService) { + public DefaultPackageDistributionService(SDCCatalogService sdcCatalogService, VfcService vfcService) { this.sdcCatalogService = sdcCatalogService; - this.aaiService = aaiService; this.vfcService = vfcService; } @@ -64,8 +59,7 @@ public class DefaultPackageDistributionService implements PackageDistributionSer try { List<SDCServiceTemplate> nsTemplate = sdcCatalogService.listServices(CATEGORY_NS, DISTRIBUTION_STATUS_DISTRIBUTED).execute().body(); List<Vnf> vnf = sdcCatalogService.listResources(RESOURCETYPE_VF, DISTRIBUTION_STATUS_DISTRIBUTED).execute().body(); - List<VimInfo> vim = aaiService.listVimInfo().execute().body(); - return new VfNsPackageInfo(nsTemplate, vnf, vim); + return new VfNsPackageInfo(nsTemplate, vnf); } catch (IOException e) { throw new SDCCatalogException("SDC Service is not available!", e); } diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java index 816889c2..6f91a75a 100644 --- a/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java +++ b/server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java @@ -18,11 +18,11 @@ package org.onap.usecaseui.server.service.lcm.impl; import com.google.common.io.Files; import okhttp3.ResponseBody; import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput; -import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInputRsp; 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.VimInfo; +import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException; import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService; import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate; import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException; @@ -75,17 +75,18 @@ public class DefaultServiceTemplateService implements ServiceTemplateService { } @Override - public ServiceTemplateInputRsp fetchServiceTemplateInput(String uuid, String toscaModelPath) { + public ServiceTemplateInput fetchServiceTemplateInput(String uuid, String toscaModelPath) { + return fetchServiceTemplate(uuid, toscaModelPath); + } + + private ServiceTemplateInput fetchServiceTemplate(String uuid, String toscaModelPath) { String rootPath = "http://localhost";// get from msb String templateUrl = String.format("%s/%s", rootPath, toscaModelPath); String toPath = String.format("temp/%s.csar", uuid); try { downloadFile(templateUrl, toPath); - List<ServiceTemplateInput> serviceTemplateInputs = new ArrayList<>(); - serviceTemplateInputs = extractInputs(toPath, serviceTemplateInputs); - List<VimInfo> vimInfo = aaiService.listVimInfo().execute().body(); - return new ServiceTemplateInputRsp(serviceTemplateInputs, vimInfo); + return extractTemplate(toPath); } catch (IOException e) { throw new SDCCatalogException("download csar file failed!", e); } catch (JToscaException e) { @@ -103,10 +104,9 @@ public class DefaultServiceTemplateService implements ServiceTemplateService { } } - private List<ServiceTemplateInput> extractInputs(String toPath, List<ServiceTemplateInput> serviceTemplateInputs) throws JToscaException, IOException { + private ServiceTemplateInput extractTemplate(String toPath) throws JToscaException, IOException { ToscaTemplate tosca = translateToToscaTemplate(toPath); ServiceTemplateInput serviceTemplateInput = fetchServiceTemplateInput(tosca); - serviceTemplateInputs.add(serviceTemplateInput); for (NodeTemplate nodeTemplate : tosca.getNodeTemplates()) { String nodeUUID = nodeTemplate.getMetaData().getValue("UUID"); SDCServiceTemplate template = sdcCatalog.getService(nodeUUID).execute().body(); @@ -114,13 +114,30 @@ public class DefaultServiceTemplateService implements ServiceTemplateService { if (toscaModelURL == null) { continue; } - String savePath = String.format("temp/%s.csar", nodeUUID); - downloadFile(toscaModelURL, savePath); - extractInputs(savePath, serviceTemplateInputs); + ServiceTemplateInput nodeService = fetchServiceTemplate(nodeUUID, toscaModelURL); + serviceTemplateInput.addNestedTemplate(nodeService); } - return serviceTemplateInputs; + return serviceTemplateInput; } +// private List<ServiceTemplateInput> extractInputs(String toPath, List<ServiceTemplateInput> serviceTemplateInputs) throws JToscaException, IOException { +// ToscaTemplate tosca = translateToToscaTemplate(toPath); +// ServiceTemplateInput serviceTemplateInput = fetchServiceTemplateInput(tosca); +// serviceTemplateInputs.add(serviceTemplateInput); +// for (NodeTemplate nodeTemplate : tosca.getNodeTemplates()) { +// String nodeUUID = nodeTemplate.getMetaData().getValue("UUID"); +// SDCServiceTemplate template = sdcCatalog.getService(nodeUUID).execute().body(); +// String toscaModelURL = template.getToscaModelURL(); +// if (toscaModelURL == null) { +// continue; +// } +// String savePath = String.format("temp/%s.csar", nodeUUID); +// downloadFile(toscaModelURL, savePath); +// extractInputs(savePath, serviceTemplateInputs); +// } +// return serviceTemplateInputs; +// } + protected ToscaTemplate translateToToscaTemplate(String toPath) throws JToscaException { return new ToscaTemplate(toPath,null,true,null,true); } @@ -130,6 +147,10 @@ public class DefaultServiceTemplateService implements ServiceTemplateService { String uuid = tosca.getMetaData().getValue("UUID"); String name = tosca.getMetaData().getValue("name"); String type = tosca.getMetaData().getValue("type"); + String version = tosca.getMetaData().getValue("version"); + if (version == null) { + version = ""; + } String description = tosca.getMetaData().getValue("description"); String category = tosca.getMetaData().getValue("category"); String subcategory = tosca.getMetaData().getValue("subcategory"); @@ -151,9 +172,20 @@ public class DefaultServiceTemplateService implements ServiceTemplateService { uuid, name, type, + version, description, category, subcategory, templateInputs); } + + @Override + public List<VimInfo> listVim() { + try { + return aaiService.listVimInfo().execute().body(); + } catch (IOException e) { + logger.error("Visit AAI occur exception"); + throw new AAIException("AAI is not available.", e); + } + } } diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java index fed2bfce..766aca7f 100644 --- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java @@ -47,16 +47,16 @@ public class DefaultPackageDistributionServiceTest { @Test public void itCanRetrievePackageFromSDCAndAAI() { - List<SDCServiceTemplate> serviceTemplate = Collections.singletonList(new SDCServiceTemplate("1", "1", "service", "", "")); + List<SDCServiceTemplate> serviceTemplate = Collections.singletonList(new SDCServiceTemplate("1", "1", "service", "V1","", "")); List<Vnf> vnf = Collections.singletonList(new Vnf("2","2","vnf")); SDCCatalogService sdcService = newSDCService(serviceTemplate, vnf); List<VimInfo> vim = Collections.singletonList(new VimInfo("owner", "regionId")); AAIService aaiService = newAAIService(vim); - PackageDistributionService service = new DefaultPackageDistributionService(sdcService,aaiService, null); + PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null); - Assert.assertThat(service.retrievePackageInfo(), equalTo(new VfNsPackageInfo(serviceTemplate, vnf, vim))); + Assert.assertThat(service.retrievePackageInfo(), equalTo(new VfNsPackageInfo(serviceTemplate, vnf))); } private AAIService newAAIService(List<VimInfo> vim) { @@ -87,7 +87,7 @@ public class DefaultPackageDistributionServiceTest { List<VimInfo> vim = Collections.singletonList(new VimInfo("owner", "regionId")); AAIService aaiService = newAAIService(vim); - PackageDistributionService service = new DefaultPackageDistributionService(sdcService,aaiService, null); + PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null); service.retrievePackageInfo(); } @@ -97,7 +97,7 @@ public class DefaultPackageDistributionServiceTest { Csar csar = new Csar(); DistributionResult result = new DistributionResult("status", "description", "errorcode"); when(vfcService.distributeNsPackage(csar)).thenReturn(successfulCall(result)); - PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService); + PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService); Assert.assertSame(result, service.postNsPackage(csar)); } @@ -107,7 +107,7 @@ public class DefaultPackageDistributionServiceTest { VfcService vfcService = mock(VfcService.class); Csar csar = new Csar(); when(vfcService.distributeNsPackage(csar)).thenReturn(failedCall("VFC is not available!")); - PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService); + PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService); service.postNsPackage(csar); } @@ -117,7 +117,7 @@ public class DefaultPackageDistributionServiceTest { Csar csar = new Csar(); Job job = new Job(); when(vfcService.distributeVnfPackage(csar)).thenReturn(successfulCall(job)); - PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService); + PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService); Assert.assertSame(job, service.postVfPackage(csar)); } @@ -127,7 +127,7 @@ public class DefaultPackageDistributionServiceTest { VfcService vfcService = mock(VfcService.class); Csar csar = new Csar(); when(vfcService.distributeVnfPackage(csar)).thenReturn(failedCall("VFC is not available!")); - PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService); + PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService); service.postVfPackage(csar); } @@ -137,7 +137,7 @@ public class DefaultPackageDistributionServiceTest { String jobId = "1"; JobStatus jobStatus = new JobStatus(); when(vfcService.getJobStatus(jobId)).thenReturn(successfulCall(jobStatus)); - PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService); + PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService); Assert.assertSame(jobStatus, service.getJobStatus(jobId)); } @@ -147,7 +147,7 @@ public class DefaultPackageDistributionServiceTest { VfcService vfcService = mock(VfcService.class); String jobId = "1"; when(vfcService.getJobStatus(jobId)).thenReturn(failedCall("VFC is not available!")); - PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService); + PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService); service.getJobStatus(jobId); } }
\ No newline at end of file diff --git a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java index 260c2379..9696a77e 100644 --- a/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java +++ b/server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java @@ -18,7 +18,6 @@ package org.onap.usecaseui.server.service.lcm.impl; import org.junit.Assert; import org.junit.Test; import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput; -import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInputRsp; 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; @@ -48,7 +47,7 @@ public class DefaultServiceTemplateServiceTest { @Test public void itCanListDistributedServiceTemplate() { - List<SDCServiceTemplate> templates = Collections.singletonList(new SDCServiceTemplate("uuid", "uuid", "name", "url", "category")); + List<SDCServiceTemplate> templates = Collections.singletonList(new SDCServiceTemplate("uuid", "uuid", "name", "V1","url", "category")); SDCCatalogService sdcService = mock(SDCCatalogService.class); when(sdcService.listServices(CATEGORY_E2E_SERVICE, DISTRIBUTION_STATUS_DISTRIBUTED)).thenReturn(successfulCall(templates)); @@ -79,7 +78,7 @@ public class DefaultServiceTemplateServiceTest { ServiceTemplateService service = newServiceTemplateService(uuid, nodeUUID, sdcService, aaiService); - Assert.assertThat(service.fetchServiceTemplateInput(uuid, modelPath), equalTo(new ServiceTemplateInputRsp(expectedServiceInputs(uuid, nodeUUID),vim))); + Assert.assertThat(service.fetchServiceTemplateInput(uuid, modelPath), equalTo(expectedServiceInputs(uuid, nodeUUID))); } private DefaultServiceTemplateService newServiceTemplateService(String uuid, String nodeUUID, SDCCatalogService sdcService, AAIService aaiService) { @@ -102,17 +101,18 @@ public class DefaultServiceTemplateServiceTest { private SDCCatalogService newSdcCatalogService(String nodeUUID) throws IOException { SDCCatalogService sdcService = mock(SDCCatalogService.class); - when(sdcService.getService(nodeUUID)).thenReturn(successfulCall(new SDCServiceTemplate(nodeUUID, nodeUUID, "node", "nodeModelUrl", "service"))); + when(sdcService.getService(nodeUUID)).thenReturn(successfulCall(new SDCServiceTemplate(nodeUUID, nodeUUID, "node", "V1", "nodeModelUrl", "service"))); return sdcService; } - private List<ServiceTemplateInput> expectedServiceInputs(String uuid, String nodeUUID) { + private ServiceTemplateInput expectedServiceInputs(String uuid, String nodeUUID) { ServiceTemplateInput e2eServiceTemplateInput = new ServiceTemplateInput( - uuid, uuid, "VoLTE", "service", "VoLTE", "service", "", Collections.EMPTY_LIST); + uuid, uuid, "VoLTE", "service","", "VoLTE", "service", "", Collections.EMPTY_LIST); TemplateInput templateInput = new TemplateInput("field_name","field_type", "field_description", "true", "field_default"); ServiceTemplateInput nodeTemplateInput = new ServiceTemplateInput( - nodeUUID, nodeUUID, "", "", "", "service", "", Collections.singletonList(templateInput)); - return Arrays.asList(e2eServiceTemplateInput, nodeTemplateInput); + nodeUUID, nodeUUID, "", "", "","", "service", "", Collections.singletonList(templateInput)); + e2eServiceTemplateInput.addNestedTemplate(nodeTemplateInput); + return e2eServiceTemplateInput; } private ToscaTemplate e2eToscaTemplate(String nodeUUID) { |