Source:
<code>public static String getAdminConsoleURL(String context) { String hostName = "localhost"; try { hostName = NetworkUtils.getMgtHostName(); } catch (Exception ignored) { } String mgtConsoleTransport = CarbonUtils.getManagementTransport(); ConfigurationContextService configContextService = CarbonUIServiceComponent .getConfigurationContextService(); int httpsPort; int httpsProxyPort; <START> String isRandomPort = System.getProperty("tomcat.random.port.enable"); <END> if (isRandomPort != null && isRandomPort.equals("true")) { CarbonTomcatService tomcatService = (CarbonTomcatService) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(CarbonTomcatService.class, null); if (tomcatService != null) { httpsPort = tomcatService.getPort(mgtConsoleTransport); httpsProxyPort = tomcatService.getProxyPort(mgtConsoleTransport); } else { httpsPort = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); httpsProxyPort = CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), mgtConsoleTransport); } } else { httpsPort = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); httpsProxyPort = CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), mgtConsoleTransport); } if ("/".equals(context)) { context = ""; } String proxyContextPath = CarbonUtils.getProxyContextPath(false); String adminConsoleURL = "https://" + hostName + ":" + (httpsProxyPort != -1 ? httpsProxyPort : httpsPort) + proxyContextPath + context + "/carbon/"; if(log.isDebugEnabled()){ log.debug("Generated admin console URL: " + adminConsoleURL); } return adminConsoleURL; }</code><technical_language>This set constants</technical_language>

Target:
public static String getAdminConsoleURL(String context) { String hostName = "localhost"; try { hostName = NetworkUtils.getMgtHostName(); } catch (Exception ignored) { } String mgtConsoleTransport = CarbonUtils.getManagementTransport(); ConfigurationContextService configContextService = CarbonUIServiceComponent .getConfigurationContextService(); int httpsPort; int httpsProxyPort; String isRandomPort = System.getProperty(CarbonConstants.TOMCAT_RANDOM_PORT_ENABLE); if (isRandomPort != null && isRandomPort.equals("true")) { CarbonTomcatService tomcatService = (CarbonTomcatService) CarbonContext.getThreadLocalCarbonContext() .getOSGiService(CarbonTomcatService.class, null); if (tomcatService != null) { httpsPort = tomcatService.getPort(mgtConsoleTransport); httpsProxyPort = tomcatService.getProxyPort(mgtConsoleTransport); } else { httpsPort = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); httpsProxyPort = CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), mgtConsoleTransport); } } else { httpsPort = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); httpsProxyPort = CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), mgtConsoleTransport); } if ("/".equals(context)) { context = ""; } String proxyContextPath = CarbonUtils.getProxyContextPath(false); String adminConsoleURL = "https://" + hostName + ":" + (httpsProxyPort != -1 ? httpsProxyPort : httpsPort) + proxyContextPath + context + "/carbon/"; if(log.isDebugEnabled()){ log.debug("Generated admin console URL: " + adminConsoleURL); } return adminConsoleURL; }