2 * Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
16 package org.openo.orchestrator.nfv.catalog.model.externalservice.ro;
\r
18 import org.openo.orchestrator.nfv.catalog.common.MSBUtil;
\r
19 import org.openo.orchestrator.nfv.catalog.common.ToolUtil;
\r
20 import org.openo.orchestrator.nfv.catalog.model.externalservice.entity.roEntity.ResourceResponseEntity;
\r
21 import org.openo.orchestrator.nfv.catalog.model.externalservice.entity.roEntity.VimEntity;
\r
22 import org.slf4j.Logger;
\r
23 import org.slf4j.LoggerFactory;
\r
25 import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
\r
26 import com.google.gson.Gson;
\r
29 * The roc resource service.
\r
33 public class ResourceServiceConsumer {
\r
34 private static final Logger LOG = LoggerFactory.getLogger(ResourceServiceConsumer.class);
\r
36 private static final String RESOURCE_REST_RESULT = "SUCCESS";
\r
39 * get vim entity from roc by vimid
\r
41 * @return vim entity
\r
43 public static VimEntity getResourceVim(String vimId) {
\r
44 LOG.info("begin query vim info from roc,vimId:" + vimId);
\r
45 IResourceServiceRest resourceserviceproxy = ConsumerFactory
\r
46 .createConsumer(MSBUtil.getRocBaseUrl(), IResourceServiceRest.class);
\r
49 result = resourceserviceproxy.getResourceVim(vimId);
\r
50 } catch (Exception e) {
\r
51 LOG.error("query vim info faild.", e);
\r
54 if (ToolUtil.isEmptyString(result)) {
\r
55 LOG.error("query vim info faild, vim info is null, vimId:" + vimId);
\r
59 Gson gson = new Gson();
\r
60 ResourceResponseEntity responseEntity = gson.fromJson(result, ResourceResponseEntity.class);
\r
61 if (!RESOURCE_REST_RESULT.equalsIgnoreCase(responseEntity.getOperationResult()))
\r
63 LOG.error("query vim info faild.vimId:" + vimId);
\r
66 if (responseEntity.getData().size() <= 0)
\r
68 LOG.error("query vim info faild, vim info is empty, vimId:" + vimId);
\r
72 LOG.info("end query vim info from roc.");
\r
73 return responseEntity.getData().get(0);
\r