public GHOrganization loadOrganization(String organization) throws IOException { if (gh != null && isAuthenticated()) return gh.getOrganization(organization); else return null; }
@SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, justification = "The field comes from JSON deserialization") public GHOrganization getOrganization() throws IOException { return (org==null || org.getLogin()==null) ? null : root.getOrganization(org.getLogin()); }
@SuppressFBWarnings(value = {"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" }, justification = "The field comes from JSON deserialization") public GHOrganization getOrganization() throws IOException { return (org==null || org.getLogin()==null) ? null : root.getOrganization(org.getLogin()); }
public GHTeam loadTeam(String organization, String team) throws IOException { if (gh != null && isAuthenticated()) { GHOrganization org = gh.getOrganization(organization); if (org != null) { Map<String, GHTeam> teamMap = org.getTeams(); return teamMap.get(team); } else return null; } else return null; } }
public boolean isUserMemberOfOrganization(String organisation, GHUser member) { boolean orgHasMember = false; try { GHOrganization org = trigger.getGitHub().getOrganization(organisation); orgHasMember = org.hasMember(member); LOGGER.log(Level.FINE, "org.hasMember(member)? user:{0} org: {1} == {2}", new Object[] {member.getLogin(), organisation, orgHasMember ? "yes" : "no"}); } catch (IOException ex) { LOGGER.log(Level.SEVERE, null, ex); return false; } return orgHasMember; }
/** * If this repository belongs to an organization, return a set of teams. */ public Set<GHTeam> getTeams() throws IOException { return Collections.unmodifiableSet(new HashSet<GHTeam>(Arrays.asList(GHTeam.wrapUp(root.retrieve().to(getApiTailUrl("teams"), GHTeam[].class), root.getOrganization(owner.login))))); }
/** * If this repository belongs to an organization, return a set of teams. */ public Set<GHTeam> getTeams() throws IOException { return Collections.unmodifiableSet(new HashSet<GHTeam>(Arrays.asList(GHTeam.wrapUp(root.retrieve().to(getApiTailUrl("teams"), GHTeam[].class), root.getOrganization(getOwnerName()))))); }
public boolean isUserMemberOfOrganization(String organisation, GHUser member) throws IOException { boolean orgHasMember; //TODO check for null member GitHub github = githubFor(URI.create(member.getHtmlUrl().toString())); orgHasMember = github.getOrganization(organisation).hasMember(member); LOGGER.debug("org.hasMember(member)? user:'{}' org: '{}' == '{}'", member.getLogin(), organisation, orgHasMember ? "yes" : "no"); return orgHasMember; }
public Iterable<GHRepository> getRepositories(final String orgName) { try { if (orgName.equals(this.user.getLogin())) { return this.gh.getMyself().listRepositories(); } else { return this.gh.getOrganization(orgName).listRepositories(); } } catch (final IOException e) { throw new RuntimeException(e); } }
public void scanOrganization(String name) { try { logger.info("scanning org: {}",name); GHOrganization org = getGitHubClient().getOrganization(name); scanOrganization(org); } catch (IOException e) { throw new MercatorException(e); } }
/** * If this repository belongs to an organization, return a set of teams. */ public Set<GHTeam> getTeams() throws IOException { return Collections.unmodifiableSet(new HashSet<GHTeam>(Arrays.asList(GHTeam.wrapUp(root.retrieve().to(getApiTailUrl("teams"), GHTeam[].class), root.getOrganization(getOwnerName()))))); }
private void retrieveRepositoryNames() throws IOException { System.err.println("Retrieving GitHub repository names..."); Cache cache = new Cache(GITHUB_API_CACHE, 20L*1024*1024); // 20 MB cache github = new GitHubBuilder().withConnector(new OkHttp3Connector(new OkUrlFactory(new OkHttpClient.Builder().cache(cache).build()))).withPassword(GITHUB_API_USERNAME, GITHUB_API_PASSWORD).build(); List<String> ret = new ArrayList<>(); for (GHRepository repo : github.getOrganization("jenkinsci").listRepositories().withPageSize(100)) { ret.add(repo.getHtmlUrl().toString()); } Files.write(GITHUB_REPO_LIST.toPath(), ret); }
@Override public Snapshot call() throws Exception { logger.info("Taking snapshot of organization '{}'.", organisationName); final OrganizationWrapper organization = new OrganizationWrapper(gitHub.getOrganization(organisationName)); Snapshot snapshot = new Snapshot( collectStatistics(organization), collectProjects(organization), collectContributors(organization), collectLanguages(organization)); logger.info("Successfully taken snapshot of organization '{}'.", organisationName); return snapshot; }
/** * Gets the organization that this user belongs to. */ public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException { GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>(); Set<String> names = new HashSet<String>(); for (GHOrganization o : root.retrieve().to("/user/orgs", GHOrganization[].class)) { if (names.add(o.getLogin())) // in case of rumoured duplicates in the data orgs.add(root.getOrganization(o.getLogin())); } return orgs; }
@Override public List<Repository> getRepositories(String accessToken, String organizationName) throws IOException, ServiceException { GitHub gitHub = GitHub.connectUsingOAuth(accessToken); GHPerson person = StringUtils.isBlank(organizationName) ? gitHub.getMyself() : gitHub.getOrganization(organizationName); return person.listRepositories().asList().stream().map(repository -> { Repository repo = new Repository(repository.getName()); repo.setPrivate(repository.isPrivate()); repo.setUrl(repository.getHtmlUrl().toString()); return repo; }).collect(Collectors.toList()); }
/** * Gets the organization that this user belongs to. */ public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException { GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>(); Set<String> names = new HashSet<String>(); for (GHOrganization o : root.retrieve().to("/user/orgs", GHOrganization[].class)) { if (names.add(o.getLogin())) // in case of rumoured duplicates in the data orgs.add(root.getOrganization(o.getLogin())); } return orgs; }
/** * Gets the organization that this user belongs to. */ public GHPersonSet<GHOrganization> getAllOrganizations() throws IOException { GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>(); Set<String> names = new HashSet<String>(); for (GHOrganization o : root.retrieve().to("/user/orgs", GHOrganization[].class)) { if (names.add(o.getLogin())) // in case of rumoured duplicates in the data orgs.add(root.getOrganization(o.getLogin())); } return orgs; }
/** * Gets the organization that this user belongs to publicly. */ @WithBridgeMethods(Set.class) public GHPersonSet<GHOrganization> getOrganizations() throws IOException { GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>(); Set<String> names = new HashSet<String>(); for (GHOrganization o : root.retrieve().to("/users/" + login + "/orgs", GHOrganization[].class)) { if (names.add(o.getLogin())) // I've seen some duplicates in the data orgs.add(root.getOrganization(o.getLogin())); } return orgs; }
/** * Gets the organization that this user belongs to publicly. */ @WithBridgeMethods(Set.class) public GHPersonSet<GHOrganization> getOrganizations() throws IOException { GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>(); Set<String> names = new HashSet<String>(); for (GHOrganization o : root.retrieve().to("/users/" + login + "/orgs", GHOrganization[].class)) { if (names.add(o.getLogin())) // I've seen some duplicates in the data orgs.add(root.getOrganization(o.getLogin())); } return orgs; }
/** * Gets the organization that this user belongs to publicly. */ @WithBridgeMethods(Set.class) public GHPersonSet<GHOrganization> getOrganizations() throws IOException { GHPersonSet<GHOrganization> orgs = new GHPersonSet<GHOrganization>(); Set<String> names = new HashSet<String>(); for (GHOrganization o : root.retrieve().to("/users/" + login + "/orgs", GHOrganization[].class)) { if (names.add(o.getLogin())) // I've seen some duplicates in the data orgs.add(root.getOrganization(o.getLogin())); } return orgs; }