From 191f6e32c8147b0607ed3a6f9c7712c623829f1a Mon Sep 17 00:00:00 2001 From: yaoxuwan Date: Thu, 31 Oct 2024 17:17:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20NodeSearch=E6=9D=83=E9=99=90=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E5=A4=B1=E8=B4=A5=20#2724?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/metadata/search/common/RepoNameRuleInterceptor.kt | 5 +++-- .../tencent/bkrepo/helm/service/impl/FixToolServiceImpl.kt | 4 ++-- .../bkrepo/npm/artifact/repository/NpmLocalRepository.kt | 2 +- .../tencent/bkrepo/npm/service/impl/NpmFixToolServiceImpl.kt | 4 ++-- .../src/main/kotlin/com/tencent/bkrepo/rpm/job/JobService.kt | 5 +++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/common/RepoNameRuleInterceptor.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/common/RepoNameRuleInterceptor.kt index 91c9ea2000..97f1e51a2f 100644 --- a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/common/RepoNameRuleInterceptor.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/search/common/RepoNameRuleInterceptor.kt @@ -36,16 +36,17 @@ import com.tencent.bkrepo.auth.pojo.enums.PermissionAction import com.tencent.bkrepo.common.api.constant.ensureSuffix import com.tencent.bkrepo.common.artifact.exception.RepoNotFoundException import com.tencent.bkrepo.common.artifact.path.PathUtils +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.metadata.permission.PermissionManager import com.tencent.bkrepo.common.metadata.service.repo.RepositoryService import com.tencent.bkrepo.common.metadata.util.NodeQueryHelper.listPermissionPaths -import com.tencent.bkrepo.common.metadata.condition.SyncCondition 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.common.security.exception.PermissionException import com.tencent.bkrepo.common.security.util.SecurityUtils +import com.tencent.bkrepo.common.service.util.HttpContextHolder import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.repo.RepoListOption import org.slf4j.LoggerFactory @@ -217,7 +218,7 @@ class RepoNameRuleInterceptor( repoName: String, repoPublic: Boolean? = null ): Boolean { - if (SecurityUtils.isServiceRequest()) { + if (HttpContextHolder.getRequestOrNull() == null || SecurityUtils.isServiceRequest()) { return true } return try { 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 486c9d458d..25cae16791 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 @@ -369,9 +369,9 @@ class FixToolServiceImpl : FixToolService, AbstractChartService() { private fun resolveNode(record: Map): NodeInfo { return NodeInfo( createdBy = record["createdBy"] as String, - createdDate = record["createdDate"] as String, + createdDate = (record["createdDate"] as LocalDateTime).toString(), lastModifiedBy = record["lastModifiedBy"] as String, - lastModifiedDate = record["lastModifiedDate"] as String, + lastModifiedDate = (record["lastModifiedDate"] as LocalDateTime).toString(), folder = record["folder"] as Boolean, path = record["path"] as String, name = record["name"] as String, 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 7746863ed3..a03f98f4b9 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 @@ -188,7 +188,7 @@ class NpmLocalRepository( metadata["description"] as? String, metadata["maintainers"] as? List> ?: emptyList(), metadata["version"] as? String, - it["lastModifiedDate"] as String, + (it["lastModifiedDate"] as LocalDateTime).toString(), metadata["keywords"] as? List ?: emptyList(), metadata["author"] as? Map ?: emptyMap() ) 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 e1308abb4a..d43e62e419 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 @@ -367,9 +367,9 @@ class NpmFixToolServiceImpl( private fun resolveNode(record: Map): NodeInfo { return NodeInfo( createdBy = record["createdBy"] as String, - createdDate = record["createdDate"] as String, + createdDate = (record["createdDate"] as LocalDateTime).toString(), lastModifiedBy = record["lastModifiedBy"] as String, - lastModifiedDate = record["lastModifiedDate"] as String, + lastModifiedDate = (record["lastModifiedDate"] as LocalDateTime).toString(), folder = record["folder"] as Boolean, path = record["path"] as String, name = record["name"] as String, diff --git a/src/backend/rpm/biz-rpm/src/main/kotlin/com/tencent/bkrepo/rpm/job/JobService.kt b/src/backend/rpm/biz-rpm/src/main/kotlin/com/tencent/bkrepo/rpm/job/JobService.kt index dcbb404234..c8844e2d76 100644 --- a/src/backend/rpm/biz-rpm/src/main/kotlin/com/tencent/bkrepo/rpm/job/JobService.kt +++ b/src/backend/rpm/biz-rpm/src/main/kotlin/com/tencent/bkrepo/rpm/job/JobService.kt @@ -86,6 +86,7 @@ import java.io.File import java.io.FileInputStream import java.io.FileOutputStream import java.io.RandomAccessFile +import java.time.LocalDateTime import java.util.Locale import java.util.concurrent.ConcurrentHashMap import javax.xml.parsers.SAXParserFactory @@ -492,8 +493,8 @@ class JobService( return NodeInfo( createdBy = mapData["createdBy"] as String, createdDate = mapData["lastModifiedBy"] as String, - lastModifiedBy = mapData["lastModifiedDate"] as String, - lastModifiedDate = mapData["lastModifiedDate"] as String, + lastModifiedBy = (mapData["lastModifiedDate"] as LocalDateTime).toString(), + lastModifiedDate = (mapData["lastModifiedDate"] as LocalDateTime).toString(), folder = mapData["folder"] as Boolean, path = mapData["path"] as String, name = mapData["name"] as String,