org.eclipse.egit.github.core.client.GitHubClient Java Examples

The following examples show how to use org.eclipse.egit.github.core.client.GitHubClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitHubSourceConnector.java    From apicurio-studio with Apache License 2.0 6 votes vote down vote up
/**
 * @see io.apicurio.hub.api.github.IGitHubSourceConnector#getBranches(java.lang.String, java.lang.String)
 */
@Override
public Collection<SourceCodeBranch> getBranches(String org, String repo)
        throws GitHubException, SourceConnectorException {
    logger.debug("Getting the branches from {} / {}", org, repo);
    Collection<SourceCodeBranch> rval = new HashSet<>();
    try {
        GitHubClient client = githubClient();
        
        RepositoryService repoService = new RepositoryService(client);
        Repository repository = repoService.getRepository(org, repo);
        List<RepositoryBranch> branches = repoService.getBranches(repository);
        for (RepositoryBranch branch : branches) {
            SourceCodeBranch ghBranch = new SourceCodeBranch();
            ghBranch.setName(branch.getName());
            ghBranch.setCommitId(branch.getCommit().getSha());
            rval.add(ghBranch);
        }
    } catch (IOException e) {
        logger.error("Error getting GitHub branches.", e);
        throw new GitHubException("Error getting GitHub branches.", e);
    }
    return rval;
}
 
Example #2
Source File: RepoTask.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();

    adapter = fragment.getRepoItemAdapter();
    list = fragment.getRepoItemList();

    GitHubClient client = fragment.getClient();
    service = new RepositoryService(client);

    if (flag == Flag.REPO_FIRST) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
    }
}
 
Example #3
Source File: StarContentTask.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();

    adapter = fragment.getContentItemAdapter();
    list = fragment.getContentItemList();
    bookmark = fragment.getBookmark();

    GitHubClient client = fragment.getClient();
    dataService = new DataService(client);
    owner = fragment.getOwner();
    name = fragment.getName();
    root = fragment.getRoot();
    entry = fragment.getEntry();

    if (flag == Flag.STAR_CONTENT_FIRST || flag == Flag.STAR_CONTENT_REFRESH) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
        bookmark.setVisible(false);
    }
}
 
Example #4
Source File: RepoContentTask.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();

    adapter = fragment.getContentItemAdapter();
    list = fragment.getContentItemList();
    bookmark = fragment.getBookmark();

    GitHubClient client = fragment.getClient();
    dataService = new DataService(client);
    owner = fragment.getOwner();
    name = fragment.getName();
    root = fragment.getRoot();
    entry = fragment.getEntry();

    if (flag == Flag.REPO_CONTENT_FIRST || flag == Flag.REPO_CONTENT_REFRESH) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
        bookmark.setVisible(false);
    }
}
 
Example #5
Source File: RepoTask.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    mainFragment.setRefreshStatus(true);
    context = mainFragment.getContentView().getContext();
    refreshType = mainFragment.getRefreshType();

    GitHubClient gitHubClient = mainFragment.getGitHubClient();
    repositoryService = new RepositoryService(gitHubClient);

    repoItemAdapter = mainFragment.getRepoItemAdapter();
    repoItemList = mainFragment.getRepoItemList();

    if (refreshType == RefreshType.REPO_FIRST) {
        mainFragment.setContentShown(false);
    }
}
 
Example #6
Source File: GitHubGovernorClientFactory.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Override
public GitHubGovernorClient build(
        GitHubGovernorConfiguration governorConfiguration) throws Exception {
    Validate.notNull(governorConfiguration, "GitHub governor configuration has to be set.");
    this.gitHubGovernorConfiguration = governorConfiguration;

    final GitHubClient gitHubClient = new GitHubClient();
    if (this.gitHubGovernorConfiguration.getUsername() != null && this.gitHubGovernorConfiguration.getUsername().length() > 0 && this.gitHubGovernorConfiguration.getPassword() != null && this.gitHubGovernorConfiguration.getPassword().length() > 0) {
        gitHubClient.setCredentials(this.gitHubGovernorConfiguration.getUsername(), this.gitHubGovernorConfiguration.getPassword());
    }

    if (this.gitHubGovernorConfiguration.getToken() != null && this.gitHubGovernorConfiguration.getToken().length() > 0) {
        gitHubClient.setOAuth2Token(gitHubGovernorConfiguration.getToken());
    }

    final GitHubGovernorClient gitHubGovernorClient = new GitHubGovernorClient(gitHubClient, gitHubGovernorConfiguration);
    gitHubGovernorClient.setGovernorStrategy(new GitHubGovernorStrategy(this.gitHubGovernorConfiguration));

    return gitHubGovernorClient;
}
 
Example #7
Source File: ContentTask.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    mainFragment.setRefreshStatus(true);

    context = mainFragment.getContentView().getContext();

    refreshType = mainFragment.getRefreshType();

    GitHubClient gitHubClient = mainFragment.getGitHubClient();
    contentsService = new ContentsService(gitHubClient);
    String repoOwner = mainFragment.getRepoOwner();
    String repoName = mainFragment.getRepoName();
    repositoryId = RepositoryId.create(repoOwner, repoName);
    repoPath = mainFragment.getRepoPath();

    contentItemAdapter = mainFragment.getContentItemAdapter();
    contentItemList = mainFragment.getContentItemList();
    contentItemListBuffer = mainFragment.getContentItemListBuffer();

    mainFragment.setContentShown(false);
}
 
Example #8
Source File: RepoTask.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();

    adapter = fragment.getRepoItemAdapter();
    list = fragment.getRepoItemList();

    GitHubClient client = fragment.getClient();
    service = new RepositoryService(client);

    if (flag == Flag.REPO_FIRST) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
    }
}
 
Example #9
Source File: GitHubSourceConnector.java    From apicurio-studio with Apache License 2.0 6 votes vote down vote up
/**
 * @throws SourceConnectorException
 */
private GitHubClient githubClient() throws SourceConnectorException {
    try {
        String ghUrl = config.getGitHubApiUrl();

        URI url = new URI(ghUrl);
        String host = url.getHost();
        int port = url.getPort();
        String scheme = url.getScheme();
        
        GitHubClient client = new GitHubClient(host, port, scheme);
        String idpToken = getExternalToken();
        client.setOAuth2Token(idpToken);
        return client;
    } catch (URISyntaxException e) {
        throw new SourceConnectorException("Error creating the GitHub client.", e);
    }
}
 
Example #10
Source File: StarContentTask.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();

    adapter = fragment.getContentItemAdapter();
    list = fragment.getContentItemList();
    bookmark = fragment.getBookmark();

    GitHubClient client = fragment.getClient();
    dataService = new DataService(client);
    owner = fragment.getOwner();
    name = fragment.getName();
    root = fragment.getRoot();
    entry = fragment.getEntry();

    if (flag == Flag.STAR_CONTENT_FIRST || flag == Flag.STAR_CONTENT_REFRESH) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
        bookmark.setVisible(false);
    }
}
 
Example #11
Source File: RepoContentTask.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();
    flag = fragment.getFlag();

    adapter = fragment.getContentItemAdapter();
    list = fragment.getContentItemList();
    bookmark = fragment.getBookmark();

    GitHubClient client = fragment.getClient();
    dataService = new DataService(client);
    owner = fragment.getOwner();
    name = fragment.getName();
    root = fragment.getRoot();
    entry = fragment.getEntry();

    if (flag == Flag.REPO_CONTENT_FIRST || flag == Flag.REPO_CONTENT_REFRESH) {
        fragment.setContentEmpty(false);
        fragment.setContentShown(false);
        bookmark.setVisible(false);
    }
}
 
Example #12
Source File: GenerateRoadmapIssuesTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Test
public void createIssuesStepB() throws Exception {

    String accessToken = System.getenv("GitHubAccessToken");
    Assume.assumeNotNull("GitHubAccessToken not null", accessToken);

    GitHubClient client = new GitHubClient();
    client.setOAuth2Token(accessToken);

    String githubUser = "wildfly-extras";
    String githubRepo = "wildfly-camel";

    Milestone milestone = null;
    MilestoneService milestoneService = new MilestoneService(client);
    for (Milestone aux : milestoneService.getMilestones(githubUser, githubRepo, IssueService.STATE_OPEN)) {
        if  (aux.getTitle().equals(MILESTONE)) {
            milestone = aux;
            break;
        }
    }
    Assert.assertNotNull("Milestone not null", milestone);

    IssueService issueService = new IssueService(client);
    try (BufferedReader br = new BufferedReader(new FileReader(auxfile.toFile()))) {
        String line = br.readLine();
        while (line != null) {
            String title = "Add support for " + line;
            System.out.println(title);
            Issue issue = new Issue();
            issue.setTitle(title);
            issue.setLabels(Collections.singletonList(LABEL));
            issue.setMilestone(milestone);
            issueService.createIssue(githubUser, githubRepo, issue);
            line = br.readLine();
            Thread.sleep(3 * 1000);
        }
    }
}
 
Example #13
Source File: AddTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();

    GitHubClient client = fragment.getClient();
    service = new RepositoryService(client);

    pull = fragment.getPull();

    listView = fragment.getListView();
    adapter = fragment.getRepoItemAdapter();
    list = fragment.getRepoItemList();

    pull.setRefreshing(true);
}
 
Example #14
Source File: AddTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    context = fragment.getContentView().getContext();

    GitHubClient client = fragment.getClient();
    service = new RepositoryService(client);

    pull = fragment.getPull();

    listView = fragment.getListView();
    adapter = fragment.getRepoItemAdapter();
    list = fragment.getRepoItemList();

    pull.setRefreshing(true);
}
 
Example #15
Source File: StarTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    adapter = fragment.getStarItemAdapter();
    list = fragment.getStarItemList();
    bookmark = fragment.getBookmark();

    GitHubClient client = fragment.getClient();
    service = new WatcherService(client);

    fragment.setContentEmpty(false);
    fragment.setContentShown(false);
    bookmark.setVisible(false);
}
 
Example #16
Source File: GitHub.java    From opoopress with Apache License 2.0 5 votes vote down vote up
/**
 * Create client
 * <p>
 * Subclasses can override to do any custom client configuration
 *
 * @param hostname
 * @return non-null client
 * @throws MojoExecutionException
 */
private GitHubClient createClient(String hostname)	throws GitHubException {
	if (!hostname.contains("://"))
		return new GitHubClient(hostname);
	try {
		URL hostUrl = new URL(hostname);
		return new GitHubClient(hostUrl.getHost(), hostUrl.getPort(), hostUrl.getProtocol());
	} catch (MalformedURLException e) {
		throw new GitHubException("Could not parse host URL " + hostname, e);
	}
}
 
Example #17
Source File: GitHubService.java    From repositoryminer with Apache License 2.0 5 votes vote down vote up
@Override
public void connect(WebSCMConfig config) {
	GitHubClient client = new GitHubClient();
	client.setCredentials(config.getUsername(), config.getToken());
	
	this.repositoryId = new RepositoryId(config.getOwner(), config.getName());
	this.issueServ = new IssueService(client);
	this.milestoneServ = new MilestoneService(client);
}
 
Example #18
Source File: CommitTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    flag = fragment.getFlag();

    GitHubClient client = fragment.getClient();
    commitService = new CommitService(client);

    adapter = fragment.getCommitItemAdapter();
    list = fragment.getCommitItemList();

    fragment.setContentShown(false);
}
 
Example #19
Source File: CommitTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    flag = fragment.getFlag();

    GitHubClient client = fragment.getClient();
    commitService = new CommitService(client);

    adapter = fragment.getCommitItemAdapter();
    list = fragment.getCommitItemList();

    fragment.setContentShown(false);
}
 
Example #20
Source File: AddTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    mainFragment.getPullToRefreshLayout().setRefreshing(true);

    context = mainFragment.getContentView().getContext();
    GitHubClient gitHubClient = mainFragment.getGitHubClient();
    repositoryService = new RepositoryService(gitHubClient);

    repoItemAdapter = mainFragment.getRepoItemAdapter();
    repoItemList = mainFragment.getRepoItemList();
}
 
Example #21
Source File: WatchTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    mainFragment.setRefreshStatus(true);
    context = mainFragment.getContentView().getContext();

    GitHubClient gitHubClient = mainFragment.getGitHubClient();
    watcherService = new WatcherService(gitHubClient);

    watchItemAdapter = mainFragment.getWatchItemAdapter();
    watchItemList = mainFragment.getWatchItemList();

    mainFragment.setContentShown(false);
}
 
Example #22
Source File: WebViewFragment.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setContentView(R.layout.webview_fragment);
    setContentShown(true);

    View view = getContentView();
    webView = (WebView) view.findViewById(R.id.webview_fragment);
    /* Do something */
    WebSettings webSettings = webView.getSettings();
    webSettings.setBuiltInZoomControls(true);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS.NORMAL);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setSupportMultipleWindows(true);
    webSettings.setSupportZoom(true);
    webSettings.setUseWideViewPort(true);

    SharedPreferences sharedPreferences = getActivity().getSharedPreferences(getString(R.string.login_sp), Context.MODE_PRIVATE);
    String oAuth = sharedPreferences.getString(getString(R.string.login_sp_oauth), null);

    gitHubClient = new GitHubClient();
    gitHubClient.setOAuth2Token(oAuth);

    Intent intent = getActivity().getIntent();
    repoOwner = intent.getStringExtra(getString(R.string.content_intent_repoowner));
    repoName = intent.getStringExtra(getString(R.string.content_intent_reponame));
    fileName = intent.getStringExtra(getString(R.string.content_intent_filename));
    sha = intent.getStringExtra(getString(R.string.content_intent_sha));

    webViewTask = new WebViewTask(WebViewFragment.this);
    webViewTask.execute();
}
 
Example #23
Source File: WebViewFragment.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setContentView(R.layout.webview_fragment);
    setContentEmpty(false);
    setContentShown(true);

    View view = getContentView();
    webView = (WebView) view.findViewById(R.id.webview);

    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS.NORMAL);
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setDisplayZoomControls(false);

    SharedPreferences preferences = getActivity().getSharedPreferences(getString(R.string.login_sp), Context.MODE_PRIVATE);
    String OAuth = preferences.getString(getString(R.string.login_sp_oauth), null);

    client = new GitHubClient();
    client.setOAuth2Token(OAuth);

    Intent intent = getActivity().getIntent();
    owner = intent.getStringExtra(getString(R.string.webview_intent_owner));
    name = intent.getStringExtra(getString(R.string.webview_intent_name));
    sha = intent.getStringExtra(getString(R.string.webview_intent_sha));
    filename = intent.getStringExtra(getString(R.string.webview_intent_title));

    task = new WebViewTask(WebViewFragment.this);
    task.execute();
}
 
Example #24
Source File: CommitTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    mainFragment.setContentShown(false);
    mainFragment.setRefreshStatus(true);

    context = mainFragment.getContentView().getContext();

    GitHubClient gitHubClient = mainFragment.getGitHubClient();
    repositoryService = new RepositoryService(gitHubClient);
    commitService = new CommitService(gitHubClient);

    commitItemAdapter = mainFragment.getCommitItemAdapter();
    commitItemList = mainFragment.getCommitItemList();
}
 
Example #25
Source File: StarTask.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPreExecute() {
    adapter = fragment.getStarItemAdapter();
    list = fragment.getStarItemList();
    bookmark = fragment.getBookmark();

    GitHubClient client = fragment.getClient();
    service = new WatcherService(client);

    fragment.setContentEmpty(false);
    fragment.setContentShown(false);
    bookmark.setVisible(false);
}
 
Example #26
Source File: WebViewFragment.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setContentView(R.layout.webview_fragment);
    setContentEmpty(false);
    setContentShown(true);

    View view = getContentView();
    webView = (WebView) view.findViewById(R.id.webview);

    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS.NORMAL);
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setDisplayZoomControls(false);

    SharedPreferences preferences = getActivity().getSharedPreferences(getString(R.string.login_sp), Context.MODE_PRIVATE);
    String OAuth = preferences.getString(getString(R.string.login_sp_oauth), null);

    client = new GitHubClient();
    client.setOAuth2Token(OAuth);

    Intent intent = getActivity().getIntent();
    owner = intent.getStringExtra(getString(R.string.webview_intent_owner));
    name = intent.getStringExtra(getString(R.string.webview_intent_name));
    sha = intent.getStringExtra(getString(R.string.webview_intent_sha));
    filename = intent.getStringExtra(getString(R.string.webview_intent_title));

    task = new WebViewTask(WebViewFragment.this);
    task.execute();
}
 
Example #27
Source File: GithubImporter.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private List<String> getGradleDependencies(GitHubClient client, Repository rep)
		throws IOException, XmlPullParserException, InterruptedException {
	String repoFullName = rep.getOwner().getLogin() + "/" + rep.getName();
	List<String> pomPath = new ArrayList<>();
	InputStream searchPomFiles = null;
	try {
		searchPomFiles = new URL("https://api.github.com/search/code?q=filename:build.gradle+repo:" + repoFullName
				+ "&access_token=" + this.token).openStream();
	} catch (Exception e) {

		logger.debug("sleep time");
		Thread.sleep(60000);
		logger.debug("wakeup");
		searchPomFiles = new URL("https://api.github.com/search/code?q=filename:build.gradle+repo:" + repoFullName
				+ "&access_token=" + this.token).openStream();
	}
	BufferedReader searchPomresults = new BufferedReader(
			new InputStreamReader(searchPomFiles, Charset.forName(UTF8)));
	String jsonSearchPom = readAll(searchPomresults);
	JSONObject pomContentsResults = (JSONObject) JSONValue.parse(jsonSearchPom);
	long i = (long) pomContentsResults.get("total_count");
	if (i > 0) {
		JSONArray pomFiles = (JSONArray) pomContentsResults.get("items");
		for (Object object : pomFiles) {
			JSONObject pomFile = (JSONObject) object;
			pomPath.add((String) pomFile.get("path"));
		}
	}
	return getGradleDependencies(client, rep, pomPath);
}
 
Example #28
Source File: GitHubSourceConnector.java    From apicurio-studio with Apache License 2.0 5 votes vote down vote up
/**
 * @see io.apicurio.hub.api.github.IGitHubSourceConnector#getRepositories(java.lang.String)
 */
@Override
public Collection<GitHubRepository> getRepositories(String org) throws GitHubException, SourceConnectorException {
    logger.debug("Getting the repositories from organization {}", org);
    Collection<GitHubRepository> rval = new HashSet<>();
    try {
        GitHubClient client = githubClient();

        // First get the user's login id
        UserService userService = new UserService(client);
        User user = userService.getUser();
        String userLogin = user.getLogin();

        // Get the Org/User repositories
        RepositoryService repoService = new RepositoryService(client);
        List<Repository> repositories = null;
        if (org.equals(userLogin)) {
            Map<String, String> filters = new HashMap<String, String>();
            filters.put("affiliation", "owner");
            filters.put("visibility", "all");
            repositories = repoService.getRepositories(filters);
        } else {
            repositories = repoService.getOrgRepositories(org);
        }
        
        for (Repository repository : repositories) {
            GitHubRepository ghrepo = new GitHubRepository();
            ghrepo.setName(repository.getName());
            ghrepo.setPriv(repository.isPrivate());
            rval.add(ghrepo);
        }
    } catch (IOException e) {
        logger.error("Error getting GitHub repositories.", e);
        throw new GitHubException("Error getting GitHub repositories.", e);
    }
    return rval;
}
 
Example #29
Source File: GitHubExporter.java    From rtc2jira with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void initialize(Settings settings, StorageEngine engine) throws IOException {
  this.store = new GitHubStorage(engine);
  this.client = new GitHubClient();
  this.service = new RepositoryService(client);
  this.issueService = new IssueService(client);
  client.setCredentials(settings.getGithubUser(), settings.getGithubPassword());
  client.setOAuth2Token(settings.getGithubToken());
  repository = service.getRepository(settings.getGithubRepoOwner(), settings.getGithubRepoName());
}
 
Example #30
Source File: GitHubSourceConnector.java    From apicurio-studio with Apache License 2.0 5 votes vote down vote up
/**
 * @see io.apicurio.hub.api.github.IGitHubSourceConnector#getOrganizations()
 */
@Override
public Collection<GitHubOrganization> getOrganizations() throws GitHubException, SourceConnectorException {
    logger.debug("Getting organizations for current user.");
    Collection<GitHubOrganization> rval = new HashSet<>();
    try {
        GitHubClient client = githubClient();
        
        // Add the user's personal org
        UserService userService = new UserService(client);
        User user = userService.getUser();
        GitHubOrganization gho = new GitHubOrganization();
        gho.setUserOrg(true);
        gho.setId(user.getLogin());
        rval.add(gho);
        
        // Now all the user's orgs
        OrganizationService orgService = new OrganizationService(client);
        List<User> organizations = orgService.getOrganizations();
        for (User org : organizations) {
            gho = new GitHubOrganization();
            gho.setUserOrg(false);
            gho.setId(org.getLogin());
            rval.add(gho);
        }
    } catch (IOException e) {
        logger.error("Error getting GitHub organizations.", e);
        throw new GitHubException("Error getting GitHub organizations.", e);
    }
    return rval;
}