Skip to content

Commit

Permalink
Merge branch '110-some-dependencies-fail' into 'master'
Browse files Browse the repository at this point in the history
Resolve "Some dependencies fail"

Closes #110

See merge request terminology/OLS!68
  • Loading branch information
Erhun Giray TUNCAY committed Aug 20, 2024
2 parents a9794b9 + 99f5213 commit 62ab201
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 100 deletions.
7 changes: 0 additions & 7 deletions ols-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.kohsuke/github-api -->
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.70</version>
</dependency>

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> 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<Release> 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<Release> releasesWithRawUrls = new ArrayList<Release>();
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<GHTag> tags = repo.listTags().asList();
List<GHRelease> releases = repo.getReleases();
for(GHRelease ghr : releases) {
Set<String> downloadUrls = new HashSet<String>();

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<Release> releasesGithubREST(String repoUrl, String externalToken, RepoFilterEnum filter, String keyword){
StringBuilder token = new StringBuilder();
Expand Down
4 changes: 2 additions & 2 deletions ontology-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.0</version>
<version>2.9.1</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.0</version>
<version>2.9.1</version>
</dependency>

</dependencies>
Expand Down

0 comments on commit 62ab201

Please sign in to comment.