2 * Copyright 2016 [ZTE] and others.
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.
17 package org.openo.commontosca.catalog.model.externalservice.lifecycle;
19 import com.google.gson.Gson;
20 import com.google.gson.reflect.TypeToken;
22 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
23 import org.openo.commontosca.catalog.common.MsbUtil;
24 import org.openo.commontosca.catalog.common.ToolUtil;
25 import org.openo.commontosca.catalog.model.externalservice.entity.lifecycle.InstanceEntity;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
29 import java.lang.reflect.Type;
30 import java.util.ArrayList;
35 * The lifecycle service.
40 public class LifeCycleServiceConsumer {
41 private static final Logger LOG = LoggerFactory.getLogger(LifeCycleServiceConsumer.class);
44 * get lifecycle application instances.
46 * @return instance entity
48 public static ArrayList<InstanceEntity> getInstances() {
49 ILifeCycleServiceRest resourceserviceproxy =
50 ConsumerFactory.createConsumer(MsbUtil.getNsocLifecycleBaseUrl(),
51 ILifeCycleServiceRest.class);
54 result = resourceserviceproxy.getVnfInstances();
55 } catch (Exception e1) {
56 LOG.error("query vim info faild.", e1);
59 if (ToolUtil.isEmptyString(result)) {
63 Gson gson = new Gson();
64 Type listType = new TypeToken<ArrayList<InstanceEntity>>() {}.getType();
65 return gson.fromJson(result, listType);