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


Java GitHub.getOrganization方法代碼示例

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


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

示例1: checkTeamMembershipUsingPersonalAccessToken

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private boolean checkTeamMembershipUsingPersonalAccessToken(LoggedInUserInfo loggedInUserInfo, AuthConfig authConfig, Map<String, List<String>> organizationAndTeamsAllowed) throws IOException {
    final GitHub gitHubForPersonalAccessToken = authConfig.gitHubConfiguration().gitHubClient();

    for (String organizationName : organizationAndTeamsAllowed.keySet()) {
        final GHOrganization organization = gitHubForPersonalAccessToken.getOrganization(organizationName);

        if (organization != null) {
            final List<String> allowedTeamsFromRole = organizationAndTeamsAllowed.get(organizationName);
            final Map<String, GHTeam> teamsFromGitHub = organization.getTeams();

            for (GHTeam team : teamsFromGitHub.values()) {
                if (allowedTeamsFromRole.contains(team.getName().toLowerCase()) && team.hasMember(loggedInUserInfo.getGitHubUser())) {
                    LOG.info(format("[MembershipChecker] User `{0}` is a member of `{1}` team.", loggedInUserInfo.getUser().username(), team.getName()));
                    return true;
                }
            }
        }
    }

    return false;
}
 
開發者ID:gocd-contrib,項目名稱:github-oauth-authorization-plugin,代碼行數:22,代碼來源:MembershipChecker.java

示例2: isAMemberOfOrganization

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private boolean isAMemberOfOrganization(GithubPluginSettings pluginSettings, User user) {
    try {
        GitHub github = getGitHub(pluginSettings);
        GHUser ghUser = github.getUser(user.getUsername());

        if(ghUser == null) return false;

        for(String orgName: pluginSettings.getGithubOrganizations()) {
            GHOrganization organization = github.getOrganization(orgName);

            if(organization != null && ghUser.isMemberOf(organization)){
                return true;
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Error occurred while trying to check if user is member of organization", e);
    }
    return false;
}
 
開發者ID:gocd-contrib,項目名稱:gocd-oauth-login,代碼行數:20,代碼來源:GitHubProvider.java

示例3: removeRepo

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public synchronized static void removeRepo(String owner, String repoName) throws KaramelException {

    try {
      GitHub gitHub = GitHub.connectUsingPassword(GithubApi.getUser(), GithubApi.getPassword());
      if (!gitHub.isCredentialValid()) {
        throw new KaramelException("Invalid GitHub credentials");
      }
      GHRepository repo = null;
      if (owner.compareToIgnoreCase(GithubApi.getUser()) != 0) {
        GHOrganization org = gitHub.getOrganization(owner);
        repo = org.getRepository(repoName);
      } else {
        repo = gitHub.getRepository(owner + "/" + repoName);
      }
      repo.delete();

    } catch (IOException ex) {
      throw new KaramelException("Problem authenticating with gihub-api when trying to remove a repository");
    }
  }
 
開發者ID:karamelchef,項目名稱:karamel,代碼行數:21,代碼來源:GithubApi.java

示例4: generateArchetypesFromGithubOrganisation

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * Iterates through all projects in the given github organisation and generates an archetype for it
 */
public void generateArchetypesFromGithubOrganisation(String githubOrg, File outputDir, List<String> dirs) throws IOException {
    GitHub github = GitHub.connectAnonymously();
    GHOrganization organization = github.getOrganization(githubOrg);
    Objects.notNull(organization, "No github organisation found for: " + githubOrg);
    Map<String, GHRepository> repositories = organization.getRepositories();
    Set<Map.Entry<String, GHRepository>> entries = repositories.entrySet();

    File cloneParentDir = new File(outputDir, "../git-clones");
    if (cloneParentDir.exists()) {
        Files.recursiveDelete(cloneParentDir);
    }
    for (Map.Entry<String, GHRepository> entry : entries) {
        String repoName = entry.getKey();
        GHRepository repo = entry.getValue();
        String url = repo.getGitTransportUrl();

        generateArchetypeFromGitRepo(outputDir, dirs, cloneParentDir, repoName, url, null);
    }
}
 
開發者ID:fabric8io,項目名稱:ipaas-quickstarts,代碼行數:23,代碼來源:ArchetypeBuilder.java

示例5: checkMembershipUsingPersonalAccessToken

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private boolean checkMembershipUsingPersonalAccessToken(LoggedInUserInfo loggedInUserInfo, AuthConfig authConfig, List<String> organizationsAllowed) throws IOException {
    final GitHub gitHubForPersonalAccessToken = authConfig.gitHubConfiguration().gitHubClient();

    for (String organizationName : organizationsAllowed) {
        final GHOrganization organization = gitHubForPersonalAccessToken.getOrganization(organizationName);
        if (organization != null && organization.hasMember(loggedInUserInfo.getGitHubUser())) {
            LOG.info(format("[MembershipChecker] User `{0}` is a member of `{1}` organization.", loggedInUserInfo.getUser().username(), organizationName));
            return true;
        }
    }

    return false;
}
 
開發者ID:gocd-contrib,項目名稱:github-oauth-authorization-plugin,代碼行數:14,代碼來源:MembershipChecker.java


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