healchow commented on code in PR #7227:
URL: https://github.com/apache/inlong/pull/7227#discussion_r1068859864
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/source/StreamSourceServiceImpl.java:
##########
@@ -626,21 +639,45 @@ private void checkRequestParams(SourceRequest request) {
if (request == null) {
throw new BusinessException(ErrorCodeEnum.REQUEST_IS_EMPTY);
}
- // check group id
- if (StringUtils.isBlank(request.getInlongGroupId())) {
- throw new BusinessException(ErrorCodeEnum.GROUP_ID_IS_EMPTY);
- }
- // check stream id
- if (StringUtils.isBlank(request.getInlongStreamId())) {
- throw new BusinessException(ErrorCodeEnum.STREAM_ID_IS_EMPTY);
- }
- // check source type
- if (StringUtils.isBlank(request.getSourceType())) {
- throw new BusinessException(ErrorCodeEnum.SOURCE_TYPE_IS_NULL);
+ // check record exists
+ StreamSourceEntity entity = sourceMapper.selectById(request.getId());
+ if (entity == null) {
+ throw new BusinessException(ErrorCodeEnum.SOURCE_INFO_NOT_FOUND,
+ String.format("not found source record by id=%d",
request.getId()));
}
- // check source name
- if (StringUtils.isBlank(request.getSourceName())) {
- throw new BusinessException(ErrorCodeEnum.SOURCE_NAME_IS_NULL);
+ // check whether modify sourceType
+ if (!Objects.equals(entity.getSourceType(), request.getSourceType())) {
+ throw new BusinessException(ErrorCodeEnum.INVALID_PARAMETER,
+ "sourceType not allowed modify");
}
+ // check record version
+ if (!Objects.equals(entity.getVersion(), request.getVersion())) {
+ throw new BusinessException(ErrorCodeEnum.CONFIG_EXPIRED,
+ String.format("source has already updated with groupId=%s,
streamId=%s, name=%s, curVersion=%s",
+ request.getInlongGroupId(),
request.getInlongStreamId(), request.getSourceName(),
+ request.getVersion()));
+ }
+ // check whether modify groupId
+ if (StringUtils.isNotBlank(request.getInlongGroupId())
Review Comment:
Check the request params is necessary, it can throw back to users to know
the error detail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]