|
|
@@ -132,7 +132,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Set<DiffVO> compare(int projectId, String fromBash, String toBash) throws GitLabApiException {
|
|
|
+ public Set<DiffVO> compare(Integer projectId, String fromBash, String toBash) throws GitLabApiException {
|
|
|
CompareResults compareResults = gitlabApi.getRepositoryApi().compare(projectId, fromBash, toBash);
|
|
|
List<Diff> diffs=compareResults.getDiffs();
|
|
|
Set<DiffVO> res=diffs.stream().map(diff -> DiffVO.builder()
|
|
|
@@ -160,13 +160,13 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean archiveProject(int projectId) throws GitLabApiException {
|
|
|
+ public boolean archiveProject(Integer projectId) throws GitLabApiException {
|
|
|
gitlabApi.getProjectApi().archiveProject(projectId);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String getProjectFile(int projectId,ProjectFileDTO projectFileDTO) throws UnsupportedEncodingException, GitLabApiException {
|
|
|
+ public String getProjectFile(Integer projectId, ProjectFileDTO projectFileDTO) throws UnsupportedEncodingException, GitLabApiException {
|
|
|
String branch=projectFileDTO.getBranch();
|
|
|
String path=projectFileDTO.getPath();
|
|
|
RepositoryFile repositoryFile = gitlabApi.getRepositoryFileApi().getFile(path, (long) projectId,branch);
|
|
|
@@ -177,7 +177,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String getProjectRawFile(int projectId, ProjectRawFileDTO projectRawFileDTO) throws GitLabApiException, IOException {
|
|
|
+ public String getProjectRawFile(Integer projectId, ProjectRawFileDTO projectRawFileDTO) throws GitLabApiException, IOException {
|
|
|
String commitOrBranchName = projectRawFileDTO.getCommitOrBranchName();
|
|
|
String path=projectRawFileDTO.getPath();
|
|
|
InputStream inputStream=gitlabApi.getRepositoryFileApi().getRawFile(projectId,commitOrBranchName,path);
|
|
|
@@ -197,7 +197,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CommitVO createCommit(int projectId, CommitDTO commitDTO) throws GitLabApiException {
|
|
|
+ public CommitVO createCommit(Integer projectId, CommitDTO commitDTO) throws GitLabApiException {
|
|
|
String branch=commitDTO.getBranch();
|
|
|
String commitMsg=commitDTO.getCommitMessage();
|
|
|
String username=commitDTO.getUsername();
|
|
|
@@ -210,7 +210,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public List<CommitVO> getAllCommitMessage(int projectId, String commitHash) throws GitLabApiException {
|
|
|
+ public List<CommitVO> getAllCommitMessage(Integer projectId, String commitHash) throws GitLabApiException {
|
|
|
Commit commit=gitlabApi.getCommitsApi().getCommit(projectId,commitHash);
|
|
|
List<Branch> branches=gitlabApi.getRepositoryApi().getBranches(projectId);
|
|
|
for (Branch branch:branches){
|
|
|
@@ -225,13 +225,13 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public CommitVO getCommitByHash(int projectId, String commitHash) throws GitLabApiException {
|
|
|
+ public CommitVO getCommitByHash(Integer projectId, String commitHash) throws GitLabApiException {
|
|
|
Commit commit=gitlabApi.getCommitsApi().getCommit(projectId,commitHash);
|
|
|
return castCommitToVO(commit);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<CommitVO> getCommitsByBranch(int projectId, String branchName) throws GitLabApiException {
|
|
|
+ public List<CommitVO> getCommitsByBranch(Integer projectId, String branchName) throws GitLabApiException {
|
|
|
try {
|
|
|
String branchNameDecode = URLDecoder.decode(branchName, "UTF-8");
|
|
|
List<Commit> commits=gitlabApi.getCommitsApi().getCommits(projectId, branchName,null,null);
|
|
|
@@ -292,7 +292,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<BranchVO> getProjectBranches(int projectId) throws GitLabApiException {
|
|
|
+ public List<BranchVO> getProjectBranches(Integer projectId) throws GitLabApiException {
|
|
|
return gitlabApi.getRepositoryApi().getBranches(projectId).stream()
|
|
|
.map(branch -> castBranchToVO(branch))
|
|
|
.collect(Collectors.toList());
|
|
|
@@ -309,7 +309,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ProjectVO> getAllProjectByUserId(int userId) throws GitLabApiException {
|
|
|
+ public List<ProjectVO> getAllProjectByUserId(Integer userId) throws GitLabApiException {
|
|
|
GitlabUser gitlabUser = getGitlabUser(userId);
|
|
|
gitlabApi.setSudoAsId((long) gitlabUser.getGitlabUserId());
|
|
|
List<ProjectVO> projectVOS = gitlabApi.getProjectApi().getMemberProjects().stream().map(project->ProjectVO.builder().projectId(Math.toIntExact(project.getId())).webUrl(project.getWebUrl()).projectName(project.getName()).build()).collect(Collectors.toList());
|
|
|
@@ -318,7 +318,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Integer> getProjectJoinedUserId(int projectId) throws GitLabApiException {
|
|
|
+ public List<Integer> getProjectJoinedUserId(Integer projectId) throws GitLabApiException {
|
|
|
List<Integer> gitlabUserIds = gitlabApi.getProjectApi().getMembers(projectId).stream().map(Member::getId).map(l -> Math.toIntExact(l)).collect(Collectors.toList());
|
|
|
return gitlabUserRepository.findAllByGitlabUserIdIn(gitlabUserIds).stream()
|
|
|
.map(GitlabUser::getUserId)
|
|
|
@@ -326,7 +326,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<String> getFilePaths(int projectId, String basePath, String branch) throws GitLabApiException {
|
|
|
+ public List<String> getFilePaths(Integer projectId, String basePath, String branch) throws GitLabApiException {
|
|
|
RepositoryApi repositoryApi = gitlabApi.getRepositoryApi();
|
|
|
List<TreeItem> treeItems = new ArrayList<>();
|
|
|
Pager<TreeItem> tree = repositoryApi.getTree(projectId, basePath, branch, true, 100);
|
|
|
@@ -343,21 +343,21 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<TreeItem> getRepositoryTree(int projectId, String filePath, String branch) throws GitLabApiException {
|
|
|
+ public List<TreeItem> getRepositoryTree(Integer projectId, String filePath, String branch) throws GitLabApiException {
|
|
|
RepositoryApi repositoryApi = gitlabApi.getRepositoryApi();
|
|
|
List<TreeItem> treeItems = repositoryApi.getTree(projectId, filePath, branch);
|
|
|
return treeItems;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public MergeRequest mergeBranch(int projectId, String sourceBranch, String targetBranch, String title, String description, int reviewerId) throws GitLabApiException {
|
|
|
+ public MergeRequest mergeBranch(Integer projectId, String sourceBranch, String targetBranch, String title, String description, Integer reviewerId) throws GitLabApiException {
|
|
|
MergeRequestApi mergeRequestApi = gitlabApi.getMergeRequestApi();
|
|
|
MergeRequest mergeRequest = mergeRequestApi.createMergeRequest(projectId, sourceBranch, targetBranch, title, description, Long.valueOf(reviewerId));
|
|
|
return mergeRequestApi.acceptMergeRequest(projectId, mergeRequest.getIid());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public VisibilityVO getProjectVisibility(int projectId) throws GitLabApiException {
|
|
|
+ public VisibilityVO getProjectVisibility(Integer projectId) throws GitLabApiException {
|
|
|
ProjectApi projectApi = gitlabApi.getProjectApi();
|
|
|
Project project = projectApi.getProject(projectId);
|
|
|
return new VisibilityVO(projectId, project.getVisibility().toString());
|
|
|
@@ -389,7 +389,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
- private GitlabUser getGitlabUser(int userId) throws GitLabApiException {
|
|
|
+ private GitlabUser getGitlabUser(Integer userId) throws GitLabApiException {
|
|
|
GitlabUser user = gitlabUserRepository.findByUserId(userId);
|
|
|
if(user != null)
|
|
|
return user;
|