diff --git a/jars/interest.jar b/jars/interest.jar
index d452324..0fe3bc9 100644
Binary files a/jars/interest.jar and b/jars/interest.jar differ
diff --git a/pom.xml b/pom.xml
index 2212e67..3d23f0a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
11
1.16.3
- 2.14.0
+ 2.15.1
diff --git a/src/main/java/gr/zisis/interestapi/controller/InterestController.java b/src/main/java/gr/zisis/interestapi/controller/InterestController.java
index fcf5354..3c4d787 100644
--- a/src/main/java/gr/zisis/interestapi/controller/InterestController.java
+++ b/src/main/java/gr/zisis/interestapi/controller/InterestController.java
@@ -6,6 +6,7 @@
import java.util.Objects;
import gr.zisis.interestapi.controller.response.entity.*;
+import gr.zisis.interestapi.domain.AnalysisInfo;
import gr.zisis.interestapi.domain.ProjectDomain;
import gr.zisis.interestapi.service.ProjectsService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -103,9 +104,9 @@ Collection getAnalyzedCommitIds(@RequestParam(required = true) S
@CrossOrigin(origins = "*")
@PostMapping(path = "/startInterestAnalysis", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
- ResponseEntity startInterestAnalysis(@RequestBody(required = true) ProjectDomain project) throws IOException {
+ ResponseEntity startInterestAnalysis(@RequestBody(required = true) AnalysisInfo info) throws IOException {
try {
- return new ResponseEntity<>(projectsService.save(project.getUrl()), HttpStatus.CREATED);
+ return new ResponseEntity<>(projectsService.save(info.getUrl(), info.getToken()), HttpStatus.CREATED);
} catch (IOException | InterruptedException e) {
throw new ServerException("IOException");
}
diff --git a/src/main/java/gr/zisis/interestapi/domain/AnalysisInfo.java b/src/main/java/gr/zisis/interestapi/domain/AnalysisInfo.java
new file mode 100644
index 0000000..3a7ebee
--- /dev/null
+++ b/src/main/java/gr/zisis/interestapi/domain/AnalysisInfo.java
@@ -0,0 +1,57 @@
+package gr.zisis.interestapi.domain;
+
+import java.util.Objects;
+
+/*
+ *
+ * * Copyright (C) 2021 UoM - University of Macedonia
+ * *
+ * * This program and the accompanying materials are made available under the
+ * * terms of the Eclipse Public License 2.0 which is available at
+ * * https://www.eclipse.org/legal/epl-2.0/
+ * *
+ * * SPDX-License-Identifier: EPL-2.0
+ *
+ */
+
+public class AnalysisInfo {
+
+ private String url;
+ private String token;
+
+ public AnalysisInfo() { }
+
+ public AnalysisInfo(String url, String token) {
+ this.url = url;
+ this.token = token;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ AnalysisInfo that = (AnalysisInfo) o;
+ return Objects.equals(url, that.url) && Objects.equals(token, that.token);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(url, token);
+ }
+}
diff --git a/src/main/java/gr/zisis/interestapi/service/ProjectsService.java b/src/main/java/gr/zisis/interestapi/service/ProjectsService.java
index 227e3f9..ce3c8cb 100644
--- a/src/main/java/gr/zisis/interestapi/service/ProjectsService.java
+++ b/src/main/java/gr/zisis/interestapi/service/ProjectsService.java
@@ -19,5 +19,5 @@
*/
public interface ProjectsService {
- Project save(String url) throws IOException, InterruptedException;
+ Project save(String url, String VCSAccessToken) throws IOException, InterruptedException;
}
diff --git a/src/main/java/gr/zisis/interestapi/service/ProjectsServiceBean.java b/src/main/java/gr/zisis/interestapi/service/ProjectsServiceBean.java
index ac1537c..730451e 100644
--- a/src/main/java/gr/zisis/interestapi/service/ProjectsServiceBean.java
+++ b/src/main/java/gr/zisis/interestapi/service/ProjectsServiceBean.java
@@ -7,9 +7,12 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
+import org.springframework.util.FileSystemUtils;
import org.springframework.web.server.ResponseStatusException;
+import java.io.File;
import java.io.IOException;
+import java.util.Objects;
/*
*
@@ -42,13 +45,19 @@ public class ProjectsServiceBean implements ProjectsService {
private String databasePass;
@Override
- public Project save(String url) throws IOException, InterruptedException {
- ProcessBuilder pb = new ProcessBuilder("java", "-jar", "interest.jar", url, databaseDriver, databaseUrl, databaseUser, databasePass);
+ public Project save(String url, String VCSAccessToken) throws IOException, InterruptedException {
+ ProcessBuilder pb;
+ String owner = getRepositoryOwner(url);
+ String repoName = getRepositoryName(url);
+ String clonePath = "/tmp/"+ owner + "_" + repoName + "_" + System.currentTimeMillis() / 1000;
+ if (Objects.isNull(VCSAccessToken))
+ pb = new ProcessBuilder("java", "-jar", "interest.jar", url, clonePath, databaseDriver, databaseUrl, databaseUser, databasePass);
+ else
+ pb = new ProcessBuilder("java", "-jar", "interest.jar", url, clonePath, databaseDriver, databaseUrl, databaseUser, databasePass, VCSAccessToken);
Process process = pb.start();
process.waitFor();
+ FileSystemUtils.deleteRecursively(new File(clonePath));
if (process.exitValue() == 0) {
- String owner = getRepositoryOwner(url);
- String repoName = getRepositoryName(url);
return projectsRepository.findProject(owner, repoName);
} else if (process.exitValue() == -1) {
throw new ResponseStatusException(