2 * Copyright 2016-2017, Nokia 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.
17 package org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.impl;
19 import java.io.IOException;
21 import org.apache.http.client.ClientProtocolException;
22 import org.apache.http.impl.client.HttpClientBuilder;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25 import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.CatalogQueryVnfResponse;
26 import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf;
27 import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
28 import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
29 import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpRequestProcessor;
30 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VnfPackageInfo;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.stereotype.Component;
33 import org.springframework.web.bind.annotation.RequestMethod;
35 import com.google.gson.Gson;
38 public class CatalogMgmrImpl implements CatalogMgmrInf{
39 private static final Logger logger = LoggerFactory.getLogger(CatalogMgmrImpl.class);
41 private Gson gson = new Gson();
44 private AdaptorEnv adaptorEnv;
47 private HttpClientBuilder httpClientBuilder;
49 public VnfPackageInfo queryVnfPackage(String vnfPackageId) throws ClientProtocolException, IOException {
50 String url=adaptorEnv.getCatalogApiUriFront() + String.format(CommonConstants.RetrieveVnfPackagePath, vnfPackageId);
51 HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.GET);
53 String responseStr = processor.process(url);
55 logger.info("CbamMgmrImpl -> queryVnfPackage, responseStr is " + responseStr);
57 CatalogQueryVnfResponse resp = gson.fromJson(responseStr, CatalogQueryVnfResponse.class);
59 return resp.getPackageInfo();