|
@@ -13,12 +13,20 @@ import com.css.simulation.resource.algorithm.mapper.AlgorithmMapper;
|
|
|
import com.css.simulation.resource.algorithm.service.AlgorithmService;
|
|
|
import com.css.simulation.resource.feign.AlgoPlatformService;
|
|
|
import com.css.simulation.resource.system.service.DictService;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
import org.eclipse.jgit.lib.Ref;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.IOException;
|
|
|
+import java.security.KeyManagementException;
|
|
|
+import java.security.KeyStoreException;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -172,13 +180,34 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
|
@Override
|
|
|
public ResponseBodyVO testConnection(AlgorithmParameter param) {
|
|
|
try{
|
|
|
- Map<String, Ref> asMap = JgitUtil.testConnectionByToken(param.getGitUrl(),param.getGitToken());
|
|
|
+ Map<String, Ref> asMap = JgitUtil.testConnection(param.getGitUrl(), param.getGitUserName(), param.getGitPassword());
|
|
|
} catch (Exception e){
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"连接失败!");
|
|
|
}
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"连接成功");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ResponseBodyVO getGitVersion(AlgorithmParameter param) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
|
|
+ String gitUrl = param.getGitUrl();
|
|
|
+ if(StringUtil.isEmpty(gitUrl)){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
+ }
|
|
|
+ //拼接get请求地址
|
|
|
+ String prefix = "https://api.github.com/repos/";
|
|
|
+ String suffix = "/commits?page=1&per_page=1";
|
|
|
+ String gitInfo = gitUrl.substring(19, gitUrl.length()-4);
|
|
|
+ String requestUrl = prefix + gitInfo + suffix;
|
|
|
+ String result = HttpUtil.get(HttpUtil.getHttpClient(), HttpUtil.getRequestConfig(), requestUrl);
|
|
|
+ List<HashMap> hashMaps = JsonUtil.jsonToList(result, HashMap.class);
|
|
|
+ String sha = "";
|
|
|
+ if(hashMaps.size() > 0){
|
|
|
+ HashMap hashMap = hashMaps.get(0);
|
|
|
+ sha = hashMap.get("sha").toString();
|
|
|
+ }
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"请求成功", sha);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public ResponseBodyVO isAlgorithmRunning(AlgorithmParameter param)
|
|
|
{
|
|
@@ -247,9 +276,11 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
|
//设置po信息
|
|
|
if("2".equals(param.getUploadMode())){ //使用仓库地址上传
|
|
|
String gitUrl = param.getGitUrl();
|
|
|
- String gitToken = param.getGitToken();
|
|
|
+ String gitUserName = param.getGitUserName();
|
|
|
+ String gitPassword = param.getGitPassword();
|
|
|
po.setGitUrl(gitUrl);
|
|
|
- po.setGitToken(gitToken);
|
|
|
+ po.setGitUserName(gitUserName);
|
|
|
+ po.setGitPassword(gitPassword);
|
|
|
}else {
|
|
|
String minioPath = param.getMinioPath();
|
|
|
String[] splits = minioPath.split("/");
|