use of org.kohsuke.github.GHTree in project nextprot-api by calipho-sib.
the class GitHubServiceImpl method getNews.
@Override
@Cacheable(value = "github-news")
public List<NextProtNews> getNews() {
List<NextProtNews> news = new ArrayList<>();
try {
GitHub github = getGitHubConnection();
GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
GHTree tree = repo.getTreeRecursive(githubDocBranch, 1);
newsFileNames.clear();
for (GHTreeEntry te : tree.getTree()) {
if (te.getPath().startsWith("news")) {
// Add only file on news
if (te.getType().equalsIgnoreCase("blob")) {
// file
String fileName = te.getPath().replaceAll("news/", "");
NextProtNews n = parseGitHubNewsFilePath(fileName);
if (n != null) {
news.add(n);
String fileEncoded = URLEncoder.encode(fileName.replace(".md", ""), "UTF-8").replace("+", "%20");
newsFileNames.put(n.getUrl(), fileEncoded);
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
throw new NextProtException("News not available, sorry for the inconvenience");
}
Collections.sort(news);
return news;
}
use of org.kohsuke.github.GHTree in project faber by mkuschov.
the class GitLoader method GetWatchedReposTrees.
public HashMap<GHRepository, HashMap<GHBranch, GHTree>> GetWatchedReposTrees() {
HashMap<GHRepository, HashMap<GHBranch, GHTree>> watchedReposTrees = new HashMap<>();
this.watchedRepos.forEach(i -> {
HashMap<GHBranch, GHTree> tmp = new HashMap<>();
try {
i.getBranches().forEach((name, branch) -> {
try {
GHTree urlToBracnhTree = i.getTreeRecursive(branch.getSHA1(), 1);
tmp.put(branch, urlToBracnhTree);
System.out.println(i.getName() + " " + branch.getName() + " " + urlToBracnhTree.toString());
} catch (IOException e) {
e.printStackTrace();
}
});
watchedReposTrees.put(i, tmp);
} catch (IOException e) {
e.printStackTrace();
}
});
return watchedReposTrees;
}
Aggregations