X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Futils%2FURLUtilities.java;h=2e00002753de0075f6a7428b20b3c6cc848e0251;hb=381d4ebc5e83d5fd5b62fff7e5a6fa6d582149d9;hp=4576bd267aa7448b049ae42e3b0d27b5b58e84e0;hpb=ce5518a60269499bc1bc77ac7ac48d844db7359a;p=dmaap%2Fdatarouter.git diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java index 4576bd26..2e000027 100644 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/utils/URLUtilities.java @@ -24,9 +24,10 @@ package org.onap.dmaap.datarouter.provisioning.utils; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.Arrays; import org.onap.dmaap.datarouter.provisioning.BaseServlet; @@ -38,6 +39,14 @@ import org.onap.dmaap.datarouter.provisioning.BaseServlet; */ public class URLUtilities { + + private static final EELFLogger utilsLogger = EELFManager.getInstance().getLogger("UtilsLog"); + private static final String HTTPS = "https://"; + private static String otherPod; + + private URLUtilities() { + } + /** * Generate the URL used to access a feed. * @@ -45,7 +54,7 @@ public class URLUtilities { * @return the URL */ public static String generateFeedURL(int feedid) { - return "https://" + BaseServlet.provName + "/feed/" + feedid; + return HTTPS + BaseServlet.getProvName() + "/feed/" + feedid; } /** @@ -55,7 +64,7 @@ public class URLUtilities { * @return the URL */ public static String generatePublishURL(int feedid) { - return "https://" + BaseServlet.provName + "/publish/" + feedid; + return HTTPS + BaseServlet.getProvName() + "/publish/" + feedid; } /** @@ -65,7 +74,7 @@ public class URLUtilities { * @return the URL */ public static String generateSubscribeURL(int feedid) { - return "https://" + BaseServlet.provName + "/subscribe/" + feedid; + return HTTPS + BaseServlet.getProvName() + "/subscribe/" + feedid; } /** @@ -75,7 +84,7 @@ public class URLUtilities { * @return the URL */ public static String generateFeedLogURL(int feedid) { - return "https://" + BaseServlet.provName + "/feedlog/" + feedid; + return HTTPS + BaseServlet.getProvName() + "/feedlog/" + feedid; } /** @@ -85,7 +94,7 @@ public class URLUtilities { * @return the URL */ public static String generateSubscriptionURL(int subid) { - return "https://" + BaseServlet.provName + "/subs/" + subid; + return HTTPS + BaseServlet.getProvName() + "/subs/" + subid; } /** @@ -95,7 +104,7 @@ public class URLUtilities { * @return the URL */ public static String generateSubLogURL(int subid) { - return "https://" + BaseServlet.provName + "/sublog/" + subid; + return HTTPS + BaseServlet.getProvName() + "/sublog/" + subid; } /** @@ -104,7 +113,7 @@ public class URLUtilities { * @return the URL */ public static String generatePeerProvURL() { - return "https://" + getPeerPodName() + "/internal/prov"; + return HTTPS + getPeerPodName() + "/internal/prov"; } /** @@ -115,11 +124,11 @@ public class URLUtilities { public static String generatePeerLogsURL() { //Fixes for Itrack ticket - DATARTR-4#Fixing if only one Prov is configured, not to give exception to fill logs. String peerPodUrl = getPeerPodName(); - if (peerPodUrl.equals("") || peerPodUrl==null) { + if (peerPodUrl == null || "".equals(peerPodUrl)) { return ""; } - return "https://" + peerPodUrl + "/internal/drlogs/"; + return HTTPS + peerPodUrl + "/internal/drlogs/"; } /** @@ -128,23 +137,21 @@ public class URLUtilities { * @return the name */ public static String getPeerPodName() { - if (other_pod == null) { - String this_pod = ""; + if (otherPod == null) { + String thisPod; try { - this_pod = InetAddress.getLocalHost().getHostName(); - System.out.println("this_pod: " + this_pod); + thisPod = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { - this_pod = ""; + utilsLogger.trace("UnkownHostException: " + e.getMessage(), e); + thisPod = ""; } - System.out.println("ALL PODS: " + Arrays.asList(BaseServlet.getPods())); for (String pod : BaseServlet.getPods()) { - if (!pod.equals(this_pod)) { - other_pod = pod; + if (!pod.equals(thisPod)) { + otherPod = pod; } } } - return other_pod; + return otherPod; } - private static String other_pod; }