forked from github/dataease
fix: 数据源校验
This commit is contained in:
parent
461f5135de
commit
e83510f4b7
@ -38,8 +38,8 @@ public class DatasourceController {
|
||||
|
||||
@ApiOperation("验证数据源")
|
||||
@PostMapping("/validate")
|
||||
public void validate(@RequestBody Datasource datasource) throws Exception {
|
||||
datasourceService.validate(datasource);
|
||||
public ResultHolder validate(@RequestBody Datasource datasource) throws Exception {
|
||||
return datasourceService.validate(datasource);
|
||||
}
|
||||
|
||||
@ApiOperation("验证数据源")
|
||||
|
@ -120,11 +120,17 @@ public class DatasourceService {
|
||||
checkAndUpdateDatasourceStatus(datasource);
|
||||
}
|
||||
|
||||
public void validate(Datasource datasource) throws Exception {
|
||||
public ResultHolder validate(Datasource datasource) throws Exception {
|
||||
try {
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasource);
|
||||
datasourceProvider.checkStatus(datasourceRequest);
|
||||
return ResultHolder.success("Success");
|
||||
}catch (Exception e){
|
||||
return ResultHolder.error("Datasource is invalid: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ResultHolder validate(String datasourceId) {
|
||||
@ -133,7 +139,10 @@ public class DatasourceService {
|
||||
return ResultHolder.error("Can not find datasource: "+ datasourceId);
|
||||
}
|
||||
try {
|
||||
validate(datasource);
|
||||
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasource);
|
||||
datasourceProvider.checkStatus(datasourceRequest);
|
||||
datasource.setStatus("Success");
|
||||
return ResultHolder.success("Success");
|
||||
}catch (Exception e){
|
||||
|
@ -572,7 +572,9 @@ public class ExtractDataService {
|
||||
}
|
||||
|
||||
private void extractData(DatasetTable datasetTable, String extractType) throws Exception {
|
||||
if(StringUtils.isNotEmpty(datasetTable.getDataSourceId())){
|
||||
datasourceService.validate(datasetTable.getDataSourceId());
|
||||
}
|
||||
KettleFileRepository repository = CommonBeanFactory.getBean(KettleFileRepository.class);
|
||||
RepositoryDirectoryInterface repositoryDirectoryInterface = repository.loadRepositoryDirectoryTree();
|
||||
TransMeta transMeta = null;
|
||||
|
@ -278,7 +278,7 @@ export default {
|
||||
data.configuration = JSON.stringify(data.configuration)
|
||||
if(data.showModel === 'show' && !this.canEdit){
|
||||
validateDsById(data.id).then(res => {
|
||||
if(res.success === 'true'){
|
||||
if(res.success){
|
||||
this.$success(this.$t('datasource.validate_success'))
|
||||
}else {
|
||||
this.$error(this.$t(res.message))
|
||||
@ -290,7 +290,7 @@ export default {
|
||||
|
||||
}else {
|
||||
validateDs(data).then(res => {
|
||||
if(res.success === 'true'){
|
||||
if(res.success){
|
||||
this.$success(this.$t('datasource.validate_success'))
|
||||
}else {
|
||||
this.$error(this.$t(res.message))
|
||||
|
Loading…
Reference in New Issue
Block a user