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=5813024c272dfc9dc94c5ba0a21a797d520b70d3;hb=f20778ffa99aa9c6f30a0f84112a5392b259ea63;hp=b73c4639f0f8b44703203e113b40241aabe7624d;hpb=67cc50441de4e771ca3e0d91a2e35e0e4057a219;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 b73c4639..5813024c 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,13 @@ 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 +53,7 @@ public class URLUtilities { * @return the URL */ public static String generateFeedURL(int feedid) { - return "https://" + BaseServlet.getProvName() + "/feed/" + feedid; + return HTTPS + BaseServlet.getProvName() + "/feed/" + feedid; } /** @@ -55,7 +63,7 @@ public class URLUtilities { * @return the URL */ public static String generatePublishURL(int feedid) { - return "https://" + BaseServlet.getProvName() + "/publish/" + feedid; + return HTTPS + BaseServlet.getProvName() + "/publish/" + feedid; } /** @@ -65,7 +73,7 @@ public class URLUtilities { * @return the URL */ public static String generateSubscribeURL(int feedid) { - return "https://" + BaseServlet.getProvName() + "/subscribe/" + feedid; + return HTTPS + BaseServlet.getProvName() + "/subscribe/" + feedid; } /** @@ -75,7 +83,7 @@ public class URLUtilities { * @return the URL */ public static String generateFeedLogURL(int feedid) { - return "https://" + BaseServlet.getProvName() + "/feedlog/" + feedid; + return HTTPS + BaseServlet.getProvName() + "/feedlog/" + feedid; } /** @@ -85,7 +93,7 @@ public class URLUtilities { * @return the URL */ public static String generateSubscriptionURL(int subid) { - return "https://" + BaseServlet.getProvName() + "/subs/" + subid; + return HTTPS + BaseServlet.getProvName() + "/subs/" + subid; } /** @@ -95,7 +103,7 @@ public class URLUtilities { * @return the URL */ public static String generateSubLogURL(int subid) { - return "https://" + BaseServlet.getProvName() + "/sublog/" + subid; + return HTTPS + BaseServlet.getProvName() + "/sublog/" + subid; } /** @@ -104,7 +112,7 @@ public class URLUtilities { * @return the URL */ public static String generatePeerProvURL() { - return "https://" + getPeerPodName() + "/internal/prov"; + return HTTPS + getPeerPodName() + "/internal/prov"; } /** @@ -115,11 +123,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.equals(null)) { + if (peerPodUrl == null || "".equals(peerPodUrl)) { return ""; } - return "https://" + peerPodUrl + "/internal/drlogs/"; + return HTTPS + peerPodUrl + "/internal/drlogs/"; } /** @@ -128,23 +136,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; }