Java Code Examples for org.eclipse.egit.github.core.service.RepositoryService#getRepositories()
The following examples show how to use
org.eclipse.egit.github.core.service.RepositoryService#getRepositories() .
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: GithubApi.java From karamel with Apache License 2.0 | 6 votes |
/** * Gets all repositories for a given organization/user. * * @param orgName * @return List of repositories * @throws KaramelException */ public synchronized static List<RepoItem> getRepos(String orgName) throws KaramelException { if (cachedRepos.get(orgName) != null) { return cachedRepos.get(orgName); } try { RepositoryService rs = new RepositoryService(client); List<Repository> repos; // If we are looking for the repositories for the current user if (GithubApi.getUser().equalsIgnoreCase(orgName)) { repos = rs.getRepositories(orgName); } else { // If we are looking for the repositories for a given organization repos = rs.getOrgRepositories(orgName); } List<RepoItem> repoItems = new ArrayList<>(); for (Repository r : repos) { repoItems.add(new RepoItem(r.getName(), r.getDescription(), r.getSshUrl())); } cachedRepos.put(orgName, repoItems); return repoItems; } catch (IOException ex) { throw new KaramelException("Problem listing GitHub repositories: " + ex.getMessage()); } }
Example 2
Source File: ListRepositoriesWorkitemHandler.java From jbpm-work-items with Apache License 2.0 | 5 votes |
public void executeWorkItem(WorkItem workItem, WorkItemManager workItemManager) { try { RequiredParameterValidator.validate(this.getClass(), workItem); Map<String, Object> results = new HashMap<String, Object>(); String user = (String) workItem.getParameter("User"); RepositoryService repoService = auth.getRespositoryService(this.userName, this.password); List<Repository> userRepos = repoService.getRepositories(user); List<RepositoryInfo> resultRepositoryInformation = new ArrayList<>(); if (userRepos != null) { for (Repository repo : userRepos) { resultRepositoryInformation.add(new RepositoryInfo(repo)); } } else { logger.info("No repositories found for " + user); } results.put(RESULTS_VALUE, resultRepositoryInformation); workItemManager.completeWorkItem(workItem.getId(), results); } catch (Exception e) { handleException(e); } }
Example 3
Source File: GitHubSourceConnector.java From apicurio-studio with Apache License 2.0 | 5 votes |
/** * @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; }