import com.att.eelf.configuration.EELFManager;\r
import java.net.InetAddress;\r
import java.net.UnknownHostException;\r
-\r
import org.onap.dmaap.datarouter.provisioning.BaseServlet;\r
+import org.onap.dmaap.datarouter.provisioning.ProvRunner;\r
\r
/**\r
* Utility functions used to generate the different URLs used by the Data Router.\r
*/\r
public class URLUtilities {\r
\r
-\r
private static final EELFLogger utilsLogger = EELFManager.getInstance().getLogger("UtilsLog");\r
- private static final String HTTPS = "https://";\r
private static String otherPod;\r
\r
private URLUtilities() {\r
* @return the URL\r
*/\r
public static String generateFeedURL(int feedid) {\r
- return HTTPS + BaseServlet.getProvName() + "/feed/" + feedid;\r
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/feed/" + feedid;\r
}\r
\r
/**\r
* @return the URL\r
*/\r
public static String generatePublishURL(int feedid) {\r
- return HTTPS + BaseServlet.getProvName() + "/publish/" + feedid;\r
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/publish/" + feedid;\r
}\r
\r
/**\r
* @return the URL\r
*/\r
public static String generateSubscribeURL(int feedid) {\r
- return HTTPS + BaseServlet.getProvName() + "/subscribe/" + feedid;\r
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/subscribe/" + feedid;\r
}\r
\r
/**\r
* @return the URL\r
*/\r
public static String generateFeedLogURL(int feedid) {\r
- return HTTPS + BaseServlet.getProvName() + "/feedlog/" + feedid;\r
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/feedlog/" + feedid;\r
}\r
\r
/**\r
* @return the URL\r
*/\r
public static String generateSubscriptionURL(int subid) {\r
- return HTTPS + BaseServlet.getProvName() + "/subs/" + subid;\r
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/subs/" + subid;\r
}\r
\r
/**\r
* @return the URL\r
*/\r
public static String generateSubLogURL(int subid) {\r
- return HTTPS + BaseServlet.getProvName() + "/sublog/" + subid;\r
+ return getUrlSecurityOption() + BaseServlet.getProvName() + getAppropriateUrlPort() + "/sublog/" + subid;\r
}\r
\r
/**\r
* @return the URL\r
*/\r
public static String generatePeerProvURL() {\r
- return HTTPS + getPeerPodName() + "/internal/prov";\r
+ return getUrlSecurityOption() + getPeerPodName() + getAppropriateUrlPort() + "/internal/prov";\r
}\r
\r
/**\r
return "";\r
}\r
\r
- return HTTPS + peerPodUrl + "/internal/drlogs/";\r
+ return getUrlSecurityOption() + peerPodUrl + getAppropriateUrlPort() + "/internal/drlogs/";\r
}\r
\r
/**\r
return otherPod;\r
}\r
\r
+ public static String getUrlSecurityOption() {\r
+ if (Boolean.parseBoolean(ProvRunner.getProvProperties()\r
+ .getProperty("org.onap.dmaap.datarouter.provserver.tlsenabled", "true"))) {\r
+ return "https://";\r
+ }\r
+ return "http://";\r
+ }\r
+\r
+ private static String getAppropriateUrlPort() {\r
+ if (Boolean.parseBoolean(ProvRunner.getProvProperties()\r
+ .getProperty("org.onap.dmaap.datarouter.provserver.tlsenabled", "true")))\r
+ return "";\r
+\r
+ return ":" + ProvRunner.getProvProperties()\r
+ .getProperty("org.onap.dmaap.datarouter.provserver.http.port", "8080");\r
+\r
+ }\r
}\r