use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.
the class SourceDbServiceImpl method updateBasic.
@Override
public boolean updateBasic(SourceDbBasicInfo basicInfo, String operator) {
LOGGER.info("begin to update db data source basic={}", basicInfo);
Preconditions.checkNotNull(basicInfo, "db data source basic is empty");
// The groupId may be modified, it is necessary to determine whether the inlong group status of
// the modified groupId supports modification
this.checkGroupIsTempStatus(basicInfo.getInlongGroupId());
// If id is empty, add
if (basicInfo.getId() == null) {
this.saveBasic(basicInfo, operator);
} else {
SourceDbBasicEntity basicEntity = dbBasicMapper.selectByPrimaryKey(basicInfo.getId());
if (basicEntity == null) {
LOGGER.error("db data source basic not found by id={}, update failed", basicInfo.getId());
throw new BusinessException(ErrorCodeEnum.SOURCE_BASIC_NOT_FOUND);
}
BeanUtils.copyProperties(basicInfo, basicEntity);
basicEntity.setModifier(operator);
dbBasicMapper.updateByPrimaryKeySelective(basicEntity);
}
LOGGER.info("success to update db data source basic");
return true;
}
use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.
the class SourceFileServiceImpl method updateDetail.
@Transactional(rollbackFor = Throwable.class)
@Override
public boolean updateDetail(SourceFileDetailInfo detailInfo, String operator) {
LOGGER.info("begin to update file data source detail={}", detailInfo);
Preconditions.checkNotNull(detailInfo, "file data source detail is empty");
Integer id = detailInfo.getId();
Preconditions.checkNotNull(id, Constant.ID_IS_EMPTY);
SourceFileDetailEntity entity = fileDetailMapper.selectByPrimaryKey(id);
if (entity == null) {
LOGGER.error("file data source detail not found by id=" + id);
throw new BusinessException(ErrorCodeEnum.SOURCE_DETAIL_NOT_FOUND);
}
// After the approval is passed, the status needs to be revised to be revised to be issued: 205
this.checkGroupIsTempStatus(detailInfo.getInlongGroupId());
detailInfo.setStatus(EntityStatus.AGENT_ADD.getCode());
SourceFileDetailEntity updateEntity = CommonBeanUtils.copyProperties(detailInfo, SourceFileDetailEntity::new);
updateEntity.setModifier(operator);
updateEntity.setModifyTime(new Date());
fileDetailMapper.updateByPrimaryKeySelective(updateEntity);
LOGGER.info("success to update file data source detail");
return true;
}
use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.
the class SourceFileServiceImpl method saveBasic.
@Override
public Integer saveBasic(SourceFileBasicInfo basicInfo, String operator) {
LOGGER.info("begin to save file data source basic={}", basicInfo);
Preconditions.checkNotNull(basicInfo, "file data source basic is empty");
String groupId = basicInfo.getInlongGroupId();
String streamId = basicInfo.getInlongStreamId();
Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
Preconditions.checkNotNull(streamId, Constant.STREAM_ID_IS_EMPTY);
// Check if it can be added
this.checkGroupIsTempStatus(groupId);
// Each groupId + streamId has only 1 valid basic information
SourceFileBasicEntity exist = fileBasicMapper.selectByIdentifier(groupId, streamId);
if (exist != null) {
LOGGER.error("file data source basic already exists, please check");
throw new BusinessException(ErrorCodeEnum.SOURCE_DUPLICATE);
}
SourceFileBasicEntity entity = CommonBeanUtils.copyProperties(basicInfo, SourceFileBasicEntity::new);
entity.setCreator(operator);
entity.setModifier(operator);
entity.setCreateTime(new Date());
fileBasicMapper.insertSelective(entity);
LOGGER.info("success to save file data source basic");
return entity.getId();
}
Aggregations