List of usage examples for org.eclipse.jgit.transport URIish setHost
public URIish setHost(String n)
From source file:com.ericsson.gerrit.plugins.highavailability.peers.jgroups.MyUrlProvider.java
License:Apache License
private static String getMyUrlFromListenUrl(Config srvConfig) throws MyUrlProviderException { String[] listenUrls = srvConfig.getStringList(HTTPD_SECTION, null, LISTEN_URL_KEY); if (listenUrls.length != 1) { throw new MyUrlProviderException(String.format( "Can only determine myUrl from %s when there is exactly 1 value configured; found %d", LISTEN_URL, listenUrls.length)); }/*from w w w . j ava 2 s. c o m*/ String url = listenUrls[0]; if (url.startsWith(PROXY_PREFIX)) { throw new MyUrlProviderException(String.format( "Cannot determine myUrl from %s when configured as reverse-proxy: %s", LISTEN_URL, url)); } if (url.contains("*")) { throw new MyUrlProviderException(String .format("Cannot determine myUrl from %s when configured with wildcard: %s", LISTEN_URL, url)); } try { URIish u = new URIish(url); return u.setHost(InetAddress.getLocalHost().getHostName()).toString(); } catch (URISyntaxException | UnknownHostException e) { throw new MyUrlProviderException(String.format("Unable to determine myUrl from %s value [%s]: %s", LISTEN_URL, url, e.getMessage())); } }
From source file:org.sonatype.m2e.egit.internal.EgitScmHandler.java
License:Open Source License
protected String normalizeUri(String uri) throws URISyntaxException { if (!uri.startsWith(GIT_SCM_ID)) { return uri; }/* w w w . j a v a2 s. co m*/ uri = uri.substring(GIT_SCM_ID.length()); if (uri.startsWith("file:") && !uri.startsWith("file:///")) { throw new URISyntaxException(uri, "Invalid git URI"); } URIish gitUri = new URIish(uri); if (gitUri.getScheme() == null) { if (gitUri.getHost() == null || "file".equals(gitUri.getHost())) { gitUri = gitUri.setHost(null); gitUri = gitUri.setScheme("file"); } else { // This must be an scp-like syntax git URL // See http://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a gitUri = gitUri.setScheme("ssh"); } } return gitUri.toString(); }