本文整理匯總了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;
}
示例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;
}
示例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");
}
}
示例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);
}
}
示例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;
}