2 * Copyright 2016 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.openo.commontosca.catalog.model.externalservice.lifecycle;
18 import com.google.gson.Gson;
19 import com.google.gson.reflect.TypeToken;
21 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
22 import org.openo.commontosca.catalog.common.MsbUtil;
23 import org.openo.commontosca.catalog.common.ToolUtil;
24 import org.openo.commontosca.catalog.model.externalservice.entity.lifecycle.InstanceEntity;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 import java.lang.reflect.Type;
29 import java.util.ArrayList;
34 * The lifecycle service.
39 public class LifeCycleServiceConsumer {
40 private static final Logger LOG = LoggerFactory.getLogger(LifeCycleServiceConsumer.class);
43 * get lifecycle application instances.
45 * @return instance entity
47 public static ArrayList<InstanceEntity> getInstances() {
48 ILifeCycleServiceRest resourceserviceproxy =
49 ConsumerFactory.createConsumer(MsbUtil.getNsocLifecycleBaseUrl(),
50 ILifeCycleServiceRest.class);
53 result = resourceserviceproxy.getVnfInstances();
54 } catch (Exception e1) {
55 LOG.error("query vim info faild.", e1);
58 if (ToolUtil.isEmptyString(result)) {
62 Gson gson = new Gson();
63 Type listType = new TypeToken<ArrayList<InstanceEntity>>() {}.getType();
64 return gson.fromJson(result, listType);