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.service.lcm.ServiceInstanceService;
19 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
20 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance;
21 import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
22 import org.onap.usecaseui.server.util.RestfulServices;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25 import org.springframework.context.annotation.EnableAspectJAutoProxy;
26 import org.springframework.stereotype.Service;
28 import java.io.IOException;
29 import java.util.List;
31 @Service("ServiceInstanceService")
32 @org.springframework.context.annotation.Configuration
33 @EnableAspectJAutoProxy
34 public class DefaultServiceInstanceService implements ServiceInstanceService {
36 private static final Logger logger = LoggerFactory.getLogger(DefaultServiceInstanceService.class);
38 private AAIService aaiService;
40 public DefaultServiceInstanceService() {
41 this(RestfulServices.create(AAIService.class));
44 public DefaultServiceInstanceService(AAIService aaiService) {
45 this.aaiService = aaiService;
49 public List<ServiceInstance> listServiceInstances(String customerId, String serviceType) {
51 return aaiService.listServiceInstances(customerId, serviceType).execute().body();
52 } catch (IOException e) {
53 logger.error("list services instances occur exception");
54 throw new AAIException("AAI is not available.", e);