public CollaboratorMinerV3(final IGitHubClient ghc) { super(); service = new CollaboratorService(ghc); }
/** * Is given user a collaborator on the given repository? * * @param repository * @param user * @return true if collaborator, false otherwise * @throws IOException */ public boolean isCollaborator(IRepositoryIdProvider repository, String user) throws IOException { return check(createUpdateUri(repository, user)); }
/** * Get collaborators for given repository * * @param repository * @return non-null list of collaborators * @throws IOException */ public List<User> getCollaborators(IRepositoryIdProvider repository) throws IOException { String id = getId(repository); StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COLLABORATORS); PagedRequest<User> request = createPagedRequest(); request.setUri(uri); request.setType(new TypeToken<List<User>>() { }.getType()); return getAll(request); }
/** * Add given user as a collaborator on the given repository * * @param repository * @param user * @throws IOException */ public void addCollaborator(IRepositoryIdProvider repository, String user) throws IOException { client.put(createUpdateUri(repository, user)); }
public List<User> getCollaborators(final IRepositoryIdProvider repo) { List<User> collaborators = null; try { collaborators = service.getCollaborators(repo); } catch (IOException e) { log.error("IOException in getting watchers for repository: {}", repo.generateId(), e); } return collaborators; } }
/** * Create URI for updating collaborators * * @param repository * @param user * @return URI */ protected String createUpdateUri(IRepositoryIdProvider repository, String user) { String id = getId(repository); 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_REPOS); uri.append('/').append(id); uri.append(SEGMENT_COLLABORATORS); uri.append('/').append(user); return uri.toString(); }
/** * Remove given user as a collaborator on the given repository * * @param repository * @param user * @throws IOException */ public void removeCollaborator(IRepositoryIdProvider repository, String user) throws IOException { client.delete(createUpdateUri(repository, user)); } }