parent
10687428c4
commit
398a8a3ec3
|
|
@ -9,7 +9,7 @@ import com.microservices.common.log.enums.BusinessType;
|
|||
import com.microservices.pms.productLibrary.domain.ProductLibraryRepositoriesFormatEnum;
|
||||
import com.microservices.pms.productLibrary.domain.vo.*;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryComponentService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryProductRepoService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -31,7 +31,7 @@ import java.util.List;
|
|||
})
|
||||
public class PmsProductLibraryController extends BaseController {
|
||||
@Autowired
|
||||
private IPmsProductLibraryProductRepoService pmsProductLibraryProductRepoService;
|
||||
private IPmsProductLibraryService pmsProductLibraryService;
|
||||
@Autowired
|
||||
private IPmsProductLibraryComponentService pmsProductLibraryComponentService;
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@ApiParam(value = "产品库制品查询条件") PmsProductLibraryComponentSearchVo search) {
|
||||
search.setPmsEnterpriseIdentifier(enterpriseIdentifier);
|
||||
startPage();
|
||||
return pmsProductLibraryProductRepoService.selectComponentList(search);
|
||||
return pmsProductLibraryService.selectComponentList(search);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -57,7 +57,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@ApiOperation(value = "获取产品库详情")
|
||||
public GenericsAjaxResult<PmsProductLibraryRepositoriesDataVo> getByRepoName(@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable String repoName) {
|
||||
return GenericsAjaxResult.success(pmsProductLibraryProductRepoService.selectPmsProductLibraryDataByName(enterpriseIdentifier, repoName));
|
||||
return GenericsAjaxResult.success(pmsProductLibraryService.selectPmsProductLibraryDataByName(enterpriseIdentifier, repoName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,7 +70,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam("模糊搜索产品库标识") String name) {
|
||||
startPage();
|
||||
return pmsProductLibraryProductRepoService.selectPmsProductLibraryPageList(enterpriseIdentifier, name);
|
||||
return pmsProductLibraryService.selectPmsProductLibraryPageList(enterpriseIdentifier, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -83,7 +83,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
public AjaxResult addProduct(@PathVariable String enterpriseIdentifier,
|
||||
@Valid @RequestBody ProductRepositoriesInputVo productRepositoriesInputVo) {
|
||||
productRepositoriesInputVo.setEnterpriseIdentifier(enterpriseIdentifier);
|
||||
return toAjax(pmsProductLibraryProductRepoService.insertPmsProductLibrary(productRepositoriesInputVo));
|
||||
return toAjax(pmsProductLibraryService.insertPmsProductLibrary(productRepositoriesInputVo));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -98,7 +98,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@Valid @RequestBody ProductRepositoriesOperateVo productRepositoriesOperateVo) {
|
||||
productRepositoriesOperateVo.setEnterpriseIdentifier(enterpriseIdentifier);
|
||||
productRepositoriesOperateVo.setName(name);
|
||||
return toAjax(pmsProductLibraryProductRepoService.updatePmsProductLibrary(productRepositoriesOperateVo));
|
||||
return toAjax(pmsProductLibraryService.updatePmsProductLibrary(productRepositoriesOperateVo));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,7 +110,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
@ApiOperation(value = "删除产品库")
|
||||
public AjaxResult remove(@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable String name) {
|
||||
return toAjax(pmsProductLibraryProductRepoService.deletePmsProductLibraryByName(enterpriseIdentifier, name));
|
||||
return toAjax(pmsProductLibraryService.deletePmsProductLibraryByName(enterpriseIdentifier, name));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
componentSearchVo.setRepositoryName(repoName);
|
||||
componentSearchVo.setProductRepoName(productRepoName);
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> result =
|
||||
pmsProductLibraryProductRepoService.selectPmsProductLibraryKeyComponentList(enterpriseIdentifier, componentSearchVo);
|
||||
pmsProductLibraryService.selectPmsProductLibraryKeyComponentList(enterpriseIdentifier, componentSearchVo);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ public class PmsProductLibraryController extends BaseController {
|
|||
commonAssetAddToProductRepoVo.setEnterpriseIdentifier(enterpriseIdentifier);
|
||||
commonAssetAddToProductRepoVo.setProductRepoName(productRepoName);
|
||||
commonAssetAddToProductRepoVo.setRepoName(repoName);
|
||||
return toAjax(pmsProductLibraryProductRepoService.addCommonAssetToProductRepo(commonAssetAddToProductRepoVo));
|
||||
return toAjax(pmsProductLibraryService.addCommonAssetToProductRepo(commonAssetAddToProductRepoVo));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -301,6 +301,18 @@ public class PmsProductLibraryController extends BaseController {
|
|||
dockerComponentAddToProductRepoVo.setEnterpriseIdentifier(enterpriseIdentifier);
|
||||
dockerComponentAddToProductRepoVo.setProductRepoName(productRepoName);
|
||||
dockerComponentAddToProductRepoVo.setRepoName(repoName);
|
||||
return toAjax(pmsProductLibraryProductRepoService.addDockerComponentToProductRepo(dockerComponentAddToProductRepoVo));
|
||||
return toAjax(pmsProductLibraryService.addDockerComponentToProductRepo(dockerComponentAddToProductRepoVo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品库打包
|
||||
*/
|
||||
// @RequiresPermissions("pms:pmsProductLibraryComponent:add")
|
||||
@Log(title = "产品库打包", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/packaged/{productRepoName}")
|
||||
@ApiOperation(value = "产品库打包")
|
||||
public AjaxResult packagedProduct(@PathVariable String enterpriseIdentifier,
|
||||
@ApiParam(value = "产品库标识", required = true) @PathVariable String productRepoName) {
|
||||
return toAjax(pmsProductLibraryService.packagedProduct(enterpriseIdentifier, productRepoName));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.microservices.pms.productLibrary.controller;
|
|||
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryProxyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
@Controller
|
||||
public class ProductLibraryProxyController extends BaseController {
|
||||
@Autowired
|
||||
private IPmsProductLibraryService pmsProductLibraryService;
|
||||
private IPmsProductLibraryProxyService pmsProductLibraryService;
|
||||
|
||||
|
||||
@ResponseBody
|
||||
|
|
|
|||
|
|
@ -47,4 +47,11 @@ public interface IPmsProductLibraryAsyncService {
|
|||
* @param directory
|
||||
*/
|
||||
void asyncAddDockerComponentToProductRepo(PmsProductLibraryRepositories productRepo, PmsProductLibraryRepositories repo, List<NexusComponentResultDataVo> nexusComponentResultDataVoList, String directory);
|
||||
|
||||
/**
|
||||
* 打包产品库
|
||||
*
|
||||
* @param productRepo 产品库
|
||||
*/
|
||||
void packagedProduct(PmsProductLibraryRepositories productRepo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,81 +0,0 @@
|
|||
package com.microservices.pms.productLibrary.service;
|
||||
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.pms.productLibrary.domain.PmsProductLibraryRepositories;
|
||||
import com.microservices.pms.productLibrary.domain.vo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
*/
|
||||
public interface IPmsProductLibraryProductRepoService {
|
||||
|
||||
PmsProductLibraryRepositoriesDataVo selectPmsProductLibraryDataByName(String enterpriseIdentifier, String repoName);
|
||||
|
||||
/**
|
||||
* 根据组织标识和名称查找产品库
|
||||
*
|
||||
* @param enterpriseIdentifier 组织标识
|
||||
* @param repoName 产品库标识
|
||||
* @return 产品库
|
||||
*/
|
||||
PmsProductLibraryRepositories selectPmsProductLibraryByName(String enterpriseIdentifier, String repoName);
|
||||
|
||||
|
||||
/**
|
||||
* 查询产品库列表
|
||||
*
|
||||
* @param enterpriseIdentifier 组织标识
|
||||
* @param name 产品库标识
|
||||
* @return 产品库列表
|
||||
*/
|
||||
GenericsTableDataInfo<PmsProductLibrarySimpleVo> selectPmsProductLibraryPageList(String enterpriseIdentifier, String name);
|
||||
|
||||
|
||||
/**
|
||||
* 创建产品库
|
||||
*
|
||||
* @param productRepositoriesInputVo 产品库输入对象
|
||||
* @return 结果
|
||||
*/
|
||||
int insertPmsProductLibrary(ProductRepositoriesInputVo productRepositoriesInputVo);
|
||||
|
||||
/**
|
||||
* 更新产品库
|
||||
*
|
||||
* @param productRepositoriesOperateVo 产品库操作对象
|
||||
* @return 结果
|
||||
*/
|
||||
int updatePmsProductLibrary(ProductRepositoriesOperateVo productRepositoriesOperateVo);
|
||||
|
||||
/**
|
||||
* 删除产品库
|
||||
*
|
||||
* @param enterpriseIdentifier 组织标识
|
||||
* @param name 产品库标识
|
||||
* @return 产品库
|
||||
*/
|
||||
int deletePmsProductLibraryByName(String enterpriseIdentifier, String name);
|
||||
|
||||
/**
|
||||
* 选择普通制品移入产品库
|
||||
*
|
||||
* @param commonAssetAddToProductRepoVo 普通制品移入产品库对象
|
||||
* @return 移入状态
|
||||
*/
|
||||
boolean addCommonAssetToProductRepo(CommonAssetAddToProductRepoVo commonAssetAddToProductRepoVo);
|
||||
|
||||
/**
|
||||
* 查询关键制品列表
|
||||
*
|
||||
* @param enterpriseIdentifier 组织标识
|
||||
* @param componentSearchVo 查询条件
|
||||
* @return 制品列表
|
||||
*/
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> selectPmsProductLibraryKeyComponentList(String enterpriseIdentifier, ComponentSearchVo componentSearchVo);
|
||||
|
||||
GenericsTableDataInfo<PmsProductLibraryComponentDataVo> selectComponentList(PmsProductLibraryComponentSearchVo search);
|
||||
|
||||
boolean addDockerComponentToProductRepo(DockerComponentAddToProductRepoVo dockerComponentAddToProductRepoVo);
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.microservices.pms.productLibrary.service;
|
||||
|
||||
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
*/
|
||||
public interface IPmsProductLibraryProxyService {
|
||||
|
||||
AjaxResult proxyNexusJson(HttpServletRequest request);
|
||||
}
|
||||
|
|
@ -1,14 +1,83 @@
|
|||
package com.microservices.pms.productLibrary.service;
|
||||
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.pms.productLibrary.domain.PmsProductLibraryRepositories;
|
||||
import com.microservices.pms.productLibrary.domain.vo.*;
|
||||
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
*/
|
||||
public interface IPmsProductLibraryService {
|
||||
|
||||
AjaxResult proxyNexusJson(HttpServletRequest request);
|
||||
GenericsTableDataInfo<PmsProductLibraryComponentDataVo> selectComponentList(PmsProductLibraryComponentSearchVo search);
|
||||
|
||||
PmsProductLibraryRepositoriesDataVo selectPmsProductLibraryDataByName(String enterpriseIdentifier, String repoName);
|
||||
|
||||
/**
|
||||
* 根据组织标识和名称查找产品库
|
||||
*
|
||||
* @param enterpriseIdentifier 组织标识
|
||||
* @param repoName 产品库标识
|
||||
* @return 产品库
|
||||
*/
|
||||
PmsProductLibraryRepositories selectPmsProductLibraryByName(String enterpriseIdentifier, String repoName);
|
||||
|
||||
|
||||
/**
|
||||
* 查询产品库列表
|
||||
*
|
||||
* @param enterpriseIdentifier 组织标识
|
||||
* @param name 产品库标识
|
||||
* @return 产品库列表
|
||||
*/
|
||||
GenericsTableDataInfo<PmsProductLibrarySimpleVo> selectPmsProductLibraryPageList(String enterpriseIdentifier, String name);
|
||||
|
||||
|
||||
/**
|
||||
* 创建产品库
|
||||
*
|
||||
* @param productRepositoriesInputVo 产品库输入对象
|
||||
* @return 结果
|
||||
*/
|
||||
int insertPmsProductLibrary(ProductRepositoriesInputVo productRepositoriesInputVo);
|
||||
|
||||
/**
|
||||
* 更新产品库
|
||||
*
|
||||
* @param productRepositoriesOperateVo 产品库操作对象
|
||||
* @return 结果
|
||||
*/
|
||||
int updatePmsProductLibrary(ProductRepositoriesOperateVo productRepositoriesOperateVo);
|
||||
|
||||
/**
|
||||
* 删除产品库
|
||||
*
|
||||
* @param enterpriseIdentifier 组织标识
|
||||
* @param name 产品库标识
|
||||
* @return 产品库
|
||||
*/
|
||||
int deletePmsProductLibraryByName(String enterpriseIdentifier, String name);
|
||||
|
||||
/**
|
||||
* 选择普通制品移入产品库
|
||||
*
|
||||
* @param commonAssetAddToProductRepoVo 普通制品移入产品库对象
|
||||
* @return 移入状态
|
||||
*/
|
||||
boolean addCommonAssetToProductRepo(CommonAssetAddToProductRepoVo commonAssetAddToProductRepoVo);
|
||||
|
||||
/**
|
||||
* 查询关键制品列表
|
||||
*
|
||||
* @param enterpriseIdentifier 组织标识
|
||||
* @param componentSearchVo 查询条件
|
||||
* @return 制品列表
|
||||
*/
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> selectPmsProductLibraryKeyComponentList(String enterpriseIdentifier, ComponentSearchVo componentSearchVo);
|
||||
|
||||
boolean addDockerComponentToProductRepo(DockerComponentAddToProductRepoVo dockerComponentAddToProductRepoVo);
|
||||
|
||||
boolean packagedProduct(String enterpriseIdentifier, String productRepoName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,6 +187,18 @@ public class PmsProductLibraryAsyncServiceImpl implements IPmsProductLibraryAsyn
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packagedProduct(PmsProductLibraryRepositories productRepo) {
|
||||
CustomExecutorFactory.threadPoolExecutor.execute(() -> {
|
||||
pmsProductLibraryRepositoriesService.lockRepository(productRepo.getPmsEnterpriseIdentifier(), productRepo.getId());
|
||||
try {
|
||||
|
||||
} finally {
|
||||
pmsProductLibraryRepositoriesService.unlockRepository(productRepo.getPmsEnterpriseIdentifier(), productRepo.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void syncMavenRepoToSnapshotRepo(PmsProductLibraryRepositories repo, PmsProductLibraryRepositories snapshotRepo) {
|
||||
List<PmsProductLibraryComponent> pmsProductLibraryComponentList = pmsProductLibraryComponentService.selectPmsProductLibraryComponentListByDatabase(repo.getId());
|
||||
for (PmsProductLibraryComponent pmsProductLibraryComponent : pmsProductLibraryComponentList) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
|||
private IPmsProductLibraryRepositoriesService pmsProductLibraryRepositoriesService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private IPmsProductLibraryProductRepoService pmsProductLibraryProductRepoService;
|
||||
private IPmsProductLibraryService pmsProductLibraryProductRepoService;
|
||||
@Autowired
|
||||
private IPmsProductLibrarySnapshotRepoService pmsProductLibrarySnapshotRepoService;
|
||||
@Autowired
|
||||
|
|
@ -427,7 +427,7 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
|||
} else {
|
||||
fileBytes = PmsUtils.getFeignFile(fileService.getFileEntityByIdentifier(assetMavenInputVo.getFileIdentifier(), SecurityConstants.INNER));
|
||||
}
|
||||
if (fileBytes == null || fileBytes.getFileInputStream() == null) {
|
||||
if (fileBytes.getFileInputStream() == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
builder.addBinaryBody(String.format("maven2.asset%d", i + 1), fileBytes.getFileInputStream(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
|
|
@ -487,7 +487,7 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
|||
} else {
|
||||
fileBytes = PmsUtils.getFeignFile(fileService.getFileEntityByIdentifier(assetRawInputVo.getFileIdentifier(), SecurityConstants.INNER));
|
||||
}
|
||||
if (fileBytes == null || fileBytes.getFileInputStream() == null) {
|
||||
if (fileBytes.getFileInputStream() == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
builder.addBinaryBody(String.format("raw.asset%d", i + 1), fileBytes.getFileInputStream(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
|
|
@ -527,7 +527,7 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
|||
} else {
|
||||
fileBytes = PmsUtils.getFeignFile(fileService.getFileEntityByIdentifier(componentInputVo.getFileIdentifier(), SecurityConstants.INNER));
|
||||
}
|
||||
if (fileBytes == null || fileBytes.getFileInputStream() == null) {
|
||||
if (fileBytes.getFileInputStream() == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
|
||||
|
|
@ -564,7 +564,7 @@ public class PmsProductLibraryComponentServiceImpl implements IPmsProductLibrary
|
|||
} else {
|
||||
fileBytes = PmsUtils.getFeignFile(fileService.getFileEntityByIdentifier(componentInputVo.getFileIdentifier(), SecurityConstants.INNER));
|
||||
}
|
||||
if (fileBytes == null || fileBytes.getFileInputStream() == null) {
|
||||
if (fileBytes.getFileInputStream() == null) {
|
||||
throw new ServiceException("制品文件读取失败");
|
||||
}
|
||||
builder.addBinaryBody("pypi.asset1", fileBytes.getFileInputStream(), ContentType.DEFAULT_BINARY, fileBytes.getFileName());
|
||||
|
|
|
|||
|
|
@ -1,326 +0,0 @@
|
|||
package com.microservices.pms.productLibrary.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.core.utils.PageUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.html.EscapeUtil;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.pms.enterprise.domain.PmsEnterprise;
|
||||
import com.microservices.pms.enterprise.service.IPmsEnterpriseService;
|
||||
import com.microservices.pms.productLibrary.domain.PmsProductLibraryComponent;
|
||||
import com.microservices.pms.productLibrary.domain.PmsProductLibraryRepositories;
|
||||
import com.microservices.pms.productLibrary.domain.ProductLibraryRepositoriesFormatEnum;
|
||||
import com.microservices.pms.productLibrary.domain.vo.*;
|
||||
import com.microservices.pms.productLibrary.mapper.PmsProductLibraryComponentMapper;
|
||||
import com.microservices.pms.productLibrary.mapper.PmsProductLibraryRepositoriesMapper;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryAsyncService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryComponentService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryProductRepoService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryRepositoriesService;
|
||||
import com.microservices.pms.utils.NexusRequestHelper;
|
||||
import com.microservices.pms.utils.NexusRequestUrl;
|
||||
import com.microservices.pms.utils.PmsUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
*/
|
||||
@Service
|
||||
public class PmsProductLibraryProductRepoServiceImpl implements IPmsProductLibraryProductRepoService {
|
||||
|
||||
@Autowired
|
||||
private PmsProductLibraryRepositoriesMapper pmsProductLibraryRepositoriesMapper;
|
||||
@Autowired
|
||||
private PmsProductLibraryComponentMapper pmsProductLibraryComponentMapper;
|
||||
@Autowired
|
||||
private NexusRequestHelper nexusRequestHelper;
|
||||
@Autowired
|
||||
private IPmsEnterpriseService pmsEnterpriseService;
|
||||
@Autowired
|
||||
private IPmsProductLibraryAsyncService pmsProductLibraryAsyncService;
|
||||
@Autowired
|
||||
private IPmsProductLibraryComponentService pmsProductLibraryComponentService;
|
||||
@Autowired
|
||||
private IPmsProductLibraryRepositoriesService pmsProductLibraryRepositoriesService;
|
||||
|
||||
@Override
|
||||
public PmsProductLibraryRepositoriesDataVo selectPmsProductLibraryDataByName(String enterpriseIdentifier, String repoName) {
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories = selectPmsProductLibraryByName(enterpriseIdentifier, repoName);
|
||||
return pmsProductLibraryRepositories.toPmsProductLibraryRepositoriesDataVo();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PmsProductLibraryRepositories selectPmsProductLibraryByName(String enterpriseIdentifier, String name) {
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories = pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryByName(enterpriseIdentifier, name);
|
||||
if (pmsProductLibraryRepositories == null) {
|
||||
throw new ServiceException("组织下不存在该产品库(组织标识[%s],产品库标识[%s])", enterpriseIdentifier, name);
|
||||
}
|
||||
return pmsProductLibraryRepositories;
|
||||
}
|
||||
|
||||
private PmsProductLibraryRepositories selectPmsProductLibraryRepositoriesById(Long repoId) {
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories =
|
||||
pmsProductLibraryRepositoriesMapper.selectProductRepoById(repoId);
|
||||
if (pmsProductLibraryRepositories == null) {
|
||||
throw new ServiceException("组织下不存在该产品库(产品库id[%d])", repoId);
|
||||
}
|
||||
return pmsProductLibraryRepositories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericsTableDataInfo<PmsProductLibrarySimpleVo> selectPmsProductLibraryPageList(String enterpriseIdentifier, String name) {
|
||||
return PageUtils.toPage(pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryList(enterpriseIdentifier, name), PmsProductLibraryRepositories::toPmsProductLibrarySimpleVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updatePmsProductLibrary(ProductRepositoriesOperateVo productRepositoriesOperateVo) {
|
||||
PmsProductLibraryRepositories oldRepo = selectPmsProductLibraryByName(productRepositoriesOperateVo.getEnterpriseIdentifier(), productRepositoriesOperateVo.getName());
|
||||
|
||||
// 校验制品库别名
|
||||
PmsProductLibraryRepositories aliasRepo = pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryRepositoriesByAlias(productRepositoriesOperateVo.getAlias(), productRepositoriesOperateVo.getEnterpriseIdentifier());
|
||||
if (aliasRepo != null && !aliasRepo.getId().equals(oldRepo.getId())) {
|
||||
throw new ServiceException("该产品库名称在当前组织下已存在(产品库名称[%s])", productRepositoriesOperateVo.getAlias());
|
||||
}
|
||||
// 构建更新对象
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories = productRepositoriesOperateVo.toPmsProductLibraryRepositories();
|
||||
pmsProductLibraryRepositories.setId(oldRepo.getId());
|
||||
pmsProductLibraryRepositories.setUpdateTime(DateUtils.getNowDate());
|
||||
pmsProductLibraryRepositories.setUpdateBy(SecurityUtils.getUsername());
|
||||
NexusHostedRepoInputVo requestBody = productRepositoriesOperateVo.toNexusRepoDataVo();
|
||||
|
||||
// 调用制品库更新接口更新制品库
|
||||
nexusRequestHelper.doRequest(NexusRequestUrl.UPDATE_REPOSITORIES(requestBody.getType(), requestBody.getFormat(), requestBody.getName()), JSONObject.from(requestBody));
|
||||
|
||||
return pmsProductLibraryRepositoriesMapper.updatePmsProductLibraryRepositories(pmsProductLibraryRepositories);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int insertPmsProductLibrary(ProductRepositoriesInputVo productRepositoriesInputVo) {
|
||||
PmsEnterprise pmsEnterprise = pmsEnterpriseService.selectPmsEnterpriseByIdentifier(productRepositoriesInputVo.getEnterpriseIdentifier());
|
||||
// 校验制品库标识
|
||||
Integer count = pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryRepositoriesByNameCount(productRepositoriesInputVo.getName(), productRepositoriesInputVo.getEnterpriseIdentifier(), productRepositoriesInputVo.getFormat());
|
||||
if (count > 0) {
|
||||
throw new ServiceException("该产品库标识在当前组织下已存在(产品库标识[%s])", productRepositoriesInputVo.getName());
|
||||
}
|
||||
// 校验制品库别名
|
||||
PmsProductLibraryRepositories aliasRepo = pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryRepositoriesByAlias(productRepositoriesInputVo.getAlias(), productRepositoriesInputVo.getEnterpriseIdentifier());
|
||||
if (aliasRepo != null) {
|
||||
throw new ServiceException("该产品库名称在当前组织下已存在(产品库名称[%s])", productRepositoriesInputVo.getAlias());
|
||||
}
|
||||
NexusHostedRepoInputVo requestBody = productRepositoriesInputVo.toNexusRepoDataVo();
|
||||
|
||||
// 调用制品库创建接口创建产品库
|
||||
nexusRequestHelper.doRequest(NexusRequestUrl.ADD_REPOSITORIES(requestBody.getType(), requestBody.getFormat()), JSONObject.from(requestBody));
|
||||
// 调用Nexus制品库详情接口获取制品库详情
|
||||
NexusHostedRepoInputVo nexusDataVo = pmsProductLibraryRepositoriesService.getNexusRepo(
|
||||
productRepositoriesInputVo.getType(),
|
||||
productRepositoriesInputVo.getFormat(),
|
||||
PmsProductLibraryRepositories.getNexusProductRepositoriesName(
|
||||
productRepositoriesInputVo.getEnterpriseIdentifier(),
|
||||
productRepositoriesInputVo.getName()
|
||||
));
|
||||
// 数据库添加该制品库
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories = productRepositoriesInputVo.toPmsProductLibraryRepositories();
|
||||
pmsProductLibraryRepositories.setUrl(nexusDataVo.getUrl());
|
||||
pmsProductLibraryRepositories.setPmsEnterpriseId(pmsEnterprise.getId());
|
||||
pmsProductLibraryRepositories.setDeptId(pmsEnterprise.getDeptId());
|
||||
pmsProductLibraryRepositories.setCreateTime(DateUtils.getNowDate());
|
||||
pmsProductLibraryRepositories.setCreateBy(SecurityUtils.getUsername());
|
||||
return pmsProductLibraryRepositoriesMapper.insertPmsProductLibraryRepositories(pmsProductLibraryRepositories);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deletePmsProductLibraryByName(String enterpriseIdentifier, String name) {
|
||||
PmsProductLibraryRepositories oldRepo = selectPmsProductLibraryByName(enterpriseIdentifier, name);
|
||||
// 调用制品库删除接口删除制品库
|
||||
nexusRequestHelper.doRequest(NexusRequestUrl.DELETE_REPOSITORIES(PmsProductLibraryRepositories.getNexusProductRepositoriesName(enterpriseIdentifier, name)));
|
||||
return pmsProductLibraryRepositoriesMapper.deletePmsProductLibraryRepositoriesById(oldRepo.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCommonAssetToProductRepo(CommonAssetAddToProductRepoVo commonAssetAddToProductRepoVo) {
|
||||
// 先校验产品库、制品库、制品库下制品Id列表是否存在,再进行异步处理
|
||||
PmsProductLibraryRepositories productRepo = selectPmsProductLibraryByName(commonAssetAddToProductRepoVo.getEnterpriseIdentifier(), commonAssetAddToProductRepoVo.getProductRepoName());
|
||||
PmsProductLibraryRepositories repo = pmsProductLibraryRepositoriesService.selectPmsProductLibraryRepositoriesByName(commonAssetAddToProductRepoVo.getEnterpriseIdentifier(), commonAssetAddToProductRepoVo.getRepoName());
|
||||
if (ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
throw new ServiceException("Docker制品移入不能使用该接口");
|
||||
}
|
||||
List<NexusAssetResultDataVo> nexusAssetResultDataVoList = new ArrayList<>();
|
||||
for (String assetId : commonAssetAddToProductRepoVo.getAssetIdList()) {
|
||||
NexusComponentResultVo<NexusAssetResultDataVo> nexusAssetResultVo = pmsProductLibraryComponentService.getAssetDetailByAssetId(commonAssetAddToProductRepoVo.getEnterpriseIdentifier(), commonAssetAddToProductRepoVo.getRepoName(), null, assetId, false);
|
||||
if (nexusAssetResultVo == null || nexusAssetResultVo.getResult() == null || !nexusAssetResultVo.getResult().getSuccess()) {
|
||||
throw new ServiceException("该制品不存在(制品库[%s],制品Id[%s])", commonAssetAddToProductRepoVo.getRepoName(), assetId);
|
||||
} else {
|
||||
NexusAssetResultDataVo data = nexusAssetResultVo.getResult().getData();
|
||||
if (pmsProductLibraryComponentService.getLockComponentStatus(productRepo.getId(), assetId)) {
|
||||
throw new ServiceException("制品锁定中,无法被移入产品库(制品名称[%s],产品库名称[%s])", data.getName(), productRepo.getName());
|
||||
}
|
||||
PmsProductLibraryComponent pmsProductLibraryComponent = pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentByIdentifier(productRepo.getId(), assetId);
|
||||
if (pmsProductLibraryComponent != null) {
|
||||
throw new ServiceException("制品已被移入产品库中,无法重复移入(制品名称[%s],产品库名称[%s])", data.getName(), productRepo.getName());
|
||||
}
|
||||
nexusAssetResultDataVoList.add(data);
|
||||
}
|
||||
}
|
||||
pmsProductLibraryAsyncService.asyncAddCommonAssetToProductRepo(productRepo, repo, nexusAssetResultDataVoList, commonAssetAddToProductRepoVo.getDirectory());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NexusComponentResultVo<List<NexusResultDataVo>> selectPmsProductLibraryKeyComponentList(String enterpriseIdentifier, ComponentSearchVo componentSearchVo) {
|
||||
PmsProductLibraryRepositories productRepo = pmsProductLibraryComponentService.getPmsProductLibraryRepositories(true, enterpriseIdentifier, componentSearchVo.getProductRepoName(), null);
|
||||
PmsProductLibraryComponent productComponentSearch = new PmsProductLibraryComponent();
|
||||
productComponentSearch.setRepoId(productRepo.getId());
|
||||
List<PmsProductLibraryComponent> productComponentList = pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentList(productComponentSearch);
|
||||
PmsProductLibraryRepositories repo = pmsProductLibraryComponentService.getPmsProductLibraryRepositories(false, enterpriseIdentifier, componentSearchVo.getRepositoryName(), null);
|
||||
componentSearchVo.setRepositoryName(repo.getNexusRepositoriesName());
|
||||
// Docker类型调用Nexus获取制品列表接口获取
|
||||
if (ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
List<NexusResultDataVo> keyNexusResultDataVoList = new ArrayList<>();
|
||||
// 需循环遍历获取所有镜像列表
|
||||
boolean isAll = false;
|
||||
// Nexus分页Token
|
||||
String continuationToken = null;
|
||||
while (!isAll) {
|
||||
NexusComponentAndAssetListVo<NexusDockerComponentVo> assetListVo = nexusRequestHelper.doRequestToJavaObject(NexusRequestUrl.GET_COMPONENTS(repo.getNexusRepositoriesName(), continuationToken), NexusComponentAndAssetListVo.class, NexusDockerComponentVo.class);
|
||||
if (assetListVo != null) {
|
||||
if (StringUtils.isEmpty(assetListVo.getContinuationToken())) {
|
||||
isAll = true;
|
||||
} else {
|
||||
continuationToken = assetListVo.getContinuationToken();
|
||||
}
|
||||
for (NexusDockerComponentVo nexusDockerComponentVo : assetListVo.getItems()) {
|
||||
NexusResultDataVo nexusResultDataVo = nexusDockerComponentVo.toNexusResultDataVo();
|
||||
keyNexusResultDataVoList.add(nexusResultDataVo);
|
||||
}
|
||||
} else {
|
||||
isAll = true;
|
||||
}
|
||||
|
||||
}
|
||||
setNexusResultDataVoChoose(productRepo, productComponentList, keyNexusResultDataVoList, true);
|
||||
setNexusResultDataVoPath(repo, keyNexusResultDataVoList);
|
||||
return buildDockerResultVo(keyNexusResultDataVoList);
|
||||
} else {
|
||||
NexusComponentSearchVo<ComponentSearchVo> nexusComponentSearchVo = NexusComponentSearchVo.toRead(componentSearchVo, nexusRequestHelper.getNexusTid());
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> assetResultDataVo = nexusRequestHelper.doRequestToJavaObjectList(NexusRequestUrl.DO_OPERATION(), JSONObject.from(nexusComponentSearchVo), NexusComponentResultVo.class, NexusResultDataVo.class);
|
||||
if (assetResultDataVo != null && assetResultDataVo.getResult() != null) {
|
||||
NexusComponentResultStateVo<List<NexusResultDataVo>> nexusComponentResultStateVo = assetResultDataVo.getResult();
|
||||
if (nexusComponentResultStateVo.getSuccess()) {
|
||||
List<NexusResultDataVo> nexusResultDataVoList = nexusComponentResultStateVo.getData();
|
||||
setNexusResultDataVoChoose(productRepo, productComponentList, nexusResultDataVoList, false);
|
||||
setNexusResultDataVoPath(repo, nexusResultDataVoList);
|
||||
// 当制品库为Maven时,需排除自动生成的制品数据
|
||||
if (ProductLibraryRepositoriesFormatEnum.MAVEN.getKey().equals(repo.getFormat())) {
|
||||
List<NexusResultDataVo> keyNexusResultDataVoList = new ArrayList<>();
|
||||
for (NexusResultDataVo nexusResultDataVo : nexusResultDataVoList) {
|
||||
// 当类型为asset时,需检查数据库是否存在记录,若存在则返回
|
||||
if ("asset".equals(nexusResultDataVo.getType())) {
|
||||
PmsProductLibraryComponent pmsProductLibraryComponent = pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentByPath(nexusResultDataVo.getId(), repo.getId(), repo.getPmsEnterpriseId());
|
||||
if (pmsProductLibraryComponent != null) {
|
||||
keyNexusResultDataVoList.add(nexusResultDataVo);
|
||||
}
|
||||
} else {
|
||||
keyNexusResultDataVoList.add(nexusResultDataVo);
|
||||
}
|
||||
}
|
||||
nexusComponentResultStateVo.setData(keyNexusResultDataVoList);
|
||||
assetResultDataVo.setResult(nexusComponentResultStateVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return assetResultDataVo;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDockerComponentToProductRepo(DockerComponentAddToProductRepoVo dockerComponentAddToProductRepoVo) {
|
||||
// 先校验产品库、制品库、制品库下制品Id列表是否存在,再进行异步处理
|
||||
PmsProductLibraryRepositories productRepo = selectPmsProductLibraryByName(dockerComponentAddToProductRepoVo.getEnterpriseIdentifier(), dockerComponentAddToProductRepoVo.getProductRepoName());
|
||||
PmsProductLibraryRepositories repo = pmsProductLibraryRepositoriesService.selectPmsProductLibraryRepositoriesByName(dockerComponentAddToProductRepoVo.getEnterpriseIdentifier(), dockerComponentAddToProductRepoVo.getRepoName());
|
||||
if (!ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
throw new ServiceException("当前接口仅允许进行Docker移入产品库操作");
|
||||
}
|
||||
List<NexusComponentResultDataVo> nexusComponentResultDataVoList = new ArrayList<>();
|
||||
for (String componentId : dockerComponentAddToProductRepoVo.getComponentIdList()) {
|
||||
NexusComponentResultVo<NexusComponentResultDataVo> nexusAssetResultVo = pmsProductLibraryComponentService.getComponentDetailByComponentId(dockerComponentAddToProductRepoVo.getEnterpriseIdentifier(), dockerComponentAddToProductRepoVo.getRepoName(), null, componentId, false);
|
||||
if (nexusAssetResultVo == null || nexusAssetResultVo.getResult() == null || !nexusAssetResultVo.getResult().getSuccess()) {
|
||||
throw new ServiceException("该制品不存在(制品库[%s],制品Id[%s])", dockerComponentAddToProductRepoVo.getRepoName(), componentId);
|
||||
} else {
|
||||
NexusComponentResultDataVo data = nexusAssetResultVo.getResult().getData();
|
||||
if (pmsProductLibraryComponentService.getLockComponentStatus(productRepo.getId(), componentId)) {
|
||||
throw new ServiceException("制品锁定中,无法被移入产品库(制品名称[%s],产品库名称[%s])", data.getName(), productRepo.getName());
|
||||
}
|
||||
PmsProductLibraryComponent pmsProductLibraryComponent = pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentByIdentifier(productRepo.getId(), componentId);
|
||||
if (pmsProductLibraryComponent != null) {
|
||||
throw new ServiceException("制品已被移入产品库中,无法重复移入(制品名称[%s],产品库名称[%s])", data.getName(), productRepo.getName());
|
||||
}
|
||||
nexusComponentResultDataVoList.add(data);
|
||||
}
|
||||
}
|
||||
pmsProductLibraryAsyncService.asyncAddDockerComponentToProductRepo(productRepo, repo, nexusComponentResultDataVoList, dockerComponentAddToProductRepoVo.getDirectory());
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public GenericsTableDataInfo<PmsProductLibraryComponentDataVo> selectComponentList(PmsProductLibraryComponentSearchVo search) {
|
||||
List<PmsProductLibraryComponent> pmsProductLibraryComponentList =
|
||||
pmsProductLibraryComponentMapper.selectProductRepoComponentList(search);
|
||||
List<Long> repoIdList = pmsProductLibraryComponentList.stream().map(PmsProductLibraryComponent::getRepoId).distinct().collect(Collectors.toList());
|
||||
List<PmsProductLibraryRepositories> repoList = repoIdList.stream().map(this::selectPmsProductLibraryRepositoriesById).collect(Collectors.toList());
|
||||
return PageUtils.toPage(pmsProductLibraryComponentList, x -> toPmsProductLibraryComponentDataVo(x, repoList));
|
||||
}
|
||||
|
||||
private PmsProductLibraryComponentDataVo toPmsProductLibraryComponentDataVo(PmsProductLibraryComponent component, List<PmsProductLibraryRepositories> repoList) {
|
||||
PmsProductLibraryComponentDataVo pmsProductLibraryComponentDataVo = component.toPmsProductLibraryComponentDataVo();
|
||||
repoList.stream().filter(x -> x.getId().equals(component.getRepoId())).findFirst().ifPresent(repo -> pmsProductLibraryComponentDataVo.setDownloadUrl(
|
||||
EscapeUtil.removeExtraSlashOfUrl(
|
||||
String.format("%s/%s", repo.getUrl(), component.getPath()))));
|
||||
return pmsProductLibraryComponentDataVo;
|
||||
}
|
||||
private void setNexusResultDataVoChoose(PmsProductLibraryRepositories productRepo, List<PmsProductLibraryComponent> productComponentList, List<NexusResultDataVo> nexusResultDataVoList, boolean isDocker) {
|
||||
for (PmsProductLibraryComponent component : productComponentList) {
|
||||
nexusResultDataVoList.forEach(x -> {
|
||||
if (pmsProductLibraryComponentService.getLockComponentStatus(productRepo.getId(), x.getComponentId())) {
|
||||
x.setIsChoose(true);
|
||||
} else if (isDocker && StringUtils.isNotEmpty(x.getComponentId())) {
|
||||
if (x.getComponentId().equals(component.getIdentifier())) {
|
||||
x.setIsChoose(true);
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(x.getAssetId()) && x.getAssetId().equals(component.getIdentifier())) {
|
||||
x.setIsChoose(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private void setNexusResultDataVoPath(PmsProductLibraryRepositories repo, List<NexusResultDataVo> nexusResultDataVoList) {
|
||||
nexusResultDataVoList.forEach(x -> {
|
||||
if (ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
x.setDefaultDir(EscapeUtil.removeExtraSlashOfUrl(String.format("/%s/", repo.getAlias())));
|
||||
} else {
|
||||
x.setDefaultDir(EscapeUtil.removeExtraSlashOfUrl(String.format("/%s/%s", repo.getAlias(), PmsUtils.parseDirectory(x.getId()))));
|
||||
}
|
||||
});
|
||||
}
|
||||
private NexusComponentResultVo<List<NexusResultDataVo>> buildDockerResultVo(List<NexusResultDataVo> data) {
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> target = new NexusComponentResultVo<>();
|
||||
target.setAction("coreui_Browse");
|
||||
target.setMethod("read");
|
||||
target.setTid(1);
|
||||
target.setType("rpc");
|
||||
NexusComponentResultStateVo<List<NexusResultDataVo>> nexusComponentResultStateVo = new NexusComponentResultStateVo<>();
|
||||
nexusComponentResultStateVo.setData(data);
|
||||
nexusComponentResultStateVo.setSuccess(true);
|
||||
target.setResult(nexusComponentResultStateVo);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.microservices.pms.productLibrary.service.impl;
|
||||
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryProxyService;
|
||||
import com.microservices.pms.utils.NexusRequestHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
*/
|
||||
@Service
|
||||
public class PmsProductLibraryProxyProxyServiceImpl implements IPmsProductLibraryProxyService {
|
||||
|
||||
@Autowired
|
||||
private NexusRequestHelper nexusRequestHelper;
|
||||
|
||||
@Override
|
||||
public AjaxResult proxyNexusJson(HttpServletRequest request) {
|
||||
return AjaxResult.success(nexusRequestHelper.doRequest(request));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,34 @@
|
|||
package com.microservices.pms.productLibrary.service.impl;
|
||||
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.core.utils.PageUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.html.EscapeUtil;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.pms.enterprise.domain.PmsEnterprise;
|
||||
import com.microservices.pms.enterprise.service.IPmsEnterpriseService;
|
||||
import com.microservices.pms.productLibrary.domain.PmsProductLibraryComponent;
|
||||
import com.microservices.pms.productLibrary.domain.PmsProductLibraryRepositories;
|
||||
import com.microservices.pms.productLibrary.domain.ProductLibraryRepositoriesFormatEnum;
|
||||
import com.microservices.pms.productLibrary.domain.vo.*;
|
||||
import com.microservices.pms.productLibrary.mapper.PmsProductLibraryComponentMapper;
|
||||
import com.microservices.pms.productLibrary.mapper.PmsProductLibraryRepositoriesMapper;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryAsyncService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryComponentService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryRepositoriesService;
|
||||
import com.microservices.pms.productLibrary.service.IPmsProductLibraryService;
|
||||
import com.microservices.pms.utils.NexusRequestHelper;
|
||||
import com.microservices.pms.utils.NexusRequestUrl;
|
||||
import com.microservices.pms.utils.PmsUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author OTTO
|
||||
|
|
@ -15,11 +36,303 @@ import javax.servlet.http.HttpServletRequest;
|
|||
@Service
|
||||
public class PmsProductLibraryServiceImpl implements IPmsProductLibraryService {
|
||||
|
||||
@Autowired
|
||||
private PmsProductLibraryRepositoriesMapper pmsProductLibraryRepositoriesMapper;
|
||||
@Autowired
|
||||
private PmsProductLibraryComponentMapper pmsProductLibraryComponentMapper;
|
||||
@Autowired
|
||||
private NexusRequestHelper nexusRequestHelper;
|
||||
@Autowired
|
||||
private IPmsEnterpriseService pmsEnterpriseService;
|
||||
@Autowired
|
||||
private IPmsProductLibraryAsyncService pmsProductLibraryAsyncService;
|
||||
@Autowired
|
||||
private IPmsProductLibraryComponentService pmsProductLibraryComponentService;
|
||||
@Autowired
|
||||
private IPmsProductLibraryRepositoriesService pmsProductLibraryRepositoriesService;
|
||||
|
||||
@Override
|
||||
public AjaxResult proxyNexusJson(HttpServletRequest request) {
|
||||
return AjaxResult.success(nexusRequestHelper.doRequest(request));
|
||||
public GenericsTableDataInfo<PmsProductLibraryComponentDataVo> selectComponentList(PmsProductLibraryComponentSearchVo search) {
|
||||
List<PmsProductLibraryComponent> pmsProductLibraryComponentList =
|
||||
pmsProductLibraryComponentMapper.selectProductRepoComponentList(search);
|
||||
List<Long> repoIdList = pmsProductLibraryComponentList.stream().map(PmsProductLibraryComponent::getRepoId).distinct().collect(Collectors.toList());
|
||||
List<PmsProductLibraryRepositories> repoList = repoIdList.stream().map(this::selectPmsProductLibraryRepositoriesById).collect(Collectors.toList());
|
||||
return PageUtils.toPage(pmsProductLibraryComponentList, x -> toPmsProductLibraryComponentDataVo(x, repoList));
|
||||
}
|
||||
|
||||
private PmsProductLibraryRepositories selectPmsProductLibraryRepositoriesById(Long repoId) {
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories =
|
||||
pmsProductLibraryRepositoriesMapper.selectProductRepoById(repoId);
|
||||
if (pmsProductLibraryRepositories == null) {
|
||||
throw new ServiceException("组织下不存在该产品库(产品库id[%d])", repoId);
|
||||
}
|
||||
return pmsProductLibraryRepositories;
|
||||
}
|
||||
|
||||
private PmsProductLibraryComponentDataVo toPmsProductLibraryComponentDataVo(PmsProductLibraryComponent component, List<PmsProductLibraryRepositories> repoList) {
|
||||
PmsProductLibraryComponentDataVo pmsProductLibraryComponentDataVo = component.toPmsProductLibraryComponentDataVo();
|
||||
repoList.stream().filter(x -> x.getId().equals(component.getRepoId())).findFirst().ifPresent(repo -> pmsProductLibraryComponentDataVo.setDownloadUrl(
|
||||
EscapeUtil.removeExtraSlashOfUrl(
|
||||
String.format("%s/%s", repo.getUrl(), component.getPath()))));
|
||||
return pmsProductLibraryComponentDataVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PmsProductLibraryRepositoriesDataVo selectPmsProductLibraryDataByName(String enterpriseIdentifier, String repoName) {
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories = selectPmsProductLibraryByName(enterpriseIdentifier, repoName);
|
||||
return pmsProductLibraryRepositories.toPmsProductLibraryRepositoriesDataVo();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PmsProductLibraryRepositories selectPmsProductLibraryByName(String enterpriseIdentifier, String name) {
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories = pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryByName(enterpriseIdentifier, name);
|
||||
if (pmsProductLibraryRepositories == null) {
|
||||
throw new ServiceException("组织下不存在该产品库(组织标识[%s],产品库标识[%s])", enterpriseIdentifier, name);
|
||||
}
|
||||
return pmsProductLibraryRepositories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericsTableDataInfo<PmsProductLibrarySimpleVo> selectPmsProductLibraryPageList(String enterpriseIdentifier, String name) {
|
||||
return PageUtils.toPage(pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryList(enterpriseIdentifier, name), PmsProductLibraryRepositories::toPmsProductLibrarySimpleVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updatePmsProductLibrary(ProductRepositoriesOperateVo productRepositoriesOperateVo) {
|
||||
PmsProductLibraryRepositories oldRepo = selectPmsProductLibraryByName(productRepositoriesOperateVo.getEnterpriseIdentifier(), productRepositoriesOperateVo.getName());
|
||||
|
||||
// 校验制品库别名
|
||||
PmsProductLibraryRepositories aliasRepo = pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryRepositoriesByAlias(productRepositoriesOperateVo.getAlias(), productRepositoriesOperateVo.getEnterpriseIdentifier());
|
||||
if (aliasRepo != null && !aliasRepo.getId().equals(oldRepo.getId())) {
|
||||
throw new ServiceException("该产品库名称在当前组织下已存在(产品库名称[%s])", productRepositoriesOperateVo.getAlias());
|
||||
}
|
||||
// 构建更新对象
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories = productRepositoriesOperateVo.toPmsProductLibraryRepositories();
|
||||
pmsProductLibraryRepositories.setId(oldRepo.getId());
|
||||
pmsProductLibraryRepositories.setUpdateTime(DateUtils.getNowDate());
|
||||
pmsProductLibraryRepositories.setUpdateBy(SecurityUtils.getUsername());
|
||||
NexusHostedRepoInputVo requestBody = productRepositoriesOperateVo.toNexusRepoDataVo();
|
||||
|
||||
// 调用制品库更新接口更新制品库
|
||||
nexusRequestHelper.doRequest(NexusRequestUrl.UPDATE_REPOSITORIES(requestBody.getType(), requestBody.getFormat(), requestBody.getName()), JSONObject.from(requestBody));
|
||||
|
||||
return pmsProductLibraryRepositoriesMapper.updatePmsProductLibraryRepositories(pmsProductLibraryRepositories);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int insertPmsProductLibrary(ProductRepositoriesInputVo productRepositoriesInputVo) {
|
||||
PmsEnterprise pmsEnterprise = pmsEnterpriseService.selectPmsEnterpriseByIdentifier(productRepositoriesInputVo.getEnterpriseIdentifier());
|
||||
// 校验制品库标识
|
||||
Integer count = pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryRepositoriesByNameCount(productRepositoriesInputVo.getName(), productRepositoriesInputVo.getEnterpriseIdentifier(), productRepositoriesInputVo.getFormat());
|
||||
if (count > 0) {
|
||||
throw new ServiceException("该产品库标识在当前组织下已存在(产品库标识[%s])", productRepositoriesInputVo.getName());
|
||||
}
|
||||
// 校验制品库别名
|
||||
PmsProductLibraryRepositories aliasRepo = pmsProductLibraryRepositoriesMapper.selectPmsProductLibraryRepositoriesByAlias(productRepositoriesInputVo.getAlias(), productRepositoriesInputVo.getEnterpriseIdentifier());
|
||||
if (aliasRepo != null) {
|
||||
throw new ServiceException("该产品库名称在当前组织下已存在(产品库名称[%s])", productRepositoriesInputVo.getAlias());
|
||||
}
|
||||
NexusHostedRepoInputVo requestBody = productRepositoriesInputVo.toNexusRepoDataVo();
|
||||
|
||||
// 调用制品库创建接口创建产品库
|
||||
nexusRequestHelper.doRequest(NexusRequestUrl.ADD_REPOSITORIES(requestBody.getType(), requestBody.getFormat()), JSONObject.from(requestBody));
|
||||
// 调用Nexus制品库详情接口获取制品库详情
|
||||
NexusHostedRepoInputVo nexusDataVo = pmsProductLibraryRepositoriesService.getNexusRepo(
|
||||
productRepositoriesInputVo.getType(),
|
||||
productRepositoriesInputVo.getFormat(),
|
||||
PmsProductLibraryRepositories.getNexusProductRepositoriesName(
|
||||
productRepositoriesInputVo.getEnterpriseIdentifier(),
|
||||
productRepositoriesInputVo.getName()
|
||||
));
|
||||
// 数据库添加该制品库
|
||||
PmsProductLibraryRepositories pmsProductLibraryRepositories = productRepositoriesInputVo.toPmsProductLibraryRepositories();
|
||||
pmsProductLibraryRepositories.setUrl(nexusDataVo.getUrl());
|
||||
pmsProductLibraryRepositories.setPmsEnterpriseId(pmsEnterprise.getId());
|
||||
pmsProductLibraryRepositories.setDeptId(pmsEnterprise.getDeptId());
|
||||
pmsProductLibraryRepositories.setCreateTime(DateUtils.getNowDate());
|
||||
pmsProductLibraryRepositories.setCreateBy(SecurityUtils.getUsername());
|
||||
return pmsProductLibraryRepositoriesMapper.insertPmsProductLibraryRepositories(pmsProductLibraryRepositories);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deletePmsProductLibraryByName(String enterpriseIdentifier, String name) {
|
||||
PmsProductLibraryRepositories oldRepo = selectPmsProductLibraryByName(enterpriseIdentifier, name);
|
||||
// 调用制品库删除接口删除制品库
|
||||
nexusRequestHelper.doRequest(NexusRequestUrl.DELETE_REPOSITORIES(PmsProductLibraryRepositories.getNexusProductRepositoriesName(enterpriseIdentifier, name)));
|
||||
return pmsProductLibraryRepositoriesMapper.deletePmsProductLibraryRepositoriesById(oldRepo.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCommonAssetToProductRepo(CommonAssetAddToProductRepoVo commonAssetAddToProductRepoVo) {
|
||||
// 先校验产品库、制品库、制品库下制品Id列表是否存在,再进行异步处理
|
||||
PmsProductLibraryRepositories productRepo = selectPmsProductLibraryByName(commonAssetAddToProductRepoVo.getEnterpriseIdentifier(), commonAssetAddToProductRepoVo.getProductRepoName());
|
||||
PmsProductLibraryRepositories repo = pmsProductLibraryRepositoriesService.selectPmsProductLibraryRepositoriesByName(commonAssetAddToProductRepoVo.getEnterpriseIdentifier(), commonAssetAddToProductRepoVo.getRepoName());
|
||||
if (ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
throw new ServiceException("Docker制品移入不能使用该接口");
|
||||
}
|
||||
List<NexusAssetResultDataVo> nexusAssetResultDataVoList = new ArrayList<>();
|
||||
for (String assetId : commonAssetAddToProductRepoVo.getAssetIdList()) {
|
||||
NexusComponentResultVo<NexusAssetResultDataVo> nexusAssetResultVo = pmsProductLibraryComponentService.getAssetDetailByAssetId(commonAssetAddToProductRepoVo.getEnterpriseIdentifier(), commonAssetAddToProductRepoVo.getRepoName(), null, assetId, false);
|
||||
if (nexusAssetResultVo == null || nexusAssetResultVo.getResult() == null || !nexusAssetResultVo.getResult().getSuccess()) {
|
||||
throw new ServiceException("该制品不存在(制品库[%s],制品Id[%s])", commonAssetAddToProductRepoVo.getRepoName(), assetId);
|
||||
} else {
|
||||
NexusAssetResultDataVo data = nexusAssetResultVo.getResult().getData();
|
||||
if (pmsProductLibraryComponentService.getLockComponentStatus(productRepo.getId(), assetId)) {
|
||||
throw new ServiceException("制品锁定中,无法被移入产品库(制品名称[%s],产品库名称[%s])", data.getName(), productRepo.getName());
|
||||
}
|
||||
PmsProductLibraryComponent pmsProductLibraryComponent = pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentByIdentifier(productRepo.getId(), assetId);
|
||||
if (pmsProductLibraryComponent != null) {
|
||||
throw new ServiceException("制品已被移入产品库中,无法重复移入(制品名称[%s],产品库名称[%s])", data.getName(), productRepo.getName());
|
||||
}
|
||||
nexusAssetResultDataVoList.add(data);
|
||||
}
|
||||
}
|
||||
pmsProductLibraryAsyncService.asyncAddCommonAssetToProductRepo(productRepo, repo, nexusAssetResultDataVoList, commonAssetAddToProductRepoVo.getDirectory());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NexusComponentResultVo<List<NexusResultDataVo>> selectPmsProductLibraryKeyComponentList(String enterpriseIdentifier, ComponentSearchVo componentSearchVo) {
|
||||
PmsProductLibraryRepositories productRepo = pmsProductLibraryComponentService.getPmsProductLibraryRepositories(true, enterpriseIdentifier, componentSearchVo.getProductRepoName(), null);
|
||||
PmsProductLibraryComponent productComponentSearch = new PmsProductLibraryComponent();
|
||||
productComponentSearch.setRepoId(productRepo.getId());
|
||||
List<PmsProductLibraryComponent> productComponentList = pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentList(productComponentSearch);
|
||||
PmsProductLibraryRepositories repo = pmsProductLibraryComponentService.getPmsProductLibraryRepositories(false, enterpriseIdentifier, componentSearchVo.getRepositoryName(), null);
|
||||
componentSearchVo.setRepositoryName(repo.getNexusRepositoriesName());
|
||||
// Docker类型调用Nexus获取制品列表接口获取
|
||||
if (ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
List<NexusResultDataVo> keyNexusResultDataVoList = new ArrayList<>();
|
||||
// 需循环遍历获取所有镜像列表
|
||||
boolean isAll = false;
|
||||
// Nexus分页Token
|
||||
String continuationToken = null;
|
||||
while (!isAll) {
|
||||
NexusComponentAndAssetListVo<NexusDockerComponentVo> assetListVo = nexusRequestHelper.doRequestToJavaObject(NexusRequestUrl.GET_COMPONENTS(repo.getNexusRepositoriesName(), continuationToken), NexusComponentAndAssetListVo.class, NexusDockerComponentVo.class);
|
||||
if (assetListVo != null) {
|
||||
if (StringUtils.isEmpty(assetListVo.getContinuationToken())) {
|
||||
isAll = true;
|
||||
} else {
|
||||
continuationToken = assetListVo.getContinuationToken();
|
||||
}
|
||||
for (NexusDockerComponentVo nexusDockerComponentVo : assetListVo.getItems()) {
|
||||
NexusResultDataVo nexusResultDataVo = nexusDockerComponentVo.toNexusResultDataVo();
|
||||
keyNexusResultDataVoList.add(nexusResultDataVo);
|
||||
}
|
||||
} else {
|
||||
isAll = true;
|
||||
}
|
||||
|
||||
}
|
||||
setNexusResultDataVoChoose(productRepo, productComponentList, keyNexusResultDataVoList, true);
|
||||
setNexusResultDataVoPath(repo, keyNexusResultDataVoList);
|
||||
return buildDockerResultVo(keyNexusResultDataVoList);
|
||||
} else {
|
||||
NexusComponentSearchVo<ComponentSearchVo> nexusComponentSearchVo = NexusComponentSearchVo.toRead(componentSearchVo, nexusRequestHelper.getNexusTid());
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> assetResultDataVo = nexusRequestHelper.doRequestToJavaObjectList(NexusRequestUrl.DO_OPERATION(), JSONObject.from(nexusComponentSearchVo), NexusComponentResultVo.class, NexusResultDataVo.class);
|
||||
if (assetResultDataVo != null && assetResultDataVo.getResult() != null) {
|
||||
NexusComponentResultStateVo<List<NexusResultDataVo>> nexusComponentResultStateVo = assetResultDataVo.getResult();
|
||||
if (nexusComponentResultStateVo.getSuccess()) {
|
||||
List<NexusResultDataVo> nexusResultDataVoList = nexusComponentResultStateVo.getData();
|
||||
setNexusResultDataVoChoose(productRepo, productComponentList, nexusResultDataVoList, false);
|
||||
setNexusResultDataVoPath(repo, nexusResultDataVoList);
|
||||
// 当制品库为Maven时,需排除自动生成的制品数据
|
||||
if (ProductLibraryRepositoriesFormatEnum.MAVEN.getKey().equals(repo.getFormat())) {
|
||||
List<NexusResultDataVo> keyNexusResultDataVoList = new ArrayList<>();
|
||||
for (NexusResultDataVo nexusResultDataVo : nexusResultDataVoList) {
|
||||
// 当类型为asset时,需检查数据库是否存在记录,若存在则返回
|
||||
if ("asset".equals(nexusResultDataVo.getType())) {
|
||||
PmsProductLibraryComponent pmsProductLibraryComponent = pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentByPath(nexusResultDataVo.getId(), repo.getId(), repo.getPmsEnterpriseId());
|
||||
if (pmsProductLibraryComponent != null) {
|
||||
keyNexusResultDataVoList.add(nexusResultDataVo);
|
||||
}
|
||||
} else {
|
||||
keyNexusResultDataVoList.add(nexusResultDataVo);
|
||||
}
|
||||
}
|
||||
nexusComponentResultStateVo.setData(keyNexusResultDataVoList);
|
||||
assetResultDataVo.setResult(nexusComponentResultStateVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return assetResultDataVo;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDockerComponentToProductRepo(DockerComponentAddToProductRepoVo dockerComponentAddToProductRepoVo) {
|
||||
// 先校验产品库、制品库、制品库下制品Id列表是否存在,再进行异步处理
|
||||
PmsProductLibraryRepositories productRepo = selectPmsProductLibraryByName(dockerComponentAddToProductRepoVo.getEnterpriseIdentifier(), dockerComponentAddToProductRepoVo.getProductRepoName());
|
||||
PmsProductLibraryRepositories repo = pmsProductLibraryRepositoriesService.selectPmsProductLibraryRepositoriesByName(dockerComponentAddToProductRepoVo.getEnterpriseIdentifier(), dockerComponentAddToProductRepoVo.getRepoName());
|
||||
if (!ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
throw new ServiceException("当前接口仅允许进行Docker移入产品库操作");
|
||||
}
|
||||
List<NexusComponentResultDataVo> nexusComponentResultDataVoList = new ArrayList<>();
|
||||
for (String componentId : dockerComponentAddToProductRepoVo.getComponentIdList()) {
|
||||
NexusComponentResultVo<NexusComponentResultDataVo> nexusAssetResultVo = pmsProductLibraryComponentService.getComponentDetailByComponentId(dockerComponentAddToProductRepoVo.getEnterpriseIdentifier(), dockerComponentAddToProductRepoVo.getRepoName(), null, componentId, false);
|
||||
if (nexusAssetResultVo == null || nexusAssetResultVo.getResult() == null || !nexusAssetResultVo.getResult().getSuccess()) {
|
||||
throw new ServiceException("该制品不存在(制品库[%s],制品Id[%s])", dockerComponentAddToProductRepoVo.getRepoName(), componentId);
|
||||
} else {
|
||||
NexusComponentResultDataVo data = nexusAssetResultVo.getResult().getData();
|
||||
if (pmsProductLibraryComponentService.getLockComponentStatus(productRepo.getId(), componentId)) {
|
||||
throw new ServiceException("制品锁定中,无法被移入产品库(制品名称[%s],产品库名称[%s])", data.getName(), productRepo.getName());
|
||||
}
|
||||
PmsProductLibraryComponent pmsProductLibraryComponent = pmsProductLibraryComponentMapper.selectPmsProductLibraryComponentByIdentifier(productRepo.getId(), componentId);
|
||||
if (pmsProductLibraryComponent != null) {
|
||||
throw new ServiceException("制品已被移入产品库中,无法重复移入(制品名称[%s],产品库名称[%s])", data.getName(), productRepo.getName());
|
||||
}
|
||||
nexusComponentResultDataVoList.add(data);
|
||||
}
|
||||
}
|
||||
pmsProductLibraryAsyncService.asyncAddDockerComponentToProductRepo(productRepo, repo, nexusComponentResultDataVoList, dockerComponentAddToProductRepoVo.getDirectory());
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setNexusResultDataVoChoose(PmsProductLibraryRepositories productRepo, List<PmsProductLibraryComponent> productComponentList, List<NexusResultDataVo> nexusResultDataVoList, boolean isDocker) {
|
||||
for (PmsProductLibraryComponent component : productComponentList) {
|
||||
nexusResultDataVoList.forEach(x -> {
|
||||
if (pmsProductLibraryComponentService.getLockComponentStatus(productRepo.getId(), x.getComponentId())) {
|
||||
x.setIsChoose(true);
|
||||
} else if (isDocker && StringUtils.isNotEmpty(x.getComponentId())) {
|
||||
if (x.getComponentId().equals(component.getIdentifier())) {
|
||||
x.setIsChoose(true);
|
||||
}
|
||||
} else if (StringUtils.isNotEmpty(x.getAssetId()) && x.getAssetId().equals(component.getIdentifier())) {
|
||||
x.setIsChoose(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void setNexusResultDataVoPath(PmsProductLibraryRepositories repo, List<NexusResultDataVo> nexusResultDataVoList) {
|
||||
nexusResultDataVoList.forEach(x -> {
|
||||
if (ProductLibraryRepositoriesFormatEnum.DOCKER.getKey().equals(repo.getFormat())) {
|
||||
x.setDefaultDir(EscapeUtil.removeExtraSlashOfUrl(String.format("/%s/", repo.getAlias())));
|
||||
} else {
|
||||
x.setDefaultDir(EscapeUtil.removeExtraSlashOfUrl(String.format("/%s/%s", repo.getAlias(), PmsUtils.parseDirectory(x.getId()))));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private NexusComponentResultVo<List<NexusResultDataVo>> buildDockerResultVo(List<NexusResultDataVo> data) {
|
||||
NexusComponentResultVo<List<NexusResultDataVo>> target = new NexusComponentResultVo<>();
|
||||
target.setAction("coreui_Browse");
|
||||
target.setMethod("read");
|
||||
target.setTid(1);
|
||||
target.setType("rpc");
|
||||
NexusComponentResultStateVo<List<NexusResultDataVo>> nexusComponentResultStateVo = new NexusComponentResultStateVo<>();
|
||||
nexusComponentResultStateVo.setData(data);
|
||||
nexusComponentResultStateVo.setSuccess(true);
|
||||
target.setResult(nexusComponentResultStateVo);
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean packagedProduct(String enterpriseIdentifier, String productRepoName) {
|
||||
PmsProductLibraryRepositories productRepo = selectPmsProductLibraryByName(enterpriseIdentifier, productRepoName);
|
||||
pmsProductLibraryAsyncService.packagedProduct(productRepo);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue