diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/listener/SubtaskStatusChangedEventListener.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/listener/SubtaskStatusChangedEventListener.kt index 8d80f0ad5c..d7791b51a9 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/listener/SubtaskStatusChangedEventListener.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/event/listener/SubtaskStatusChangedEventListener.kt @@ -27,23 +27,23 @@ package com.tencent.bkrepo.analyst.event.listener +import com.tencent.bkrepo.analyst.event.SubtaskStatusChangedEvent +import com.tencent.bkrepo.analyst.model.SubScanTaskDefinition +import com.tencent.bkrepo.analyst.model.TPlanArtifactLatestSubScanTask +import com.tencent.bkrepo.analyst.pojo.request.ArtifactPlanRelationRequest +import com.tencent.bkrepo.analyst.service.ScanPlanService +import com.tencent.bkrepo.common.analysis.pojo.scanner.SubScanTaskStatus import com.tencent.bkrepo.common.api.util.toJsonString import com.tencent.bkrepo.common.artifact.constant.FORBID_STATUS import com.tencent.bkrepo.common.artifact.constant.FORBID_TYPE import com.tencent.bkrepo.common.artifact.constant.SCAN_STATUS import com.tencent.bkrepo.common.artifact.pojo.RepositoryType -import com.tencent.bkrepo.common.analysis.pojo.scanner.SubScanTaskStatus -import com.tencent.bkrepo.repository.api.PackageMetadataClient +import com.tencent.bkrepo.common.metadata.service.metadata.MetadataService +import com.tencent.bkrepo.common.metadata.service.metadata.PackageMetadataService import com.tencent.bkrepo.repository.pojo.metadata.ForbidType import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.metadata.MetadataSaveRequest import com.tencent.bkrepo.repository.pojo.metadata.packages.PackageMetadataSaveRequest -import com.tencent.bkrepo.analyst.event.SubtaskStatusChangedEvent -import com.tencent.bkrepo.analyst.model.SubScanTaskDefinition -import com.tencent.bkrepo.analyst.model.TPlanArtifactLatestSubScanTask -import com.tencent.bkrepo.analyst.pojo.request.ArtifactPlanRelationRequest -import com.tencent.bkrepo.analyst.service.ScanPlanService -import com.tencent.bkrepo.common.metadata.service.metadata.MetadataService import org.slf4j.LoggerFactory import org.springframework.context.event.EventListener import org.springframework.scheduling.annotation.Async @@ -52,7 +52,7 @@ import org.springframework.stereotype.Component @Component class SubtaskStatusChangedEventListener( private val metadataService: MetadataService, - private val packageMetadataClient: PackageMetadataClient, + private val packageMetadataService: PackageMetadataService, private val scanPlanService: ScanPlanService ) { @Async @@ -158,7 +158,7 @@ class SubtaskStatusChangedEventListener( version = version!!, versionMetadata = metadata ) - packageMetadataClient.saveMetadata(request) + packageMetadataService.saveMetadata(request) } } } diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ProjectUsageStatisticsServiceImpl.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ProjectUsageStatisticsServiceImpl.kt index f8b7bb704e..0f063a100c 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ProjectUsageStatisticsServiceImpl.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ProjectUsageStatisticsServiceImpl.kt @@ -28,20 +28,18 @@ package com.tencent.bkrepo.analyst.service.impl import com.tencent.bkrepo.common.api.pojo.Page -import com.tencent.bkrepo.common.metadata.service.project.ProjectUsageStatisticsService import com.tencent.bkrepo.common.metadata.pojo.project.ProjectUsageStatistics import com.tencent.bkrepo.common.metadata.pojo.project.ProjectUsageStatisticsListOption -import com.tencent.bkrepo.repository.api.ProjectUsageStatisticsClient -import org.springframework.beans.factory.ObjectProvider +import com.tencent.bkrepo.common.metadata.service.project.ProjectUsageStatisticsService import org.springframework.scheduling.annotation.Async open class ProjectUsageStatisticsServiceImpl( - private val projectUsageStatisticsClient: ObjectProvider + private val projectUsageStatisticsService: ProjectUsageStatisticsService ) : ProjectUsageStatisticsService { @Async override fun inc(projectId: String, reqCount: Long, receivedBytes: Long, responseBytes: Long) { - projectUsageStatisticsClient.ifAvailable?.inc(projectId, reqCount, receivedBytes, responseBytes) + projectUsageStatisticsService.inc(projectId, reqCount, receivedBytes, responseBytes) } override fun page(options: ProjectUsageStatisticsListOption): Page { diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ScanPlanServiceImpl.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ScanPlanServiceImpl.kt index 50b71b1e17..3ed1e28478 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ScanPlanServiceImpl.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/service/impl/ScanPlanServiceImpl.kt @@ -46,7 +46,6 @@ import com.tencent.bkrepo.analyst.pojo.response.ScanLicensePlanInfo import com.tencent.bkrepo.analyst.pojo.response.ScanPlanInfo import com.tencent.bkrepo.analyst.service.ScanPlanService import com.tencent.bkrepo.analyst.service.ScannerService -import com.tencent.bkrepo.analyst.utils.Request import com.tencent.bkrepo.analyst.utils.RuleConverter import com.tencent.bkrepo.analyst.utils.RuleUtil import com.tencent.bkrepo.analyst.utils.ScanLicenseConverter @@ -59,18 +58,18 @@ import com.tencent.bkrepo.common.api.message.CommonMessageCode import com.tencent.bkrepo.common.api.pojo.Page import com.tencent.bkrepo.common.api.util.toJsonString import com.tencent.bkrepo.common.artifact.pojo.RepositoryType +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.query.model.PageLimit import com.tencent.bkrepo.common.query.model.Rule import com.tencent.bkrepo.common.security.permission.PrincipalType import com.tencent.bkrepo.common.security.util.SecurityUtils -import com.tencent.bkrepo.repository.api.PackageClient import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import java.time.LocalDateTime @Service class ScanPlanServiceImpl( - private val packageClient: PackageClient, + private val packageService: PackageService, private val scanPlanDao: ScanPlanDao, private val scanTaskDao: ScanTaskDao, private val scannerDao: ScannerDao, @@ -284,10 +283,7 @@ class ScanPlanServiceImpl( fullPath = fullPath ) if (fullPath == null) { - val packageVersion = Request.request { - packageClient.findVersionByName(projectId, repoName, packageKey!!, version!!) - } - + val packageVersion = packageService.findVersionByName(projectId, repoName, packageKey!!, version!!) fullPath = packageVersion?.contentPath ?: packageVersion?.manifestPath fullPath ?: throw NotFoundException(CommonMessageCode.RESOURCE_NOT_FOUND, packageKey!!, version!!) } diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/statemachine/iterator/IteratorManager.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/statemachine/iterator/IteratorManager.kt index 50a53fdf83..1397745bc7 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/statemachine/iterator/IteratorManager.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/statemachine/iterator/IteratorManager.kt @@ -35,10 +35,10 @@ import com.tencent.bkrepo.analyst.utils.RuleUtil import com.tencent.bkrepo.common.analysis.pojo.scanner.Scanner import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.metadata.service.node.NodeSearchService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.query.model.Rule -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.packages.PackageSummary @@ -51,7 +51,7 @@ import org.springframework.stereotype.Component class IteratorManager( private val nodeSearchService: NodeSearchService, private val repositoryService: RepositoryService, - private val packageClient: PackageClient + private val packageService: PackageService ) { /** * 创建待扫描文件迭代器 @@ -75,7 +75,7 @@ class IteratorManager( val isPackageScanPlanType = scanTask.scanPlan != null && scanTask.scanPlan!!.type != RepositoryType.GENERIC.name return if (isPackageScanPlanType || packageRule(rule)) { - PackageIterator(packageClient, nodeSearchService, PackageIterator.PackageIteratePosition(rule)) + PackageIterator(packageService, nodeSearchService, PackageIterator.PackageIteratePosition(rule)) } else { NodeIterator(projectIdIterator, nodeSearchService, NodeIterator.NodeIteratePosition(rule)) } diff --git a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/statemachine/iterator/PackageIterator.kt b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/statemachine/iterator/PackageIterator.kt index 14aae43203..aab7a5d4df 100644 --- a/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/statemachine/iterator/PackageIterator.kt +++ b/src/backend/analyst/biz-analyst/src/main/kotlin/com/tencent/bkrepo/analyst/statemachine/iterator/PackageIterator.kt @@ -34,12 +34,12 @@ import com.tencent.bkrepo.analyst.utils.Request import com.tencent.bkrepo.common.api.constant.DEFAULT_PAGE_NUMBER import com.tencent.bkrepo.common.api.constant.DEFAULT_PAGE_SIZE import com.tencent.bkrepo.common.metadata.service.node.NodeSearchService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.query.matcher.RuleMatcher import com.tencent.bkrepo.common.query.model.PageLimit import com.tencent.bkrepo.common.query.model.QueryModel import com.tencent.bkrepo.common.query.model.Rule -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import org.slf4j.LoggerFactory @@ -49,7 +49,7 @@ import kotlin.math.min * 依赖包迭代器 */ class PackageIterator( - private val packageClient: PackageClient, + private val packageService: PackageService, private val nodeSearchService: NodeSearchService, override val position: PackageIteratePosition ) : PageableIterator() { @@ -101,7 +101,7 @@ class PackageIterator( rule = packageSummaryRule(position.rule) ) - val records = Request.request { packageClient.searchPackage(packageQueryModel) }!!.records + val records = packageService.searchPackage(packageQueryModel).records return if (records.isEmpty()) { emptyList() } else { @@ -218,9 +218,7 @@ class PackageIterator( if (logger.isDebugEnabled) { logger.debug("populating package[$pkg]") } - val packageVersion = Request.request { - packageClient.findVersionByName(projectId, repoName, packageKey, packageVersion!!) - } + val packageVersion = packageService.findVersionByName(projectId, repoName, packageKey, packageVersion!!) pkg.fullPath = packageVersion?.contentPath ?: packageVersion?.manifestPath pkg.size = packageVersion?.size } diff --git a/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/service/CompressServiceTest.kt b/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/service/CompressServiceTest.kt index 99120da73a..e71edcad0e 100644 --- a/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/service/CompressServiceTest.kt +++ b/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/service/CompressServiceTest.kt @@ -10,8 +10,6 @@ import com.tencent.bkrepo.common.api.constant.StringPool import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.storage.StorageAutoConfiguration import com.tencent.bkrepo.common.storage.core.StorageService -import com.tencent.bkrepo.repository.api.FileReferenceClient -import com.tencent.bkrepo.repository.api.RepositoryClient import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -34,12 +32,6 @@ class CompressServiceTest @Autowired constructor( @MockBean lateinit var storageService: StorageService - @MockBean - lateinit var fileReferenceClient: FileReferenceClient - - @MockBean - lateinit var repositoryClient: RepositoryClient - @BeforeEach fun beforeEach() { compressFileRepository.deleteAll() diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/PackageManager.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/PackageManager.kt index e62f064a92..9058fc2fb7 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/PackageManager.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/PackageManager.kt @@ -33,7 +33,7 @@ package com.tencent.bkrepo.common.artifact.manager import com.tencent.bkrepo.common.api.exception.NotFoundException import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode -import com.tencent.bkrepo.repository.api.PackageClient +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion @@ -41,11 +41,11 @@ import com.tencent.bkrepo.repository.pojo.packages.PackageVersion * 包版本相关Manager */ class PackageManager( - private val packageClient: PackageClient + private val packageService: PackageService ) { fun findPackageByKey(projectId: String, repoName: String, packageKey: String): PackageSummary { - return packageClient.findPackageByKey(projectId, repoName, packageKey).data + return packageService.findPackageByKey(projectId, repoName, packageKey) ?: throw NotFoundException(ArtifactMessageCode.PACKAGE_NOT_FOUND, packageKey) } @@ -55,7 +55,7 @@ class PackageManager( packageKey: String, version: String ): PackageVersion { - return packageClient.findVersionByName(projectId, repoName, packageKey, version).data + return packageService.findVersionByName(projectId, repoName, packageKey, version) ?: throw NotFoundException(ArtifactMessageCode.VERSION_NOT_FOUND, version) } @@ -65,7 +65,7 @@ class PackageManager( packageKey: String, tag: String ): String { - return packageClient.findVersionNameByTag(projectId, repoName, packageKey, tag).data + return packageService.findVersionNameByTag(projectId, repoName, packageKey, tag) ?: throw NotFoundException(ArtifactMessageCode.VERSION_NOT_FOUND, tag) } } diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/core/AbstractArtifactRepository.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/core/AbstractArtifactRepository.kt index 3d8bfb7770..ec19bf0a05 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/core/AbstractArtifactRepository.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/core/AbstractArtifactRepository.kt @@ -56,6 +56,8 @@ import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactResourceWrite import com.tencent.bkrepo.common.artifact.util.PackageKeys import com.tencent.bkrepo.common.metadata.service.node.NodeSearchService import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageDownloadsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.service.util.HeaderUtils @@ -64,8 +66,6 @@ import com.tencent.bkrepo.common.service.util.LocaleMessageUtils import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.monitor.Throughput import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier -import com.tencent.bkrepo.repository.api.PackageClient -import com.tencent.bkrepo.repository.api.PackageDownloadsClient import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -91,7 +91,7 @@ abstract class AbstractArtifactRepository : ArtifactRepository { lateinit var repositoryService: RepositoryService @Autowired - lateinit var packageClient: PackageClient + lateinit var packageService: PackageService @Autowired lateinit var storageService: StorageService @@ -106,7 +106,7 @@ abstract class AbstractArtifactRepository : ArtifactRepository { lateinit var publisher: ApplicationEventPublisher @Autowired - lateinit var packageDownloadsClient: PackageDownloadsClient + lateinit var packageDownloadsService: PackageDownloadsService @Autowired lateinit var artifactResourceWriter: ArtifactResourceWriter @@ -237,7 +237,7 @@ abstract class AbstractArtifactRepository : ArtifactRepository { ) { if (artifactResource.channel == ArtifactChannel.LOCAL) { buildDownloadRecord(context, artifactResource)?.let { - taskAsyncExecutor.execute { packageDownloadsClient.record(it) } + taskAsyncExecutor.execute { packageDownloadsService.record(it) } publishPackageDownloadEvent(context, it) } } diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/local/LocalRepository.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/local/LocalRepository.kt index c73b60c492..b6a610bd7a 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/local/LocalRepository.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/local/LocalRepository.kt @@ -75,7 +75,7 @@ abstract class LocalRepository : AbstractArtifactRepository() { val packageKey = nodeDetail.packageName()?.let { PackageKeys.ofName(repo.type, it) } val version = nodeDetail.packageVersion() if (packageKey != null && version != null) { - packageClient.findVersionByName(projectId, repoName, packageKey, version).data?.let { packageVersion -> + packageService.findVersionByName(projectId, repoName, packageKey, version)?.let { packageVersion -> downloadIntercept(context, packageVersion) } } diff --git a/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersionTest.kt b/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersionTest.kt index 3d68333bd8..31dd4a5fe2 100644 --- a/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersionTest.kt +++ b/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersionTest.kt @@ -31,6 +31,7 @@ package com.tencent.bkrepo.common.artifact.util.version +import com.tencent.bkrepo.common.metadata.util.version.SemVersion import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageDao.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageDao.kt similarity index 93% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageDao.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageDao.kt index 53ce5319ed..53cee57620 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageDao.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageDao.kt @@ -29,12 +29,14 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.dao +package com.tencent.bkrepo.common.metadata.dao.packages import com.mongodb.client.result.UpdateResult +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.mongo.dao.simple.SimpleMongoDao -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.util.PackageQueryHelper +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.util.PackageQueryHelper +import org.springframework.context.annotation.Conditional import org.springframework.data.mongodb.core.FindAndModifyOptions import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query @@ -46,6 +48,7 @@ import org.springframework.stereotype.Repository * 包数据访问层 */ @Repository +@Conditional(SyncCondition::class) class PackageDao : SimpleMongoDao() { /** diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageDependentsDao.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageDependentsDao.kt similarity index 89% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageDependentsDao.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageDependentsDao.kt index 2a4a965879..f0178c175b 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageDependentsDao.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageDependentsDao.kt @@ -29,11 +29,13 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.dao +package com.tencent.bkrepo.common.metadata.dao.packages +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.mongo.dao.simple.SimpleMongoDao -import com.tencent.bkrepo.repository.model.TPackageDependents -import com.tencent.bkrepo.repository.util.PackageQueryHelper +import com.tencent.bkrepo.common.metadata.model.TPackageDependents +import com.tencent.bkrepo.common.metadata.util.PackageQueryHelper +import org.springframework.context.annotation.Conditional import org.springframework.data.mongodb.core.query.Update import org.springframework.stereotype.Repository @@ -41,6 +43,7 @@ import org.springframework.stereotype.Repository * 包依赖关系数据访问层 */ @Repository +@Conditional(SyncCondition::class) class PackageDependentsDao : SimpleMongoDao() { fun findByPackageKey(projectId: String, repoName: String, key: String): TPackageDependents? { diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageDownloadsDao.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageDownloadsDao.kt similarity index 86% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageDownloadsDao.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageDownloadsDao.kt index 497838592d..0cea3ec285 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageDownloadsDao.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageDownloadsDao.kt @@ -29,14 +29,17 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.dao +package com.tencent.bkrepo.common.metadata.dao.packages +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.mongo.dao.simple.SimpleMongoDao -import com.tencent.bkrepo.repository.model.TPackageDownloads +import com.tencent.bkrepo.common.metadata.model.TPackageDownloads +import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Repository /** * 包下载统计数据访问层 */ @Repository +@Conditional(SyncCondition::class) class PackageDownloadsDao : SimpleMongoDao() diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageVersionDao.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageVersionDao.kt similarity index 91% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageVersionDao.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageVersionDao.kt index e7ecce8588..cb73d10008 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/PackageVersionDao.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/packages/PackageVersionDao.kt @@ -29,11 +29,13 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.dao +package com.tencent.bkrepo.common.metadata.dao.packages +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.mongo.dao.simple.SimpleMongoDao -import com.tencent.bkrepo.repository.model.TPackageVersion -import com.tencent.bkrepo.repository.util.PackageQueryHelper +import com.tencent.bkrepo.common.metadata.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.util.PackageQueryHelper +import org.springframework.context.annotation.Conditional import org.springframework.data.mongodb.core.FindAndModifyOptions import org.springframework.data.mongodb.core.query.Update import org.springframework.stereotype.Repository @@ -42,6 +44,7 @@ import org.springframework.stereotype.Repository * 包版本 DAO */ @Repository +@Conditional(SyncCondition::class) class PackageVersionDao : SimpleMongoDao() { fun listByPackageId(packageId: String): List { diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/ClusterResource.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/ClusterResource.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/ClusterResource.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/ClusterResource.kt index 0b6d69a29f..6c15bacc2f 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/ClusterResource.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/ClusterResource.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.model +package com.tencent.bkrepo.common.metadata.model /** * 集群资源 diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackage.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackage.kt similarity index 89% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackage.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackage.kt index 7d820cbd9e..4b8a26a34c 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackage.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackage.kt @@ -29,12 +29,12 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.model +package com.tencent.bkrepo.common.metadata.model -import com.tencent.bkrepo.repository.model.TPackage.Companion.PACKAGE_KEY_IDX -import com.tencent.bkrepo.repository.model.TPackage.Companion.PACKAGE_KEY_IDX_DEF -import com.tencent.bkrepo.repository.model.TPackage.Companion.PACKAGE_NAME_IDX -import com.tencent.bkrepo.repository.model.TPackage.Companion.PACKAGE_NAME_IDX_DEF +import com.tencent.bkrepo.common.metadata.model.TPackage.Companion.PACKAGE_KEY_IDX +import com.tencent.bkrepo.common.metadata.model.TPackage.Companion.PACKAGE_KEY_IDX_DEF +import com.tencent.bkrepo.common.metadata.model.TPackage.Companion.PACKAGE_NAME_IDX +import com.tencent.bkrepo.common.metadata.model.TPackage.Companion.PACKAGE_NAME_IDX_DEF import com.tencent.bkrepo.repository.pojo.packages.PackageType import org.springframework.data.mongodb.core.index.CompoundIndex import org.springframework.data.mongodb.core.index.CompoundIndexes diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackageDependents.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackageDependents.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackageDependents.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackageDependents.kt index 0d315b6318..d8eaccc5c3 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackageDependents.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackageDependents.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.model +package com.tencent.bkrepo.common.metadata.model import org.springframework.data.mongodb.core.index.CompoundIndex import org.springframework.data.mongodb.core.index.CompoundIndexes diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackageDownloads.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackageDownloads.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackageDownloads.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackageDownloads.kt index de91c10e39..91e8746470 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackageDownloads.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackageDownloads.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.model +package com.tencent.bkrepo.common.metadata.model import org.springframework.data.mongodb.core.index.CompoundIndex import org.springframework.data.mongodb.core.index.CompoundIndexes diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackageVersion.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackageVersion.kt similarity index 84% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackageVersion.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackageVersion.kt index d90c7b5091..3acd0cba32 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TPackageVersion.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TPackageVersion.kt @@ -29,15 +29,14 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.model +package com.tencent.bkrepo.common.metadata.model -import com.tencent.bkrepo.common.metadata.model.TMetadata -import com.tencent.bkrepo.repository.model.TPackageVersion.Companion.VERSION_METADATA_IDX -import com.tencent.bkrepo.repository.model.TPackageVersion.Companion.VERSION_METADATA_IDX_DEF -import com.tencent.bkrepo.repository.model.TPackageVersion.Companion.VERSION_NAME_IDX -import com.tencent.bkrepo.repository.model.TPackageVersion.Companion.VERSION_NAME_IDX_DEF -import com.tencent.bkrepo.repository.model.TPackageVersion.Companion.VERSION_TAGS_IDX -import com.tencent.bkrepo.repository.model.TPackageVersion.Companion.VERSION_TAGS_IDX_DEF +import com.tencent.bkrepo.common.metadata.model.TPackageVersion.Companion.VERSION_METADATA_IDX +import com.tencent.bkrepo.common.metadata.model.TPackageVersion.Companion.VERSION_METADATA_IDX_DEF +import com.tencent.bkrepo.common.metadata.model.TPackageVersion.Companion.VERSION_NAME_IDX +import com.tencent.bkrepo.common.metadata.model.TPackageVersion.Companion.VERSION_NAME_IDX_DEF +import com.tencent.bkrepo.common.metadata.model.TPackageVersion.Companion.VERSION_TAGS_IDX +import com.tencent.bkrepo.common.metadata.model.TPackageVersion.Companion.VERSION_TAGS_IDX_DEF import org.springframework.data.mongodb.core.index.CompoundIndex import org.springframework.data.mongodb.core.index.CompoundIndexes import org.springframework.data.mongodb.core.mapping.Document diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/packages/PackageQueryContext.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/packages/PackageQueryContext.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/packages/PackageQueryContext.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/packages/PackageQueryContext.kt index b9ced552cb..2b305924d7 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/packages/PackageQueryContext.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/packages/PackageQueryContext.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.search.packages +package com.tencent.bkrepo.common.metadata.search.packages import com.tencent.bkrepo.common.query.builder.MongoQueryInterpreter import com.tencent.bkrepo.common.query.model.QueryModel diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/packages/PackageSearchInterpreter.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/packages/PackageSearchInterpreter.kt similarity index 98% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/packages/PackageSearchInterpreter.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/packages/PackageSearchInterpreter.kt index 5fb10a24ec..7854b27b74 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/packages/PackageSearchInterpreter.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/packages/PackageSearchInterpreter.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.search.packages +package com.tencent.bkrepo.common.metadata.search.packages import com.tencent.bkrepo.common.query.interceptor.QueryContext import com.tencent.bkrepo.common.query.model.QueryModel diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/metadata/PackageMetadataService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/metadata/PackageMetadataService.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/metadata/PackageMetadataService.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/metadata/PackageMetadataService.kt index 76ba36b2f2..71baf2831b 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/metadata/PackageMetadataService.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/metadata/PackageMetadataService.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.metadata +package com.tencent.bkrepo.common.metadata.service.metadata import com.tencent.bkrepo.repository.pojo.metadata.packages.PackageMetadataSaveRequest diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/metadata/impl/PackageMetadataServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/metadata/impl/PackageMetadataServiceImpl.kt similarity index 88% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/metadata/impl/PackageMetadataServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/metadata/impl/PackageMetadataServiceImpl.kt index d2e39e2a0a..6a601aadd4 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/metadata/impl/PackageMetadataServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/metadata/impl/PackageMetadataServiceImpl.kt @@ -29,18 +29,20 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.metadata.impl +package com.tencent.bkrepo.common.metadata.service.metadata.impl import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.message.CommonMessageCode -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.condition.SyncCondition +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageVersion import com.tencent.bkrepo.repository.pojo.metadata.packages.PackageMetadataSaveRequest -import com.tencent.bkrepo.repository.service.metadata.PackageMetadataService +import com.tencent.bkrepo.common.metadata.service.metadata.PackageMetadataService import com.tencent.bkrepo.common.metadata.util.MetadataUtils import org.slf4j.LoggerFactory +import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @@ -48,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional * 元数据服务实现类 */ @Service +@Conditional(SyncCondition::class) class PackageMetadataServiceImpl( private val packageDao: PackageDao, private val packageVersionDao: PackageVersionDao diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageDependentsService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageDependentsService.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageDependentsService.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageDependentsService.kt index f9dfaf8da5..5bfb805044 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageDependentsService.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageDependentsService.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages +package com.tencent.bkrepo.common.metadata.service.packages import com.tencent.bkrepo.repository.pojo.dependent.PackageDependentsRelation diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageDownloadsService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageDownloadsService.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageDownloadsService.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageDownloadsService.kt index 561ae87ac7..328d4fe256 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageDownloadsService.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageDownloadsService.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages +package com.tencent.bkrepo.common.metadata.service.packages import com.tencent.bkrepo.repository.pojo.download.DetailsQueryRequest import com.tencent.bkrepo.repository.pojo.download.DownloadsMigrationRequest diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageRepairService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageRepairService.kt similarity index 76% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageRepairService.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageRepairService.kt index 3e35dde55a..63363a13af 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageRepairService.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageRepairService.kt @@ -1,4 +1,4 @@ -package com.tencent.bkrepo.repository.service.packages +package com.tencent.bkrepo.common.metadata.service.packages interface PackageRepairService { diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageService.kt similarity index 94% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageService.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageService.kt index afbb829ddb..ad5e6b735a 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageService.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageService.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages +package com.tencent.bkrepo.common.metadata.service.packages import com.tencent.bkrepo.common.api.pojo.Page import com.tencent.bkrepo.common.query.model.QueryModel @@ -214,22 +214,6 @@ interface PackageService { */ fun updateVersion(request: PackageVersionUpdateRequest, realIpAddress: String? = null) - /** - * 下载包版本 - * - * @param projectId 项目id - * @param repoName 项目id - * @param packageKey 包唯一标识 - * @param versionName 版本名称 - */ - fun downloadVersion( - projectId: String, - repoName: String, - packageKey: String, - versionName: String, - realIpAddress: String? = null - ) - /** * 添加包下载记录 * diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageStatisticsService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageStatisticsService.kt similarity index 81% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageStatisticsService.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageStatisticsService.kt index b0bbfe5028..dbed0dbfff 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageStatisticsService.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/PackageStatisticsService.kt @@ -1,4 +1,4 @@ -package com.tencent.bkrepo.repository.service.packages +package com.tencent.bkrepo.common.metadata.service.packages import com.tencent.bkrepo.repository.pojo.software.ProjectPackageOverview diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/StageService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/StageService.kt similarity index 96% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/StageService.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/StageService.kt index 6a80bffced..828ef1230b 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/StageService.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/StageService.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages +package com.tencent.bkrepo.common.metadata.service.packages import com.tencent.bkrepo.repository.pojo.stage.StageUpgradeRequest diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageBaseService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageBaseService.kt similarity index 94% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageBaseService.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageBaseService.kt index 3d87e6c0c0..e573a679f0 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageBaseService.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageBaseService.kt @@ -25,21 +25,21 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl +package com.tencent.bkrepo.common.metadata.service.packages.impl import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode -import com.tencent.bkrepo.common.artifact.util.version.SemVersion -import com.tencent.bkrepo.repository.dao.PackageDao +import com.tencent.bkrepo.common.metadata.util.version.SemVersion +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao -import com.tencent.bkrepo.repository.model.ClusterResource -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.model.ClusterResource +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageVersion import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.packages.request.PackagePopulateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PopulatedPackageVersion -import com.tencent.bkrepo.repository.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.util.MetadataUtils import org.slf4j.LoggerFactory import org.springframework.dao.DuplicateKeyException diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageDependentsServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageDependentsServiceImpl.kt similarity index 86% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageDependentsServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageDependentsServiceImpl.kt index 43b8e969bc..7820e705f0 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageDependentsServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageDependentsServiceImpl.kt @@ -29,18 +29,21 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl +package com.tencent.bkrepo.common.metadata.service.packages.impl -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageDependentsDao -import com.tencent.bkrepo.repository.model.TPackage +import com.tencent.bkrepo.common.metadata.condition.SyncCondition +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDependentsDao +import com.tencent.bkrepo.common.metadata.model.TPackage import com.tencent.bkrepo.repository.pojo.dependent.PackageDependentsRelation -import com.tencent.bkrepo.repository.service.packages.PackageDependentsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageDependentsService import org.slf4j.Logger import org.slf4j.LoggerFactory +import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Service @Service +@Conditional(SyncCondition::class) class PackageDependentsServiceImpl( private val packageDao: PackageDao, private val packageDependentsDao: PackageDependentsDao diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageDownloadsServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageDownloadsServiceImpl.kt similarity index 94% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageDownloadsServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageDownloadsServiceImpl.kt index 5b128d0ca5..fbc90aa796 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageDownloadsServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageDownloadsServiceImpl.kt @@ -29,28 +29,30 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl +package com.tencent.bkrepo.common.metadata.service.packages.impl import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.message.CommonMessageCode import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.mongo.dao.AbstractMongoDao.Companion.ID -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageDownloadsDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TPackageDownloads -import com.tencent.bkrepo.repository.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDownloadsDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageDownloads +import com.tencent.bkrepo.common.metadata.model.TPackageVersion import com.tencent.bkrepo.repository.pojo.download.DetailsQueryRequest import com.tencent.bkrepo.repository.pojo.download.DownloadsMigrationRequest import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord import com.tencent.bkrepo.repository.pojo.download.PackageDownloadsDetails import com.tencent.bkrepo.repository.pojo.download.PackageDownloadsSummary import com.tencent.bkrepo.repository.pojo.download.SummaryQueryRequest -import com.tencent.bkrepo.repository.service.packages.PackageDownloadsService -import com.tencent.bkrepo.repository.util.PackageQueryHelper +import com.tencent.bkrepo.common.metadata.service.packages.PackageDownloadsService +import com.tencent.bkrepo.common.metadata.util.PackageQueryHelper import org.slf4j.Logger import org.slf4j.LoggerFactory +import org.springframework.context.annotation.Conditional import org.springframework.data.mongodb.core.aggregation.Aggregation.group import org.springframework.data.mongodb.core.aggregation.Aggregation.match import org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation @@ -67,6 +69,7 @@ import java.time.LocalDate import java.time.temporal.ChronoUnit @Service +@Conditional(SyncCondition::class) class PackageDownloadsServiceImpl( private val packageDao: PackageDao, private val packageVersionDao: PackageVersionDao, diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageRepairServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageRepairServiceImpl.kt similarity index 90% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageRepairServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageRepairServiceImpl.kt index 5e650010b7..5b40feb843 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageRepairServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageRepairServiceImpl.kt @@ -1,17 +1,19 @@ -package com.tencent.bkrepo.repository.service.packages.impl +package com.tencent.bkrepo.common.metadata.service.packages.impl import com.tencent.bkrepo.common.api.pojo.Page import com.tencent.bkrepo.common.api.util.HumanReadable +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.mongo.dao.util.Pages -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.model.TPackage +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.model.TPackage import com.tencent.bkrepo.repository.pojo.packages.VersionListOption -import com.tencent.bkrepo.repository.service.packages.PackageRepairService -import com.tencent.bkrepo.repository.service.packages.PackageService -import com.tencent.bkrepo.repository.util.PackageQueryHelper +import com.tencent.bkrepo.common.metadata.service.packages.PackageRepairService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.util.PackageQueryHelper import org.slf4j.Logger import org.slf4j.LoggerFactory +import org.springframework.context.annotation.Conditional import org.springframework.data.domain.Sort import org.springframework.data.mongodb.core.query.Query import org.springframework.data.mongodb.core.query.Update @@ -21,6 +23,7 @@ import java.time.LocalDateTime import kotlin.system.measureNanoTime @Service +@Conditional(SyncCondition::class) class PackageRepairServiceImpl( private val packageService: PackageService, private val packageDao: PackageDao, diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageServiceImpl.kt similarity index 90% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageServiceImpl.kt index a5382c7020..4b2073ef36 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageServiceImpl.kt @@ -29,28 +29,29 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl +package com.tencent.bkrepo.common.metadata.service.packages.impl import com.tencent.bkrepo.common.api.constant.StringPool import com.tencent.bkrepo.common.api.exception.ErrorCodeException -import com.tencent.bkrepo.common.api.message.CommonMessageCode import com.tencent.bkrepo.common.api.pojo.Page import com.tencent.bkrepo.common.api.util.Preconditions -import com.tencent.bkrepo.common.artifact.api.DefaultArtifactInfo -import com.tencent.bkrepo.common.artifact.constant.ARTIFACT_INFO_KEY import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode -import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHolder -import com.tencent.bkrepo.common.artifact.repository.context.ArtifactDownloadContext +import com.tencent.bkrepo.common.metadata.condition.SyncCondition +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.util.MetadataUtils +import com.tencent.bkrepo.common.metadata.util.PackageEventFactory +import com.tencent.bkrepo.common.metadata.util.PackageEventFactory.buildCreatedEvent +import com.tencent.bkrepo.common.metadata.util.PackageEventFactory.buildUpdatedEvent +import com.tencent.bkrepo.common.metadata.util.PackageQueryHelper import com.tencent.bkrepo.common.mongo.dao.util.Pages import com.tencent.bkrepo.common.query.model.QueryModel import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.service.util.HttpContextHolder import com.tencent.bkrepo.common.service.util.SpringContextUtils.Companion.publishEvent -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TPackageVersion import com.tencent.bkrepo.repository.pojo.packages.PackageListOption import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion @@ -59,13 +60,9 @@ import com.tencent.bkrepo.repository.pojo.packages.request.PackagePopulateReques import com.tencent.bkrepo.repository.pojo.packages.request.PackageUpdateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionUpdateRequest -import com.tencent.bkrepo.repository.search.packages.PackageSearchInterpreter -import com.tencent.bkrepo.common.metadata.util.MetadataUtils -import com.tencent.bkrepo.repository.util.PackageEventFactory -import com.tencent.bkrepo.repository.util.PackageEventFactory.buildCreatedEvent -import com.tencent.bkrepo.repository.util.PackageEventFactory.buildUpdatedEvent -import com.tencent.bkrepo.repository.util.PackageQueryHelper +import com.tencent.bkrepo.common.metadata.search.packages.PackageSearchInterpreter import org.slf4j.LoggerFactory +import org.springframework.context.annotation.Conditional import org.springframework.dao.DuplicateKeyException import org.springframework.data.domain.Sort import org.springframework.data.mongodb.core.query.Query @@ -77,6 +74,7 @@ import org.springframework.stereotype.Service import java.time.LocalDateTime @Service +@Conditional(SyncCondition::class) class PackageServiceImpl( repositoryDao: RepositoryDao, packageDao: PackageDao, @@ -372,40 +370,6 @@ class PackageServiceImpl( ) } - override fun downloadVersion( - projectId: String, - repoName: String, - packageKey: String, - versionName: String, - realIpAddress: String? - ) { - val tPackage = findPackageExcludeHistoryVersion(projectId, repoName, packageKey) - val tPackageVersion = checkPackageVersion(tPackage.id!!, versionName) - if (tPackageVersion.artifactPath.isNullOrBlank()) { - throw ErrorCodeException(CommonMessageCode.METHOD_NOT_ALLOWED, "artifactPath is null") - } - val artifactInfo = DefaultArtifactInfo(projectId, repoName, tPackageVersion.artifactPath!!) - val context = ArtifactDownloadContext(artifact = artifactInfo, useDisposition = true) - // 拦截package下载 - val packageVersion = convert(tPackageVersion)!! - context.getPackageInterceptors().forEach { it.intercept(projectId, packageVersion) } - // context 复制时会从request map中获取对应的artifactInfo, 而artifactInfo设置到map中是在接口url解析时 - HttpContextHolder.getRequestOrNull()?.setAttribute(ARTIFACT_INFO_KEY, artifactInfo) - ArtifactContextHolder.getRepository().download(context) - publishEvent( - PackageEventFactory.buildDownloadEvent( - projectId = projectId, - repoName = repoName, - packageType = tPackage.type, - packageKey = packageKey, - packageName = tPackage.name, - versionName = versionName, - createdBy = SecurityUtils.getUserId(), - realIpAddress = realIpAddress ?: HttpContextHolder.getClientAddress() - ) - ) - } - override fun addDownloadRecord(projectId: String, repoName: String, packageKey: String, versionName: String) { val tPackage = checkPackage(projectId, repoName, packageKey) val tPackageVersion = checkPackageVersion(tPackage.id!!, versionName) diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageStatisticsServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageStatisticsServiceImpl.kt similarity index 83% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageStatisticsServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageStatisticsServiceImpl.kt index 0c0a68a9e1..9ff60eada5 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageStatisticsServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/PackageStatisticsServiceImpl.kt @@ -1,17 +1,20 @@ -package com.tencent.bkrepo.repository.service.packages.impl +package com.tencent.bkrepo.common.metadata.service.packages.impl import com.tencent.bkrepo.common.api.util.EscapeUtils -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.model.TPackage +import com.tencent.bkrepo.common.metadata.condition.SyncCondition +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.model.TPackage import com.tencent.bkrepo.repository.pojo.software.CountResult import com.tencent.bkrepo.repository.pojo.software.ProjectPackageOverview -import com.tencent.bkrepo.repository.service.packages.PackageStatisticsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageStatisticsService +import org.springframework.context.annotation.Conditional import org.springframework.data.mongodb.core.aggregation.Aggregation import org.springframework.data.mongodb.core.query.Criteria import org.springframework.stereotype.Service import java.util.Locale @Service +@Conditional(SyncCondition::class) class PackageStatisticsServiceImpl( private val packageDao: PackageDao ) : PackageStatisticsService { diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/StageServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/StageServiceImpl.kt similarity index 88% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/StageServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/StageServiceImpl.kt index 91c36d8ce1..d6645f456a 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/StageServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/StageServiceImpl.kt @@ -29,18 +29,20 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl +package com.tencent.bkrepo.common.metadata.service.packages.impl import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.message.CommonMessageCode import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.condition.SyncCondition +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.model.TPackageVersion import com.tencent.bkrepo.repository.pojo.stage.ArtifactStageEnum import com.tencent.bkrepo.repository.pojo.stage.StageUpgradeRequest -import com.tencent.bkrepo.repository.service.packages.StageService +import com.tencent.bkrepo.common.metadata.service.packages.StageService import org.slf4j.LoggerFactory +import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Service import java.time.LocalDateTime @@ -48,6 +50,7 @@ import java.time.LocalDateTime * 制品晋级服务接口实现类 */ @Service +@Conditional(SyncCondition::class) class StageServiceImpl( private val packageDao: PackageDao, private val packageVersionDao: PackageVersionDao diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageDependentsServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/center/CenterPackageDependentsServiceImpl.kt similarity index 80% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageDependentsServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/center/CenterPackageDependentsServiceImpl.kt index 87815bec21..d606c03590 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageDependentsServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/center/CenterPackageDependentsServiceImpl.kt @@ -25,22 +25,23 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl.center +package com.tencent.bkrepo.common.metadata.service.packages.impl.center +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.metadata.util.ClusterUtils import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeCenterPackageCondition -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageDependentsDao -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.service.packages.impl.PackageDependentsServiceImpl +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDependentsDao +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.service.packages.impl.PackageDependentsServiceImpl import org.springframework.context.annotation.Conditional import org.springframework.context.annotation.Primary import org.springframework.stereotype.Service @Service -@Conditional(CommitEdgeCenterPackageCondition::class) +@Conditional(SyncCondition::class, CommitEdgeCenterPackageCondition::class) @Primary -class CommitEdgeCenterPackageDependentsServiceImpl( +class CenterPackageDependentsServiceImpl( private val packageDao: PackageDao, packageDependentsDao: PackageDependentsDao ) : PackageDependentsServiceImpl( diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/center/CenterPackageServiceImpl.kt similarity index 91% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/center/CenterPackageServiceImpl.kt index 9640d15c9e..c180b45624 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/center/CenterPackageServiceImpl.kt @@ -25,26 +25,27 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl.center +package com.tencent.bkrepo.common.metadata.service.packages.impl.center import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.message.CommonMessageCode +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.metadata.util.ClusterUtils import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeCenterPackageCondition -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao -import com.tencent.bkrepo.repository.model.ClusterResource -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.model.ClusterResource +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageVersion import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.packages.request.PackagePopulateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PopulatedPackageVersion -import com.tencent.bkrepo.repository.search.packages.PackageSearchInterpreter -import com.tencent.bkrepo.repository.service.packages.impl.PackageServiceImpl +import com.tencent.bkrepo.common.metadata.search.packages.PackageSearchInterpreter +import com.tencent.bkrepo.common.metadata.service.packages.impl.PackageServiceImpl import org.slf4j.LoggerFactory import org.springframework.context.annotation.Conditional import org.springframework.context.annotation.Primary @@ -55,9 +56,9 @@ import org.springframework.stereotype.Service * CommitEdge组网方式的Center节点Package管理服务 */ @Service -@Conditional(CommitEdgeCenterPackageCondition::class) +@Conditional(SyncCondition::class, CommitEdgeCenterPackageCondition::class) @Primary -class CommitEdgeCenterPackageServiceImpl( +class CenterPackageServiceImpl( repositoryDao: RepositoryDao, packageDao: PackageDao, packageVersionDao: PackageVersionDao, @@ -184,6 +185,6 @@ class CommitEdgeCenterPackageServiceImpl( private fun srcCluster() = SecurityUtils.getClusterName() ?: clusterProperties.self.name!! companion object { - private val logger = LoggerFactory.getLogger(CommitEdgeCenterPackageServiceImpl::class.java) + private val logger = LoggerFactory.getLogger(CenterPackageServiceImpl::class.java) } } diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterStageServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/center/CenterStageServiceImpl.kt similarity index 83% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterStageServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/center/CenterStageServiceImpl.kt index 6714792acf..3287caa2b9 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterStageServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/center/CenterStageServiceImpl.kt @@ -25,22 +25,23 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl.center +package com.tencent.bkrepo.common.metadata.service.packages.impl.center +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.metadata.util.ClusterUtils import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeCenterPackageCondition -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao import com.tencent.bkrepo.repository.pojo.stage.StageUpgradeRequest -import com.tencent.bkrepo.repository.service.packages.impl.StageServiceImpl +import com.tencent.bkrepo.common.metadata.service.packages.impl.StageServiceImpl import org.springframework.context.annotation.Conditional import org.springframework.context.annotation.Primary import org.springframework.stereotype.Service @Service -@Conditional(CommitEdgeCenterPackageCondition::class) +@Conditional(SyncCondition::class, CommitEdgeCenterPackageCondition::class) @Primary -class CommitEdgeCenterStageServiceImpl( +class CenterStageServiceImpl( packageDao: PackageDao, packageVersionDao: PackageVersionDao ) : StageServiceImpl(packageDao, packageVersionDao) { diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageDependentsServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/edge/EdgePackageDependentsServiceImpl.kt similarity index 86% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageDependentsServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/edge/EdgePackageDependentsServiceImpl.kt index 390f91bc6b..344f166639 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageDependentsServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/edge/EdgePackageDependentsServiceImpl.kt @@ -25,22 +25,23 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl.edge +package com.tencent.bkrepo.common.metadata.service.packages.impl.edge +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeEdgePackageCondition import com.tencent.bkrepo.common.service.feign.FeignClientFactory import com.tencent.bkrepo.repository.api.cluster.ClusterPackageDependentsClient -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageDependentsDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDependentsDao import com.tencent.bkrepo.repository.pojo.dependent.PackageDependentsRelation -import com.tencent.bkrepo.repository.service.packages.impl.PackageDependentsServiceImpl +import com.tencent.bkrepo.common.metadata.service.packages.impl.PackageDependentsServiceImpl import org.springframework.context.annotation.Conditional import org.springframework.context.annotation.Primary import org.springframework.stereotype.Service @Service -@Conditional(CommitEdgeEdgePackageCondition::class) +@Conditional(SyncCondition::class, CommitEdgeEdgePackageCondition::class) @Primary class EdgePackageDependentsServiceImpl( packageDao: PackageDao, diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/edge/EdgePackageServiceImpl.kt similarity index 88% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/edge/EdgePackageServiceImpl.kt index 1e70bf47c8..8322160648 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/edge/EdgePackageServiceImpl.kt @@ -25,27 +25,28 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl.edge +package com.tencent.bkrepo.common.metadata.service.packages.impl.edge +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeEdgePackageCondition import com.tencent.bkrepo.common.service.feign.FeignClientFactory import com.tencent.bkrepo.repository.api.cluster.ClusterPackageClient -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.pojo.packages.request.PackageUpdateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionUpdateRequest -import com.tencent.bkrepo.repository.search.packages.PackageSearchInterpreter -import com.tencent.bkrepo.repository.service.packages.impl.PackageServiceImpl +import com.tencent.bkrepo.common.metadata.search.packages.PackageSearchInterpreter +import com.tencent.bkrepo.common.metadata.service.packages.impl.PackageServiceImpl import org.springframework.context.annotation.Conditional import org.springframework.context.annotation.Primary import org.springframework.stereotype.Service @Service -@Conditional(CommitEdgeEdgePackageCondition::class) +@Conditional(SyncCondition::class, CommitEdgeEdgePackageCondition::class) @Primary class EdgePackageServiceImpl( repositoryDao: RepositoryDao, diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgeStageServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/edge/EdgeStageServiceImpl.kt similarity index 85% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgeStageServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/edge/EdgeStageServiceImpl.kt index 17e876949e..27a6f7b046 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgeStageServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/packages/impl/edge/EdgeStageServiceImpl.kt @@ -25,22 +25,23 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.service.packages.impl.edge +package com.tencent.bkrepo.common.metadata.service.packages.impl.edge +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeEdgePackageCondition import com.tencent.bkrepo.common.service.feign.FeignClientFactory import com.tencent.bkrepo.repository.api.cluster.ClusterStageClient -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao import com.tencent.bkrepo.repository.pojo.stage.StageUpgradeRequest -import com.tencent.bkrepo.repository.service.packages.impl.StageServiceImpl +import com.tencent.bkrepo.common.metadata.service.packages.impl.StageServiceImpl import org.springframework.context.annotation.Conditional import org.springframework.context.annotation.Primary import org.springframework.stereotype.Service @Service -@Conditional(CommitEdgeEdgePackageCondition::class) +@Conditional(SyncCondition::class, CommitEdgeEdgePackageCondition::class) @Primary class EdgeStageServiceImpl( packageDao: PackageDao, diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/util/PackageEventFactory.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/PackageEventFactory.kt similarity index 98% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/util/PackageEventFactory.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/PackageEventFactory.kt index af77b83875..cf9a2bcf73 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/util/PackageEventFactory.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/PackageEventFactory.kt @@ -1,4 +1,4 @@ -package com.tencent.bkrepo.repository.util +package com.tencent.bkrepo.common.metadata.util import com.tencent.bkrepo.common.artifact.event.packages.VersionCreatedEvent import com.tencent.bkrepo.common.artifact.event.packages.VersionDeletedEvent diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/util/PackageQueryHelper.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/PackageQueryHelper.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/util/PackageQueryHelper.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/PackageQueryHelper.kt index 7818590fe7..2f0ed512a3 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/util/PackageQueryHelper.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/PackageQueryHelper.kt @@ -29,10 +29,10 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.util +package com.tencent.bkrepo.common.metadata.util -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageVersion import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.packages.PackageVersion import org.springframework.data.domain.Sort diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersion.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/version/SemVersion.kt similarity index 98% rename from src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersion.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/version/SemVersion.kt index c7a6e45222..07d7a9ec0a 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersion.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/version/SemVersion.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.common.artifact.util.version +package com.tencent.bkrepo.common.metadata.util.version import kotlin.math.min import kotlin.math.pow diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersionParser.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/version/SemVersionParser.kt similarity index 97% rename from src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersionParser.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/version/SemVersionParser.kt index 8544b3fad4..6bda2cc2fe 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/util/version/SemVersionParser.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/version/SemVersionParser.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.common.artifact.util.version +package com.tencent.bkrepo.common.metadata.util.version object SemVersionParser { diff --git a/src/backend/composer/biz-composer/src/main/kotlin/com/tencent/bkrepo/composer/artifact/repository/ComposerLocalRepository.kt b/src/backend/composer/biz-composer/src/main/kotlin/com/tencent/bkrepo/composer/artifact/repository/ComposerLocalRepository.kt index 1ecc8f8b69..43151e30b6 100644 --- a/src/backend/composer/biz-composer/src/main/kotlin/com/tencent/bkrepo/composer/artifact/repository/ComposerLocalRepository.kt +++ b/src/backend/composer/biz-composer/src/main/kotlin/com/tencent/bkrepo/composer/artifact/repository/ComposerLocalRepository.kt @@ -44,6 +44,7 @@ import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactChannel import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactResource import com.tencent.bkrepo.common.artifact.stream.closeQuietly import com.tencent.bkrepo.common.artifact.util.PackageKeys +import com.tencent.bkrepo.common.metadata.service.packages.StageService import com.tencent.bkrepo.common.service.util.HttpContextHolder import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.composer.COMPOSER_VERSION_INIT @@ -61,7 +62,6 @@ import com.tencent.bkrepo.composer.util.JsonUtil import com.tencent.bkrepo.composer.util.JsonUtil.wrapperJson import com.tencent.bkrepo.composer.util.JsonUtil.wrapperPackageJson import com.tencent.bkrepo.composer.util.pojo.ComposerArtifact -import com.tencent.bkrepo.repository.api.StageClient import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -80,7 +80,7 @@ import java.io.ByteArrayInputStream import java.io.InputStreamReader @Component -class ComposerLocalRepository(private val stageClient: StageClient) : LocalRepository() { +class ComposerLocalRepository(private val stageService: StageService) : LocalRepository() { // 默认值为方便本地调试 // 服务域名,例:bkrepo.com @@ -118,7 +118,7 @@ class ComposerLocalRepository(private val stageClient: StageClient) : LocalRepos val oldVersion = oldComposerArtifact.version return if (composerArtifact.name != oldName || composerArtifact.version != oldVersion) { with(context.artifactInfo) { - packageClient.deleteVersion( + packageService.deleteVersion( projectId, repoName, PackageKeys.ofComposer(oldName), @@ -250,7 +250,7 @@ class ComposerLocalRepository(private val stageClient: StageClient) : LocalRepos // 更新索引 updateIndex(composerArtifact, oldComposerArtifact, repeat, context) // 保存版本信息 - packageClient.createVersion( + packageService.createPackageVersion( PackageVersionCreateRequest( projectId = context.projectId, repoName = context.repoName, @@ -288,9 +288,9 @@ class ComposerLocalRepository(private val stageClient: StageClient) : LocalRepos * 返回包的版本数量 */ private fun getVersions(packageKey: String, context: ArtifactContext): Long? { - return packageClient.findPackageByKey( + return packageService.findPackageByKey( context.projectId, context.repoName, packageKey - ).data?.versions ?: return null + )?.versions ?: return null } @Transactional(rollbackFor = [Throwable::class]) @@ -302,24 +302,24 @@ class ComposerLocalRepository(private val stageClient: StageClient) : LocalRepos if (version.isNullOrBlank()) { // 删除包 val versions = getVersions(packageKey, context) - val pages = packageClient.listVersionPage( + val pages = packageService.listVersionPage( projectId, repoName, packageKey, VersionListOption(1, versions!!.toInt(), null, null) - ).data?.records ?: return + ).records for (packageVersion in pages) { val node = nodeService.getNodeDetail(ArtifactInfo(projectId, repoName, packageVersion.contentPath!!)) ?: continue removeComposerArtifact(node, packageKey, packageVersion.name, context) } } else { - val packageVersion = packageClient.findVersionByName( + val packageVersion = packageService.findVersionByName( projectId = projectId, repoName = repoName, packageKey = packageKey, - version = version - ).data ?: return + versionName = version + ) ?: return val node = nodeService.getNodeDetail(ArtifactInfo(projectId, repoName, packageVersion.contentPath!!)) ?: return removeComposerArtifact(node, packageKey, version, context) @@ -375,9 +375,9 @@ class ComposerLocalRepository(private val stageClient: StageClient) : LocalRepos * 删除版本后,检查该包下是否还有包。 */ fun deleteVersion(projectId: String, repoName: String, packageKey: String, version: String) { - packageClient.deleteVersion(projectId, repoName, packageKey, version, HttpContextHolder.getClientAddress()) - val page = packageClient.listVersionPage(projectId, repoName, packageKey).data ?: return - if (page.records.isEmpty()) packageClient.deletePackage( + packageService.deleteVersion(projectId, repoName, packageKey, version, HttpContextHolder.getClientAddress()) + val page = packageService.listVersionPage(projectId, repoName, packageKey, VersionListOption()) + if (page.records.isEmpty()) packageService.deletePackage( projectId, repoName, packageKey, @@ -500,21 +500,21 @@ class ComposerLocalRepository(private val stageClient: StageClient) : LocalRepos val packageKey = context.request.getParameter("packageKey") val version = context.request.getParameter("version") val name = PackageKeys.resolveComposer(packageKey) - val trueVersion = packageClient.findVersionByName( + val trueVersion = packageService.findVersionByName( context.projectId, context.repoName, packageKey, version - ).data ?: return null + ) ?: return null val artifactPath = trueVersion.contentPath ?: return null with(context.artifactInfo) { val jarNode = nodeService.getNodeDetail( ArtifactInfo(projectId, repoName, artifactPath) ) ?: return null - val stageTag = stageClient.query(projectId, repoName, packageKey, version).data - val packageVersion = packageClient.findVersionByName( + val stageTag = stageService.query(projectId, repoName, packageKey, version) + val packageVersion = packageService.findVersionByName( projectId, repoName, packageKey, version - ).data + ) val count = packageVersion?.downloads ?: 0 val composerArtifactBasic = Basic( name, @@ -553,7 +553,7 @@ class ComposerLocalRepository(private val stageClient: StageClient) : LocalRepos with(node) { val packageKey = metadata[METADATA_KEY_PACKAGE_KEY]?.toString() ?: return null val packageVersion = metadata[METADATA_KEY_VERSION]?.toString() ?: return null - return packageClient.findVersionByName(projectId, repoName, packageKey, packageVersion).data + return packageService.findVersionByName(projectId, repoName, packageKey, packageVersion) } } diff --git a/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/artifact/repository/ConanLocalRepository.kt b/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/artifact/repository/ConanLocalRepository.kt index af9b94f06e..7e7aaabc95 100644 --- a/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/artifact/repository/ConanLocalRepository.kt +++ b/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/artifact/repository/ConanLocalRepository.kt @@ -41,15 +41,14 @@ import com.tencent.bkrepo.conan.constant.X_CHECKSUM_SHA1 import com.tencent.bkrepo.conan.listener.event.ConanPackageUploadEvent import com.tencent.bkrepo.conan.listener.event.ConanRecipeUploadEvent import com.tencent.bkrepo.conan.pojo.artifact.ConanArtifactInfo -import com.tencent.bkrepo.conan.utils.ConanArtifactInfoUtil import com.tencent.bkrepo.conan.utils.ConanArtifactInfoUtil.convertToConanFileReference +import com.tencent.bkrepo.conan.utils.ConanPathUtils +import com.tencent.bkrepo.conan.utils.ConanPathUtils.generateFullPath import com.tencent.bkrepo.conan.utils.ObjectBuildUtil import com.tencent.bkrepo.conan.utils.ObjectBuildUtil.buildDownloadResponse import com.tencent.bkrepo.conan.utils.ObjectBuildUtil.buildPackageVersionCreateRequest import com.tencent.bkrepo.conan.utils.ObjectBuildUtil.toConanFileReference import com.tencent.bkrepo.conan.utils.ObjectBuildUtil.toMetadataList -import com.tencent.bkrepo.conan.utils.ConanPathUtils -import com.tencent.bkrepo.conan.utils.ConanPathUtils.generateFullPath import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -132,7 +131,7 @@ class ConanLocalRepository : LocalRepository() { size = size, sourceType = sourceType ) - packageClient.createVersion(packageVersionCreateRequest).apply { + packageService.createPackageVersion(packageVersionCreateRequest).apply { logger.info("user: [$userId] create package version [$packageVersionCreateRequest] success!") } } @@ -166,7 +165,7 @@ class ConanLocalRepository : LocalRepository() { context: ArtifactDownloadContext, artifactResource: ArtifactResource ): PackageDownloadRecord? { - val conanFileReference = ConanArtifactInfoUtil.convertToConanFileReference( + val conanFileReference = convertToConanFileReference( context.artifactInfo as ConanArtifactInfo ) val refStr = ConanPathUtils.buildReferenceWithoutVersion(conanFileReference) @@ -180,7 +179,7 @@ class ConanLocalRepository : LocalRepository() { val conanFileReference = node.nodeMetadata.toConanFileReference() ?: return null val refStr = ConanPathUtils.buildReferenceWithoutVersion(conanFileReference) val packageKey = PackageKeys.ofConan(refStr) - return packageClient.findVersionByName(projectId, repoName, packageKey, conanFileReference.version).data + return packageService.findVersionByName(projectId, repoName, packageKey, conanFileReference.version) } } diff --git a/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/service/impl/ConanDeleteServiceImpl.kt b/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/service/impl/ConanDeleteServiceImpl.kt index df41c0458c..eff2d380e3 100644 --- a/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/service/impl/ConanDeleteServiceImpl.kt +++ b/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/service/impl/ConanDeleteServiceImpl.kt @@ -33,6 +33,7 @@ import com.tencent.bkrepo.common.artifact.exception.VersionNotFoundException import com.tencent.bkrepo.common.artifact.path.PathUtils import com.tencent.bkrepo.common.artifact.util.PackageKeys import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.service.util.SpringContextUtils.Companion.publishEvent import com.tencent.bkrepo.conan.constant.ConanMessageCode @@ -58,9 +59,9 @@ import com.tencent.bkrepo.conan.utils.ConanPathUtils.joinString import com.tencent.bkrepo.conan.utils.ObjectBuildUtil import com.tencent.bkrepo.conan.utils.ObjectBuildUtil.buildBasicInfo import com.tencent.bkrepo.conan.utils.ObjectBuildUtil.toConanFileReference -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.node.service.NodeDeleteRequest import com.tencent.bkrepo.repository.pojo.packages.PackageVersion +import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -72,7 +73,7 @@ class ConanDeleteServiceImpl : ConanDeleteService { @Autowired lateinit var nodeService: NodeService @Autowired - lateinit var packageClient: PackageClient + lateinit var packageService: PackageService @Autowired lateinit var commonService: CommonService @@ -86,7 +87,7 @@ class ConanDeleteServiceImpl : ConanDeleteService { nodeService.deleteNode(request) val refStr = ConanPathUtils.buildReferenceWithoutVersion(conanFileReference) val packageKey = PackageKeys.ofConan(refStr) - packageClient.deleteVersion(projectId, repoName, packageKey, version) + packageService.deleteVersion(projectId, repoName, packageKey, version) } else { val conanFileReference = convertToConanFileReference(conanArtifactInfo, revision) val rootPath = PathUtils.normalizeFullPath(buildRevisionPath(conanFileReference)) @@ -174,16 +175,16 @@ class ConanDeleteServiceImpl : ConanDeleteService { override fun removePackageByKey(conanArtifactInfo: ConanArtifactInfo, packageKey: String) { with(conanArtifactInfo) { - packageClient.listAllVersion(projectId, repoName, packageKey).data.orEmpty().forEach { + packageService.listAllVersion(projectId, repoName, packageKey, VersionListOption()).forEach { deleteVersion(projectId, repoName, packageKey, it, false) } - packageClient.deletePackage(projectId, repoName, packageKey) + packageService.deletePackage(projectId, repoName, packageKey) } } override fun removePackageVersion(conanArtifactInfo: ConanArtifactInfo, packageKey: String, version: String) { with(conanArtifactInfo) { - val versionDetail = packageClient.findVersionByName(projectId, repoName, packageKey, version).data ?: return + val versionDetail = packageService.findVersionByName(projectId, repoName, packageKey, version) ?: return deleteVersion(projectId, repoName, packageKey, versionDetail) } } @@ -198,7 +199,7 @@ class ConanDeleteServiceImpl : ConanDeleteService { conanArtifactInfo: ConanArtifactInfo, packageKey: String, version: String ): PackageVersionInfo { with(conanArtifactInfo) { - val versionDetail = packageClient.findVersionByName(projectId, repoName, packageKey, version).data + val versionDetail = packageService.findVersionByName(projectId, repoName, packageKey, version) ?: throw VersionNotFoundException(version) if (versionDetail.contentPath.isNullOrEmpty()) throw VersionNotFoundException(version) val nodeDetail = nodeService.getNodeDetail(ArtifactInfo(projectId, repoName, versionDetail.contentPath!!)) @@ -221,7 +222,7 @@ class ConanDeleteServiceImpl : ConanDeleteService { val request = NodeDeleteRequest(projectId, repoName, rootPath, SecurityUtils.getUserId()) nodeService.deleteNode(request) if (deleteVersion) { - packageClient.deleteVersion(projectId, repoName, packageKey, versionDetail.name) + packageService.deleteVersion(projectId, repoName, packageKey, versionDetail.name) } } diff --git a/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/service/impl/ConanSearchServiceImpl.kt b/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/service/impl/ConanSearchServiceImpl.kt index 3c2f558cbe..4d2ecdf04b 100644 --- a/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/service/impl/ConanSearchServiceImpl.kt +++ b/src/backend/conan/biz-conan/src/main/kotlin/com/tencent/bkrepo/conan/service/impl/ConanSearchServiceImpl.kt @@ -28,6 +28,7 @@ package com.tencent.bkrepo.conan.service.impl import com.tencent.bkrepo.common.api.constant.StringPool +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.conan.constant.ConanMessageCode import com.tencent.bkrepo.conan.exception.ConanSearchNotFoundException import com.tencent.bkrepo.conan.pojo.ConanInfo @@ -35,10 +36,10 @@ import com.tencent.bkrepo.conan.pojo.ConanSearchResult import com.tencent.bkrepo.conan.pojo.artifact.ConanArtifactInfo import com.tencent.bkrepo.conan.service.ConanSearchService import com.tencent.bkrepo.conan.utils.ConanArtifactInfoUtil.convertToConanFileReference -import com.tencent.bkrepo.conan.utils.ObjectBuildUtil.toConanFileReference import com.tencent.bkrepo.conan.utils.ConanPathUtils.buildConanFileName import com.tencent.bkrepo.conan.utils.ConanPathUtils.buildPackagePath -import com.tencent.bkrepo.repository.api.PackageClient +import com.tencent.bkrepo.conan.utils.ObjectBuildUtil.toConanFileReference +import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @@ -46,7 +47,7 @@ import org.springframework.stereotype.Service class ConanSearchServiceImpl : ConanSearchService { @Autowired - lateinit var packageClient: PackageClient + lateinit var packageService: PackageService @Autowired lateinit var commonService: CommonService @@ -95,8 +96,8 @@ class ConanSearchServiceImpl : ConanSearchService { fun searchRecipes(projectId: String, repoName: String): List { val result = mutableListOf() - packageClient.listAllPackageNames(projectId, repoName).data.orEmpty().forEach { - packageClient.listAllVersion(projectId, repoName, it).data.orEmpty().forEach { pv -> + packageService.listAllPackageName(projectId, repoName).forEach { + packageService.listAllVersion(projectId, repoName, it, VersionListOption()).forEach { pv -> pv.packageMetadata.toConanFileReference()?.apply { result.add(buildConanFileName(this)) } diff --git a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/artifact/repository/HelmLocalRepository.kt b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/artifact/repository/HelmLocalRepository.kt index 48f5ec290b..6ccbfca033 100644 --- a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/artifact/repository/HelmLocalRepository.kt +++ b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/artifact/repository/HelmLocalRepository.kt @@ -255,7 +255,7 @@ class HelmLocalRepository( val packageName = node.metadata[NAME] ?: return null val packageVersion = node.metadata[VERSION] ?: return null val packageKey = PackageKeys.ofHelm(packageName.toString()) - return packageClient.findVersionByName(projectId, repoName, packageKey, packageVersion.toString()).data + return packageService.findVersionByName(projectId, repoName, packageKey, packageVersion.toString()) } } diff --git a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/listener/base/RemoteEventJobExecutor.kt b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/listener/base/RemoteEventJobExecutor.kt index e5cb6c9b9e..e3b50dd518 100644 --- a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/listener/base/RemoteEventJobExecutor.kt +++ b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/listener/base/RemoteEventJobExecutor.kt @@ -31,13 +31,13 @@ import com.tencent.bkrepo.common.artifact.constant.SOURCE_TYPE import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent import com.tencent.bkrepo.common.artifact.event.base.EventType import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactChannel +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.service.util.SpringContextUtils import com.tencent.bkrepo.helm.listener.event.ChartUploadEvent import com.tencent.bkrepo.helm.pojo.artifact.HelmArtifactInfo import com.tencent.bkrepo.helm.pojo.chart.ChartUploadRequest import com.tencent.bkrepo.helm.service.impl.HelmOperationService import com.tencent.bkrepo.helm.utils.HelmUtils -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.constant.SYSTEM_USER import com.tencent.bkrepo.repository.pojo.packages.PackageType import com.tencent.bkrepo.repository.pojo.packages.PackageVersion @@ -47,7 +47,7 @@ import org.springframework.stereotype.Component @Component class RemoteEventJobExecutor( private val helmOperationService: HelmOperationService, - private val packageClient: PackageClient + private val packageService: PackageService ) : AbstractEventJobExecutor() { /** * 执行同步 @@ -83,9 +83,9 @@ class RemoteEventJobExecutor( val packageKey = event.data["packageKey"].toString() val version = event.data["packageVersion"].toString() val packageName = event.data["packageName"].toString() - val packageVersion = packageClient.findVersionByName( + val packageVersion = packageService.findVersionByName( event.projectId, event.repoName, packageKey, version - ).data ?: return + ) ?: return if (packageVersion.metadata[SOURCE_TYPE] != ArtifactChannel.REPLICATION.name) return val fullPath = HelmUtils.getChartFileFullPath(packageName, version) SpringContextUtils.publishEvent(buildChartUploadEvent( diff --git a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/AbstractChartService.kt b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/AbstractChartService.kt index 49a2c811f3..8cb406af4f 100644 --- a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/AbstractChartService.kt +++ b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/AbstractChartService.kt @@ -59,8 +59,10 @@ import com.tencent.bkrepo.common.artifact.stream.ArtifactInputStream import com.tencent.bkrepo.common.artifact.util.PackageKeys import com.tencent.bkrepo.common.lock.service.LockOperation import com.tencent.bkrepo.common.metadata.service.metadata.MetadataService +import com.tencent.bkrepo.common.metadata.service.metadata.PackageMetadataService import com.tencent.bkrepo.common.metadata.service.node.NodeSearchService import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.service.repo.ProxyChannelService import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import com.tencent.bkrepo.common.query.enums.OperationType @@ -100,8 +102,6 @@ import com.tencent.bkrepo.helm.utils.HelmUtils import com.tencent.bkrepo.helm.utils.ObjectBuilderUtil import com.tencent.bkrepo.helm.utils.RemoteDownloadUtil import com.tencent.bkrepo.helm.utils.TimeFormatUtil -import com.tencent.bkrepo.repository.api.PackageClient -import com.tencent.bkrepo.repository.api.PackageMetadataClient import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.node.service.NodeCreateRequest @@ -133,13 +133,13 @@ open class AbstractChartService : ArtifactService() { lateinit var metadataService: MetadataService @Autowired - lateinit var packageMetadataClient: PackageMetadataClient + lateinit var packageMetadataService: PackageMetadataService @Autowired lateinit var repositoryService: RepositoryService @Autowired - lateinit var packageClient: PackageClient + lateinit var packageService: PackageService @Autowired lateinit var artifactResourceWriter: ArtifactResourceWriter @@ -377,14 +377,14 @@ open class AbstractChartService : ArtifactService() { * check package [key] version [version] exists */ fun packageVersionExist(projectId: String, repoName: String, key: String, version: String): Boolean { - return packageClient.findVersionByName(projectId, repoName, key, version).data?.let { true } ?: false + return packageService.findVersionByName(projectId, repoName, key, version)?.let { true } ?: false } /** * check package [key] exists */ fun packageExist(projectId: String, repoName: String, key: String): Boolean { - return packageClient.findPackageByKey(projectId, repoName, key).data?.let { true } ?: false + return packageService.findPackageByKey(projectId, repoName, key)?.let { true } ?: false } /** @@ -411,7 +411,7 @@ open class AbstractChartService : ArtifactService() { description = description, versionList = packageVersionList ) - packageClient.populatePackage(packagePopulateRequest) + packageService.populatePackage(packagePopulateRequest) } } @@ -429,12 +429,12 @@ open class AbstractChartService : ArtifactService() { ) { val contentPath = HelmUtils.getChartFileFullPath(chartInfo.name, chartInfo.version) try { - val packageVersion = packageClient.findVersionByName( + val packageVersion = packageService.findVersionByName( projectId = projectId, repoName = repoName, packageKey = PackageKeys.ofHelm(chartInfo.name), - version = chartInfo.version - ).data + versionName = chartInfo.version + ) if (packageVersion == null || isOverwrite) { val packageVersionCreateRequest = ObjectBuilderUtil.buildPackageVersionCreateRequest( userId = userId, @@ -445,7 +445,7 @@ open class AbstractChartService : ArtifactService() { isOverwrite = isOverwrite, sourceType = sourceType ) - packageClient.createVersion(packageVersionCreateRequest).apply { + packageService.createPackageVersion(packageVersionCreateRequest).apply { logger.info("user: [$userId] create package version [$packageVersionCreateRequest] success!") } } else { @@ -456,7 +456,7 @@ open class AbstractChartService : ArtifactService() { size = size, sourceType = sourceType ) - packageClient.updateVersion(packageVersionUpdateRequest).apply { + packageService.updateVersion(packageVersionUpdateRequest).apply { logger.info("user: [$userId] update package version [$packageVersionUpdateRequest] success!") } } diff --git a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/ChartRepositoryServiceImpl.kt b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/ChartRepositoryServiceImpl.kt index dd3d102725..2dfd4427df 100644 --- a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/ChartRepositoryServiceImpl.kt +++ b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/ChartRepositoryServiceImpl.kt @@ -167,7 +167,7 @@ class ChartRepositoryServiceImpl( logger.warn("node [$fullPath] don't found.") throw HelmFileNotFoundException(HelmMessageCode.HELM_FILE_NOT_FOUND, fullPath, "$projectId|$repoName") } - val packageVersion = packageClient.findVersionByName(projectId, repoName, packageKey, version).data ?: run { + val packageVersion = packageService.findVersionByName(projectId, repoName, packageKey, version) ?: run { logger.warn("packageKey [$packageKey] don't found.") throw PackageNotFoundException(packageKey) } diff --git a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/FixToolServiceImpl.kt b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/FixToolServiceImpl.kt index 5166d7397b..486c9d458d 100644 --- a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/FixToolServiceImpl.kt +++ b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/FixToolServiceImpl.kt @@ -424,7 +424,7 @@ class FixToolServiceImpl : FixToolService, AbstractChartService() { version = chartMetadata.version, versionMetadata = metadata ) - packageMetadataClient.saveMetadata(packageMetadataRequest) + packageMetadataService.saveMetadata(packageMetadataRequest) val metadataSaveRequest = MetadataSaveRequest( projectId = artifactInfo.projectId, repoName = artifactInfo.repoName, diff --git a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/HelmOperationService.kt b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/HelmOperationService.kt index e8e0839da9..6a8b373bb8 100644 --- a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/HelmOperationService.kt +++ b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/HelmOperationService.kt @@ -48,6 +48,7 @@ import com.tencent.bkrepo.helm.utils.HelmMetadataUtils import com.tencent.bkrepo.helm.utils.HelmUtils import com.tencent.bkrepo.helm.utils.ObjectBuilderUtil import com.tencent.bkrepo.repository.pojo.node.service.NodeDeleteRequest +import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -66,7 +67,7 @@ class HelmOperationService( fun removeChartOrProv(context: ArtifactRemoveContext) { with(context.artifactInfo as HelmDeleteArtifactInfo) { if (version.isNotBlank()) { - packageClient.findVersionByName(projectId, repoName, packageName, version).data?.let { + packageService.findVersionByName(projectId, repoName, packageName, version)?.let { removeVersion( projectId = projectId, repoName = repoName, @@ -76,7 +77,7 @@ class HelmOperationService( ) } ?: throw VersionNotFoundException(version) } else { - packageClient.listAllVersion(projectId, repoName, packageName).data.orEmpty().forEach { + packageService.listAllVersion(projectId, repoName, packageName, VersionListOption()).forEach { removeVersion( projectId = projectId, repoName = repoName, @@ -85,7 +86,7 @@ class HelmOperationService( userId = context.userId ) } - packageClient.deletePackage(projectId, repoName, packageName) + packageService.deletePackage(projectId, repoName, packageName) } deleteIndex(this) updatePackageExtension(context) @@ -97,7 +98,7 @@ class HelmOperationService( */ private fun deleteIndex(artifactInfo: HelmDeleteArtifactInfo) { with(artifactInfo) { - if (!packageClient.listAllPackageNames(projectId, repoName).data.isNullOrEmpty()) { + if (packageService.listAllPackageName(projectId, repoName).isNotEmpty()) { return } // 删除index文件 @@ -122,7 +123,7 @@ class HelmOperationService( packageKey: String, userId: String ) { - packageClient.deleteVersion(projectId, repoName, packageKey, version) + packageService.deleteVersion(projectId, repoName, packageKey, version) val packageName = PackageKeys.resolveHelm(packageKey) val chartPath = HelmUtils.getChartFileFullPath(packageName, version) val provPath = HelmUtils.getProvFileFullPath(packageName, version) @@ -140,7 +141,7 @@ class HelmOperationService( */ private fun updatePackageExtension(context: ArtifactRemoveContext) { with(context.artifactInfo as HelmDeleteArtifactInfo) { - val version = packageClient.findPackageByKey(projectId, repoName, packageName).data?.latest + val version = packageService.findPackageByKey(projectId, repoName, packageName)?.latest try { val chartPath = HelmUtils.getChartFileFullPath(getArtifactName(), version!!) val map = nodeService.getNodeDetail(ArtifactInfo(projectId, repoName, chartPath))?.metadata @@ -153,7 +154,7 @@ class HelmOperationService( appVersion = chartInfo.appVersion!!, description = chartInfo.description ) - packageClient.updatePackage(packageUpdateRequest) + packageService.updatePackage(packageUpdateRequest) } } catch (e: Exception) { logger.warn("can not convert meta data") diff --git a/src/backend/maven/biz-maven/src/main/kotlin/com/tencent/bkrepo/maven/artifact/repository/MavenLocalRepository.kt b/src/backend/maven/biz-maven/src/main/kotlin/com/tencent/bkrepo/maven/artifact/repository/MavenLocalRepository.kt index 170c2a0203..496f0bc506 100644 --- a/src/backend/maven/biz-maven/src/main/kotlin/com/tencent/bkrepo/maven/artifact/repository/MavenLocalRepository.kt +++ b/src/backend/maven/biz-maven/src/main/kotlin/com/tencent/bkrepo/maven/artifact/repository/MavenLocalRepository.kt @@ -50,6 +50,7 @@ import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactFileFactory import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactChannel import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactResource import com.tencent.bkrepo.common.artifact.util.PackageKeys +import com.tencent.bkrepo.common.metadata.service.packages.StageService import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.service.util.HeaderUtils import com.tencent.bkrepo.common.storage.credentials.StorageCredentials @@ -97,7 +98,6 @@ import com.tencent.bkrepo.maven.util.MavenStringUtils.isSnapshotNonUniqueUri import com.tencent.bkrepo.maven.util.MavenStringUtils.isSnapshotUri import com.tencent.bkrepo.maven.util.MavenStringUtils.resolverName import com.tencent.bkrepo.maven.util.MavenUtil -import com.tencent.bkrepo.repository.api.StageClient import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -106,6 +106,7 @@ import com.tencent.bkrepo.repository.pojo.node.service.NodeCreateRequest import com.tencent.bkrepo.repository.pojo.node.service.NodeDeleteRequest import com.tencent.bkrepo.repository.pojo.packages.PackageType import com.tencent.bkrepo.repository.pojo.packages.PackageVersion +import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import org.apache.commons.lang3.StringUtils import org.apache.maven.artifact.repository.metadata.Snapshot @@ -129,7 +130,7 @@ import java.util.regex.Pattern @Component class MavenLocalRepository( - private val stageClient: StageClient, + private val stageService: StageService, private val mavenMetadataService: MavenMetadataService, private val mavenProperties: MavenProperties, ) : LocalRepository() { @@ -907,7 +908,7 @@ class MavenLocalRepository( ) try { mavenGAVC.classifier?.let { metadata[METADATA_KEY_CLASSIFIER] = it } - packageClient.createVersion( + packageService.createPackageVersion( PackageVersionCreateRequest( context.projectId, context.repoName, @@ -977,7 +978,7 @@ class MavenLocalRepository( with(artifactInfo) { logger.info("Will prepare to delete package [$packageName|$version] in repo ${getRepoIdentify()}") if (version.isBlank()) { - packageClient.listAllVersion(projectId, repoName, packageName).data.orEmpty().forEach { + packageService.listAllVersion(projectId, repoName, packageName, VersionListOption()).orEmpty().forEach { removeVersion(artifactInfo, it, userId) } // 删除artifactId目录 @@ -991,7 +992,7 @@ class MavenLocalRepository( ) nodeService.deleteNode(request) } else { - packageClient.findVersionByName(projectId, repoName, packageName, version).data?.let { + packageService.findVersionByName(projectId, repoName, packageName, version)?.let { removeVersion(artifactInfo, it, userId) // 需要更新对应的metadata.xml文件 updatePackageMetadata( @@ -1027,7 +1028,7 @@ class MavenLocalRepository( val artifactInfo = if (nodes.records.first().folder) { // 判断当前目录是否是artifactId所在目录 val packageKey = extractPackageKey(node.fullPath) - packageClient.findPackageByKey(context.projectId, context.repoName, packageKey).data + packageService.findPackageByKey(context.projectId, context.repoName, packageKey) ?: throw MavenBadRequestException(MavenMessageCode.MAVEN_ARTIFACT_DELETE, node.fullPath) val url = MavenUtil.extractPath(packageKey) + "/$MAVEN_METADATA_FILE_NAME" MavenDeleteArtifactInfo( @@ -1044,12 +1045,12 @@ class MavenLocalRepository( var packageKey = PackageKeys.ofGav(mavenGAVC.groupId, mavenGAVC.artifactId) val url = MavenUtil.extractPath(packageKey) + "/$MAVEN_METADATA_FILE_NAME" var version = mavenGAVC.version - packageClient.findVersionByName( + packageService.findVersionByName( projectId = context.projectId, repoName = context.repoName, packageKey = packageKey, - version = mavenGAVC.version - ).data ?: run { + versionName = mavenGAVC.version + ) ?: run { // 当前目录是artifactId目录(没有实际版本) packageKey = extractPackageKey(node.fullPath) version = StringPool.EMPTY @@ -1112,7 +1113,7 @@ class MavenLocalRepository( logger.info( "Will delete package $packageName version ${version.name} in repo ${getRepoIdentify()}" ) - packageClient.deleteVersion(projectId, repoName, packageName, version.name) + packageService.deleteVersion(projectId, repoName, packageName, version.name) val artifactPath = MavenUtil.extractPath(packageName) + "/${version.name}" // 需要删除对应的metadata表记录 val (artifactId, groupId) = MavenUtil.extractGroupIdAndArtifactId(packageName) @@ -1245,21 +1246,21 @@ class MavenLocalRepository( val version = context.request.getParameter(VERSION) val artifactId = packageKey.split(StringPool.COLON).last() val groupId = packageKey.removePrefix("gav://").split(StringPool.COLON)[0] - val trueVersion = packageClient.findVersionByName( + val trueVersion = packageService.findVersionByName( context.projectId, context.repoName, packageKey, version - ).data ?: return null + ) ?: return null with(context.artifactInfo) { val jarNode = nodeService.getNodeDetail( ArtifactInfo(projectId, repoName, trueVersion.contentPath!!) ) ?: return null val type = jarNode.nodeMetadata.find { it.key == METADATA_KEY_PACKAGING }?.value as String? - val stageTag = stageClient.query(projectId, repoName, packageKey, version).data - val packageVersion = packageClient.findVersionByName( + val stageTag = stageService.query(projectId, repoName, packageKey, version) + val packageVersion = packageService.findVersionByName( projectId, repoName, packageKey, version - ).data + ) val count = packageVersion?.downloads ?: 0 val mavenArtifactBasic = Basic( groupId, @@ -1306,7 +1307,7 @@ class MavenLocalRepository( val version = node.metadata[METADATA_KEY_VERSION]?.toString() return if (groupId != null && artifactId != null && version != null) { val packageKey = PackageKeys.ofGav(groupId, artifactId) - packageClient.findVersionByName(node.projectId, node.repoName, packageKey, version).data + packageService.findVersionByName(node.projectId, node.repoName, packageKey, version) } else { null } diff --git a/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/TranscodeService.kt b/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/TranscodeService.kt index 75d5ac62e0..15734405a3 100644 --- a/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/TranscodeService.kt +++ b/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/TranscodeService.kt @@ -11,12 +11,12 @@ import com.tencent.bkrepo.common.artifact.repository.context.ArtifactDownloadCon import com.tencent.bkrepo.common.artifact.repository.context.ArtifactRemoveContext import com.tencent.bkrepo.common.artifact.repository.context.ArtifactUploadContext import com.tencent.bkrepo.common.artifact.repository.core.ArtifactService +import com.tencent.bkrepo.common.metadata.service.metadata.MetadataService import com.tencent.bkrepo.media.artifact.MediaArtifactInfo import com.tencent.bkrepo.media.config.MediaProperties -import com.tencent.bkrepo.media.stream.TranscodeParam import com.tencent.bkrepo.media.stream.TranscodeConfig import com.tencent.bkrepo.media.stream.TranscodeHelper -import com.tencent.bkrepo.repository.api.MetadataClient +import com.tencent.bkrepo.media.stream.TranscodeParam import com.tencent.bkrepo.repository.pojo.metadata.MetadataSaveRequest import org.slf4j.LoggerFactory import org.springframework.stereotype.Service @@ -28,7 +28,7 @@ import org.springframework.stereotype.Service class TranscodeService( private val tokenService: TokenService, private val mediaProperties: MediaProperties, - private val metadataClient: MetadataClient, + private val metadataService: MetadataService, ) : ArtifactService() { @@ -71,11 +71,14 @@ class TranscodeService( logger.info("Upload new file[$newArtifactInfo]") // 复制原有视频的metadata val originMetadata = - metadataClient.listMetadata(projectId, repoName, originArtifactInfo.getArtifactFullPath()).data - originMetadata?.let { - val copyRequest = MetadataSaveRequest(projectId, repoName, newArtifactInfo.getArtifactFullPath(), it) - metadataClient.saveMetadata(copyRequest) - } + metadataService.listMetadata(projectId, repoName, originArtifactInfo.getArtifactFullPath()) + val copyRequest = MetadataSaveRequest( + projectId = projectId, + repoName = repoName, + fullPath = newArtifactInfo.getArtifactFullPath(), + metadata = originMetadata + ) + metadataService.saveMetadata(copyRequest) val removeContext = ArtifactRemoveContext(repo, originArtifactInfo) repository.remove(removeContext) logger.info("Delete origin file[$originArtifactInfo]") diff --git a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/artifact/repository/NpmLocalRepository.kt b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/artifact/repository/NpmLocalRepository.kt index cd2d0de219..7746863ed3 100644 --- a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/artifact/repository/NpmLocalRepository.kt +++ b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/artifact/repository/NpmLocalRepository.kt @@ -215,7 +215,7 @@ class NpmLocalRepository( val (packageName, packageVersion) = NpmUtils.parseNameAndVersionFromFullPath(artifactInfo.getArtifactFullPath()) val packageKey = PackageKeys.ofNpm(packageName) - return packageClient.findVersionByName(projectId, repoName, packageKey, packageVersion).data + return packageService.findVersionByName(projectId, repoName, packageKey, packageVersion) } } diff --git a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/handler/NpmDependentHandler.kt b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/handler/NpmDependentHandler.kt index 0f8608c674..894d2c597a 100644 --- a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/handler/NpmDependentHandler.kt +++ b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/handler/NpmDependentHandler.kt @@ -33,11 +33,11 @@ package com.tencent.bkrepo.npm.handler import com.tencent.bkrepo.common.artifact.api.ArtifactInfo import com.tencent.bkrepo.common.artifact.util.PackageKeys +import com.tencent.bkrepo.common.metadata.service.packages.PackageDependentsService import com.tencent.bkrepo.npm.model.metadata.NpmPackageMetaData import com.tencent.bkrepo.npm.model.metadata.NpmVersionMetadata import com.tencent.bkrepo.npm.pojo.enums.NpmOperationAction import com.tencent.bkrepo.npm.utils.NpmUtils -import com.tencent.bkrepo.repository.api.PackageDependentsClient import com.tencent.bkrepo.repository.pojo.dependent.PackageDependentsRelation import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -48,7 +48,7 @@ import org.springframework.stereotype.Component class NpmDependentHandler { @Autowired - private lateinit var packageDependentsClient: PackageDependentsClient + private lateinit var packageDependentsService: PackageDependentsService @Async fun updatePackageDependents( @@ -89,7 +89,7 @@ class NpmDependentHandler { packageKey = name, dependencies = versionMetaData.dependencies?.keys.orEmpty().map { PackageKeys.ofNpm(it) }.toSet() ) - packageDependentsClient.addDependents(relation) + packageDependentsService.addDependents(relation) logger.info("user [$userId] publish dependent for package: [$name] success.") } } @@ -108,7 +108,7 @@ class NpmDependentHandler { packageKey = name, dependencies = versionMetaData.dependencies?.keys.orEmpty().map { PackageKeys.ofNpm(it) }.toSet() ) - packageDependentsClient.reduceDependents(relation) + packageDependentsService.reduceDependents(relation) logger.info("user [$userId] delete dependent for package: [$name] success.") } } diff --git a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/handler/NpmPackageHandler.kt b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/handler/NpmPackageHandler.kt index 0636433125..98c300a529 100644 --- a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/handler/NpmPackageHandler.kt +++ b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/handler/NpmPackageHandler.kt @@ -33,6 +33,7 @@ package com.tencent.bkrepo.npm.handler import com.tencent.bkrepo.common.api.util.JsonUtils import com.tencent.bkrepo.common.artifact.util.PackageKeys +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.service.util.HttpContextHolder import com.tencent.bkrepo.npm.artifact.NpmArtifactInfo import com.tencent.bkrepo.npm.constants.NPM_PKG_TGZ_FULL_PATH @@ -44,7 +45,6 @@ import com.tencent.bkrepo.npm.pojo.fixtool.FailPackageDetail import com.tencent.bkrepo.npm.pojo.fixtool.FailVersionDetail import com.tencent.bkrepo.npm.utils.BeanUtils import com.tencent.bkrepo.npm.utils.NpmUtils -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.packages.PackageType @@ -60,7 +60,7 @@ import java.time.LocalDateTime @Component class NpmPackageHandler { @Autowired - private lateinit var packageClient: PackageClient + private lateinit var packageService: PackageService /** * 包版本数据填充 @@ -126,7 +126,7 @@ class NpmPackageHandler { description = packageMetaData.description.orEmpty(), versionList = versionList ) - packageClient.populatePackage(packagePopulateRequest) + packageService.populatePackage(packagePopulateRequest) } return if (failPackageDetail.failedVersionSet.isEmpty()) null else failPackageDetail } @@ -165,9 +165,10 @@ class NpmPackageHandler { overwrite = true, createdBy = userId ) - packageClient.createVersion(packageVersionCreateRequest, HttpContextHolder.getClientAddress()).apply { - logger.info("user: [$userId] create package version [$packageVersionCreateRequest] success!") - } + packageService.createPackageVersion(packageVersionCreateRequest, HttpContextHolder.getClientAddress()) + .apply { + logger.info("user: [$userId] create package version [$packageVersionCreateRequest] success!") + } } } } @@ -187,7 +188,7 @@ class NpmPackageHandler { fun deletePackage(userId: String, name: String, artifactInfo: NpmArtifactInfo) { val packageKey = PackageKeys.ofNpm(name) with(artifactInfo) { - packageClient.deletePackage(projectId, repoName, packageKey, HttpContextHolder.getClientAddress()).apply { + packageService.deletePackage(projectId, repoName, packageKey, HttpContextHolder.getClientAddress()).apply { logger.info("user: [$userId] delete package [$name] in repo [$projectId/$repoName] success!") } } @@ -199,7 +200,7 @@ class NpmPackageHandler { fun deleteVersion(userId: String, name: String, version: String, artifactInfo: NpmArtifactInfo) { val packageKey = PackageKeys.ofNpm(name) with(artifactInfo) { - packageClient.deleteVersion(projectId, repoName, packageKey, version, HttpContextHolder.getClientAddress()) + packageService.deleteVersion(projectId, repoName, packageKey, version, HttpContextHolder.getClientAddress()) .apply { logger.info( "user: [$userId] delete package [$name] with version [$version] " + diff --git a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/AbstractNpmService.kt b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/AbstractNpmService.kt index 57d1cb9a78..27a2425207 100644 --- a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/AbstractNpmService.kt +++ b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/AbstractNpmService.kt @@ -36,6 +36,7 @@ import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHold import com.tencent.bkrepo.common.artifact.repository.context.ArtifactQueryContext import com.tencent.bkrepo.common.metadata.service.node.NodeSearchService import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import com.tencent.bkrepo.common.service.util.HeaderUtils import com.tencent.bkrepo.npm.artifact.NpmArtifactInfo @@ -47,7 +48,6 @@ import com.tencent.bkrepo.npm.model.metadata.NpmPackageMetaData import com.tencent.bkrepo.npm.model.metadata.NpmVersionMetadata import com.tencent.bkrepo.npm.properties.NpmProperties import com.tencent.bkrepo.npm.utils.NpmUtils -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -68,7 +68,7 @@ open class AbstractNpmService { lateinit var repositoryService: RepositoryService @Autowired - lateinit var packageClient: PackageClient + lateinit var packageService: PackageService @Autowired lateinit var npmProperties: NpmProperties @@ -87,21 +87,21 @@ open class AbstractNpmService { * check package exists */ fun packageExist(projectId: String, repoName: String, key: String): Boolean { - return packageClient.findPackageByKey(projectId, repoName, key).data?.let { true } ?: false + return packageService.findPackageByKey(projectId, repoName, key)?.let { true } ?: false } /** * check package version exists */ fun packageVersionExist(projectId: String, repoName: String, key: String, version: String): Boolean { - return packageClient.findVersionByName(projectId, repoName, key, version).data?.let { true } ?: false + return packageService.findVersionByName(projectId, repoName, key, version)?.let { true } ?: false } /** * check package history version exists */ fun packageHistoryVersionExist(projectId: String, repoName: String, key: String, version: String): Boolean { - val packageSummary = packageClient.findPackageByKey(projectId, repoName, key).data ?: return false + val packageSummary = packageService.findPackageByKey(projectId, repoName, key) ?: return false return packageSummary.historyVersion.contains(version) } diff --git a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/NpmFixToolServiceImpl.kt b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/NpmFixToolServiceImpl.kt index 1752090dbc..e1308abb4a 100644 --- a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/NpmFixToolServiceImpl.kt +++ b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/NpmFixToolServiceImpl.kt @@ -42,6 +42,7 @@ import com.tencent.bkrepo.npm.utils.TimeUtil import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.node.service.NodeCreateRequest import com.tencent.bkrepo.repository.pojo.packages.PackageSummary +import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import java.time.Duration @@ -392,12 +393,12 @@ class NpmFixToolServiceImpl( */ with(artifactInfo) { val packageKey = PackageKeys.ofNpm(name) - val packageSummary = packageClient.findPackageByKey(projectId, repoName, packageKey).data + val packageSummary = packageService.findPackageByKey(projectId, repoName, packageKey) ?: throw PackageNotFoundException("package [$name] not found") val packageInfo = queryPackageInfo(this, name, false) val metadataVersions = packageInfo.versions.map.keys val packageVersions = - packageClient.listAllVersion(projectId, repoName, packageKey).data.orEmpty().map { it.name } + packageService.listAllVersion(projectId, repoName, packageKey, VersionListOption()).map { it.name } val subVersion = metadataVersions subtract packageVersions val fullPathList = mutableListOf() if (subVersion.isNotEmpty()) { diff --git a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/NpmWebServiceImpl.kt b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/NpmWebServiceImpl.kt index ba50f1a530..f0b134da0c 100644 --- a/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/NpmWebServiceImpl.kt +++ b/src/backend/npm/biz-npm/src/main/kotlin/com/tencent/bkrepo/npm/service/impl/NpmWebServiceImpl.kt @@ -38,6 +38,7 @@ import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHold import com.tencent.bkrepo.common.artifact.repository.context.ArtifactUploadContext import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactFileFactory import com.tencent.bkrepo.common.artifact.util.PackageKeys +import com.tencent.bkrepo.common.metadata.service.packages.PackageDependentsService import com.tencent.bkrepo.npm.artifact.NpmArtifactInfo import com.tencent.bkrepo.npm.constants.LATEST import com.tencent.bkrepo.npm.constants.NPM_FILE_FULL_PATH @@ -55,7 +56,6 @@ import com.tencent.bkrepo.npm.pojo.user.request.PackageVersionDeleteRequest import com.tencent.bkrepo.npm.service.NpmClientService import com.tencent.bkrepo.npm.service.NpmWebService import com.tencent.bkrepo.npm.utils.NpmUtils -import com.tencent.bkrepo.repository.api.PackageDependentsClient import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.packages.PackageVersion import org.slf4j.Logger @@ -68,7 +68,7 @@ import org.springframework.transaction.annotation.Transactional class NpmWebServiceImpl : NpmWebService, AbstractNpmService() { @Autowired - private lateinit var packageDependentsClient: PackageDependentsClient + private lateinit var packageDependentsService: PackageDependentsService @Autowired private lateinit var npmClientService: NpmClientService @@ -89,7 +89,7 @@ class NpmWebServiceImpl : NpmWebService, AbstractNpmService() { logger.warn("node [$fullPath] don't found.") throw NpmArtifactNotFoundException("node [$fullPath] don't found.") } - val packageVersion = packageClient.findVersionByName(projectId, repoName, packageKey, version).data ?: run { + val packageVersion = packageService.findVersionByName(projectId, repoName, packageKey, version) ?: run { logger.warn("packageKey [$packageKey] don't found.") throw NpmArtifactNotFoundException("packageKey [$packageKey] don't found.") } @@ -105,8 +105,8 @@ class NpmWebServiceImpl : NpmWebService, AbstractNpmService() { packageKey: String, versionMetadata: NpmVersionMetadata ): VersionDependenciesInfo { - val packageDependents = packageDependentsClient.queryDependents(artifactInfo.projectId, - artifactInfo.repoName, packageKey).data.orEmpty() + val packageDependents = packageDependentsService.findByPackageKey(artifactInfo.projectId, + artifactInfo.repoName, packageKey) val dependenciesList = parseDependencies(versionMetadata) val devDependenciesList = parseDevDependencies(versionMetadata) return VersionDependenciesInfo(dependenciesList, devDependenciesList, packageDependents) @@ -182,7 +182,7 @@ class NpmWebServiceImpl : NpmWebService, AbstractNpmService() { private fun findNewLatest(request: PackageVersionDeleteRequest): String { return with(request) { - packageClient.findPackageByKey(projectId, repoName, PackageKeys.ofNpm(name)).data?.latest + packageService.findPackageByKey(projectId, repoName, PackageKeys.ofNpm(name))?.latest ?: run { val message = "delete version by web operator to find new latest version failed with package [$name]" diff --git a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/repository/NugetLocalRepository.kt b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/repository/NugetLocalRepository.kt index 8cbf1ac035..3438e3024b 100644 --- a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/repository/NugetLocalRepository.kt +++ b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/repository/NugetLocalRepository.kt @@ -73,6 +73,7 @@ import com.tencent.bkrepo.nuget.util.NugetVersionUtils import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord import com.tencent.bkrepo.repository.pojo.node.service.NodeDeleteRequest import com.tencent.bkrepo.repository.pojo.packages.PackageVersion +import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.stereotype.Component @@ -95,9 +96,9 @@ class NugetLocalRepository( } private fun enumerateVersions(context: ArtifactQueryContext, packageId: String): List? { - return packageClient.listExistPackageVersion( - context.projectId, context.repoName, PackageKeys.ofNuget(packageId) - ).data?.takeIf { it.isNotEmpty() } + return packageService.listExistPackageVersion( + context.projectId, context.repoName, PackageKeys.ofNuget(packageId), emptyList() + ).takeIf { it.isNotEmpty() } } private fun feed(artifactInfo: NugetArtifactInfo): Feed { @@ -108,9 +109,13 @@ class NugetLocalRepository( with(context) { val packageName = (artifactInfo as NugetRegistrationArtifactInfo).packageName val registrationPath = context.getStringAttribute(REGISTRATION_PATH) - val packageVersionList = - packageClient.listAllVersion(projectId, repoName, PackageKeys.ofNuget(packageName)).data - if (packageVersionList.isNullOrEmpty()) return null + val packageVersionList = packageService.listAllVersion( + projectId = projectId, + repoName = repoName, + packageKey = PackageKeys.ofNuget(packageName), + option = VersionListOption() + ) + if (packageVersionList.isEmpty()) return null val sortedVersionList = packageVersionList.stream().sorted { o1, o2 -> NugetVersionUtils.compareSemVer(o1.name, o2.name) }.toList() @@ -129,9 +134,8 @@ class NugetLocalRepository( val nugetArtifactInfo = artifactInfo as NugetRegistrationArtifactInfo val registrationPath = context.getStringAttribute(REGISTRATION_PATH) val packageKey = PackageKeys.ofNuget(nugetArtifactInfo.packageName) - val packageVersionList = - packageClient.listAllVersion(projectId, repoName, packageKey).data - if (packageVersionList.isNullOrEmpty()) return null + val packageVersionList = packageService.listAllVersion(projectId, repoName, packageKey, VersionListOption()) + if (packageVersionList.isEmpty()) return null val sortedVersionList = packageVersionList.stream().sorted { o1, o2 -> NugetVersionUtils.compareSemVer(o1.name, o2.name) }.toList() @@ -157,8 +161,7 @@ class NugetLocalRepository( val nugetArtifactInfo = artifactInfo as NugetRegistrationArtifactInfo val packageKey = PackageKeys.ofNuget(nugetArtifactInfo.packageName) // 确保version一定存在 - packageClient.findVersionByName(projectId, repoName, packageKey, nugetArtifactInfo.version).data - ?: return null + packageService.findVersionByName(projectId, repoName, packageKey, nugetArtifactInfo.version) ?: return null try { val v3RegistrationUrl = NugetUtils.getV3Url(artifactInfo) + '/' + registrationPath return NugetV3RegistrationUtils.metadataToRegistrationLeaf( @@ -175,9 +178,9 @@ class NugetLocalRepository( super.onUploadBefore(context) // 校验版本是否存在,存在则冲突 with(context.artifactInfo as NugetPublishArtifactInfo) { - packageClient.findVersionByName( + packageService.findVersionByName( projectId, repoName, PackageKeys.ofNuget(packageName.toLowerCase()), version - ).data?.let { + )?.let { throw ErrorCodeException( messageCode = NugetMessageCode.VERSION_EXISTED, params = arrayOf(version), @@ -231,11 +234,12 @@ class NugetLocalRepository( override fun remove(context: ArtifactRemoveContext) { with(context.artifactInfo as NugetDeleteArtifactInfo) { if (version.isNotBlank()) { - packageClient.findVersionByName(projectId, repoName, packageName, version).data?.let { + packageService.findVersionByName(projectId, repoName, packageName, version)?.let { removeVersion(this, it, context.userId) } ?: throw VersionNotFoundException(version) } else { - packageClient.listAllVersion(projectId, repoName, packageName).data.takeUnless { it.isNullOrEmpty() } + packageService.listAllVersion(projectId, repoName, packageName, VersionListOption()) + .takeUnless { it.isEmpty() } ?.forEach { removeVersion(this, it, context.userId) } ?: throw PackageNotFoundException(packageName) } @@ -247,7 +251,7 @@ class NugetLocalRepository( */ private fun removeVersion(artifactInfo: NugetDeleteArtifactInfo, version: PackageVersion, userId: String) { with(artifactInfo) { - packageClient.deleteVersion( + packageService.deleteVersion( projectId, repoName, packageName, diff --git a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/repository/NugetVirtualRepository.kt b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/repository/NugetVirtualRepository.kt index 449a515b81..0d5e84d9da 100644 --- a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/repository/NugetVirtualRepository.kt +++ b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/repository/NugetVirtualRepository.kt @@ -49,6 +49,7 @@ import com.tencent.bkrepo.nuget.util.NugetUtils import com.tencent.bkrepo.nuget.util.NugetV3RegistrationUtils import com.tencent.bkrepo.nuget.util.RemoteRegistrationUtils import com.tencent.bkrepo.nuget.util.NugetVersionUtils +import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -181,9 +182,13 @@ class NugetVirtualRepository( it: RepositoryDetail ): Stream { with(artifactInfo) { - val packageVersionList = - packageClient.listAllVersion(projectId, repoName, PackageKeys.ofNuget(packageName)).data - val sortedVersionList = packageVersionList.orEmpty().stream().sorted { o1, o2 -> + val packageVersionList = packageService.listAllVersion( + projectId = projectId, + repoName = repoName, + packageKey = PackageKeys.ofNuget(packageName), + option = VersionListOption() + ) + val sortedVersionList = packageVersionList.stream().sorted { o1, o2 -> NugetVersionUtils.compareSemVer(o1.name, o2.name) }.toList() val v3RegistrationUrl = NugetUtils.getV3Url(artifactInfo) + '/' + registrationPath diff --git a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/resolver/NugetPublishInfoResolver.kt b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/resolver/NugetPublishInfoResolver.kt index d9abc66833..b074535889 100644 --- a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/resolver/NugetPublishInfoResolver.kt +++ b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/artifact/resolver/NugetPublishInfoResolver.kt @@ -9,7 +9,7 @@ import com.tencent.bkrepo.common.artifact.api.ArtifactInfo import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactFileFactory import com.tencent.bkrepo.common.artifact.resolve.path.ArtifactInfoResolver import com.tencent.bkrepo.common.artifact.resolve.path.Resolver -import com.tencent.bkrepo.common.artifact.util.version.SemVersion +import com.tencent.bkrepo.common.metadata.util.version.SemVersion import com.tencent.bkrepo.nuget.constant.PACKAGE import com.tencent.bkrepo.nuget.constant.VERSION import com.tencent.bkrepo.nuget.exception.NugetArtifactReceiveException diff --git a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/handler/NugetPackageHandler.kt b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/handler/NugetPackageHandler.kt index 5cbf5a3f83..b2be05a3b9 100644 --- a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/handler/NugetPackageHandler.kt +++ b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/handler/NugetPackageHandler.kt @@ -3,6 +3,7 @@ package com.tencent.bkrepo.nuget.handler import com.tencent.bkrepo.common.api.util.toJsonString import com.tencent.bkrepo.common.artifact.repository.context.ArtifactUploadContext import com.tencent.bkrepo.common.artifact.util.PackageKeys +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.service.util.HttpContextHolder import com.tencent.bkrepo.nuget.artifact.NugetArtifactInfo import com.tencent.bkrepo.nuget.constant.DEPENDENCY @@ -18,7 +19,6 @@ import com.tencent.bkrepo.nuget.pojo.nuspec.FrameworkAssembly import com.tencent.bkrepo.nuget.pojo.nuspec.Reference import com.tencent.bkrepo.nuget.pojo.nuspec.ReferenceGroup import com.tencent.bkrepo.nuget.util.NugetV3RegistrationUtils -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.packages.PackageType import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest @@ -27,13 +27,12 @@ import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component import java.util.StringJoiner -import kotlin.collections.HashSet @Component class NugetPackageHandler { @Autowired - private lateinit var packageClient: PackageClient + private lateinit var packageService: PackageService /** * 创建包版本 @@ -79,7 +78,7 @@ class NugetPackageHandler { overwrite = true, createdBy = context.userId ) - packageClient.createVersion(packageVersionCreateRequest, HttpContextHolder.getClientAddress()) + packageService.createPackageVersion(packageVersionCreateRequest, HttpContextHolder.getClientAddress()) if (logger.isDebugEnabled) { logger.info( "user: [${context.userId}] create package version [$packageVersionCreateRequest] success!" @@ -214,7 +213,7 @@ class NugetPackageHandler { fun deleteVersion(userId: String, name: String, version: String, artifactInfo: NugetArtifactInfo) { val packageKey = PackageKeys.ofNuget(name) with(artifactInfo) { - packageClient.deleteVersion(projectId, repoName, packageKey, version, HttpContextHolder.getClientAddress()) + packageService.deleteVersion(projectId, repoName, packageKey, version, HttpContextHolder.getClientAddress()) .apply { logger.info( "user: [$userId] delete package [$name] with version [$version] " + diff --git a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/service/impl/NugetSearchServiceImpl.kt b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/service/impl/NugetSearchServiceImpl.kt index d70dff76b1..be962446ad 100644 --- a/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/service/impl/NugetSearchServiceImpl.kt +++ b/src/backend/nuget/biz-nuget/src/main/kotlin/com/tencent/bkrepo/nuget/service/impl/NugetSearchServiceImpl.kt @@ -1,6 +1,7 @@ package com.tencent.bkrepo.nuget.service.impl import com.tencent.bkrepo.common.api.util.Preconditions +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.nuget.artifact.NugetArtifactInfo import com.tencent.bkrepo.nuget.pojo.request.NugetSearchRequest import com.tencent.bkrepo.nuget.pojo.response.search.NugetSearchResponse @@ -9,16 +10,16 @@ import com.tencent.bkrepo.nuget.service.NugetSearchService import com.tencent.bkrepo.nuget.util.NugetUtils import com.tencent.bkrepo.nuget.util.NugetV3RegistrationUtils import com.tencent.bkrepo.nuget.util.NugetVersionUtils -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.packages.PackageListOption import com.tencent.bkrepo.repository.pojo.packages.PackageSummary +import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import org.slf4j.LoggerFactory import org.springframework.stereotype.Service import kotlin.streams.toList @Service class NugetSearchServiceImpl( - private val packageClient: PackageClient + private val packageService: PackageService ) : NugetSearchService { override fun search(artifactInfo: NugetArtifactInfo, searchRequest: NugetSearchRequest): NugetSearchResponse { logger.info("handling search request in repo [${artifactInfo.getRepoIdentify()}], parameter: $searchRequest") @@ -32,9 +33,9 @@ class NugetSearchServiceImpl( val packageListOption = PackageListOption(pageSize = 1000, packageName = q) while (true) { - val page = packageClient.listPackagePage( + val page = packageService.listPackagePage( artifactInfo.projectId, artifactInfo.repoName, packageListOption - ).data?.records.takeUnless { it.isNullOrEmpty() } ?: break + ).records.takeUnless { it.isEmpty() } ?: break packageListOption.pageNumber++ val pageResult = page.map { buildSearchResponseData(it, this, v3RegistrationUrl) @@ -54,7 +55,7 @@ class NugetSearchServiceImpl( v3RegistrationUrl: String ): SearchResponseData { with(packageSummary) { - val packageVersionList = packageClient.listAllVersion(projectId, repoName, key).data!! + val packageVersionList = packageService.listAllVersion(projectId, repoName, key, VersionListOption()) // preRelease需要处理 val sortedPackageVersionList = packageVersionList.stream() diff --git a/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/artifact/repository/OciRegistryLocalRepository.kt b/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/artifact/repository/OciRegistryLocalRepository.kt index 0c9f526a42..9497ce4268 100644 --- a/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/artifact/repository/OciRegistryLocalRepository.kt +++ b/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/artifact/repository/OciRegistryLocalRepository.kt @@ -79,6 +79,7 @@ import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.node.service.NodeDeleteRequest import com.tencent.bkrepo.repository.pojo.packages.PackageVersion +import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import org.slf4j.LoggerFactory import org.springframework.stereotype.Component import java.util.Locale @@ -447,7 +448,7 @@ class OciRegistryLocalRepository( val artifactInfo = context.artifactInfo as OciArtifactInfo val packageKey = PackageKeys.ofName(repo.type, artifactInfo.packageName) val version = node.metadata[IMAGE_VERSION]?.toString() ?: return null - return packageClient.findVersionByName(projectId, repoName, packageKey, version).data + return packageService.findVersionByName(projectId, repoName, packageKey, version) } } @@ -466,7 +467,7 @@ class OciRegistryLocalRepository( with(context.artifactInfo as OciTagArtifactInfo) { val n = context.getAttribute(N) val last = context.getAttribute(LAST_TAG) - val packageList = packageClient.listAllPackageNames(projectId, repoName).data.orEmpty() + val packageList = packageService.listAllPackageName(projectId, repoName) if (packageList.isEmpty()) return null val nameList = mutableListOf().apply { packageList.forEach { @@ -497,11 +498,7 @@ class OciRegistryLocalRepository( val last = context.getAttribute(LAST_TAG) val packageKey = PackageKeys.ofName(context.repositoryDetail.type.name.lowercase(Locale.getDefault()), packageName) - val versionList = packageClient.listAllVersion( - projectId, - repoName, - packageKey - ).data.orEmpty() + val versionList = packageService.listAllVersion(projectId, repoName, packageKey, VersionListOption()) if (versionList.isEmpty()) return null val tagList = mutableListOf().apply { versionList.forEach { diff --git a/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/service/impl/OciOperationServiceImpl.kt b/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/service/impl/OciOperationServiceImpl.kt index 50cf06a4f1..007cc1d245 100644 --- a/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/service/impl/OciOperationServiceImpl.kt +++ b/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/service/impl/OciOperationServiceImpl.kt @@ -47,8 +47,10 @@ import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactChannel import com.tencent.bkrepo.common.artifact.stream.ArtifactInputStream import com.tencent.bkrepo.common.artifact.util.PackageKeys import com.tencent.bkrepo.common.metadata.service.metadata.MetadataService +import com.tencent.bkrepo.common.metadata.service.metadata.PackageMetadataService import com.tencent.bkrepo.common.metadata.service.node.NodeSearchService import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.query.enums.OperationType @@ -99,8 +101,6 @@ import com.tencent.bkrepo.oci.util.OciLocationUtils import com.tencent.bkrepo.oci.util.OciLocationUtils.buildBlobsFolderPath import com.tencent.bkrepo.oci.util.OciResponseUtils import com.tencent.bkrepo.oci.util.OciUtils -import com.tencent.bkrepo.repository.api.PackageClient -import com.tencent.bkrepo.repository.api.PackageMetadataClient import com.tencent.bkrepo.repository.constant.SYSTEM_USER import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -135,8 +135,8 @@ class OciOperationServiceImpl( private val nodeService: NodeService, private val nodeSearchService: NodeSearchService, private val metadataService: MetadataService, - private val packageMetadataClient: PackageMetadataClient, - private val packageClient: PackageClient, + private val packageMetadataService: PackageMetadataService, + private val packageService: PackageService, private val storageManager: StorageManager, private val repositoryService: RepositoryService, private val ociProperties: OciProperties, @@ -155,12 +155,12 @@ class OciOperationServiceImpl( packageKey: String, version: String ) { - packageClient.findVersionByName( + packageService.findVersionByName( projectId = projectId, repoName = repoName, packageKey = packageKey, - version = version - ).data ?: throw OciVersionNotFoundException( + versionName = version + ) ?: throw OciVersionNotFoundException( OciMessageCode.OCI_VERSION_NOT_FOUND, "$packageKey/$version", "$projectId|$repoName" ) } @@ -175,12 +175,12 @@ class OciOperationServiceImpl( val repoDetail = getRepositoryInfo(artifactInfo) val packageKey = PackageKeys.ofName(repoDetail.type.name.lowercase(Locale.getDefault()), packageName) if (version.isNotBlank()) { - packageClient.findVersionByName( + packageService.findVersionByName( projectId = projectId, repoName = repoName, packageKey = packageKey, - version = version - ).data?.let { + versionName = version + )?.let { removeVersion( artifactInfo = this, version = it.name, @@ -188,7 +188,7 @@ class OciOperationServiceImpl( packageKey = packageKey ) } ?: throw VersionNotFoundException(version) - if (!packageClient.listAllVersion(projectId, repoName, packageKey).data.isNullOrEmpty()) { + if (packageService.listAllVersion(projectId, repoName, packageKey, VersionListOption()).isNotEmpty()) { return } // 当没有版本时删除删除package目录 @@ -197,7 +197,7 @@ class OciOperationServiceImpl( // 删除package目录 deleteNode(projectId, repoName, "${StringPool.SLASH}$packageName", userId) //删除package下所有版本 - packageClient.deletePackage( + packageService.deletePackage( projectId, repoName, packageKey @@ -222,7 +222,7 @@ class OciOperationServiceImpl( version = version, userId = userId ) - packageClient.deleteVersion(projectId, repoName, packageKey, version) + packageService.deleteVersion(projectId, repoName, packageKey, version) } } @@ -299,7 +299,7 @@ class OciOperationServiceImpl( ) ?: throw OciVersionNotFoundException( OciMessageCode.OCI_VERSION_NOT_FOUND, "$packageKey/$version", "$projectId|$repoName" ) - val packageVersion = packageClient.findVersionByName(projectId, repoName, packageKey, version).data!! + val packageVersion = packageService.findVersionByName(projectId, repoName, packageKey, version)!! val basicInfo = ObjectBuildUtils.buildBasicInfo(nodeDetail, packageVersion) return PackageVersionInfo(basicInfo, packageVersion.packageMetadata) } @@ -720,7 +720,7 @@ class OciOperationServiceImpl( repoType = repoType, userId = userId ) - packageClient.createVersion(request) + packageService.createPackageVersion(request) savePackageMetaData( projectId = projectId, repoName = repoName, @@ -750,7 +750,7 @@ class OciOperationServiceImpl( userId = SecurityUtils.getUserId() ) try { - packageMetadataClient.saveMetadata(metadataSaveRequest) + packageMetadataService.saveMetadata(metadataSaveRequest) } catch (ignore: Exception) { } } @@ -905,10 +905,7 @@ class OciOperationServiceImpl( name?.let { queryModel.name("*$name*", OperationType.MATCH) } - val result = packageClient.searchPackage(queryModel.build()).data ?: run { - logger.warn("find repo list failed: [$projectId, $repoName] ") - return OciImageResult(0, emptyList()) - } + val result = packageService.searchPackage(queryModel.build()) val data = mutableListOf() result.records.forEach { val imageName = it[OCI_PACKAGE_NAME] as String @@ -942,12 +939,12 @@ class OciOperationServiceImpl( val artifactInfo = OciArtifactInfo(projectId, repoName, StringPool.EMPTY, StringPool.EMPTY) val repoDetail = getRepositoryInfo(artifactInfo) val packageKey = PackageKeys.ofName(repoDetail.type.name.lowercase(Locale.getDefault()), packageName) - val result = packageClient.listVersionPage( + val result = packageService.listVersionPage( projectId, repoName, packageKey, VersionListOption(pageNumber, pageSize, tag, null) - ).data ?: return OciTagResult(0, emptyList()) + ) val data = mutableListOf() result.records.forEach { val name = it.name diff --git a/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/artifact/repository/PypiLocalRepository.kt b/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/artifact/repository/PypiLocalRepository.kt index e4edffa7e4..92a4e89c8a 100644 --- a/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/artifact/repository/PypiLocalRepository.kt +++ b/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/artifact/repository/PypiLocalRepository.kt @@ -40,8 +40,9 @@ import com.tencent.bkrepo.common.artifact.repository.local.LocalRepository import com.tencent.bkrepo.common.artifact.resolve.file.multipart.MultipartArtifactFile import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactResource import com.tencent.bkrepo.common.artifact.util.PackageKeys -import com.tencent.bkrepo.common.artifact.util.version.SemVersion -import com.tencent.bkrepo.common.artifact.util.version.SemVersionParser +import com.tencent.bkrepo.common.metadata.service.packages.StageService +import com.tencent.bkrepo.common.metadata.util.version.SemVersion +import com.tencent.bkrepo.common.metadata.util.version.SemVersionParser import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.query.model.PageLimit import com.tencent.bkrepo.common.query.model.QueryModel @@ -71,7 +72,6 @@ import com.tencent.bkrepo.pypi.util.HtmlUtils import com.tencent.bkrepo.pypi.util.PypiVersionUtils.toPypiPackagePojo import com.tencent.bkrepo.pypi.util.XmlUtils import com.tencent.bkrepo.pypi.util.XmlUtils.readXml -import com.tencent.bkrepo.repository.api.StageClient import com.tencent.bkrepo.repository.constant.FULL_PATH import com.tencent.bkrepo.repository.constant.METADATA import com.tencent.bkrepo.repository.constant.NAME @@ -93,7 +93,7 @@ import org.springframework.stereotype.Component @Component class PypiLocalRepository( - private val stageClient: StageClient, + private val stageService: StageService, private val pypiProperties: PypiProperties ) : LocalRepository() { @@ -130,7 +130,7 @@ class PypiLocalRepository( val artifactFile = context.getArtifactFile("content") val name: String = context.request.getParameter("name") val version: String = context.request.getParameter("version") - packageClient.createVersion( + packageService.createPackageVersion( PackageVersionCreateRequest( projectId = context.projectId, repoName = context.repoName, @@ -243,7 +243,7 @@ class PypiLocalRepository( context.userId ) ) - packageClient.deletePackage( + packageService.deletePackage( context.projectId, context.repoName, packageKey, @@ -259,7 +259,7 @@ class PypiLocalRepository( context.userId ) ) - packageClient.deleteVersion( + packageService.deleteVersion( context.projectId, context.repoName, packageKey, @@ -287,21 +287,21 @@ class PypiLocalRepository( val version = context.request.getParameter("version") logger.info("Get version detail. packageKey[$packageKey], version[$version]") val name = PackageKeys.resolvePypi(packageKey) - val trueVersion = packageClient.findVersionByName( + val trueVersion = packageService.findVersionByName( context.projectId, context.repoName, packageKey, version - ).data ?: return null + ) ?: return null val artifactPath = trueVersion.contentPaths?.firstOrNull() ?: trueVersion.contentPath ?: return null with(context.artifactInfo) { val jarNode = nodeService.getNodeDetail( ArtifactInfo(projectId, repoName, artifactPath) ) ?: return null - val stageTag = stageClient.query(projectId, repoName, packageKey, version).data - val packageVersion = packageClient.findVersionByName( + val stageTag = stageService.query(projectId, repoName, packageKey, version) + val packageVersion = packageService.findVersionByName( projectId, repoName, packageKey, version - ).data + ) val count = packageVersion?.downloads ?: 0 val pypiArtifactBasic = Basic( name, @@ -498,7 +498,7 @@ class PypiLocalRepository( } ?: return null val packageKey = PackageKeys.ofPypi(pypiPackagePojo.name) - return packageClient.findVersionByName(projectId, repoName, packageKey, pypiPackagePojo.version).data + return packageService.findVersionByName(projectId, repoName, packageKey, pypiPackagePojo.version) } } diff --git a/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/service/PypiWebService.kt b/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/service/PypiWebService.kt index 69bf6ec216..d716398456 100644 --- a/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/service/PypiWebService.kt +++ b/src/backend/pypi/biz-pypi/src/main/kotlin/com/tencent/bkrepo/pypi/service/PypiWebService.kt @@ -40,12 +40,12 @@ import com.tencent.bkrepo.common.artifact.repository.context.ArtifactQueryContex import com.tencent.bkrepo.common.artifact.repository.context.ArtifactRemoveContext import com.tencent.bkrepo.common.artifact.repository.core.ArtifactService import com.tencent.bkrepo.common.artifact.util.PackageKeys -import com.tencent.bkrepo.common.artifact.util.version.SemVersion -import com.tencent.bkrepo.common.artifact.util.version.SemVersionParser import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.util.version.SemVersion +import com.tencent.bkrepo.common.metadata.util.version.SemVersionParser import com.tencent.bkrepo.common.security.permission.Permission import com.tencent.bkrepo.pypi.artifact.PypiArtifactInfo -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.node.NodeListOption import com.tencent.bkrepo.repository.pojo.packages.PackageVersion @@ -55,7 +55,7 @@ import java.time.LocalDateTime @Service class PypiWebService( private val nodeService: NodeService, - private val packageClient: PackageClient + private val packageService: PackageService ) : ArtifactService() { @Permission(type = ResourceType.REPO, action = PermissionAction.DELETE) @@ -93,7 +93,7 @@ class PypiWebService( ) val packageVersionList = data.records.map { val version = parseSemVersion(it.path).toString() - val packageVersion = packageClient.findVersionByName(it.projectId, it.repoName, packageKey, version).data + val packageVersion = packageService.findVersionByName(it.projectId, it.repoName, packageKey, version) buildPackageVersion(it, version, packageVersion) }.sortedWith(compareByDescending { it.name }.thenByDescending { it.createdDate }) return Page(pageNumber, pageSize, data.totalRecords, packageVersionList) diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/service/ArtifactReplicaController.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/service/ArtifactReplicaController.kt index 6d78797872..0f0b9109e7 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/service/ArtifactReplicaController.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/service/ArtifactReplicaController.kt @@ -33,6 +33,7 @@ import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.artifact.api.ArtifactInfo import com.tencent.bkrepo.common.metadata.service.metadata.MetadataService import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.service.project.ProjectService import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import com.tencent.bkrepo.common.security.exception.PermissionException @@ -45,7 +46,6 @@ import com.tencent.bkrepo.replication.constant.DEFAULT_VERSION import com.tencent.bkrepo.replication.pojo.request.CheckPermissionRequest import com.tencent.bkrepo.replication.pojo.request.NodeExistCheckRequest import com.tencent.bkrepo.replication.pojo.request.PackageVersionExistCheckRequest -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.metadata.MetadataDeleteRequest import com.tencent.bkrepo.repository.pojo.metadata.MetadataSaveRequest import com.tencent.bkrepo.repository.pojo.node.NodeDeleteResult @@ -74,7 +74,7 @@ class ArtifactReplicaController( private val projectService: ProjectService, private val repositoryService: RepositoryService, private val nodeService: NodeService, - private val packageClient: PackageClient, + private val packageService: PackageService, private val metadataService: MetadataService, private val userResource: ServiceUserClient, private val permissionManager: PermissionManager @@ -186,18 +186,19 @@ class ArtifactReplicaController( override fun checkPackageVersionExist( request: PackageVersionExistCheckRequest ): Response { - val packageVersion = packageClient.findVersionByName( + val packageVersion = packageService.findVersionByName( request.projectId, request.repoName, request.packageKey, request.versionName - ).data + ) return ResponseBuilder.success(packageVersion != null) } override fun replicaPackageVersionCreatedRequest( request: PackageVersionCreateRequest ): Response { - return packageClient.createVersion(request) + packageService.createPackageVersion(request) + return ResponseBuilder.success() } } diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/manager/LocalDataManager.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/manager/LocalDataManager.kt index 4fcbb8036c..00adfa0a8e 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/manager/LocalDataManager.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/manager/LocalDataManager.kt @@ -40,6 +40,7 @@ import com.tencent.bkrepo.common.artifact.path.PathUtils import com.tencent.bkrepo.common.artifact.stream.Range import com.tencent.bkrepo.common.metadata.service.node.NodeSearchService import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.service.project.ProjectService import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService @@ -52,7 +53,6 @@ import com.tencent.bkrepo.common.storage.pojo.FileInfo import com.tencent.bkrepo.replication.constant.MD5 import com.tencent.bkrepo.replication.constant.NODE_FULL_PATH import com.tencent.bkrepo.replication.constant.SIZE -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.constant.SHARDING_COUNT import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -84,7 +84,7 @@ class LocalDataManager( private val repositoryService: RepositoryService, private val nodeService: NodeService, private val nodeSearchService: NodeSearchService, - private val packageClient: PackageClient, + private val packageService: PackageService, private val storageService: StorageService, private val storageCredentialService: StorageCredentialService, private val storageProperties: StorageProperties, @@ -166,7 +166,7 @@ class LocalDataManager( * 根据packageKey查找包信息 */ fun findPackageByKey(projectId: String, repoName: String, packageKey: String): PackageSummary { - return packageClient.findPackageByKey(projectId, repoName, packageKey).data + return packageService.findPackageByKey(projectId, repoName, packageKey) ?: throw PackageNotFoundException(packageKey) } @@ -179,15 +179,14 @@ class LocalDataManager( packageKey: String, option: VersionListOption ): List { - return packageClient.listAllVersion(projectId, repoName, packageKey, option).data - ?: throw PackageNotFoundException(packageKey) + return packageService.listAllVersion(projectId, repoName, packageKey, option) } /** * 查询指定版本 */ fun findPackageVersion(projectId: String, repoName: String, packageKey: String, version: String): PackageVersion { - return packageClient.findVersionByName(projectId, repoName, packageKey, version).data + return packageService.findVersionByName(projectId, repoName, packageKey, version) ?: throw VersionNotFoundException(packageKey) } @@ -253,14 +252,11 @@ class LocalDataManager( * 分页查询包 */ fun listPackagePage(projectId: String, repoName: String, option: PackageListOption): List { - val packages = packageClient.listPackagePage( + val packages = packageService.listPackagePage( projectId = projectId, repoName = repoName, option = option - ).data?.records - if (packages.isNullOrEmpty()) { - return emptyList() - } + ).records return packages } diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeReplicaTaskJob.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeReplicaTaskJob.kt index 66e85f4e5b..7dfc51e1ee 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeReplicaTaskJob.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/replica/type/edge/EdgeReplicaTaskJob.kt @@ -36,6 +36,7 @@ import com.tencent.bkrepo.common.artifact.exception.PackageNotFoundException import com.tencent.bkrepo.common.artifact.exception.VersionNotFoundException import com.tencent.bkrepo.common.metadata.constant.FAKE_SHA256 import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeEdgeCondition import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.feign.FeignClientFactory @@ -49,7 +50,6 @@ import com.tencent.bkrepo.replication.replica.base.interceptor.SignInterceptor import com.tencent.bkrepo.replication.replica.context.ReplicaContext import com.tencent.bkrepo.replication.replica.executor.ManualThreadPoolExecutor import com.tencent.bkrepo.replication.util.OkHttpClientPool -import com.tencent.bkrepo.repository.api.PackageClient import okhttp3.Request import org.slf4j.LoggerFactory import org.springframework.context.annotation.Conditional @@ -65,7 +65,7 @@ class EdgeReplicaTaskJob( private val clusterProperties: ClusterProperties, private val replicationProperties: ReplicationProperties, private val nodeService: NodeService, - private val packageClient: PackageClient + private val packageService: PackageService ) { private val centerReplicaTaskClient: ClusterReplicaTaskClient @@ -182,10 +182,10 @@ class EdgeReplicaTaskJob( replicationProperties = replicationProperties ) try { - val packageSummary = packageClient.findPackageByKey(projectId, repoName, packageKey!!).data + val packageSummary = packageService.findPackageByKey(projectId, repoName, packageKey!!) ?: throw PackageNotFoundException(packageKey!!) val packageVersion = - packageClient.findVersionByName(projectId, repoName, packageKey!!, packageVersion!!).data + packageService.findVersionByName(projectId, repoName, packageKey!!, packageVersion!!) ?: throw VersionNotFoundException(packageVersion!!) replicaContext.replicator.replicaPackageVersion(replicaContext, packageSummary, packageVersion) status = ExecutionStatus.SUCCESS diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaExtServiceImpl.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaExtServiceImpl.kt index c2fa75020d..0307e8d2bc 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaExtServiceImpl.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/service/impl/ReplicaExtServiceImpl.kt @@ -41,6 +41,7 @@ import com.tencent.bkrepo.common.artifact.exception.RepoNotFoundException import com.tencent.bkrepo.common.artifact.path.PathUtils import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.metadata.service.node.NodeService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.query.model.PageLimit @@ -64,7 +65,6 @@ import com.tencent.bkrepo.replication.replica.context.ReplicaContext.Companion.W import com.tencent.bkrepo.replication.service.RemoteNodeService import com.tencent.bkrepo.replication.service.ReplicaExtService import com.tencent.bkrepo.replication.util.OkHttpClientPool -import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.node.NodeListOption import com.tencent.bkrepo.repository.pojo.packages.PackageListOption @@ -82,7 +82,7 @@ import java.time.Duration @Service class ReplicaExtServiceImpl( private val repositoryService: RepositoryService, - private val packageClient: PackageClient, + private val packageService: PackageService, private val nodeService: NodeService, private val remoteNodeService: RemoteNodeService, private val replicationProperties: ReplicationProperties, @@ -329,7 +329,7 @@ class ReplicaExtServiceImpl( packageKey: String ): List? { return if (host.isNullOrEmpty()) { - packageClient.listAllVersion(projectId, repoName, packageKey).data + packageService.listAllVersion(projectId, repoName, packageKey, VersionListOption()) } else { listPackageVersionsFromRemote( host = host, @@ -347,11 +347,11 @@ class ReplicaExtServiceImpl( ) : List { with(request) { return if (localHost.isNullOrEmpty()) { - packageClient.listPackagePage( + packageService.listPackagePage( projectId = localProjectId, repoName = localRepoName, option = option - ).data?.records ?: emptyList() + ).records } else { listPackagesFromHost( host = localHost!!, diff --git a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageClient.kt b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageClient.kt index 0d52621119..14beec520b 100644 --- a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageClient.kt +++ b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageClient.kt @@ -57,6 +57,7 @@ import org.springframework.web.bind.annotation.RequestParam @Primary @FeignClient(REPOSITORY_SERVICE_NAME, contextId = "PackageClient") @RequestMapping("/service") +@Deprecated("replace with PackageService") interface PackageClient { @ApiOperation("查询包信息") diff --git a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageDependentsClient.kt b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageDependentsClient.kt index 8961b46839..747db20da0 100644 --- a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageDependentsClient.kt +++ b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageDependentsClient.kt @@ -45,6 +45,7 @@ import org.springframework.web.bind.annotation.RequestParam @Primary @FeignClient(REPOSITORY_SERVICE_NAME, contextId = "PackageDependentsClient") @RequestMapping("/service/package/dependents/") +@Deprecated("replace with PackageDependentsService") interface PackageDependentsClient { @PostMapping("/add") diff --git a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageDownloadsClient.kt b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageDownloadsClient.kt index ae8156e2b4..f8e8f45c56 100644 --- a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageDownloadsClient.kt +++ b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageDownloadsClient.kt @@ -50,6 +50,7 @@ import org.springframework.web.bind.annotation.RequestMapping @Primary @FeignClient(REPOSITORY_SERVICE_NAME, contextId = "PackageDownloadsClient") @RequestMapping("/service/package/downloads/") +@Deprecated("replace with PackageDownloadsService") interface PackageDownloadsClient { @ApiOperation("记录包下载") diff --git a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageMetadataClient.kt b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageMetadataClient.kt index 403d174468..b167cf6969 100644 --- a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageMetadataClient.kt +++ b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/PackageMetadataClient.kt @@ -49,6 +49,7 @@ import org.springframework.web.bind.annotation.RequestMapping @Primary @FeignClient(REPOSITORY_SERVICE_NAME, contextId = "PackageMetadataClient") @RequestMapping("/service/metadata/package") +@Deprecated("replace with PackageMetadataService") interface PackageMetadataClient { @ApiOperation("创建/更新元数据列表") diff --git a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/ProjectUsageStatisticsClient.kt b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/ProjectUsageStatisticsClient.kt index 78cbd08080..ce30893ee5 100644 --- a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/ProjectUsageStatisticsClient.kt +++ b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/ProjectUsageStatisticsClient.kt @@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.RequestParam @Api("操作统计数据接口") @FeignClient(REPOSITORY_SERVICE_NAME, contextId = "ProjectUsageStatisticsClient") @RequestMapping("/service/project/usage/statistics") +@Deprecated("replace with ProjectUsageStatisticsService") interface ProjectUsageStatisticsClient { @ApiOperation("增加使用数据") @PostMapping("/inc") diff --git a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/StageClient.kt b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/StageClient.kt index b52ec1ea42..107752069a 100644 --- a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/StageClient.kt +++ b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/StageClient.kt @@ -47,6 +47,7 @@ import org.springframework.web.bind.annotation.RequestParam @Primary @FeignClient(REPOSITORY_SERVICE_NAME, contextId = "StageClient") @RequestMapping("/service/stage") +@Deprecated("replace with StageService") interface StageClient { @ApiOperation("查询晋级状态") diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/config/CommonRemoteRepository.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/config/CommonRemoteRepository.kt index 154cb3058f..4aec7c4900 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/config/CommonRemoteRepository.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/config/CommonRemoteRepository.kt @@ -38,7 +38,6 @@ import com.tencent.bkrepo.common.artifact.repository.context.ArtifactDownloadCon import com.tencent.bkrepo.common.artifact.repository.remote.RemoteRepository import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.service.NodeCreateRequest -import com.tencent.bkrepo.repository.service.packages.PackageService import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.stereotype.Component @@ -49,9 +48,7 @@ import java.net.URL * 公共远程仓库 */ @Component -class CommonRemoteRepository( - private val packageService: PackageService -) : RemoteRepository() { +class CommonRemoteRepository : RemoteRepository() { override fun createRemoteDownloadUrl(context: ArtifactContext): String { logger.info("Will prepare to create remote download url...") val type = context.repositoryDetail.type diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterPackageController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterPackageController.kt index c758502427..fb4869ff69 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterPackageController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterPackageController.kt @@ -39,7 +39,7 @@ import com.tencent.bkrepo.repository.api.cluster.ClusterPackageClient import com.tencent.bkrepo.repository.pojo.packages.request.PackageUpdateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionUpdateRequest -import com.tencent.bkrepo.repository.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import org.springframework.web.bind.annotation.RestController @RestController diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterPackageDependentsController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterPackageDependentsController.kt index cf25943e8e..9a5740bf06 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterPackageDependentsController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterPackageDependentsController.kt @@ -37,7 +37,7 @@ import com.tencent.bkrepo.common.security.manager.PermissionManager import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.repository.api.cluster.ClusterPackageDependentsClient import com.tencent.bkrepo.repository.pojo.dependent.PackageDependentsRelation -import com.tencent.bkrepo.repository.service.packages.PackageDependentsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageDependentsService import org.springframework.web.bind.annotation.RestController @RestController diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterStageController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterStageController.kt index fbaee0786c..4018e25219 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterStageController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/cluster/ClusterStageController.kt @@ -37,7 +37,7 @@ import com.tencent.bkrepo.common.security.manager.PermissionManager import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.repository.api.cluster.ClusterStageClient import com.tencent.bkrepo.repository.pojo.stage.StageUpgradeRequest -import com.tencent.bkrepo.repository.service.packages.StageService +import com.tencent.bkrepo.common.metadata.service.packages.StageService import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RestController diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageController.kt index fe03c20026..95b50e6e23 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageController.kt @@ -44,7 +44,7 @@ import com.tencent.bkrepo.repository.pojo.packages.request.PackagePopulateReques import com.tencent.bkrepo.repository.pojo.packages.request.PackageUpdateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionUpdateRequest -import com.tencent.bkrepo.repository.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import org.springframework.web.bind.annotation.RestController @RestController diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageDependentsController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageDependentsController.kt index 75ac936b26..3df4d06a8f 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageDependentsController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageDependentsController.kt @@ -35,7 +35,7 @@ import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.repository.api.PackageDependentsClient import com.tencent.bkrepo.repository.pojo.dependent.PackageDependentsRelation -import com.tencent.bkrepo.repository.service.packages.PackageDependentsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageDependentsService import org.springframework.web.bind.annotation.RestController @RestController diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageDownloadsController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageDownloadsController.kt index 5b6d868e2f..e4ab17650e 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageDownloadsController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageDownloadsController.kt @@ -39,7 +39,7 @@ import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord import com.tencent.bkrepo.repository.pojo.download.PackageDownloadsDetails import com.tencent.bkrepo.repository.pojo.download.PackageDownloadsSummary import com.tencent.bkrepo.repository.pojo.download.SummaryQueryRequest -import com.tencent.bkrepo.repository.service.packages.PackageDownloadsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageDownloadsService import org.springframework.web.bind.annotation.RestController @RestController diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageMetadataController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageMetadataController.kt index 945d2a6bb9..d25066f554 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageMetadataController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/PackageMetadataController.kt @@ -35,7 +35,7 @@ import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.repository.api.PackageMetadataClient import com.tencent.bkrepo.repository.pojo.metadata.packages.PackageMetadataSaveRequest -import com.tencent.bkrepo.repository.service.metadata.PackageMetadataService +import com.tencent.bkrepo.common.metadata.service.metadata.PackageMetadataService import org.springframework.web.bind.annotation.RestController /** diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/StageController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/StageController.kt index 511afe10da..48fc341b71 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/StageController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/StageController.kt @@ -35,7 +35,7 @@ import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.repository.api.StageClient import com.tencent.bkrepo.repository.pojo.stage.StageUpgradeRequest -import com.tencent.bkrepo.repository.service.packages.StageService +import com.tencent.bkrepo.common.metadata.service.packages.StageService import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RestController diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageController.kt index 607f14e88e..3870104f07 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageController.kt @@ -43,8 +43,9 @@ import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageVersion import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import com.tencent.bkrepo.repository.pojo.software.ProjectPackageOverview -import com.tencent.bkrepo.repository.service.packages.PackageService -import com.tencent.bkrepo.repository.service.packages.PackageStatisticsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.service.packages.PackageStatisticsService +import com.tencent.bkrepo.repository.service.packages.PackageDownloadService import io.swagger.annotations.ApiOperation import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.GetMapping @@ -62,6 +63,7 @@ import org.springframework.web.bind.annotation.RestController @RequestMapping("/api") class UserPackageController( private val packageService: PackageService, + private val packageDownloadService: PackageDownloadService, private val packageStatisticsService: PackageStatisticsService ) { @@ -157,7 +159,7 @@ class UserPackageController( @RequestParam packageKey: String, @RequestParam version: String ) { - packageService.downloadVersion(projectId, repoName, packageKey, version) + packageDownloadService.downloadVersion(projectId, repoName, packageKey, version) } @ApiOperation("仓库 包数量 总览") diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageDownloadsController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageDownloadsController.kt index cf5ad73dcf..5a4c33a046 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageDownloadsController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageDownloadsController.kt @@ -39,7 +39,7 @@ import com.tencent.bkrepo.repository.pojo.download.DetailsQueryRequest import com.tencent.bkrepo.repository.pojo.download.PackageDownloadsDetails import com.tencent.bkrepo.repository.pojo.download.PackageDownloadsSummary import com.tencent.bkrepo.repository.pojo.download.SummaryQueryRequest -import com.tencent.bkrepo.repository.service.packages.PackageDownloadsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageDownloadsService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation import org.springframework.web.bind.annotation.PostMapping diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageMetadataController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageMetadataController.kt index 3de2f38bbd..1c3cf7f78b 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageMetadataController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageMetadataController.kt @@ -38,7 +38,7 @@ import com.tencent.bkrepo.common.security.permission.Permission import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.repository.pojo.metadata.packages.PackageMetadataSaveRequest import com.tencent.bkrepo.repository.pojo.metadata.packages.UserPackageMetadataSaveRequest -import com.tencent.bkrepo.repository.service.metadata.PackageMetadataService +import com.tencent.bkrepo.common.metadata.service.metadata.PackageMetadataService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation import org.springframework.web.bind.annotation.PathVariable diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageRepairController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageRepairController.kt index bc06229c9e..9963e4d88c 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageRepairController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserPackageRepairController.kt @@ -4,7 +4,7 @@ import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.security.permission.Principal import com.tencent.bkrepo.common.security.permission.PrincipalType import com.tencent.bkrepo.common.service.util.ResponseBuilder -import com.tencent.bkrepo.repository.service.packages.PackageRepairService +import com.tencent.bkrepo.common.metadata.service.packages.PackageRepairService import io.swagger.annotations.ApiOperation import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PutMapping diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserStageController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserStageController.kt index a3cbe184fe..a9f9adf074 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserStageController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserStageController.kt @@ -37,7 +37,7 @@ import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.security.permission.Permission import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.repository.pojo.stage.StageUpgradeRequest -import com.tencent.bkrepo.repository.service.packages.StageService +import com.tencent.bkrepo.common.metadata.service.packages.StageService import io.swagger.annotations.ApiOperation import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageDownloadsMigrationJob.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageDownloadsMigrationJob.kt index e4df1cc0f1..d3fc9d53d4 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageDownloadsMigrationJob.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageDownloadsMigrationJob.kt @@ -41,8 +41,8 @@ import com.tencent.bkrepo.repository.pojo.packages.PackageSummary import com.tencent.bkrepo.repository.pojo.packages.PackageType import com.tencent.bkrepo.repository.pojo.packages.PackageVersion import com.tencent.bkrepo.repository.pojo.packages.VersionListOption -import com.tencent.bkrepo.repository.service.packages.PackageDownloadsService -import com.tencent.bkrepo.repository.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.service.packages.PackageDownloadsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import org.springframework.data.mongodb.core.MongoTemplate import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageVersionCorrectionJob.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageVersionCorrectionJob.kt index 1734ad01a7..ce01d938a2 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageVersionCorrectionJob.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageVersionCorrectionJob.kt @@ -37,12 +37,12 @@ import com.tencent.bkrepo.common.mongo.dao.util.Pages import com.tencent.bkrepo.common.service.log.LoggerHolder import com.tencent.bkrepo.common.service.util.HttpContextHolder import com.tencent.bkrepo.common.metadata.dao.node.NodeDao -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.model.TPackage +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.model.TPackage import com.tencent.bkrepo.common.metadata.model.TRepository -import com.tencent.bkrepo.repository.service.packages.PackageService -import com.tencent.bkrepo.repository.util.PackageQueryHelper +import com.tencent.bkrepo.common.metadata.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.util.PackageQueryHelper import org.springframework.data.mongodb.core.MongoTemplate import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/software/interceptor/SoftwareRepoTypeRuleInterceptor.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/software/interceptor/SoftwareRepoTypeRuleInterceptor.kt index 34103613a5..ac71e434d1 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/software/interceptor/SoftwareRepoTypeRuleInterceptor.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/software/interceptor/SoftwareRepoTypeRuleInterceptor.kt @@ -35,7 +35,7 @@ import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.query.interceptor.QueryContext import com.tencent.bkrepo.common.query.interceptor.QueryRuleInterceptor import com.tencent.bkrepo.common.query.model.Rule -import com.tencent.bkrepo.repository.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackage import com.tencent.bkrepo.common.metadata.search.common.CommonQueryContext import org.springframework.data.mongodb.core.query.Criteria import org.springframework.stereotype.Component diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/software/packages/SoftwarePackageSearchInterpreter.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/software/packages/SoftwarePackageSearchInterpreter.kt index 37c27208be..323659ba98 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/software/packages/SoftwarePackageSearchInterpreter.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/search/software/packages/SoftwarePackageSearchInterpreter.kt @@ -36,7 +36,7 @@ import com.tencent.bkrepo.common.query.interceptor.QueryContext import com.tencent.bkrepo.common.query.model.QueryModel import com.tencent.bkrepo.common.metadata.search.common.MetadataRuleInterceptor import com.tencent.bkrepo.common.metadata.search.common.SelectFieldInterceptor -import com.tencent.bkrepo.repository.search.packages.PackageQueryContext +import com.tencent.bkrepo.common.metadata.search.packages.PackageQueryContext import com.tencent.bkrepo.repository.search.software.interceptor.SoftwareModelValidateInterceptor import com.tencent.bkrepo.repository.search.software.interceptor.SoftwareRepoNameRuleInterceptor import com.tencent.bkrepo.repository.search.software.interceptor.SoftwareRepoTypeRuleInterceptor diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageDownloadService.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageDownloadService.kt new file mode 100644 index 0000000000..bf7f87b277 --- /dev/null +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/PackageDownloadService.kt @@ -0,0 +1,20 @@ +package com.tencent.bkrepo.repository.service.packages + +interface PackageDownloadService { + + /** + * 下载包版本 + * + * @param projectId 项目id + * @param repoName 项目id + * @param packageKey 包唯一标识 + * @param versionName 版本名称 + */ + fun downloadVersion( + projectId: String, + repoName: String, + packageKey: String, + versionName: String, + realIpAddress: String? = null + ) +} diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageDownloadServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageDownloadServiceImpl.kt new file mode 100644 index 0000000000..aa97bcf8b6 --- /dev/null +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageDownloadServiceImpl.kt @@ -0,0 +1,101 @@ +package com.tencent.bkrepo.repository.service.packages.impl + +import com.tencent.bkrepo.common.api.exception.ErrorCodeException +import com.tencent.bkrepo.common.api.message.CommonMessageCode +import com.tencent.bkrepo.common.artifact.api.DefaultArtifactInfo +import com.tencent.bkrepo.common.artifact.constant.ARTIFACT_INFO_KEY +import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode +import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHolder +import com.tencent.bkrepo.common.artifact.repository.context.ArtifactDownloadContext +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.util.MetadataUtils +import com.tencent.bkrepo.common.metadata.util.PackageEventFactory +import com.tencent.bkrepo.common.security.util.SecurityUtils +import com.tencent.bkrepo.common.service.util.HttpContextHolder +import com.tencent.bkrepo.common.service.util.SpringContextUtils.Companion.publishEvent +import com.tencent.bkrepo.repository.pojo.packages.PackageVersion +import com.tencent.bkrepo.repository.service.packages.PackageDownloadService +import org.springframework.stereotype.Service + +@Service +class PackageDownloadServiceImpl( + private val packageDao: PackageDao, + private val packageVersionDao: PackageVersionDao, +) : PackageDownloadService { + + override fun downloadVersion( + projectId: String, + repoName: String, + packageKey: String, + versionName: String, + realIpAddress: String? + ) { + val tPackage = findPackageExcludeHistoryVersion(projectId, repoName, packageKey) + val tPackageVersion = checkPackageVersion(tPackage.id!!, versionName) + if (tPackageVersion.artifactPath.isNullOrBlank()) { + throw ErrorCodeException(CommonMessageCode.METHOD_NOT_ALLOWED, "artifactPath is null") + } + val artifactInfo = DefaultArtifactInfo(projectId, repoName, tPackageVersion.artifactPath!!) + val context = ArtifactDownloadContext(artifact = artifactInfo, useDisposition = true) + // 拦截package下载 + val packageVersion = convert(tPackageVersion)!! + context.getPackageInterceptors().forEach { it.intercept(projectId, packageVersion) } + // context 复制时会从request map中获取对应的artifactInfo, 而artifactInfo设置到map中是在接口url解析时 + HttpContextHolder.getRequestOrNull()?.setAttribute(ARTIFACT_INFO_KEY, artifactInfo) + ArtifactContextHolder.getRepository().download(context) + publishEvent( + PackageEventFactory.buildDownloadEvent( + projectId = projectId, + repoName = repoName, + packageType = tPackage.type, + packageKey = packageKey, + packageName = tPackage.name, + versionName = versionName, + createdBy = SecurityUtils.getUserId(), + realIpAddress = realIpAddress ?: HttpContextHolder.getClientAddress() + ) + ) + } + + /** + * 查找包,不存在则抛异常 + */ + private fun findPackageExcludeHistoryVersion(projectId: String, repoName: String, packageKey: String): TPackage { + return packageDao.findByKeyExcludeHistoryVersion(projectId, repoName, packageKey) + ?: throw ErrorCodeException(ArtifactMessageCode.PACKAGE_NOT_FOUND, packageKey) + } + + /** + * 查找版本,不存在则抛异常 + */ + private fun checkPackageVersion(packageId: String, versionName: String): TPackageVersion { + return packageVersionDao.findByName(packageId, versionName) + ?: throw ErrorCodeException(ArtifactMessageCode.VERSION_NOT_FOUND, versionName) + } + + fun convert(tPackageVersion: TPackageVersion?): PackageVersion? { + return tPackageVersion?.let { + PackageVersion( + createdBy = it.createdBy, + createdDate = it.createdDate, + lastModifiedBy = it.lastModifiedBy, + lastModifiedDate = it.lastModifiedDate, + name = it.name, + size = it.size, + downloads = it.downloads, + stageTag = it.stageTag, + metadata = MetadataUtils.toMap(it.metadata), + packageMetadata = MetadataUtils.toList(it.metadata), + tags = it.tags.orEmpty(), + extension = it.extension.orEmpty(), + contentPath = it.artifactPath, + contentPaths = it.artifactPaths ?: it.artifactPath?.let { path -> setOf(path) }, + manifestPath = it.manifestPath, + clusterNames = it.clusterNames + ) + } + } +} diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/SoftwarePackageServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/SoftwarePackageServiceImpl.kt index 6852ccafe9..b1702e3d9f 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/SoftwarePackageServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/SoftwarePackageServiceImpl.kt @@ -7,8 +7,8 @@ import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.query.model.QueryModel import com.tencent.bkrepo.common.query.model.Rule -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.model.TPackage +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.model.TPackage import com.tencent.bkrepo.repository.pojo.repo.RepositoryInfo import com.tencent.bkrepo.repository.pojo.software.ProjectPackageOverview import com.tencent.bkrepo.repository.pojo.software.SoftwarePackageSearchPojo diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/ResourceClearServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/ResourceClearServiceImpl.kt index 377b961714..1ed058da6e 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/ResourceClearServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/ResourceClearServiceImpl.kt @@ -7,7 +7,7 @@ import com.tencent.bkrepo.common.artifact.path.PathUtils.ROOT import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.common.metadata.service.node.NodeService import com.tencent.bkrepo.common.metadata.service.repo.ResourceClearService -import com.tencent.bkrepo.repository.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import org.slf4j.LoggerFactory import org.springframework.stereotype.Service diff --git a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/PackageDownloadsServiceTest.kt b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/PackageDownloadsServiceTest.kt index 479616588a..5b91317f96 100644 --- a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/PackageDownloadsServiceTest.kt +++ b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/PackageDownloadsServiceTest.kt @@ -35,17 +35,17 @@ import com.tencent.bkrepo.repository.UT_PACKAGE_KEY import com.tencent.bkrepo.repository.UT_PACKAGE_VERSION import com.tencent.bkrepo.repository.UT_PROJECT_ID import com.tencent.bkrepo.repository.UT_REPO_NAME -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageDownloadsDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDownloadsDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageVersion import com.tencent.bkrepo.repository.pojo.download.DetailsQueryRequest import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord -import com.tencent.bkrepo.repository.search.packages.PackageSearchInterpreter +import com.tencent.bkrepo.common.metadata.search.packages.PackageSearchInterpreter import com.tencent.bkrepo.repository.service.PackageServiceTest.Companion.buildCreateRequest -import com.tencent.bkrepo.repository.service.packages.PackageDownloadsService -import com.tencent.bkrepo.repository.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.service.packages.PackageDownloadsService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll diff --git a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/PackageServiceTest.kt b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/PackageServiceTest.kt index cb2342c697..9f3a0b768d 100644 --- a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/PackageServiceTest.kt +++ b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/PackageServiceTest.kt @@ -38,17 +38,17 @@ import com.tencent.bkrepo.repository.UT_PACKAGE_VERSION import com.tencent.bkrepo.repository.UT_PROJECT_ID import com.tencent.bkrepo.repository.UT_REPO_NAME import com.tencent.bkrepo.repository.UT_USER -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageVersion import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.packages.PackageListOption import com.tencent.bkrepo.repository.pojo.packages.PackageType import com.tencent.bkrepo.repository.pojo.packages.VersionListOption import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest -import com.tencent.bkrepo.repository.search.packages.PackageSearchInterpreter -import com.tencent.bkrepo.repository.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.search.packages.PackageSearchInterpreter +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.BeforeEach diff --git a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/StageServiceTest.kt b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/StageServiceTest.kt index 4ca8433dfc..5783e2402a 100644 --- a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/StageServiceTest.kt +++ b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/StageServiceTest.kt @@ -37,16 +37,16 @@ import com.tencent.bkrepo.repository.UT_PACKAGE_VERSION import com.tencent.bkrepo.repository.UT_PROJECT_ID import com.tencent.bkrepo.repository.UT_REPO_NAME import com.tencent.bkrepo.repository.UT_USER -import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TPackageVersion +import com.tencent.bkrepo.common.metadata.dao.packages.PackageDao +import com.tencent.bkrepo.common.metadata.dao.packages.PackageVersionDao +import com.tencent.bkrepo.common.metadata.model.TPackage +import com.tencent.bkrepo.common.metadata.model.TPackageVersion import com.tencent.bkrepo.repository.pojo.stage.ArtifactStageEnum import com.tencent.bkrepo.repository.pojo.stage.StageUpgradeRequest -import com.tencent.bkrepo.repository.search.packages.PackageSearchInterpreter +import com.tencent.bkrepo.common.metadata.search.packages.PackageSearchInterpreter import com.tencent.bkrepo.repository.service.PackageServiceTest.Companion.buildCreateRequest -import com.tencent.bkrepo.repository.service.packages.PackageService -import com.tencent.bkrepo.repository.service.packages.StageService +import com.tencent.bkrepo.common.metadata.service.packages.PackageService +import com.tencent.bkrepo.common.metadata.service.packages.StageService import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.BeforeEach diff --git a/src/backend/rpm/biz-rpm/src/main/kotlin/com/tencent/bkrepo/rpm/artifact/repository/RpmLocalRepository.kt b/src/backend/rpm/biz-rpm/src/main/kotlin/com/tencent/bkrepo/rpm/artifact/repository/RpmLocalRepository.kt index 1bc9efcf8a..7eeb794d74 100644 --- a/src/backend/rpm/biz-rpm/src/main/kotlin/com/tencent/bkrepo/rpm/artifact/repository/RpmLocalRepository.kt +++ b/src/backend/rpm/biz-rpm/src/main/kotlin/com/tencent/bkrepo/rpm/artifact/repository/RpmLocalRepository.kt @@ -54,6 +54,7 @@ import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactFileFactory import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactChannel import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactResource import com.tencent.bkrepo.common.artifact.util.PackageKeys +import com.tencent.bkrepo.common.metadata.service.packages.StageService import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.query.model.PageLimit import com.tencent.bkrepo.common.query.model.QueryModel @@ -62,7 +63,6 @@ import com.tencent.bkrepo.common.query.model.Sort import com.tencent.bkrepo.common.service.util.HeaderUtils import com.tencent.bkrepo.common.service.util.HttpContextHolder import com.tencent.bkrepo.common.storage.credentials.StorageCredentials -import com.tencent.bkrepo.repository.api.StageClient import com.tencent.bkrepo.repository.pojo.download.PackageDownloadRecord import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -130,7 +130,7 @@ import java.time.LocalDateTime @Component class RpmLocalRepository( - private val stageClient: StageClient, + private val stageService: StageService, private val jobService: JobService ) : LocalRepository() { @@ -465,7 +465,7 @@ class RpmLocalRepository( val rpmPackagePojo = rpmVersion.toRpmPackagePojo(context.artifactInfo.getArtifactFullPath()) // 保存包版本 val packageKey = PackageKeys.ofRpm(rpmPackagePojo.path, rpmPackagePojo.name) - packageClient.createVersion( + packageService.createPackageVersion( PackageVersionCreateRequest( projectId = context.projectId, repoName = context.repoName, @@ -536,7 +536,7 @@ class RpmLocalRepository( } ?: return null val packageKey = PackageKeys.ofRpm(rpmPackage.path, rpmPackage.name) - return packageClient.findVersionByName(projectId, repoName, packageKey, rpmPackage.version).data + return packageService.findVersionByName(projectId, repoName, packageKey, rpmPackage.version) } } @@ -544,9 +544,9 @@ class RpmLocalRepository( * 返回包的版本数量 */ private fun getVersions(packageKey: String, context: ArtifactContext): Long? { - return packageClient.findPackageByKey( + return packageService.findPackageByKey( context.projectId, context.repoName, packageKey - ).data?.versions ?: return null + )?.versions ?: return null } /** @@ -579,13 +579,13 @@ class RpmLocalRepository( val version = HttpContextHolder.getRequest().getParameter("version") if (version.isNullOrBlank()) { val versions = getVersions(packageKey, context) - val pages = packageClient.listVersionPage( + val pages = packageService.listVersionPage( context.projectId, context.repoName, packageKey, VersionListOption(0, versions!!.toInt(), null, null) - ).data?.records ?: return + ).records for (packageVersion in pages) { val artifactFullPath = packageVersion.contentPath!! @@ -596,12 +596,12 @@ class RpmLocalRepository( } } else { with(context.artifactInfo) { - val packageVersion = packageClient.findVersionByName( + val packageVersion = packageService.findVersionByName( context.projectId, context.repoName, packageKey, version - ).data ?: return + ) ?: return val node = nodeService.getNodeDetail(ArtifactInfo(projectId, repoName, packageVersion.contentPath!!)) ?: return removeRpmArtifact(node, packageVersion.contentPath!!, context, packageKey, version) @@ -659,7 +659,7 @@ class RpmLocalRepository( } fun deleteVersion(projectId: String, repoName: String, packageKey: String, version: String) { - packageClient.deleteVersion(projectId, repoName, packageKey, version, HttpContextHolder.getClientAddress()) + packageService.deleteVersion(projectId, repoName, packageKey, version, HttpContextHolder.getClientAddress()) } /** @@ -678,21 +678,21 @@ class RpmLocalRepository( val version = context.request.getParameter("version") val name = packageKey.split(":").last() val path = packageKey.removePrefix("rpm://").split(":")[0] - val trueVersion = packageClient.findVersionByName( + val trueVersion = packageService.findVersionByName( context.projectId, context.repoName, packageKey, version - ).data ?: return null + ) ?: return null val artifactPath = trueVersion.contentPath ?: return null with(context.artifactInfo) { val jarNode = nodeService.getNodeDetail( ArtifactInfo(projectId, repoName, artifactPath) ) ?: return null - val stageTag = stageClient.query(projectId, repoName, packageKey, version).data - val packageVersion = packageClient.findVersionByName( + val stageTag = stageService.query(projectId, repoName, packageKey, version) + val packageVersion = packageService.findVersionByName( projectId, repoName, packageKey, version - ).data + ) val count = packageVersion?.downloads ?: 0 val rpmArtifactBasic = Basic( path, @@ -811,7 +811,7 @@ class RpmLocalRepository( ) ) - packageClient.populatePackage(packagePopulateRequest) + packageService.populatePackage(packagePopulateRequest) logger.info("Success create version $packagePopulateRequest") } } diff --git a/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/payload/builder/version/VersionCreatedPayloadBuilder.kt b/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/payload/builder/version/VersionCreatedPayloadBuilder.kt index a1b099f5ac..e330f93bf5 100644 --- a/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/payload/builder/version/VersionCreatedPayloadBuilder.kt +++ b/src/backend/webhook/biz-webhook/src/main/kotlin/com/tencent/bkrepo/webhook/payload/builder/version/VersionCreatedPayloadBuilder.kt @@ -30,7 +30,7 @@ package com.tencent.bkrepo.webhook.payload.builder.version import com.tencent.bkrepo.common.api.exception.NotFoundException import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent import com.tencent.bkrepo.common.artifact.event.base.EventType -import com.tencent.bkrepo.repository.api.PackageClient +import com.tencent.bkrepo.common.metadata.service.packages.PackageService import com.tencent.bkrepo.repository.pojo.packages.PackageVersion import com.tencent.bkrepo.webhook.exception.WebHookMessageCode import com.tencent.bkrepo.webhook.payload.builder.EventPayloadBuilder @@ -39,7 +39,7 @@ import org.springframework.stereotype.Component @Component class VersionCreatedPayloadBuilder( - private val packageClient: PackageClient + private val packageService: PackageService ) : EventPayloadBuilder( eventType = EventType.VERSION_CREATED ) { @@ -58,7 +58,7 @@ class VersionCreatedPayloadBuilder( packageKey: String, version: String ): PackageVersion { - return packageClient.findVersionByName(projectId, repoName, packageKey, version).data + return packageService.findVersionByName(projectId, repoName, packageKey, version) ?: throw NotFoundException(WebHookMessageCode.WEBHOOK_VERSION_NOT_FOUND) } }