當前位置: 首頁>>代碼示例>>Java>>正文


Java URIish.getPort方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.transport.URIish.getPort方法的典型用法代碼示例。如果您正苦於以下問題:Java URIish.getPort方法的具體用法?Java URIish.getPort怎麽用?Java URIish.getPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.transport.URIish的用法示例。


在下文中一共展示了URIish.getPort方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: equals

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
/**
 * Compare the two given git remote URIs. This method is a reimplementation of {@link URIish#equals(Object)} with
 * one difference. The scheme of the URIs is only considered if both URIs have a non-null and non-empty scheme part.
 *
 * @param lhs
 *            the left hand side
 * @param rhs
 *            the right hand side
 * @return <code>true</code> if the two URIs are to be considered equal and <code>false</code> otherwise
 */
private static boolean equals(URIish lhs, URIish rhs) {
	// We only consider the scheme if both URIs have one
	if (!StringUtils.isEmptyOrNull(lhs.getScheme()) && !StringUtils.isEmptyOrNull(rhs.getScheme())) {
		if (!Objects.equals(lhs.getScheme(), rhs.getScheme()))
			return false;
	}
	if (!equals(lhs.getUser(), rhs.getUser()))
		return false;
	if (!equals(lhs.getPass(), rhs.getPass()))
		return false;
	if (!equals(lhs.getHost(), rhs.getHost()))
		return false;
	if (lhs.getPort() != rhs.getPort())
		return false;
	if (!pathEquals(lhs.getPath(), rhs.getPath()))
		return false;
	return true;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:29,代碼來源:GitUtils.java

示例2: getGerritProjectName

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
public static String getGerritProjectName(Repository repository) {
	try {
		RemoteConfig config = new RemoteConfig(repository.getConfig(),
				"origin"); //$NON-NLS-1$
		
		List<URIish> urls = new ArrayList<URIish>(config.getPushURIs());
		urls.addAll(config.getURIs());
		
		for (URIish uri: urls) {
			if (uri.getPort() == 29418) { //Gerrit refspec
				String path = uri.getPath();
				while (path.startsWith("/")) { //$NON-NLS-1$
					path = path.substring(1);
				}
				return path;
			}
			break;
		}
	} catch (Exception e) {
		GerritToolsPlugin.getDefault().log(e);
	}
	return null;
}
 
開發者ID:Genuitec,項目名稱:gerrit-tools,代碼行數:24,代碼來源:GerritUtils.java

示例3: getGerritURL

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
public static String getGerritURL(Repository repository) {
	String best = null;
	try {
		RemoteConfig config = new RemoteConfig(repository.getConfig(),
				"origin"); //$NON-NLS-1$
		
		List<URIish> urls = new ArrayList<URIish>(config.getPushURIs());
		urls.addAll(config.getURIs());
		
		for (URIish uri: urls) {
			best = "https://" + uri.getHost(); //$NON-NLS-1$
			if (uri.getPort() == 29418) { //Gerrit refspec
				return best;
			}
			break;
		}
	} catch (Exception e) {
		GerritToolsPlugin.getDefault().log(e);
	}
	return best;
}
 
開發者ID:Genuitec,項目名稱:gerrit-tools,代碼行數:22,代碼來源:GerritUtils.java

示例4: format

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
private static String format(URIish uri) {
    StringBuilder r = new StringBuilder();

    if (uri.getScheme() != null) r.append(uri.getScheme()).append("://");

    if (uri.getHost() != null) {
        r.append(uri.getHost());
        if (uri.getScheme() != null && uri.getPort() > 0) r.append(':').append(uri.getPort());
    }

    if (uri.getPath() != null) {
        if (uri.getScheme() != null) {
            if (!uri.getPath().startsWith("/") && !uri.getPath().isEmpty()) r.append('/');
        } else if(uri.getHost() != null) r.append(':');

        if (uri.getScheme() != null) r.append(uri.getRawPath());
        else r.append(uri.getPath());
    }

    return r.toString();
}
 
開發者ID:twizmwazin,項目名稱:CardinalPGM,代碼行數:22,代碼來源:GitRepository.java

示例5: resolveNodeName

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
static String resolveNodeName(URIish uri) {
  StringBuilder sb = new StringBuilder();
  if (uri.isRemote()) {
    sb.append(uri.getHost());
    if (uri.getPort() != -1) {
      sb.append(":");
      sb.append(uri.getPort());
    }
  } else {
    sb.append(uri.getPath());
  }
  return sb.toString();
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_replication,代碼行數:14,代碼來源:PushResultProcessing.java

示例6: toSshUri

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
private URIish toSshUri(URIish uri) throws URISyntaxException {
  String uriStr = uri.toString();
  if (uri.getHost() != null && uriStr.startsWith(GERRIT_ADMIN_PROTOCOL_PREFIX)) {
    return new URIish(uriStr.substring(0, GERRIT_ADMIN_PROTOCOL_PREFIX.length()));
  }
  String rawPath = uri.getRawPath();
  if (!rawPath.endsWith("/")) {
    rawPath = rawPath + "/";
  }
  URIish sshUri = new URIish("ssh://" + rawPath);
  if (sshUri.getPort() < 0) {
    sshUri = sshUri.setPort(SshAddressesModule.DEFAULT_PORT);
  }
  return sshUri;
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_replication,代碼行數:16,代碼來源:GerritSshApi.java

示例7: getSession

import org.eclipse.jgit.transport.URIish; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public RemoteSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException {
    try {
        int p = uri.getPort();
        if (p<0)    p = 22;
        Connection con = new Connection(uri.getHost(), p);
        con.setTCPNoDelay(true);
        con.connect();  // TODO: host key check

        boolean authenticated;
        if (credentialsProvider instanceof SmartCredentialsProvider) {
            final SmartCredentialsProvider smart = (SmartCredentialsProvider) credentialsProvider;
            StandardUsernameCredentialsCredentialItem
                    item = new StandardUsernameCredentialsCredentialItem("Credentials for " + uri, false);
            authenticated = smart.supports(item)
                    && smart.get(uri, item)
                    && SSHAuthenticator.newInstance(con, item.getValue(), uri.getUser())
                    .authenticate(smart.listener);
        } else if (credentialsProvider instanceof CredentialsProviderImpl) {
            CredentialsProviderImpl sshcp = (CredentialsProviderImpl) credentialsProvider;

            authenticated = SSHAuthenticator.newInstance(con, sshcp.cred).authenticate(sshcp.listener);
        } else {
            authenticated = false;
        }
        if (!authenticated && con.isAuthenticationComplete())
            throw new TransportException("Authentication failure");

        return wrap(con);
    } catch (UnsupportedCredentialItem | IOException | InterruptedException e) {
        throw new TransportException(uri,"Failed to connect",e);
    }
}
 
開發者ID:jenkinsci,項目名稱:git-client-plugin,代碼行數:35,代碼來源:TrileadSessionFactory.java


注:本文中的org.eclipse.jgit.transport.URIish.getPort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。