public OrganizationMinerV3(final IGitHubClient ghc) { super(); service = new OrganizationService(ghc); }
/** * Get organizations that the currently authenticated user is a member of * * @return list of organizations * @throws IOException */ public List<User> getOrganizations() throws IOException { PagedRequest<User> request = createOrgRequest(null, PAGE_FIRST, PAGE_SIZE); return getAll(request); }
public Collection<User> getMembers(final String organization) { Collection<User> members = null; try { members = service.getMembers(organization); } catch (IOException e) { log.error("IOException getting organization members for {}: {}", organization, e); } return members; }
OrganizationService orgService = new OrganizationService(client); List<User> organizations = orgService.getOrganizations(); for (User org : organizations) { gho = new GitHubOrganization();
/** * Get members of organization * * @param organization * @return list of all organization members * @throws IOException */ public List<User> getMembers(String organization) throws IOException { if (organization == null) throw new IllegalArgumentException("Organization cannot be null"); //$NON-NLS-1$ if (organization.length() == 0) throw new IllegalArgumentException("Organization cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_ORGS); uri.append('/').append(organization); uri.append(SEGMENT_MEMBERS); PagedRequest<User> request = createPagedRequest(); request.setUri(uri); request.setType(new TypeToken<List<User>>() { }.getType()); return getAll(request); }
/** * Check if the given user is a member of the given organization * * @param organization * @param user * @return true if member, false if not member * @throws IOException */ public boolean isMember(String organization, String user) throws IOException { if (organization == null) throw new IllegalArgumentException("Organization cannot be null"); //$NON-NLS-1$ if (organization.length() == 0) throw new IllegalArgumentException("Organization cannot be empty"); //$NON-NLS-1$ if (user == null) throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$ if (user.length() == 0) throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_ORGS); uri.append('/').append(organization); uri.append(SEGMENT_MEMBERS); uri.append('/').append(user); return check(uri.toString()); }
public User getOrganization(final String organization) { User org = null; try { org = service.getOrganization(organization); } catch (IOException e) { log.error("IOException getting organization {}: {}", organization, e); } return org; } }
public Collection<User> getPublicMembers(final String organization) { Collection<User> members = null; try { members = service.getPublicMembers(organization); } catch (IOException e) { log.error("IOException getting public organization members for {}: {}", organization, e); } return members; }
/** * Get organization with the given name * * @param name * @return organization * @throws IOException */ public User getOrganization(String name) throws IOException { if (name == null) throw new IllegalArgumentException("Name cannot be null"); //$NON-NLS-1$ if (name.length() == 0) throw new IllegalArgumentException("Name cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_ORGS); uri.append('/').append(name); GitHubRequest request = createRequest(); request.setUri(uri); request.setType(User.class); return (User) client.get(request).getBody(); }
/** * Get public members of organization * * @param organization * @return list of public organization members * @throws IOException */ public List<User> getPublicMembers(String organization) throws IOException { if (organization == null) throw new IllegalArgumentException("Organization cannot be null"); //$NON-NLS-1$ if (organization.length() == 0) throw new IllegalArgumentException("Organization cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_ORGS); uri.append('/').append(organization); uri.append(SEGMENT_PUBLIC_MEMBERS); PagedRequest<User> request = createPagedRequest(); request.setUri(uri); request.setType(new TypeToken<List<User>>() { }.getType()); return getAll(request); }
/** * Check if the given user is a public member of the given organization * * @param organization * @param user * @return true if public member, false if not public member * @throws IOException */ public boolean isPublicMember(String organization, String user) throws IOException { if (organization == null) throw new IllegalArgumentException("Organization cannot be null"); //$NON-NLS-1$ if (organization.length() == 0) throw new IllegalArgumentException("Organization cannot be empty"); //$NON-NLS-1$ if (user == null) throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$ if (user.length() == 0) throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(SEGMENT_ORGS); uri.append('/').append(organization); uri.append(SEGMENT_PUBLIC_MEMBERS); uri.append('/').append(user); return check(uri.toString()); }
/** * Get organizations that the given user is a member of * * @param user * @return list of organizations * @throws IOException */ public List<User> getOrganizations(String user) throws IOException { if (user == null) throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$ if (user.length() == 0) throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$ PagedRequest<User> request = createOrgRequest(user, PAGE_FIRST, PAGE_SIZE); return getAll(request); }