From 99f5213954080c20bdc3a756cb6c52c60a5dbd33 Mon Sep 17 00:00:00 2001 From: Erhun Giray TUNCAY Date: Tue, 20 Aug 2024 09:03:31 +0000 Subject: [PATCH] Fully removed kohsuke dependency and upgraded springfox-swagger2 to 2.9.1 to Resolve "Some dependencies fail" --- ols-web/pom.xml | 7 -- .../spot/ols/service/RepoMetadataService.java | 91 ------------------- ontology-tools/pom.xml | 4 +- 3 files changed, 2 insertions(+), 100 deletions(-) diff --git a/ols-web/pom.xml b/ols-web/pom.xml index 31c0ccd6..db550c94 100644 --- a/ols-web/pom.xml +++ b/ols-web/pom.xml @@ -169,13 +169,6 @@ spring-boot-starter-cache - - - org.kohsuke - github-api - 1.70 - - org.json json diff --git a/ols-web/src/main/java/uk/ac/ebi/spot/ols/service/RepoMetadataService.java b/ols-web/src/main/java/uk/ac/ebi/spot/ols/service/RepoMetadataService.java index 276d3dc3..6b41fe38 100644 --- a/ols-web/src/main/java/uk/ac/ebi/spot/ols/service/RepoMetadataService.java +++ b/ols-web/src/main/java/uk/ac/ebi/spot/ols/service/RepoMetadataService.java @@ -22,12 +22,6 @@ import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; -import org.kohsuke.github.GHContent; -import org.kohsuke.github.GHRelease; -import org.kohsuke.github.GHRepository; -import org.kohsuke.github.GHTag; -import org.kohsuke.github.GitHub; -import org.kohsuke.github.GitHubBuilder; import org.springframework.cache.annotation.Cacheable; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; @@ -66,91 +60,6 @@ public static String removePrefix(String s, String prefix) return s; } - public static GHContent traverse (GHContent ghc, String keyword, GHTag tag, GHRepository repo, GHRelease ghr, Set downloadUrls) { - - if (ghc.isFile()) { - try { - downloadUrls.add(repo.getFileContent(ghc.getPath(), tag.getCommit().getSHA1()).getDownloadUrl()); ; - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } else if (ghc.isDirectory()) { - try { - for (GHContent ghc2 : repo.getDirectoryContent(ghc.getPath(),ghr.getTagName())) { - traverse(ghc2,keyword, tag, repo, ghr, downloadUrls); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - return null; - } - - @Cacheable(value = "releases", key="#repoUrl.concat('-').concat('kohsuke').concat('-').concat(#filter).concat('-').concat(#keyword)") - public List releasesKohsuke(String repoUrl, String externalToken, RepoFilterEnum filter, String keyword) { - String userName = ""; - String personalAccessToken = ""; - - if(externalToken != null) - if (externalToken.length() >= 1) - personalAccessToken = externalToken; - if(externalToken == null || externalToken.length() < 1) { - try { - // reads from src/main/resource - InputStream is = new ClassPathResource("/github.com.token.txt").getInputStream(); - try { - String contents = new String(FileCopyUtils.copyToByteArray(is), StandardCharsets.UTF_8); - System.out.println(contents); - personalAccessToken = contents.split("\n")[0]; - userName = contents.split("\n")[1]; - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (is != null) { - is.close(); - } - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - List releasesWithRawUrls = new ArrayList(); - try { - GitHub github = new GitHubBuilder().withOAuthToken(personalAccessToken, userName).build(); - GHRepository repo = null; - if(repoUrl.startsWith("https://github.com/")) - repo = github.getRepository(removePrefix(repoUrl,"https://github.com/")); - else if (repoUrl.startsWith("http://github.com/")) - repo = github.getRepository(removePrefix(repoUrl,"http://github.com/")); - if(repo != null) { - List tags = repo.listTags().asList(); - List releases = repo.getReleases(); - for(GHRelease ghr : releases) { - Set downloadUrls = new HashSet(); - - for (GHTag tag : tags) { - if(tag.getName().equals(ghr.getTagName())) { - for (GHContent ghc : repo.getDirectoryContent("",ghr.getTagName())) { - traverse(ghc,keyword, tag, repo, ghr, downloadUrls); - } - } - } - releasesWithRawUrls.add(addRelease(ghr.getName(), ghr.getHtmlUrl().toString(), ghr.getCreatedAt().toString(),downloadUrls, filter, keyword)); - } - } - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return releasesWithRawUrls; - } - @Cacheable(value = "releases", key="#repoUrl.concat('-').concat('github').concat('-').concat('rest').concat('-').concat(#filter).concat('-').concat(#keyword)") public List releasesGithubREST(String repoUrl, String externalToken, RepoFilterEnum filter, String keyword){ StringBuilder token = new StringBuilder(); diff --git a/ontology-tools/pom.xml b/ontology-tools/pom.xml index dc471b9f..bfa864df 100644 --- a/ontology-tools/pom.xml +++ b/ontology-tools/pom.xml @@ -86,13 +86,13 @@ io.springfox springfox-swagger2 - 2.9.0 + 2.9.1 io.springfox springfox-swagger-ui - 2.9.0 + 2.9.1