diff --git a/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamCallbackAspect.java b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamCallbackAspect.java new file mode 100644 index 0000000000..28411cd570 --- /dev/null +++ b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/aspect/IamCallbackAspect.java @@ -0,0 +1,51 @@ +package com.tencent.bk.job.common.iam.aspect; + +import com.tencent.bk.job.common.util.json.JsonUtils; +import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Slf4j +@Aspect +@Component +public class IamCallbackAspect { + + @Autowired + public IamCallbackAspect() { + } + + @Pointcut("execution (* com.tencent.bk.job.*.api.iam.impl.*.callback(..))") + public void processCallbackRequest() { + } + + private void logRequest(CallbackRequestDTO callbackRequest) { + if (log.isDebugEnabled()) { + log.debug("callbackRequest={}", JsonUtils.toJson(callbackRequest)); + } else { + log.info( + "Received iam callbackRequest:[{}|{}|{}|{}]", + callbackRequest.getMethod().getMethod(), + callbackRequest.getType(), + callbackRequest.getFilter(), + callbackRequest.getPage() + ); + } + } + + @Around("processCallbackRequest()") + public Object logBeforeProcessCallbackRequest(ProceedingJoinPoint pjp) throws Throwable { + Object[] args = pjp.getArgs(); + if (args.length < 1) { + log.warn("unexpected ProceedingJoinPoint, please check"); + return pjp.proceed(); + } + CallbackRequestDTO callbackRequest = (CallbackRequestDTO) args[0]; + logRequest(callbackRequest); + return pjp.proceed(); + } +} diff --git a/src/backend/job-crontab/api-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/IamCallbackController.java b/src/backend/job-crontab/api-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/IamCallbackController.java index fbcd7ff788..2ced74041a 100644 --- a/src/backend/job-crontab/api-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/IamCallbackController.java +++ b/src/backend/job-crontab/api-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/IamCallbackController.java @@ -43,5 +43,5 @@ public interface IamCallbackController { * @return 权限中心回调响应 */ @PostMapping("/job") - CallbackBaseResponseDTO cronJobCallback(@RequestBody CallbackRequestDTO callbackRequest); + CallbackBaseResponseDTO callback(@RequestBody CallbackRequestDTO callbackRequest); } diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/impl/IamCallbackControllerImpl.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/impl/IamCallbackControllerImpl.java index 14b6ff0008..70ba83918e 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/impl/IamCallbackControllerImpl.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/impl/IamCallbackControllerImpl.java @@ -41,6 +41,7 @@ import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.SearchInstanceResponseDTO; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.tuple.Pair; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RestController; @@ -61,6 +62,17 @@ public IamCallbackControllerImpl(CronJobService cronJobService) { this.cronJobService = cronJobService; } + private Pair getBasicQueryCondition(CallbackRequestDTO callbackRequest) { + IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); + BaseSearchCondition baseSearchCondition = new BaseSearchCondition(); + baseSearchCondition.setStart(searchCondition.getStart().intValue()); + baseSearchCondition.setLength(searchCondition.getLength().intValue()); + + CronJobInfoDTO cronJobQuery = new CronJobInfoDTO(); + cronJobQuery.setAppId(searchCondition.getAppIdList().get(0)); + return Pair.of(cronJobQuery, baseSearchCondition); + } + private InstanceInfoDTO convert(CronJobInfoDTO cronJobInfo) { InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); instanceInfo.setId(String.valueOf(cronJobInfo.getId())); @@ -71,25 +83,13 @@ private InstanceInfoDTO convert(CronJobInfoDTO cronJobInfo) { private SearchInstanceResponseDTO searchInstanceResp( CallbackRequestDTO callbackRequest ) { - log.info( - "{}|{}|{}|{}", - callbackRequest.getMethod().getMethod(), - callbackRequest.getType(), - callbackRequest.getFilter(), - callbackRequest.getPage() - ); - IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); - CronJobInfoDTO condition = new CronJobInfoDTO(); - BaseSearchCondition baseSearchCondition = new BaseSearchCondition(); - PageData cronJobInfoPageData; - condition.setAppId(searchCondition.getAppIdList().get(0)); - condition.setName(callbackRequest.getFilter().getKeyword()); + Pair basicQueryCond = getBasicQueryCondition(callbackRequest); + CronJobInfoDTO cronJobQuery = basicQueryCond.getLeft(); + BaseSearchCondition baseSearchCondition = basicQueryCond.getRight(); - baseSearchCondition.setStart(searchCondition.getStart().intValue()); - baseSearchCondition.setLength(searchCondition.getLength().intValue()); - - cronJobInfoPageData = - cronJobService.listPageCronJobInfos(condition, baseSearchCondition); + cronJobQuery.setName(callbackRequest.getFilter().getKeyword()); + PageData cronJobInfoPageData = + cronJobService.listPageCronJobInfos(cronJobQuery, baseSearchCondition); return IamRespUtil.getSearchInstanceRespFromPageData(cronJobInfoPageData, this::convert); } @@ -97,38 +97,24 @@ private SearchInstanceResponseDTO searchInstanceResp( private ListInstanceResponseDTO listInstanceResp( CallbackRequestDTO callbackRequest ) { - log.info( - "{}|{}|{}|{}", - callbackRequest.getMethod().getMethod(), - callbackRequest.getType(), - callbackRequest.getFilter(), - callbackRequest.getPage() - ); - IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); - CronJobInfoDTO condition = new CronJobInfoDTO(); - condition.setAppId(searchCondition.getAppIdList().get(0)); - BaseSearchCondition baseSearchCondition = new BaseSearchCondition(); - baseSearchCondition.setStart(searchCondition.getStart().intValue()); - baseSearchCondition.setLength(searchCondition.getLength().intValue()); + Pair basicQueryCond = getBasicQueryCondition(callbackRequest); + CronJobInfoDTO cronJobQuery = basicQueryCond.getLeft(); + BaseSearchCondition baseSearchCondition = basicQueryCond.getRight(); PageData cronJobInfoPageData = - cronJobService.listPageCronJobInfos(condition, baseSearchCondition); + cronJobService.listPageCronJobInfos(cronJobQuery, baseSearchCondition); return IamRespUtil.getListInstanceRespFromPageData(cronJobInfoPageData, this::convert); } @Override - public CallbackBaseResponseDTO cronJobCallback(CallbackRequestDTO callbackRequest) { - log.debug("Receive iam callback|{}", callbackRequest); + public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { CallbackBaseResponseDTO response; switch (callbackRequest.getMethod()) { case LIST_INSTANCE: response = listInstanceResp(callbackRequest); break; case FETCH_INSTANCE_INFO: - log.debug("Fetch instance info request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); List instanceAttributeInfoList = new ArrayList<>(); for (String instanceId : searchCondition.getIdList()) { @@ -150,20 +136,14 @@ public CallbackBaseResponseDTO cronJobCallback(CallbackRequestDTO callbackReques response = fetchInstanceInfoResponse; break; case LIST_ATTRIBUTE: - log.debug("List attribute request!|{}|{}|{}", callbackRequest.getType(), callbackRequest.getFilter(), - callbackRequest.getPage()); response = new ListAttributeResponseDTO(); response.setCode(0L); break; case LIST_ATTRIBUTE_VALUE: - log.debug("List attribute value request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListAttributeValueResponseDTO(); response.setCode(0L); break; case LIST_INSTANCE_BY_POLICY: - log.debug("List instance by policy request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListInstanceByPolicyResponseDTO(); response.setCode(0L); break; diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/iam/IamFileSourceCallbackResourceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/iam/IamFileSourceCallbackResourceImpl.java index a5a6b7c591..b9daa5364c 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/iam/IamFileSourceCallbackResourceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/iam/IamFileSourceCallbackResourceImpl.java @@ -24,11 +24,21 @@ package com.tencent.bk.job.file_gateway.api.iam; +import com.tencent.bk.job.common.iam.util.IamRespUtil; +import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.file_gateway.model.dto.FileSourceDTO; import com.tencent.bk.job.file_gateway.service.FileSourceService; import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; import com.tencent.bk.sdk.iam.dto.callback.request.IamSearchCondition; -import com.tencent.bk.sdk.iam.dto.callback.response.*; +import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.FetchInstanceInfoResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.InstanceInfoDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeValueResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceByPolicyResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.SearchInstanceResponseDTO; +import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RestController; @@ -48,47 +58,111 @@ public IamFileSourceCallbackResourceImpl(FileSourceService fileSourceService) { this.fileSourceService = fileSourceService; } + @Data + static class FileSourceSearchCondition { + List appIdList; + List idStrList; + List fileSourceIdList; + int start; + int length; + String keyword; + + public FileSourceSearchCondition( + List appIdList, + List idStrList, + List fileSourceIdList, + int start, + int length, + String keyword + ) { + this.appIdList = appIdList; + this.idStrList = idStrList; + this.fileSourceIdList = fileSourceIdList; + this.start = start; + this.length = length; + this.keyword = keyword; + } + } + + private FileSourceSearchCondition getSearchCondition(CallbackRequestDTO callbackRequest) { + IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); + // 文件源列表实现 + List appIdList = searchCondition.getAppIdList(); + List idStrList = searchCondition.getIdList(); + List fileSourceIdList = null; + if (idStrList != null) { + fileSourceIdList = idStrList.parallelStream().map(Integer::parseInt).collect(Collectors.toList()); + } + + int start = searchCondition.getStart().intValue(); + int length = searchCondition.getLength().intValue(); + + String keyword = callbackRequest.getFilter().getKeyword(); + return new FileSourceSearchCondition( + appIdList, idStrList, fileSourceIdList, start, length, keyword + ); + } + + private ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { + FileSourceSearchCondition searchCondition = getSearchCondition(callbackRequest); + + List fileSourceDTOList = fileSourceService.listWorkTableFileSource( + searchCondition.getAppIdList(), + searchCondition.getFileSourceIdList(), + searchCondition.getStart(), + searchCondition.getLength() + ); + Long totalCount = fileSourceService.countWorkTableFileSource( + searchCondition.getAppIdList(), searchCondition.getFileSourceIdList() + ).longValue(); + PageData fileSourceDTOPageData = new PageData<>( + searchCondition.getStart(), + searchCondition.getLength(), + totalCount, + fileSourceDTOList + ); + return IamRespUtil.getListInstanceRespFromPageData(fileSourceDTOPageData, this::convert); + } + + private InstanceInfoDTO convert(FileSourceDTO fileSourceDTO) { + InstanceInfoDTO tmpInstanceInfo = new InstanceInfoDTO(); + tmpInstanceInfo.setId(fileSourceDTO.getId().toString()); + tmpInstanceInfo.setDisplayName(fileSourceDTO.getAlias()); + return tmpInstanceInfo; + } + + private SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { + FileSourceSearchCondition searchCondition = getSearchCondition(callbackRequest); + + List fileSourceDTOList = fileSourceService.listWorkTableFileSource( + searchCondition.getAppIdList().get(0), + null, + searchCondition.getKeyword(), + searchCondition.getStart(), + searchCondition.getLength() + ); + + Long totalCount = fileSourceService.countWorkTableFileSource( + searchCondition.getAppIdList(), searchCondition.getFileSourceIdList() + ).longValue(); + PageData fileSourceDTOPageData = new PageData<>( + searchCondition.getStart(), + searchCondition.getLength(), + totalCount, + fileSourceDTOList + ); + return IamRespUtil.getSearchInstanceRespFromPageData(fileSourceDTOPageData, this::convert); + } + @Override public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - log.debug("Receive iam callback|{}", callbackRequest); CallbackBaseResponseDTO response; IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); switch (callbackRequest.getMethod()) { case LIST_INSTANCE: - log.debug("List instance request!|{}|{}|{}", callbackRequest.getType(), callbackRequest.getFilter(), - callbackRequest.getPage()); - // 文件源列表实现 - List appIdList = searchCondition.getAppIdList(); - List idStrList = searchCondition.getIdList(); - List fileSourceIdList = null; - if (idStrList != null) { - fileSourceIdList = idStrList.parallelStream().map(Integer::parseInt).collect(Collectors.toList()); - } - List fileSourceDTOList = fileSourceService.listWorkTableFileSource( - appIdList, - fileSourceIdList, - searchCondition.getStart().intValue(), - searchCondition.getLength().intValue()); - Long totalCount = fileSourceService.countWorkTableFileSource(appIdList, fileSourceIdList).longValue(); - List instanceInfoList = fileSourceDTOList.parallelStream().map(fileSourceDTO -> { - InstanceInfoDTO tmpInstanceInfo = new InstanceInfoDTO(); - tmpInstanceInfo.setId(fileSourceDTO.getId().toString()); - tmpInstanceInfo.setDisplayName(fileSourceDTO.getAlias()); - return tmpInstanceInfo; - }).collect(Collectors.toList()); - - ListInstanceResponseDTO instanceResponse = new ListInstanceResponseDTO(); - instanceResponse.setCode(0L); - BaseDataResponseDTO baseDataResponse = new BaseDataResponseDTO<>(); - baseDataResponse.setResult(instanceInfoList); - baseDataResponse.setCount(totalCount); - instanceResponse.setData(baseDataResponse); - response = instanceResponse; + response = listInstanceResp(callbackRequest); break; case FETCH_INSTANCE_INFO: - log.debug("Fetch instance info request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - List instanceAttributeInfoList = new ArrayList<>(); for (String instanceId : searchCondition.getIdList()) { try { @@ -115,23 +189,20 @@ public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { response = fetchInstanceInfoResponse; break; case LIST_ATTRIBUTE: - log.debug("List attribute request!|{}|{}|{}", callbackRequest.getType(), callbackRequest.getFilter(), - callbackRequest.getPage()); response = new ListAttributeResponseDTO(); response.setCode(0L); break; case LIST_ATTRIBUTE_VALUE: - log.debug("List attribute value request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListAttributeValueResponseDTO(); response.setCode(0L); break; case LIST_INSTANCE_BY_POLICY: - log.debug("List instance by policy request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListInstanceByPolicyResponseDTO(); response.setCode(0L); break; + case SEARCH_INSTANCE: + response = searchInstanceResp(callbackRequest); + break; default: log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java index bea4dcb3c9..64f6831bf1 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java @@ -24,6 +24,7 @@ package com.tencent.bk.job.file_gateway.service; +import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.file_gateway.model.dto.FileSourceDTO; import com.tencent.bk.job.file_gateway.model.dto.FileSourceTypeDTO; import com.tencent.bk.job.file_gateway.model.req.common.FileSourceStaticParam; @@ -43,14 +44,28 @@ public interface FileSourceService { Integer countWorkTableFileSource(List appIdList, List idList); - List listAvailableFileSource(Long appId, String credentialId, String alias, Integer start, - Integer pageSize); - - List listWorkTableFileSource(Long appId, String credentialId, String alias, Integer start, - Integer pageSize); - - List listWorkTableFileSource(List appIdList, List idList, Integer start, - Integer pageSize); + List listAvailableFileSource( + Long appId, + String credentialId, + String alias, + Integer start, + Integer pageSize + ); + + List listWorkTableFileSource( + Long appId, + String credentialId, + String alias, + Integer start, + Integer pageSize + ); + + List listWorkTableFileSource( + List appIdList, + List idList, + Integer start, + Integer pageSize + ); Integer saveFileSource(Long appId, FileSourceDTO fileSourceDTO); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamAccountCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamAccountCallbackResourceImpl.java index 5e9c7c106f..020a251dc1 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamAccountCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamAccountCallbackResourceImpl.java @@ -53,16 +53,6 @@ public class IamAccountCallbackResourceImpl implements IamAccountCallbackResource { private final AccountService accountService; - private void logRequest(CallbackRequestDTO callbackRequest) { - log.info( - "{}|{}|{}|{}", - callbackRequest.getMethod().getMethod(), - callbackRequest.getType(), - callbackRequest.getFilter(), - callbackRequest.getPage() - ); - } - private Pair getBasicQueryCondition(CallbackRequestDTO callbackRequest) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); BaseSearchCondition baseSearchCondition = new BaseSearchCondition(); @@ -112,16 +102,12 @@ public IamAccountCallbackResourceImpl(AccountService accountService) { @Override public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - logRequest(callbackRequest); CallbackBaseResponseDTO response; switch (callbackRequest.getMethod()) { case LIST_INSTANCE: response = listInstanceResp(callbackRequest); break; case FETCH_INSTANCE_INFO: - log.debug("Fetch instance info request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); List instanceAttributeInfoList = new ArrayList<>(); for (String instanceId : searchCondition.getIdList()) { @@ -149,20 +135,14 @@ public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { response = fetchInstanceInfoResponse; break; case LIST_ATTRIBUTE: - log.debug("List attribute request!|{}|{}|{}", callbackRequest.getType(), callbackRequest.getFilter(), - callbackRequest.getPage()); response = new ListAttributeResponseDTO(); response.setCode(0L); break; case LIST_ATTRIBUTE_VALUE: - log.debug("List attribute value request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListAttributeValueResponseDTO(); response.setCode(0L); break; case LIST_INSTANCE_BY_POLICY: - log.debug("List instance by policy request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListInstanceByPolicyResponseDTO(); response.setCode(0L); break; diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamPublicScriptCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamPublicScriptCallbackResourceImpl.java index 435ab47ef2..d717edebad 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamPublicScriptCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamPublicScriptCallbackResourceImpl.java @@ -54,12 +54,11 @@ private Pair getBasicQueryCondition(Callbac ScriptQueryDTO scriptQuery = new ScriptQueryDTO(); scriptQuery.setPublicScript(true); - scriptQuery.setAppId(searchCondition.getAppIdList().get(0)); return Pair.of(scriptQuery, baseSearchCondition); } @Override public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - return scriptCallbackHelper.callback(callbackRequest); + return scriptCallbackHelper.doCallback(callbackRequest); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamScriptCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamScriptCallbackResourceImpl.java index 5ae3f7c385..1a599a5a59 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamScriptCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamScriptCallbackResourceImpl.java @@ -59,6 +59,6 @@ private Pair getBasicQueryCondition(Callbac @Override public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - return scriptCallbackHelper.callback(callbackRequest); + return scriptCallbackHelper.doCallback(callbackRequest); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTagCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTagCallbackResourceImpl.java index 1364f5620f..b481823e8d 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTagCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTagCallbackResourceImpl.java @@ -99,9 +99,6 @@ private ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequ } private FetchInstanceInfoResponseDTO fetchInstanceResp(CallbackRequestDTO callbackRequest) { - log.debug("Fetch instance info request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); List instanceAttributeInfoList = new ArrayList<>(); for (String instanceId : searchCondition.getIdList()) { @@ -130,7 +127,6 @@ private FetchInstanceInfoResponseDTO fetchInstanceResp(CallbackRequestDTO callba @Override public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - log.debug("Receive iam callback|{}", callbackRequest); CallbackBaseResponseDTO response; switch (callbackRequest.getMethod()) { case LIST_INSTANCE: @@ -140,20 +136,14 @@ public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { response = fetchInstanceResp(callbackRequest); break; case LIST_ATTRIBUTE: - log.debug("List attribute request!|{}|{}|{}", callbackRequest.getType(), callbackRequest.getFilter(), - callbackRequest.getPage()); response = new ListAttributeResponseDTO(); response.setCode(0L); break; case LIST_ATTRIBUTE_VALUE: - log.debug("List attribute value request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListAttributeValueResponseDTO(); response.setCode(0L); break; case LIST_INSTANCE_BY_POLICY: - log.debug("List instance by policy request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListInstanceByPolicyResponseDTO(); response.setCode(0L); break; diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskPlanCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskPlanCallbackResourceImpl.java index bf881a7172..a435fa0733 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskPlanCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskPlanCallbackResourceImpl.java @@ -74,7 +74,7 @@ private Pair getBasicQueryCondition(Callb baseSearchCondition.setLength(searchCondition.getLength().intValue()); TaskPlanQueryDTO planQuery = new TaskPlanQueryDTO(); - planQuery.setAppId(searchCondition.getAppIdList().get(0)); + planQuery.setTemplateId(Long.parseLong(callbackRequest.getFilter().getParent().getId())); return Pair.of(planQuery, baseSearchCondition); } @@ -106,7 +106,6 @@ public SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackR @Override public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - log.debug("Receive iam callback|{}", callbackRequest); CallbackBaseResponseDTO response; IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); switch (callbackRequest.getMethod()) { @@ -114,9 +113,6 @@ public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { response = listInstanceResp(callbackRequest); break; case FETCH_INSTANCE_INFO: - log.debug("Fetch instance info request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - List instanceAttributeInfoList = new ArrayList<>(); for (String instanceId : searchCondition.getIdList()) { try { @@ -137,20 +133,14 @@ public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { response = fetchInstanceInfoResponse; break; case LIST_ATTRIBUTE: - log.debug("List attribute request!|{}|{}|{}", callbackRequest.getType(), callbackRequest.getFilter(), - callbackRequest.getPage()); response = new ListAttributeResponseDTO(); response.setCode(0L); break; case LIST_ATTRIBUTE_VALUE: - log.debug("List attribute value request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListAttributeValueResponseDTO(); response.setCode(0L); break; case LIST_INSTANCE_BY_POLICY: - log.debug("List instance by policy request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListInstanceByPolicyResponseDTO(); response.setCode(0L); break; diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskTemplateCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskTemplateCallbackResourceImpl.java index f261e63347..3cbf3eaca0 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskTemplateCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskTemplateCallbackResourceImpl.java @@ -105,7 +105,6 @@ public SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackR @Override public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - log.debug("Receive iam callback|{}", callbackRequest); CallbackBaseResponseDTO response; IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); switch (callbackRequest.getMethod()) { @@ -113,9 +112,6 @@ public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { response = listInstanceResp(callbackRequest); break; case FETCH_INSTANCE_INFO: - log.debug("Fetch instance info request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - List instanceAttributeInfoList = new ArrayList<>(); for (String instanceId : searchCondition.getIdList()) { try { @@ -136,20 +132,14 @@ public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { response = fetchInstanceInfoResponse; break; case LIST_ATTRIBUTE: - log.debug("List attribute request!|{}|{}|{}", callbackRequest.getType(), callbackRequest.getFilter(), - callbackRequest.getPage()); response = new ListAttributeResponseDTO(); response.setCode(0L); break; case LIST_ATTRIBUTE_VALUE: - log.debug("List attribute value request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListAttributeValueResponseDTO(); response.setCode(0L); break; case LIST_INSTANCE_BY_POLICY: - log.debug("List instance by policy request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); response = new ListInstanceByPolicyResponseDTO(); response.setCode(0L); break; diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/ScriptCallbackHelper.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/ScriptCallbackHelper.java index 28d42dfa49..13c552cfe7 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/ScriptCallbackHelper.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/ScriptCallbackHelper.java @@ -73,8 +73,7 @@ public SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackR return IamRespUtil.getSearchInstanceRespFromPageData(accountDTOPageData, this::convert); } - public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest){ - log.debug("Receive iam callback|{}", callbackRequest); + public CallbackBaseResponseDTO doCallback(CallbackRequestDTO callbackRequest){ CallbackBaseResponseDTO response; IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); switch (callbackRequest.getMethod()) {