X-Git-Url: https://gerrit.onap.org/r/gitweb?p=holmes%2Fcommon.git;a=blobdiff_plain;f=holmes-actions%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Fcommon%2Fconfig%2FMicroServiceConfig.java;h=c179280a00f83840d7904e41e1a1402e07c69676;hp=f74d1b2978198faba803b91510b1a30f9104b3b2;hb=c7fd788a1cfc030e54047701b1c1f27e42a91d1c;hpb=67ef2af341cbe8530437f67bbffdc7721f4e5587 diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java b/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java index f74d1b2..c179280 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/config/MicroServiceConfig.java @@ -1,12 +1,12 @@ /** * Copyright 2017 ZTE Corporation. - * + *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ package org.onap.holmes.common.config; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; + import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; + import lombok.extern.slf4j.Slf4j; import org.onap.holmes.common.constant.AlarmConst; @@ -84,7 +86,7 @@ public class MicroServiceConfig { public static String getMsbServerAddrWithHttpPrefix() { String[] addrInfo = getMsbIpAndPort(); String ret = addrInfo[0] + ":" + addrInfo[1]; - if (!ret.startsWith(AlarmConst.HTTP) || !ret.startsWith(AlarmConst.HTTPS)){ + if (!ret.startsWith(AlarmConst.HTTP) || !ret.startsWith(AlarmConst.HTTPS)) { ret = AlarmConst.HTTP + ret; } return ret; @@ -98,7 +100,7 @@ public class MicroServiceConfig { String[] serviceAddrInfo = null; String info = getServiceAddrInfoFromDcaeConsulByHostName(getEnv(HOSTNAME)); log.info("Got the service information of \"" + getEnv(HOSTNAME) + "\" from Consul. The response is " + info + "."); - if (info != null && !info.isEmpty()){ + if (info != null && !info.isEmpty()) { serviceAddrInfo = split(info); } else { serviceAddrInfo = split(getEnv(HOSTNAME)); @@ -109,7 +111,7 @@ public class MicroServiceConfig { private static String[] split(String addr) { String ip; String port = "80"; - if (addr.lastIndexOf(":") == -1){ + if (addr.lastIndexOf(":") == -1) { ip = addr; } else if (addr.lastIndexOf(":") < 5 && addr.indexOf("://") != -1) { ip = addr.substring(addr.indexOf("//") + 2); //remove the http(s):// prefix @@ -117,7 +119,7 @@ public class MicroServiceConfig { ip = addr.substring(addr.indexOf("://") != -1 ? addr.indexOf("//") + 2 : 0, addr.lastIndexOf(":")); port = addr.substring(addr.lastIndexOf(":") + 1); } - return new String[] {ip, port}; + return new String[]{ip, port}; } }