|
|
@@ -93,7 +93,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String,Integer> forkProject(UserForkDTO userForkDTO) throws GitLabApiException {
|
|
|
+ public Integer forkProject(UserForkDTO userForkDTO) throws GitLabApiException {
|
|
|
Map<String,Integer> forkedAndId=new HashMap<>();
|
|
|
int userId=userForkDTO.getUserId();
|
|
|
int projectId=userForkDTO.getProjectId();
|
|
|
@@ -103,11 +103,10 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
Integer namespaceId=gitlabUser.getNamespaceId();
|
|
|
Project project;
|
|
|
log.info("trying to fork project {} to user {} (whose gitlab id is {})", projectId, userId, gitlabUser.getGitlabUserId());
|
|
|
- Integer existProjectId=searchForkedProject(username, examUuid);
|
|
|
- if(existProjectId!=-1){
|
|
|
- forkedAndId.put("forked",1);
|
|
|
- forkedAndId.put("id",existProjectId);
|
|
|
- return forkedAndId;
|
|
|
+ if(username!=null&&examUuid!=null) { //适配软工2系统,软工2系统不能传username(软工2系统数据库中的username不是门户用户名而是昵称)
|
|
|
+ Integer existProjectId = searchForkedProject(username, examUuid);
|
|
|
+ if (existProjectId != -1)
|
|
|
+ return existProjectId;
|
|
|
}
|
|
|
try{
|
|
|
gitlabApi.setSudoAsId((long) gitlabUser.getGitlabUserId());
|
|
|
@@ -117,9 +116,8 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}finally {
|
|
|
gitlabApi.unsudo();
|
|
|
}
|
|
|
- forkedAndId.put("forked", 0);
|
|
|
- forkedAndId.put("id", Math.toIntExact(project != null ? project.getId() : null));
|
|
|
- return forkedAndId;
|
|
|
+
|
|
|
+ return Math.toIntExact(project != null ? project.getId() : null);
|
|
|
}
|
|
|
|
|
|
public Integer searchForkedProject(String username, String examUuid) throws GitLabApiException {
|
|
|
@@ -133,7 +131,6 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public Integer forkGroupProject(GroupForkDTO groupForkDTO) throws GitLabApiException {
|
|
|
int groupId=groupForkDTO.getGroupId();
|