2 * Copyright 2016-2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.usecaseui.server.service.lcm.impl;
18 import org.onap.usecaseui.server.bean.lcm.VfNsPackageInfo;
19 import org.onap.usecaseui.server.service.lcm.PackageDistributionService;
20 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
21 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
22 import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
23 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
24 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.Vnf;
25 import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException;
26 import org.onap.usecaseui.server.util.RestfulServices;
27 import org.springframework.context.annotation.EnableAspectJAutoProxy;
28 import org.springframework.stereotype.Service;
30 import java.io.IOException;
31 import java.util.List;
33 import static org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts.*;
35 @Service("PackageDistributionService")
36 @org.springframework.context.annotation.Configuration
37 @EnableAspectJAutoProxy
38 public class DefaultPackageDistributionService implements PackageDistributionService {
40 private SDCCatalogService sdcCatalogService;
42 private AAIService aaiService;
44 public DefaultPackageDistributionService() {
45 this(RestfulServices.create(SDCCatalogService.class), RestfulServices.create(AAIService.class));
48 public DefaultPackageDistributionService(SDCCatalogService sdcCatalogService, AAIService aaiService) {
49 this.sdcCatalogService = sdcCatalogService;
50 this.aaiService = aaiService;
54 public VfNsPackageInfo retrievePackageInfo() {
56 List<SDCServiceTemplate> nsTemplate = sdcCatalogService.listServices(CATEGORY_NS, DISTRIBUTION_STATUS_DISTRIBUTED).execute().body();
57 List<Vnf> vnfs = sdcCatalogService.listResources(RESOURCETYPE_VF, DISTRIBUTION_STATUS_DISTRIBUTED).execute().body();
58 List<VimInfo> vim = aaiService.listVimInfo().execute().body();
59 return new VfNsPackageInfo(nsTemplate, vnfs, vim);
60 } catch (IOException e) {
61 throw new SDCCatalogException("SDC Service is not available!", e);