|
|
@@ -2,7 +2,6 @@ package com.nju.edu.gitlab;
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
-import com.fasterxml.jackson.databind.JavaType;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.nju.edu.gitlab.dto.*;
|
|
|
@@ -15,6 +14,7 @@ import com.nju.edu.gitlab.dto.project.VisibilityForm;
|
|
|
import com.nju.edu.gitlab.vo.*;
|
|
|
import com.nju.edu.gitlab.vo.commit.CommitVO;
|
|
|
import org.gitlab4j.api.GitLabApiException;
|
|
|
+import org.gitlab4j.api.models.User;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import okhttp3.*;
|
|
|
@@ -32,7 +32,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.nju.edu.gitlab.SeecoderGitlabException.BIZ_ERROR_CODE;
|
|
|
|
|
|
-public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
+public class SeecoderGitlabClient implements SeecoderGitlabApi {
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@@ -40,12 +40,12 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
private String host;
|
|
|
private String token;
|
|
|
|
|
|
- public SeecoderGitlabClient(String host,String token){
|
|
|
- this.token=token;
|
|
|
- this.host=host;
|
|
|
- this.client=new OkHttpClient.Builder()
|
|
|
+ public SeecoderGitlabClient(String host, String token) {
|
|
|
+ this.token = token;
|
|
|
+ this.host = host;
|
|
|
+ this.client = new OkHttpClient.Builder()
|
|
|
.connectTimeout(60, TimeUnit.SECONDS)
|
|
|
- .writeTimeout(60,TimeUnit.SECONDS)
|
|
|
+ .writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.retryOnConnectionFailure(true)
|
|
|
.build();
|
|
|
}
|
|
|
@@ -65,7 +65,7 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
if (typeReference == null) {
|
|
|
return null;
|
|
|
}
|
|
|
- if (node.get("res")!=null)
|
|
|
+ if (node.get("res") != null)
|
|
|
return objectMapper.readValue(node.get("res").traverse(), typeReference);
|
|
|
else
|
|
|
throw SeecoderGitlabException.NOT_FOUND_ERROR;
|
|
|
@@ -87,24 +87,25 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public GitlabUserVO createGitlabUser(int userId,String username, String password, String email) throws SeecoderGitlabException {
|
|
|
+ public GitlabUserVO createGitlabUser(int userId, String username, String password, String email) throws SeecoderGitlabException {
|
|
|
try {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- GitlabUserDTO gitlabUserDTO=GitlabUserDTO.builder()
|
|
|
- .userId(userId)
|
|
|
- .email(email)
|
|
|
- .password(password)
|
|
|
- .username(username)
|
|
|
- .build();
|
|
|
+ GitlabUserDTO gitlabUserDTO = GitlabUserDTO.builder()
|
|
|
+ .userId(userId)
|
|
|
+ .email(email)
|
|
|
+ .password(password)
|
|
|
+ .username(username)
|
|
|
+ .build();
|
|
|
builder = builder
|
|
|
.url(host + "/api/user/")
|
|
|
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(gitlabUserDTO)));
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
Response response = call.execute();
|
|
|
- GitlabUserVO gitlabUserVO = processResponse(objectMapper, response, new TypeReference<GitlabUserVO>() {});
|
|
|
+ GitlabUserVO gitlabUserVO = processResponse(objectMapper, response, new TypeReference<GitlabUserVO>() {
|
|
|
+ });
|
|
|
return gitlabUserVO;
|
|
|
} catch (JsonProcessingException e) {
|
|
|
logger.error("JSON writeValueAsString error", e);
|
|
|
@@ -121,17 +122,46 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- ChangePasswordDTO changePasswordDTO=ChangePasswordDTO.builder()
|
|
|
- .password(password)
|
|
|
- .userId(userId)
|
|
|
- .build();
|
|
|
+ ChangePasswordDTO changePasswordDTO = ChangePasswordDTO.builder()
|
|
|
+ .password(password)
|
|
|
+ .userId(userId)
|
|
|
+ .build();
|
|
|
builder = builder
|
|
|
.url(host + "/api/user/changePassword")
|
|
|
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(changePasswordDTO)));
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
Response response = call.execute();
|
|
|
- return processResponse(objectMapper, response, new TypeReference<Boolean>() {});
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<Boolean>() {
|
|
|
+ });
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsString error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean changeUserName(int userId, String password, String username) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ ChangeUserNameDTO changeUserNameDTO = ChangeUserNameDTO.builder()
|
|
|
+ .userId(userId)
|
|
|
+ .username(username)
|
|
|
+ .password(password)
|
|
|
+ .build();
|
|
|
+ builder = builder
|
|
|
+ .url(host + "/api/user/changeUserName")
|
|
|
+ .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(changeUserNameDTO)));
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<Boolean>() {
|
|
|
+ });
|
|
|
} catch (JsonProcessingException e) {
|
|
|
logger.error("JSON writeValueAsString error", e);
|
|
|
throw SeecoderGitlabException.JSON_ERROR;
|
|
|
@@ -148,7 +178,7 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
builder = builder
|
|
|
- .url(host + "/api/user/"+userId)
|
|
|
+ .url(host + "/api/user/" + userId)
|
|
|
.delete();
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
@@ -172,12 +202,36 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
builder = builder
|
|
|
- .url(host + "/api/user/"+userId+"/email")
|
|
|
+ .url(host + "/api/user/" + userId + "/email")
|
|
|
+ .get();
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<String>() {
|
|
|
+ });
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsString error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public User getUserByUserName(String userName) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ builder = builder
|
|
|
+ .url(host + "/api/user/getByUserName?userName=" + userName)
|
|
|
.get();
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
Response response = call.execute();
|
|
|
- return processResponse(objectMapper, response, new TypeReference<String>() {});
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<User>() {
|
|
|
+ });
|
|
|
} catch (JsonProcessingException e) {
|
|
|
logger.error("JSON writeValueAsString error", e);
|
|
|
throw SeecoderGitlabException.JSON_ERROR;
|
|
|
@@ -217,12 +271,12 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- AccessLevel accessLevel=AccessLevel.forValue(accessLevelForm.value);
|
|
|
- GroupMemberDTO groupMemberDTO=GroupMemberDTO.builder()
|
|
|
- .accessLevel(accessLevel)
|
|
|
- .userId(userId)
|
|
|
- .groupId(groupId)
|
|
|
- .build();
|
|
|
+ AccessLevel accessLevel = AccessLevel.forValue(accessLevelForm.value);
|
|
|
+ GroupMemberDTO groupMemberDTO = GroupMemberDTO.builder()
|
|
|
+ .accessLevel(accessLevel)
|
|
|
+ .userId(userId)
|
|
|
+ .groupId(groupId)
|
|
|
+ .build();
|
|
|
builder = builder
|
|
|
.url(host + "/api/group/addMember")
|
|
|
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(groupMemberDTO)));
|
|
|
@@ -247,11 +301,11 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- Visibility visibility=Visibility.valueOf(visibilityForm.toString());
|
|
|
- ProjectDTO projectDTO= ProjectDTO.builder()
|
|
|
- .projectName(projectName)
|
|
|
- .visibility(visibility)
|
|
|
- .build();
|
|
|
+ Visibility visibility = Visibility.valueOf(visibilityForm.toString());
|
|
|
+ ProjectDTO projectDTO = ProjectDTO.builder()
|
|
|
+ .projectName(projectName)
|
|
|
+ .visibility(visibility)
|
|
|
+ .build();
|
|
|
builder = builder
|
|
|
.url(host + "/api/project/")
|
|
|
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(projectDTO)));
|
|
|
@@ -275,8 +329,8 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- Visibility visibility=Visibility.valueOf(visibilityForm.toString());
|
|
|
- ProjectDTO projectDTO= ProjectDTO.builder()
|
|
|
+ Visibility visibility = Visibility.valueOf(visibilityForm.toString());
|
|
|
+ ProjectDTO projectDTO = ProjectDTO.builder()
|
|
|
.projectName(projectName)
|
|
|
.visibility(visibility)
|
|
|
.userId(userId)
|
|
|
@@ -298,6 +352,30 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean deleteProject(int projectId) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ builder = builder
|
|
|
+ .url(host + "/api/project/" + projectId)
|
|
|
+ .delete();
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ boolean isDeleted = processResponse(objectMapper, response, new TypeReference<Boolean>() {
|
|
|
+ });
|
|
|
+ return isDeleted;
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsString error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Integer forkProject(int projectId, int userId) throws SeecoderGitlabException {
|
|
|
@@ -305,7 +383,7 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- UserForkDTO userForkDTO= UserForkDTO.builder()
|
|
|
+ UserForkDTO userForkDTO = UserForkDTO.builder()
|
|
|
.projectId(projectId)
|
|
|
.userId(userId)
|
|
|
.build();
|
|
|
@@ -333,7 +411,7 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- GroupForkDTO groupForkDTO= GroupForkDTO.builder()
|
|
|
+ GroupForkDTO groupForkDTO = GroupForkDTO.builder()
|
|
|
.projectId(projectId)
|
|
|
.groupId(groupId)
|
|
|
.build();
|
|
|
@@ -362,13 +440,13 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
builder = builder
|
|
|
- .url(host + "/api/project/compare?projectId="+projectId+"&fromBash="+fromBash+"&toBash="+toBash)
|
|
|
+ .url(host + "/api/project/compare?projectId=" + projectId + "&fromBash=" + fromBash + "&toBash=" + toBash)
|
|
|
.get();
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
Response response = call.execute();
|
|
|
- Set<DiffVO> diffVOSet= new HashSet<>();
|
|
|
- diffVOSet=processResponse(objectMapper, response, new TypeReference<Set<DiffVO>>() {
|
|
|
+ Set<DiffVO> diffVOSet = new HashSet<>();
|
|
|
+ diffVOSet = processResponse(objectMapper, response, new TypeReference<Set<DiffVO>>() {
|
|
|
});
|
|
|
return diffVOSet;
|
|
|
} catch (JsonProcessingException e) {
|
|
|
@@ -386,13 +464,13 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- WebHookDTO webHookDTO= WebHookDTO.builder()
|
|
|
- .projectId(projectId)
|
|
|
- .url(url)
|
|
|
- .doIssueEvents(doIssueEvents)
|
|
|
- .doPushEvents(doPushEvents)
|
|
|
- .doMergeRequestsEvents(doMergeRequestsEvents)
|
|
|
- .build();
|
|
|
+ WebHookDTO webHookDTO = WebHookDTO.builder()
|
|
|
+ .projectId(projectId)
|
|
|
+ .url(url)
|
|
|
+ .doIssueEvents(doIssueEvents)
|
|
|
+ .doPushEvents(doPushEvents)
|
|
|
+ .doMergeRequestsEvents(doMergeRequestsEvents)
|
|
|
+ .build();
|
|
|
builder = builder
|
|
|
.url(host + "/api/project/webhook")
|
|
|
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(webHookDTO)));
|
|
|
@@ -439,12 +517,12 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- ProjectFileDTO projectFileDTO=ProjectFileDTO.builder()
|
|
|
- .path(path)
|
|
|
- .branch(branch)
|
|
|
- .build();
|
|
|
+ ProjectFileDTO projectFileDTO = ProjectFileDTO.builder()
|
|
|
+ .path(path)
|
|
|
+ .branch(branch)
|
|
|
+ .build();
|
|
|
builder = builder
|
|
|
- .url(host + "/api/project/"+projectId+"/getFile")
|
|
|
+ .url(host + "/api/project/" + projectId + "/getFile")
|
|
|
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(projectFileDTO)));
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
@@ -466,12 +544,12 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- ProjectRawFileDTO projectFileDTO=ProjectRawFileDTO.builder()
|
|
|
- .commitOrBranchName(commitOrBranchName)
|
|
|
- .path(path)
|
|
|
- .build();
|
|
|
+ ProjectRawFileDTO projectFileDTO = ProjectRawFileDTO.builder()
|
|
|
+ .commitOrBranchName(commitOrBranchName)
|
|
|
+ .path(path)
|
|
|
+ .build();
|
|
|
builder = builder
|
|
|
- .url(host + "/api/project/"+projectId+"/getRawFile")
|
|
|
+ .url(host + "/api/project/" + projectId + "/getRawFile")
|
|
|
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(projectFileDTO)));
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
@@ -493,20 +571,20 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- List<CommitAction> actionList=actions.stream().map(action-> new CommitAction()
|
|
|
- .withAction(CommitAction.Action.forValue(action.getAction().toString()))
|
|
|
- .withEncoding(CommitAction.Encoding.forValue(action.getEncoding().toString()))
|
|
|
- .withFilePath(action.getFilepath())
|
|
|
- .withContent(action.getContent())).collect(Collectors.toList());
|
|
|
- CommitDTO commitDTO=CommitDTO.builder()
|
|
|
- .branch(branch)
|
|
|
- .commitMessage(commitMessage)
|
|
|
- .email(email)
|
|
|
- .username(username)
|
|
|
- .actions(actionList)
|
|
|
- .build();
|
|
|
+ List<CommitAction> actionList = actions.stream().map(action -> new CommitAction()
|
|
|
+ .withAction(CommitAction.Action.forValue(action.getAction().toString()))
|
|
|
+ .withEncoding(CommitAction.Encoding.forValue(action.getEncoding().toString()))
|
|
|
+ .withFilePath(action.getFilepath())
|
|
|
+ .withContent(action.getContent())).collect(Collectors.toList());
|
|
|
+ CommitDTO commitDTO = CommitDTO.builder()
|
|
|
+ .branch(branch)
|
|
|
+ .commitMessage(commitMessage)
|
|
|
+ .email(email)
|
|
|
+ .username(username)
|
|
|
+ .actions(actionList)
|
|
|
+ .build();
|
|
|
builder = builder
|
|
|
- .url(host + "/api/project/"+projectId+"/commit")
|
|
|
+ .url(host + "/api/project/" + projectId + "/commit")
|
|
|
.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), objectMapper.writeValueAsString(commitDTO)));
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
@@ -529,13 +607,13 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
builder = builder
|
|
|
- .url(host + "/api/project/"+projectId+"/commit/"+commitHash)
|
|
|
+ .url(host + "/api/project/" + projectId + "/commit/" + commitHash)
|
|
|
.get();
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
Response response = call.execute();
|
|
|
- List<CommitVO> commitVOList=new ArrayList<>();
|
|
|
- commitVOList=processResponse(objectMapper, response, new TypeReference<List<CommitVO>>() {
|
|
|
+ List<CommitVO> commitVOList = new ArrayList<>();
|
|
|
+ commitVOList = processResponse(objectMapper, response, new TypeReference<List<CommitVO>>() {
|
|
|
});
|
|
|
return commitVOList;
|
|
|
} catch (JsonProcessingException e) {
|
|
|
@@ -554,13 +632,13 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
builder = builder
|
|
|
- .url(host + "/api/project/"+projectId+"/branches")
|
|
|
+ .url(host + "/api/project/" + projectId + "/branches")
|
|
|
.get();
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
Response response = call.execute();
|
|
|
- List<BranchVO> branchVOList=new ArrayList<>();
|
|
|
- branchVOList=processResponse(objectMapper, response, new TypeReference<List<BranchVO>>() {
|
|
|
+ List<BranchVO> branchVOList = new ArrayList<>();
|
|
|
+ branchVOList = processResponse(objectMapper, response, new TypeReference<List<BranchVO>>() {
|
|
|
});
|
|
|
return branchVOList;
|
|
|
} catch (JsonProcessingException e) {
|
|
|
@@ -578,8 +656,8 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
- AccessLevel accessLevel=AccessLevel.forValue(accessLevelForm.value);
|
|
|
- UpdateMemberDTO updateMemberDTO=UpdateMemberDTO.builder()
|
|
|
+ AccessLevel accessLevel = AccessLevel.forValue(accessLevelForm.value);
|
|
|
+ UpdateMemberDTO updateMemberDTO = UpdateMemberDTO.builder()
|
|
|
.accessLevel(accessLevel)
|
|
|
.userId(userId)
|
|
|
.projectId(projectId)
|
|
|
@@ -609,13 +687,14 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
builder = builder
|
|
|
- .url(host + "/api/project/allProjects/"+userId)
|
|
|
+ .url(host + "/api/project/allProjects/" + userId)
|
|
|
.get();
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
Response response = call.execute();
|
|
|
- List<ProjectVO> projectVOList=new ArrayList<>();
|
|
|
- projectVOList=processResponse(objectMapper, response, new TypeReference<List<ProjectVO>>() {});
|
|
|
+ List<ProjectVO> projectVOList = new ArrayList<>();
|
|
|
+ projectVOList = processResponse(objectMapper, response, new TypeReference<List<ProjectVO>>() {
|
|
|
+ });
|
|
|
return projectVOList;
|
|
|
} catch (JsonProcessingException e) {
|
|
|
logger.error("JSON writeValueAsString error", e);
|
|
|
@@ -633,13 +712,13 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
Request.Builder builder = new Request.Builder()
|
|
|
.addHeader("Authorization", token);
|
|
|
builder = builder
|
|
|
- .url(host + "/api/project/projectMembers/"+projectId)
|
|
|
+ .url(host + "/api/project/projectMembers/" + projectId)
|
|
|
.get();
|
|
|
Request request = builder.build();
|
|
|
final Call call = client.newCall(request);
|
|
|
Response response = call.execute();
|
|
|
- List<Integer> userList=new ArrayList<>();
|
|
|
- userList=processResponse(objectMapper, response, new TypeReference<List<Integer>>() {
|
|
|
+ List<Integer> userList = new ArrayList<>();
|
|
|
+ userList = processResponse(objectMapper, response, new TypeReference<List<Integer>>() {
|
|
|
});
|
|
|
return userList;
|
|
|
} catch (JsonProcessingException e) {
|
|
|
@@ -650,4 +729,27 @@ public class SeecoderGitlabClient implements SeecoderGitlabApi{
|
|
|
throw SeecoderGitlabException.IO_ERROR;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> getFilePaths(int projectId, String basePath, String branch) throws SeecoderGitlabException {
|
|
|
+ try {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ Request.Builder builder = new Request.Builder()
|
|
|
+ .addHeader("Authorization", token);
|
|
|
+ builder = builder
|
|
|
+ .url(host + String.format("/api/project/filePaths?projectId=%d&&basePath=%s&&branch=%s", projectId, basePath, branch))
|
|
|
+ .get();
|
|
|
+ Request request = builder.build();
|
|
|
+ final Call call = client.newCall(request);
|
|
|
+ Response response = call.execute();
|
|
|
+ return processResponse(objectMapper, response, new TypeReference<List<String>>() {
|
|
|
+ });
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ logger.error("JSON writeValueAsString error", e);
|
|
|
+ throw SeecoderGitlabException.JSON_ERROR;
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("IOException", e);
|
|
|
+ throw SeecoderGitlabException.IO_ERROR;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|