Example usage for java.net URL getPort

List of usage examples for java.net URL getPort

Introduction

In this page you can find the example usage for java.net URL getPort.

Prototype

public int getPort() 

Source Link

Document

Gets the port number of this URL .

Usage

From source file:org.openremote.android.console.net.ORControllerServerSwitcher.java

/**
 * Detect the groupmembers of current server url
 *//*w w w.  java 2  s. com*/
public static boolean detectGroupMembers(Context context) {
    Log.i(LOG_CATEGORY, "Detecting group members with current controller server url "
            + AppSettingsModel.getCurrentServer(context));

    HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(params, 5 * 1000);
    HttpConnectionParams.setSoTimeout(params, 5 * 1000);
    HttpClient httpClient = new DefaultHttpClient(params);
    String url = AppSettingsModel.getSecuredServer(context);
    HttpGet httpGet = new HttpGet(url + "/rest/servers");

    if (httpGet == null) {
        Log.e(LOG_CATEGORY, "Create HttpRequest fail.");

        return false;
    }

    SecurityUtil.addCredentialToHttpRequest(context, httpGet);

    // TODO : fix the exception handling in this method -- it is ridiculous.

    try {
        URL uri = new URL(url);

        if ("https".equals(uri.getProtocol())) {
            Scheme sch = new Scheme(uri.getProtocol(), new SelfCertificateSSLSocketFactory(context),
                    uri.getPort());
            httpClient.getConnectionManager().getSchemeRegistry().register(sch);
        }

        HttpResponse httpResponse = httpClient.execute(httpGet);

        try {
            if (httpResponse.getStatusLine().getStatusCode() == Constants.HTTP_SUCCESS) {
                InputStream data = httpResponse.getEntity().getContent();

                try {
                    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                    DocumentBuilder builder = factory.newDocumentBuilder();
                    Document dom = builder.parse(data);
                    Element root = dom.getDocumentElement();

                    NodeList nodeList = root.getElementsByTagName("server");
                    int nodeNums = nodeList.getLength();
                    List<String> groupMembers = new ArrayList<String>();

                    for (int i = 0; i < nodeNums; i++) {
                        groupMembers.add(nodeList.item(i).getAttributes().getNamedItem("url").getNodeValue());
                    }

                    Log.i(LOG_CATEGORY, "Detected groupmembers. Groupmembers are " + groupMembers);

                    return saveGroupMembersToFile(context, groupMembers);
                } catch (IOException e) {
                    Log.e(LOG_CATEGORY, "The data is from ORConnection is bad", e);
                } catch (ParserConfigurationException e) {
                    Log.e(LOG_CATEGORY, "Cant build new Document builder", e);
                } catch (SAXException e) {
                    Log.e(LOG_CATEGORY, "Parse data error", e);
                }
            }

            else {
                Log.e(LOG_CATEGORY, "detectGroupMembers Parse data error");
            }
        }

        catch (IllegalStateException e) {
            Log.e(LOG_CATEGORY, "detectGroupMembers Parse data error", e);
        }

        catch (IOException e) {
            Log.e(LOG_CATEGORY, "detectGroupMembers Parse data error", e);
        }

    }

    catch (MalformedURLException e) {
        Log.e(LOG_CATEGORY, "Create URL fail:" + url);
    }

    catch (ConnectException e) {
        Log.e(LOG_CATEGORY, "Connection refused: " + AppSettingsModel.getCurrentServer(context), e);
    }

    catch (ClientProtocolException e) {
        Log.e(LOG_CATEGORY, "Can't Detect groupmembers with current controller server "
                + AppSettingsModel.getCurrentServer(context), e);
    }

    catch (SocketTimeoutException e) {
        Log.e(LOG_CATEGORY, "Can't Detect groupmembers with current controller server "
                + AppSettingsModel.getCurrentServer(context), e);
    }

    catch (IOException e) {
        Log.e(LOG_CATEGORY, "Can't Detect groupmembers with current controller server "
                + AppSettingsModel.getCurrentServer(context), e);
    }

    catch (IllegalArgumentException e) {
        Log.e(LOG_CATEGORY, "Host name can be null :" + AppSettingsModel.getCurrentServer(context), e);
    }

    return false;
}

From source file:io.fabric8.apiman.gateway.ApimanGatewayStarter.java

private static URL waitForDependency(URL url, String serviceName, String key, String value, String username,
        String password) throws InterruptedException {
    boolean isFoundRunningService = false;
    ObjectMapper mapper = new ObjectMapper();
    int counter = 0;
    URL endpoint = null;/*from ww w. ja va 2 s .  c  o  m*/
    while (!isFoundRunningService) {
        endpoint = resolveServiceEndpoint(url.getProtocol(), url.getHost(), String.valueOf(url.getPort()));
        if (endpoint != null) {
            String isLive = null;
            try {
                URL statusURL = new URL(endpoint.toExternalForm() + url.getPath());
                HttpURLConnection urlConnection = (HttpURLConnection) statusURL.openConnection();
                urlConnection.setConnectTimeout(500);
                if (urlConnection instanceof HttpsURLConnection) {
                    try {
                        KeyStoreUtil.Info tPathInfo = new KeyStoreUtil().new Info(TRUSTSTORE_PATH,
                                TRUSTSTORE_PASSWORD_PATH);
                        TrustManager[] tms = KeyStoreUtil.getTrustManagers(tPathInfo);
                        KeyStoreUtil.Info kPathInfo = new KeyStoreUtil().new Info(CLIENT_KEYSTORE_PATH,
                                CLIENT_KEYSTORE_PASSWORD_PATH);
                        KeyManager[] kms = KeyStoreUtil.getKeyManagers(kPathInfo);
                        final SSLContext sc = SSLContext.getInstance("TLS");
                        sc.init(kms, tms, new java.security.SecureRandom());
                        final SSLSocketFactory socketFactory = sc.getSocketFactory();
                        HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory);
                        HttpsURLConnection httpsConnection = (HttpsURLConnection) urlConnection;
                        httpsConnection.setHostnameVerifier(new DefaultHostnameVerifier());
                        httpsConnection.setSSLSocketFactory(socketFactory);
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                        throw e;
                    }
                }
                if (Utils.isNotNullOrEmpty(username)) {
                    String encoded = Base64.getEncoder()
                            .encodeToString((username + ":" + password).getBytes("UTF-8"));
                    log.info(username + ":******");
                    urlConnection.setRequestProperty("Authorization", "Basic " + encoded);
                }
                isLive = IOUtils.toString(urlConnection.getInputStream());
                Map<String, Object> esResponse = mapper.readValue(isLive,
                        new TypeReference<Map<String, Object>>() {
                        });
                if (esResponse.containsKey(key) && value.equals(String.valueOf(esResponse.get(key)))) {
                    isFoundRunningService = true;
                } else {
                    if (counter % 10 == 0)
                        log.info(endpoint.toExternalForm() + " not yet up (host=" + endpoint.getHost() + ")"
                                + isLive);
                }
            } catch (Exception e) {
                if (counter % 10 == 0)
                    log.info(endpoint.toExternalForm() + " not yet up. (host=" + endpoint.getHost() + ")"
                            + e.getMessage());
            }
        } else {
            if (counter % 10 == 0)
                log.info("Could not find " + serviceName + " in namespace, waiting..");
        }
        counter++;
        Thread.sleep(1000l);
    }
    return endpoint;
}

From source file:javarestart.WebClassLoaderRegistry.java

public static WebClassLoader resolveClassLoader(URL url) {
    if (url.getPath().endsWith("/..")) {
        return null;
    }/*from  w w w .j  a va 2  s . co m*/
    WebClassLoader cl = null;
    URL baseURL = normalizeURL(url);
    try {
        URL rootURL = new URL(baseURL, "/");
        while (((cl = associatedClassloaders.get(baseURL)) == null) && !baseURL.equals(rootURL)) {
            baseURL = new URL(baseURL, "..");
        }
    } catch (MalformedURLException e) {
    }

    if (cl == null) {
        try {
            JSONObject desc = Utils.getJSON(new URL(url.getProtocol(), url.getHost(), url.getPort(),
                    url.getPath() + "?getAppDescriptor"));
            if (desc != null) {
                cl = new WebClassLoader(url, desc);
            }
        } catch (Exception e) {
        }
    }
    associatedClassloaders.put(normalizeURL(url), cl);
    if (cl != null) {
        URL clURL = normalizeURL(cl.getBaseURL());
        associatedClassloaders.put(clURL, cl);
        classloaders.put(clURL, cl);
    }
    return cl;
}

From source file:jp.sf.fess.solr.plugin.suggest.util.SolrConfigUtil.java

public static SuggestUpdateConfig getUpdateHandlerConfig(final SolrConfig config) {
    final SuggestUpdateConfig suggestUpdateConfig = new SuggestUpdateConfig();

    final Node solrServerNode = config.getNode("updateHandler/suggest/solrServer", false);
    if (solrServerNode != null) {
        try {//  w w  w .  j  a  va 2  s .c om
            final Node classNode = solrServerNode.getAttributes().getNamedItem("class");
            String className;
            if (classNode != null) {
                className = classNode.getTextContent();
            } else {
                className = "org.codelibs.solr.lib.server.SolrLibHttpSolrServer";
            }
            @SuppressWarnings("unchecked")
            final Class<? extends SolrServer> clazz = (Class<? extends SolrServer>) Class.forName(className);
            final String arg = config.getVal("updateHandler/suggest/solrServer/arg", false);
            SolrServer solrServer;
            if (StringUtils.isNotBlank(arg)) {
                final Constructor<? extends SolrServer> constructor = clazz.getConstructor(String.class);
                solrServer = constructor.newInstance(arg);
            } else {
                solrServer = clazz.newInstance();
            }

            final String username = config.getVal("updateHandler/suggest/solrServer/credentials/username",
                    false);
            final String password = config.getVal("updateHandler/suggest/solrServer/credentials/password",
                    false);
            if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)
                    && solrServer instanceof SolrLibHttpSolrServer) {
                final SolrLibHttpSolrServer solrLibHttpSolrServer = (SolrLibHttpSolrServer) solrServer;
                final URL u = new URL(arg);
                final AuthScope authScope = new AuthScope(u.getHost(), u.getPort());
                final Credentials credentials = new UsernamePasswordCredentials(username, password);
                solrLibHttpSolrServer.setCredentials(authScope, credentials);
                solrLibHttpSolrServer.addRequestInterceptor(new PreemptiveAuthInterceptor());
            }

            final NodeList childNodes = solrServerNode.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
                final Node node = childNodes.item(i);
                if (node.getNodeType() == Node.ELEMENT_NODE) {
                    final String name = node.getNodeName();
                    if (!"arg".equals(name) && !"credentials".equals(name)) {
                        final String value = node.getTextContent();
                        final Node typeNode = node.getAttributes().getNamedItem("type");
                        final Method method = clazz.getMethod(
                                "set" + name.substring(0, 1).toUpperCase() + name.substring(1),
                                getMethodArgClass(typeNode));
                        method.invoke(solrServer, getMethodArgValue(typeNode, value));
                    }
                }
            }
            if (solrServer instanceof SolrLibHttpSolrServer) {
                ((SolrLibHttpSolrServer) solrServer).init();
            }
            suggestUpdateConfig.setSolrServer(solrServer);
        } catch (final Exception e) {
            throw new FessSuggestException("Failed to load SolrServer.", e);
        }
    }

    final String labelFields = config.getVal("updateHandler/suggest/labelFields", false);
    if (StringUtils.isNotBlank(labelFields)) {
        suggestUpdateConfig.setLabelFields(labelFields.trim().split(","));
    }
    final String roleFields = config.getVal("updateHandler/suggest/roleFields", false);
    if (StringUtils.isNotBlank(roleFields)) {
        suggestUpdateConfig.setRoleFields(roleFields.trim().split(","));
    }

    final String expiresField = config.getVal("updateHandler/suggest/expiresField", false);
    if (StringUtils.isNotBlank(expiresField)) {
        suggestUpdateConfig.setExpiresField(expiresField);
    }
    final String segmentField = config.getVal("updateHandler/suggest/segmentField", false);
    if (StringUtils.isNotBlank(segmentField)) {
        suggestUpdateConfig.setSegmentField(segmentField);
    }
    final String updateInterval = config.getVal("updateHandler/suggest/updateInterval", false);
    if (StringUtils.isNotBlank(updateInterval) && StringUtils.isNumeric(updateInterval)) {
        suggestUpdateConfig.setUpdateInterval(Long.parseLong(updateInterval));
    }

    //set suggestFieldInfo
    final NodeList nodeList = config.getNodeList("updateHandler/suggest/suggestFieldInfo", true);
    for (int i = 0; i < nodeList.getLength(); i++) {
        try {
            final SuggestUpdateConfig.FieldConfig fieldConfig = new SuggestUpdateConfig.FieldConfig();
            final Node fieldInfoNode = nodeList.item(i);
            final NamedNodeMap fieldInfoAttributes = fieldInfoNode.getAttributes();
            final Node fieldNameNode = fieldInfoAttributes.getNamedItem("fieldName");
            final String fieldName = fieldNameNode.getNodeValue();
            if (StringUtils.isBlank(fieldName)) {
                continue;
            }
            fieldConfig.setTargetFields(fieldName.trim().split(","));
            if (logger.isInfoEnabled()) {
                for (final String s : fieldConfig.getTargetFields()) {
                    logger.info("fieldName : " + s);
                }
            }

            final NodeList fieldInfoChilds = fieldInfoNode.getChildNodes();
            for (int j = 0; j < fieldInfoChilds.getLength(); j++) {
                final Node fieldInfoChildNode = fieldInfoChilds.item(j);
                final String fieldInfoChildNodeName = fieldInfoChildNode.getNodeName();

                if ("tokenizerFactory".equals(fieldInfoChildNodeName)) {
                    //field tokenier settings
                    final SuggestUpdateConfig.TokenizerConfig tokenizerConfig = new SuggestUpdateConfig.TokenizerConfig();

                    final NamedNodeMap tokenizerFactoryAttributes = fieldInfoChildNode.getAttributes();
                    final Node tokenizerClassNameNode = tokenizerFactoryAttributes.getNamedItem("class");
                    final String tokenizerClassName = tokenizerClassNameNode.getNodeValue();
                    tokenizerConfig.setClassName(tokenizerClassName);
                    if (logger.isInfoEnabled()) {
                        logger.info("tokenizerFactory : " + tokenizerClassName);
                    }

                    final Map<String, String> args = new HashMap<String, String>();
                    for (int k = 0; k < tokenizerFactoryAttributes.getLength(); k++) {
                        final Node attribute = tokenizerFactoryAttributes.item(k);
                        final String key = attribute.getNodeName();
                        final String value = attribute.getNodeValue();
                        if (!"class".equals(key)) {
                            args.put(key, value);
                        }
                    }
                    if (!args.containsKey(USER_DICT_PATH)) {
                        final String userDictPath = System.getProperty(SuggestConstants.USER_DICT_PATH, "");
                        if (StringUtils.isNotBlank(userDictPath)) {
                            args.put(USER_DICT_PATH, userDictPath);
                        }
                        final String userDictEncoding = System.getProperty(SuggestConstants.USER_DICT_ENCODING,
                                "");
                        if (StringUtils.isNotBlank(userDictEncoding)) {
                            args.put(USER_DICT_ENCODING, userDictEncoding);
                        }
                    }
                    tokenizerConfig.setArgs(args);

                    fieldConfig.setTokenizerConfig(tokenizerConfig);
                } else if ("suggestReadingConverter".equals(fieldInfoChildNodeName)) {
                    //field reading converter settings
                    final NodeList converterNodeList = fieldInfoChildNode.getChildNodes();
                    for (int k = 0; k < converterNodeList.getLength(); k++) {
                        final SuggestUpdateConfig.ConverterConfig converterConfig = new SuggestUpdateConfig.ConverterConfig();

                        final Node converterNode = converterNodeList.item(k);
                        if (!"converter".equals(converterNode.getNodeName())) {
                            continue;
                        }

                        final NamedNodeMap converterAttributes = converterNode.getAttributes();
                        final Node classNameNode = converterAttributes.getNamedItem("class");
                        final String className = classNameNode.getNodeValue();
                        converterConfig.setClassName(className);
                        if (logger.isInfoEnabled()) {
                            logger.info("converter : " + className);
                        }

                        final Map<String, String> properties = new HashMap<String, String>();
                        for (int l = 0; l < converterAttributes.getLength(); l++) {
                            final Node attribute = converterAttributes.item(l);
                            final String key = attribute.getNodeName();
                            final String value = attribute.getNodeValue();
                            if (!"class".equals(key)) {
                                properties.put(key, value);
                            }
                        }
                        converterConfig.setProperties(properties);
                        if (logger.isInfoEnabled()) {
                            logger.info("converter properties = " + properties);
                        }
                        fieldConfig.addConverterConfig(converterConfig);
                    }
                } else if ("suggestNormalizer".equals(fieldInfoChildNodeName)) {
                    //field normalizer settings
                    final NodeList normalizerNodeList = fieldInfoChildNode.getChildNodes();
                    for (int k = 0; k < normalizerNodeList.getLength(); k++) {
                        final SuggestUpdateConfig.NormalizerConfig normalizerConfig = new SuggestUpdateConfig.NormalizerConfig();

                        final Node normalizerNode = normalizerNodeList.item(k);
                        if (!"normalizer".equals(normalizerNode.getNodeName())) {
                            continue;
                        }

                        final NamedNodeMap normalizerAttributes = normalizerNode.getAttributes();
                        final Node classNameNode = normalizerAttributes.getNamedItem("class");
                        final String className = classNameNode.getNodeValue();
                        normalizerConfig.setClassName(className);
                        if (logger.isInfoEnabled()) {
                            logger.info("normalizer : " + className);
                        }

                        final Map<String, String> properties = new HashMap<String, String>();
                        for (int l = 0; l < normalizerAttributes.getLength(); l++) {
                            final Node attribute = normalizerAttributes.item(l);
                            final String key = attribute.getNodeName();
                            final String value = attribute.getNodeValue();
                            if (!"class".equals(key)) {
                                properties.put(key, value);
                            }
                        }
                        normalizerConfig.setProperties(properties);
                        if (logger.isInfoEnabled()) {
                            logger.info("normalize properties = " + properties);
                        }
                        fieldConfig.addNormalizerConfig(normalizerConfig);
                    }
                }
            }

            suggestUpdateConfig.addFieldConfig(fieldConfig);
        } catch (final Exception e) {
            throw new FessSuggestException("Failed to load Suggest Field Info.", e);
        }
    }

    return suggestUpdateConfig;
}

From source file:it.geosolutions.figis.requester.HTTPUtils.java

private static void setAuth(HttpClient client, String url, String username, String pw)
        throws MalformedURLException {
    URL u = new URL(url);
    if ((username != null) && (pw != null)) {
        Credentials defaultcreds = new UsernamePasswordCredentials(username, pw);
        client.getState().setCredentials(new AuthScope(u.getHost(), u.getPort()), defaultcreds);
        client.getParams().setAuthenticationPreemptive(true); // GS2 by default always requires authentication
    } else {/*  www  .j a  v a2  s  .c o m*/
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Not setting credentials to access to " + url);
        }
    }
}

From source file:com.redhat.rcm.version.util.InputUtils.java

public static File getFile(final String location, final File downloadsDir, final boolean deleteExisting)
        throws VManException {
    if (client == null) {
        setupClient();/* ww  w.  ja v  a 2  s.  com*/
    }

    File result = null;

    if (location.startsWith("http")) {
        logger.info("Downloading: '" + location + "'...");

        try {
            final URL url = new URL(location);
            final String userpass = url.getUserInfo();
            if (!isEmpty(userpass)) {
                final AuthScope scope = new AuthScope(url.getHost(), url.getPort());
                final Credentials creds = new UsernamePasswordCredentials(userpass);

                client.getCredentialsProvider().setCredentials(scope, creds);
            }
        } catch (final MalformedURLException e) {
            logger.error("Malformed URL: '" + location + "'", e);
            throw new VManException("Failed to download: %s. Reason: %s", e, location, e.getMessage());
        }

        final File downloaded = new File(downloadsDir, new File(location).getName());
        if (deleteExisting && downloaded.exists()) {
            downloaded.delete();
        }

        if (!downloaded.exists()) {
            HttpGet get = new HttpGet(location);
            OutputStream out = null;
            try {
                HttpResponse response = null;
                // Work around for scenario where we are loading from a server
                // that does a refresh e.g. gitweb
                final int tries = 0;
                do {
                    get = new HttpGet(location);
                    response = client.execute(get);
                    if (response.containsHeader("Cache-control")) {
                        logger.info("Waiting for server to generate cache...");
                        get.abort();
                        try {
                            Thread.sleep(3000);
                        } catch (final InterruptedException e) {
                        }
                    } else {
                        break;
                    }
                } while (tries < MAX_RETRIES);

                if (response.containsHeader("Cache-control")) {
                    throw new VManException(
                            "Failed to read: %s. Cache-control header was present in final attempt.", location);
                }

                final int code = response.getStatusLine().getStatusCode();
                if (code == 200) {
                    final InputStream in = response.getEntity().getContent();
                    out = new FileOutputStream(downloaded);

                    copy(in, out);
                } else {
                    logger.info("Received status: '{}' while downloading: {}", response.getStatusLine(),
                            location);

                    throw new VManException("Received status: '%s' while downloading: %s",
                            response.getStatusLine(), location);
                }
            } catch (final ClientProtocolException e) {
                throw new VManException("Failed to download: '%s'. Error: %s", e, location, e.getMessage());
            } catch (final IOException e) {
                throw new VManException("Failed to download: '%s'. Error: %s", e, location, e.getMessage());
            } finally {
                closeQuietly(out);
                get.abort();
            }
        }

        result = downloaded;
    } else {
        logger.info("Using local file: '" + location + "'...");

        result = new File(location);
    }

    return result;
}

From source file:org.frontcache.core.FCUtils.java

public static HttpHost getHttpHost(URL host) {
    HttpHost httpHost = new HttpHost(host.getHost(), host.getPort(), host.getProtocol());
    return httpHost;
}

From source file:de.jlo.talendcomp.jasperrepo.RepositoryClient.java

public static String checkRepositoryUrl(String urlStr) {
    if (urlStr == null || urlStr.isEmpty()) {
        throw new IllegalArgumentException("url cannot be null or empty");
    }//from   w ww. j  av a 2s.c o m
    if (urlStr.endsWith(repositoryUrlPath)) {
        // everything is fine
        return urlStr;
    } else {
        // extract url parts
        try {
            URL url = new URL(urlStr);
            String host = url.getHost();
            String prot = url.getProtocol();
            int port = url.getPort();
            String path = url.getPath();
            if (path.length() > 1) {
                int pos = path.indexOf('/', 1);
                if (pos > 0) {
                    path = path.substring(0, pos);
                }
                path = path + repositoryUrlPath;
            } else {
                path = repositoryUrlPath;
            }
            StringBuilder newUrl = new StringBuilder();
            newUrl.append(prot);
            newUrl.append("://");
            newUrl.append(host);
            if (port > 0) {
                newUrl.append(":");
                newUrl.append(port);
            }
            newUrl.append(path);
            System.out.println("Given URL:" + urlStr + " changed to a repository URL:" + newUrl.toString());
            return newUrl.toString();
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException("URL: " + urlStr + " is not valied:" + e.getMessage(), e);
        }
    }
}

From source file:it.geosolutions.geonetwork.util.HTTPUtils.java

private static void setAuth(HttpClient client, String url, String username, String pw)
        throws MalformedURLException {
    URL u = new URL(url);
    if (username != null && pw != null) {
        Credentials defaultcreds = new UsernamePasswordCredentials(username, pw);
        client.getState().setCredentials(new AuthScope(u.getHost(), u.getPort()), defaultcreds);
        client.getParams().setAuthenticationPreemptive(true); // GS2 by default always requires authentication
    } else {/*from  w w w.  j ava  2 s. co m*/
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Not setting credentials to access to " + url);
        }
    }
}

From source file:io.fabric8.apiman.ApimanStarter.java

public static void setFabric8Props(URL elasticEndpoint) throws IOException {

    log.info("** Setting API Manager Configuration Properties **");

    setConfigProp("apiman.plugins.repositories", "http://repository.jboss.org/nexus/content/groups/public/");

    setConfigProp("apiman.es.protocol", elasticEndpoint.getProtocol());
    setConfigProp("apiman.es.host", elasticEndpoint.getHost());
    setConfigProp("apiman.es.port", String.valueOf(elasticEndpoint.getPort()));

    String esIndexPrefix = getSystemPropertyOrEnvVar("apiman.es.index.prefix", ".apiman_");
    if (esIndexPrefix != null) {
        setConfigProp(ApiManagerConfig.APIMAN_MANAGER_STORAGE_ES_INDEX_NAME, esIndexPrefix + "manager");
    }/*from w ww  . j a v  a  2 s .c o m*/
    setConfigProp(ApiManagerConfig.APIMAN_MANAGER_STORAGE_ES_CLIENT_FACTORY,
            Fabric8EsClientFactory.class.getName());

    setConfigProp(ApiManagerConfig.APIMAN_MANAGER_STORAGE_TYPE, "es");
    setConfigProp("apiman-manager.storage.es.protocol",
            Systems.getEnvVarOrSystemProperty("apiman.es.protocol"));
    setConfigProp("apiman-manager.storage.es.host", Systems.getEnvVarOrSystemProperty("apiman.es.host"));
    setConfigProp("apiman-manager.storage.es.port", Systems.getEnvVarOrSystemProperty("apiman.es.port"));
    setConfigProp("apiman-manager.storage.es.username",
            Systems.getEnvVarOrSystemProperty("apiman.es.username"));
    setConfigProp("apiman-manager.storage.es.password",
            Systems.getEnvVarOrSystemProperty("apiman.es.password"));
    setConfigProp(ApiManagerConfig.APIMAN_MANAGER_STORAGE_ES_INITIALIZE, "true");

    setConfigProp(ApiManagerConfig.APIMAN_MANAGER_METRICS_TYPE, "es");
    setConfigProp("apiman-manager.metrics.es.protocol",
            Systems.getEnvVarOrSystemProperty("apiman.es.protocol"));
    setConfigProp("apiman-manager.metrics.es.host", Systems.getEnvVarOrSystemProperty("apiman.es.host"));
    setConfigProp("apiman-manager.metrics.es.port", Systems.getEnvVarOrSystemProperty("apiman.es.port"));
    setConfigProp("apiman-manager.metrics.es.username",
            Systems.getEnvVarOrSystemProperty("apiman.es.username"));
    setConfigProp("apiman-manager.metrics.es.password",
            Systems.getEnvVarOrSystemProperty("apiman.es.password"));

    setConfigProp(ApiManagerConfig.APIMAN_MANAGER_API_CATALOG_TYPE, KubernetesServiceCatalog.class.getName());

    File gatewayUserFile = new File(ApimanStarter.APIMAN_GATEWAY_USER_PATH);
    if (gatewayUserFile.exists()) {
        String[] user = IOUtils.toString(gatewayUserFile.toURI()).split(",");
        setConfigProp(ApimanStarter.APIMAN_GATEWAY_USERNAME, user[0]);
        setConfigProp(ApimanStarter.APIMAN_GATEWAY_PASSWORD, user[1]);
    }

    log.info("** ******************************************** **");
}