1 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MsbRestServiceProxy.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">vfc-nfvo-driver-ems-ems-boco</a> > <a href="index.source.html" class="el_package">org.onap.vfc.nfvo.emsdriver.serviceregister</a> > <span class="el_source">MsbRestServiceProxy.java</span></div><h1>MsbRestServiceProxy.java</h1><pre class="source lang-java linenums">/**
2 * Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd
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.vfc.nfvo.emsdriver.serviceregister;
19 import java.util.ArrayList;
20 import java.util.List;
22 import org.onap.vfc.nfvo.emsdriver.commons.constant.Constant;
23 import org.onap.vfc.nfvo.emsdriver.northbound.client.HttpClientUtil;
24 import org.onap.vfc.nfvo.emsdriver.serviceregister.model.MsbRegisterVo;
25 import org.onap.vfc.nfvo.emsdriver.serviceregister.model.ServiceNodeVo;
27 import com.alibaba.fastjson.JSON;
29 <span class="nc" id="L29">public class MsbRestServiceProxy {</span>
31 public static String registerService(MsbRegisterVo registerInfo){
32 <span class="fc" id="L32"> String url = MsbConfiguration.getMsbAddress()+Constant.MSBAPIROOTDOMAIN;</span>
33 <span class="fc" id="L33"> String registerObj = JSON.toJSONString(registerInfo);</span>
35 <span class="fc" id="L35"> String registerResponse = HttpClientUtil.doPost(url, registerObj, Constant.ENCODING_UTF8);</span>
36 <span class="fc" id="L36"> return registerResponse;</span>
39 public static void unRegiserService(String serviceName,String version,String ip,String port){
40 <span class="fc" id="L40"> String url = MsbConfiguration.getMsbAddress()+Constant.MSBAPIROOTDOMAIN+"/"+serviceName+"/version/"+version+"/nodes/"+ip+"/"+port;</span>
41 <span class="fc" id="L41"> HttpClientUtil.doDelete(url, Constant.ENCODING_UTF8);</span>
42 <span class="fc" id="L42"> }</span>
44 public static List<String> queryService(String serviceName,String version){
45 <span class="fc" id="L45"> List<String> ipList = new ArrayList<String>();</span>
46 <span class="fc" id="L46"> String url = MsbConfiguration.getMsbAddress()+Constant.MSBAPIROOTDOMAIN+"/"+serviceName+"/version/"+version;</span>
47 <span class="fc" id="L47"> String response = HttpClientUtil.doGet(url, Constant.ENCODING_UTF8);</span>
48 <span class="pc bpc" id="L48" title="3 of 4 branches missed."> if(response !=null && !"".equals(response)){</span>
49 <span class="nc" id="L49"> MsbRegisterVo msbRegisterVo = JSON.parseObject(response,MsbRegisterVo.class);</span>
50 <span class="nc" id="L50"> List<ServiceNodeVo> nodeList = msbRegisterVo.getNodes();</span>
52 <span class="nc bnc" id="L52" title="All 2 branches missed."> for(ServiceNodeVo node :nodeList){</span>
53 <span class="nc" id="L53"> String ip = node.getIp();</span>
54 <span class="nc" id="L54"> ipList.add(ip);</span>
55 <span class="nc" id="L55"> }</span>
57 <span class="fc" id="L57"> return ipList;</span>
62 </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.7.201606060606</span></div></body></html>