提交 4a5935ca authored 作者: wangjiahao's avatar wangjiahao

feat: 优化代码格式 异常抛出优化

上级 3f94b2f7
...@@ -7,6 +7,7 @@ import io.dataease.auth.service.AuthUserService; ...@@ -7,6 +7,7 @@ import io.dataease.auth.service.AuthUserService;
import io.dataease.auth.util.JWTUtils; import io.dataease.auth.util.JWTUtils;
import io.dataease.commons.utils.CommonBeanFactory; import io.dataease.commons.utils.CommonBeanFactory;
import io.dataease.commons.utils.LogUtil; import io.dataease.commons.utils.LogUtil;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
...@@ -95,7 +96,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter { ...@@ -95,7 +96,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
AuthUserService authUserService = CommonBeanFactory.getBean(AuthUserService.class); AuthUserService authUserService = CommonBeanFactory.getBean(AuthUserService.class);
SysUserEntity user = authUserService.getUserById(tokenInfo.getUserId()); SysUserEntity user = authUserService.getUserById(tokenInfo.getUserId());
if(user == null){ if(user == null){
throw new Exception(Translator.get("i18n_not_find_user")); DataEaseException.throwException(Translator.get("i18n_not_find_user"));
} }
String password = user.getPassword(); String password = user.getPassword();
......
...@@ -14,6 +14,7 @@ import io.dataease.commons.utils.BeanUtils; ...@@ -14,6 +14,7 @@ import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.CodingUtil; import io.dataease.commons.utils.CodingUtil;
import io.dataease.commons.utils.ServletUtils; import io.dataease.commons.utils.ServletUtils;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -40,10 +41,10 @@ public class AuthServer implements AuthApi { ...@@ -40,10 +41,10 @@ public class AuthServer implements AuthApi {
SysUserEntity user = authUserService.getUserByName(username); SysUserEntity user = authUserService.getUserByName(username);
if (ObjectUtils.isEmpty(user)) { if (ObjectUtils.isEmpty(user)) {
throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); DataEaseException.throwException(Translator.get("i18n_id_or_pwd_error"));
} }
if (user.getEnabled() == 0) { if (user.getEnabled() == 0) {
throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); DataEaseException.throwException(Translator.get("i18n_id_or_pwd_error"));
} }
String realPwd = user.getPassword(); String realPwd = user.getPassword();
//私钥解密 //私钥解密
...@@ -52,7 +53,7 @@ public class AuthServer implements AuthApi { ...@@ -52,7 +53,7 @@ public class AuthServer implements AuthApi {
pwd = CodingUtil.md5(pwd); pwd = CodingUtil.md5(pwd);
if (!StringUtils.equals(pwd, realPwd)) { if (!StringUtils.equals(pwd, realPwd)) {
throw new RuntimeException(Translator.get("i18n_id_or_pwd_error")); DataEaseException.throwException(Translator.get("i18n_id_or_pwd_error"));
} }
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).build(); TokenInfo tokenInfo = TokenInfo.builder().userId(user.getUserId()).username(username).build();
......
...@@ -7,6 +7,7 @@ import com.auth0.jwt.exceptions.JWTDecodeException; ...@@ -7,6 +7,7 @@ import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT; import com.auth0.jwt.interfaces.DecodedJWT;
import io.dataease.auth.entity.TokenInfo; import io.dataease.auth.entity.TokenInfo;
import io.dataease.commons.utils.CommonBeanFactory; import io.dataease.commons.utils.CommonBeanFactory;
import io.dataease.exception.DataEaseException;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
...@@ -50,7 +51,7 @@ public class JWTUtils { ...@@ -50,7 +51,7 @@ public class JWTUtils {
String username = jwt.getClaim("username").asString(); String username = jwt.getClaim("username").asString();
Long userId = jwt.getClaim("userId").asLong(); Long userId = jwt.getClaim("userId").asLong();
if (StringUtils.isEmpty(username) || ObjectUtils.isEmpty(userId) ){ if (StringUtils.isEmpty(username) || ObjectUtils.isEmpty(userId) ){
throw new RuntimeException("token格式错误!"); DataEaseException.throwException("token格式错误!");
} }
TokenInfo tokenInfo = TokenInfo.builder().username(username).userId(userId).build(); TokenInfo tokenInfo = TokenInfo.builder().username(username).userId(userId).build();
return tokenInfo; return tokenInfo;
......
...@@ -5,6 +5,7 @@ package io.dataease.controller; ...@@ -5,6 +5,7 @@ package io.dataease.controller;
import com.google.gson.Gson; import com.google.gson.Gson;
import io.dataease.commons.license.DefaultLicenseService; import io.dataease.commons.license.DefaultLicenseService;
import io.dataease.commons.license.F2CLicenseResponse; import io.dataease.commons.license.F2CLicenseResponse;
import io.dataease.exception.DataEaseException;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -35,11 +36,12 @@ public class LicenseController { ...@@ -35,11 +36,12 @@ public class LicenseController {
return ResultHolder.success(null); return ResultHolder.success(null);
case expired: case expired:
String expired = f2CLicenseResponse.getLicense().getExpired(); String expired = f2CLicenseResponse.getLicense().getExpired();
throw new Exception("License has expired since " + expired + ", please update license."); DataEaseException.throwException("License has expired since " + expired + ", please update license.");
case invalid: case invalid:
throw new Exception(f2CLicenseResponse.getMessage()); DataEaseException.throwException(f2CLicenseResponse.getMessage());
default: default:
throw new Exception("Invalid License."); DataEaseException.throwException("Invalid License.");
} }
return new ResultHolder();
} }
} }
...@@ -7,6 +7,7 @@ import io.dataease.datasource.dto.MysqlConfigration; ...@@ -7,6 +7,7 @@ import io.dataease.datasource.dto.MysqlConfigration;
import io.dataease.datasource.dto.SqlServerConfigration; import io.dataease.datasource.dto.SqlServerConfigration;
import io.dataease.datasource.dto.TableFiled; import io.dataease.datasource.dto.TableFiled;
import io.dataease.datasource.request.DatasourceRequest; import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.exception.DataEaseException;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -31,9 +32,9 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -31,9 +32,9 @@ public class JdbcProvider extends DatasourceProvider {
ResultSet rs = stat.executeQuery(datasourceRequest.getQuery()); ResultSet rs = stat.executeQuery(datasourceRequest.getQuery());
list = fetchResult(rs); list = fetchResult(rs);
} catch (SQLException e) { } catch (SQLException e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} finally { } finally {
if(connection != null){ if(connection != null){
connection.close(); connection.close();
...@@ -50,9 +51,9 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -50,9 +51,9 @@ public class JdbcProvider extends DatasourceProvider {
Boolean result = stat.execute(datasourceRequest.getQuery()); Boolean result = stat.execute(datasourceRequest.getQuery());
stat.close(); stat.close();
} catch (SQLException e) { } catch (SQLException e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} finally { } finally {
if(connection != null){ if(connection != null){
connection.close(); connection.close();
...@@ -70,14 +71,15 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -70,14 +71,15 @@ public class JdbcProvider extends DatasourceProvider {
rs = stat.executeQuery(datasourceRequest.getQuery()); rs = stat.executeQuery(datasourceRequest.getQuery());
return fetchResult(rs); return fetchResult(rs);
} catch (SQLException e) { } catch (SQLException e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} finally { } finally {
if(connection != null){ if(connection != null){
connection.close(); connection.close();
} }
} }
return new ArrayList<>();
} }
private List<String[]> fetchResult(ResultSet rs) throws Exception { private List<String[]> fetchResult(ResultSet rs) throws Exception {
...@@ -112,14 +114,15 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -112,14 +114,15 @@ public class JdbcProvider extends DatasourceProvider {
rs = stat.executeQuery(datasourceRequest.getQuery()); rs = stat.executeQuery(datasourceRequest.getQuery());
return fetchResultField(rs); return fetchResultField(rs);
} catch (SQLException e) { } catch (SQLException e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} finally { } finally {
if(connection != null){ if(connection != null){
connection.close(); connection.close();
} }
} }
return new ArrayList<>();
} }
@Override @Override
...@@ -139,14 +142,15 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -139,14 +142,15 @@ public class JdbcProvider extends DatasourceProvider {
result.put("fieldList", fieldList); result.put("fieldList", fieldList);
return result; return result;
} catch (SQLException e) { } catch (SQLException e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} finally { } finally {
if(connection != null){ if(connection != null){
connection.close(); connection.close();
} }
} }
return new HashMap<>();
} }
private List<TableFiled> fetchResultField(ResultSet rs) throws Exception { private List<TableFiled> fetchResultField(ResultSet rs) throws Exception {
...@@ -183,12 +187,13 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -183,12 +187,13 @@ public class JdbcProvider extends DatasourceProvider {
statement.close(); statement.close();
return tables; return tables;
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR: " + e.getMessage(), e); DataEaseException.throwException(e);
} finally { } finally {
if(con != null){ if(con != null){
con.close(); con.close();
} }
} }
return new ArrayList<>();
} }
@Override @Override
...@@ -222,9 +227,9 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -222,9 +227,9 @@ public class JdbcProvider extends DatasourceProvider {
} }
resultSet.close(); resultSet.close();
} catch (SQLException e) { } catch (SQLException e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR:" + e.getMessage(), e); DataEaseException.throwException(e);
} finally { } finally {
if(connection != null){ if(connection != null){
connection.close(); connection.close();
...@@ -244,7 +249,7 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -244,7 +249,7 @@ public class JdbcProvider extends DatasourceProvider {
resultSet.close(); resultSet.close();
ps.close(); ps.close();
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR: " + e.getMessage(), e); DataEaseException.throwException(e);
} finally { } finally {
if(con != null){con.close();} if(con != null){con.close();}
} }
...@@ -261,7 +266,7 @@ public class JdbcProvider extends DatasourceProvider { ...@@ -261,7 +266,7 @@ public class JdbcProvider extends DatasourceProvider {
return resultSet.getLong(1); return resultSet.getLong(1);
} }
} catch (Exception e) { } catch (Exception e) {
throw new Exception("ERROR: " + e.getMessage(), e); DataEaseException.throwException( e);
} finally { } finally {
con.close(); con.close();
} }
......
...@@ -18,6 +18,7 @@ import io.dataease.datasource.provider.ProviderFactory; ...@@ -18,6 +18,7 @@ import io.dataease.datasource.provider.ProviderFactory;
import io.dataease.datasource.request.DatasourceRequest; import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.dto.DatasourceDTO; import io.dataease.dto.DatasourceDTO;
import io.dataease.dto.dataset.DataTableInfoDTO; import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import io.dataease.service.dataset.DataSetGroupService; import io.dataease.service.dataset.DataSetGroupService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -97,7 +98,7 @@ public class DatasourceService { ...@@ -97,7 +98,7 @@ public class DatasourceService {
example.createCriteria().andDataSourceIdEqualTo(datasourceId); example.createCriteria().andDataSourceIdEqualTo(datasourceId);
List<DatasetTable> datasetTables = datasetTableMapper.selectByExample(example); List<DatasetTable> datasetTables = datasetTableMapper.selectByExample(example);
if(CollectionUtils.isNotEmpty(datasetTables)){ if(CollectionUtils.isNotEmpty(datasetTables)){
throw new Exception(datasetTables.size() + Translator.get("i18n_datasource_not_allow_delete_msg")); DataEaseException.throwException(datasetTables.size() + Translator.get("i18n_datasource_not_allow_delete_msg"));
} }
datasourceMapper.deleteByPrimaryKey(datasourceId); datasourceMapper.deleteByPrimaryKey(datasourceId);
} }
......
...@@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcel; ...@@ -4,6 +4,7 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.metadata.style.WriteCellStyle; import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import io.dataease.commons.utils.LogUtil; import io.dataease.commons.utils.LogUtil;
import io.dataease.exception.DataEaseException;
import io.dataease.exception.ExcelException; import io.dataease.exception.ExcelException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -31,10 +32,10 @@ public class EasyExcelExporter { ...@@ -31,10 +32,10 @@ public class EasyExcelExporter {
EasyExcel.write(response.getOutputStream(), this.clazz).registerWriteHandler(horizontalCellStyleStrategy).sheet(sheetName).doWrite(data); EasyExcel.write(response.getOutputStream(), this.clazz).registerWriteHandler(horizontalCellStyleStrategy).sheet(sheetName).doWrite(data);
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new ExcelException("Utf-8 encoding is not supported"); DataEaseException.throwException("Utf-8 encoding is not supported");
} catch (IOException e) { } catch (IOException e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new ExcelException("IO exception"); DataEaseException.throwException("IO exception");
} }
} }
......
package io.dataease.job.sechedule; package io.dataease.job.sechedule;
import io.dataease.commons.utils.LogUtil; import io.dataease.commons.utils.LogUtil;
import io.dataease.exception.DataEaseException;
import org.quartz.*; import org.quartz.*;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -96,7 +97,7 @@ public class ScheduleManager { ...@@ -96,7 +97,7 @@ public class ScheduleManager {
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new RuntimeException(e); DataEaseException.throwException(e);
} }
} }
...@@ -126,7 +127,7 @@ public class ScheduleManager { ...@@ -126,7 +127,7 @@ public class ScheduleManager {
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new RuntimeException(e); DataEaseException.throwException(e);
} }
} }
...@@ -187,7 +188,7 @@ public class ScheduleManager { ...@@ -187,7 +188,7 @@ public class ScheduleManager {
// addJob(jobName, jobGroupName, triggerName, triggerGroupName, jobClass, cron); // addJob(jobName, jobGroupName, triggerName, triggerGroupName, jobClass, cron);
/** 方式二 :先删除,然后在创建一个新的Job */ /** 方式二 :先删除,然后在创建一个新的Job */
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); DataEaseException.throwException(e);
} }
} }
...@@ -239,7 +240,7 @@ public class ScheduleManager { ...@@ -239,7 +240,7 @@ public class ScheduleManager {
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new RuntimeException(e); DataEaseException.throwException(e);
} }
} }
...@@ -271,7 +272,7 @@ public class ScheduleManager { ...@@ -271,7 +272,7 @@ public class ScheduleManager {
} }
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new RuntimeException(e); DataEaseException.throwException(e);
} }
} }
...@@ -295,7 +296,7 @@ public class ScheduleManager { ...@@ -295,7 +296,7 @@ public class ScheduleManager {
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new RuntimeException(e); DataEaseException.throwException(e);
} }
} }
...@@ -305,7 +306,7 @@ public class ScheduleManager { ...@@ -305,7 +306,7 @@ public class ScheduleManager {
sched.start(); sched.start();
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new RuntimeException(e); DataEaseException.throwException(e);
} }
} }
...@@ -317,7 +318,7 @@ public class ScheduleManager { ...@@ -317,7 +318,7 @@ public class ScheduleManager {
} }
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
throw new RuntimeException(e); DataEaseException.throwException(e);
} }
} }
...@@ -435,7 +436,7 @@ public class ScheduleManager { ...@@ -435,7 +436,7 @@ public class ScheduleManager {
public static CronTrigger getCronTrigger(String cron) { public static CronTrigger getCronTrigger(String cron) {
if (!CronExpression.isValidExpression(cron)) { if (!CronExpression.isValidExpression(cron)) {
throw new RuntimeException("cron :" + cron + " error"); DataEaseException.throwException("cron :" + cron + " error");
} }
return TriggerBuilder.newTrigger().withIdentity("Calculate Date").withSchedule(CronScheduleBuilder.cronSchedule(cron)).build(); return TriggerBuilder.newTrigger().withIdentity("Calculate Date").withSchedule(CronScheduleBuilder.cronSchedule(cron)).build();
......
...@@ -18,6 +18,7 @@ import io.dataease.datasource.provider.JdbcProvider; ...@@ -18,6 +18,7 @@ import io.dataease.datasource.provider.JdbcProvider;
import io.dataease.datasource.provider.ProviderFactory; import io.dataease.datasource.provider.ProviderFactory;
import io.dataease.datasource.request.DatasourceRequest; import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.dto.dataset.*; import io.dataease.dto.dataset.*;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import io.dataease.provider.DDLProvider; import io.dataease.provider.DDLProvider;
import io.dataease.provider.QueryProvider; import io.dataease.provider.QueryProvider;
...@@ -412,7 +413,7 @@ public class DataSetTableService { ...@@ -412,7 +413,7 @@ public class DataSetTableService {
String sql = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getSql(); String sql = new Gson().fromJson(dataSetTableRequest.getInfo(), DataTableInfoDTO.class).getSql();
if (StringUtils.isEmpty(sql)) { if (StringUtils.isEmpty(sql)) {
throw new Exception(Translator.get("i18n_sql_not_empty")); DataEaseException.throwException(Translator.get("i18n_sql_not_empty"));
} }
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType()); QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
String sqlAsTable = qp.createSQLPreview(sql, null); String sqlAsTable = qp.createSQLPreview(sql, null);
...@@ -734,7 +735,7 @@ public class DataSetTableService { ...@@ -734,7 +735,7 @@ public class DataSetTableService {
}); });
sort(sqlFileds); sort(sqlFileds);
if (!originNameFileds.equals(sqlFileds)) { if (!originNameFileds.equals(sqlFileds)) {
throw new Exception(Translator.get("i18n_sql_add_not_matching") + sqlFileds.toString()); DataEaseException.throwException(Translator.get("i18n_sql_add_not_matching") + sqlFileds.toString());
} }
} }
if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete()) && StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete().replace(" ", ""))) {// 增量删除 if (StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete()) && StringUtils.isNotEmpty(datasetTableIncrementalConfig.getIncrementalDelete().replace(" ", ""))) {// 增量删除
...@@ -747,7 +748,7 @@ public class DataSetTableService { ...@@ -747,7 +748,7 @@ public class DataSetTableService {
}); });
sort(sqlFileds); sort(sqlFileds);
if (!originNameFileds.equals(sqlFileds)) { if (!originNameFileds.equals(sqlFileds)) {
throw new Exception(Translator.get("i18n_sql_delete_not_matching") + sqlFileds.toString()); DataEaseException.throwException(Translator.get("i18n_sql_delete_not_matching") + sqlFileds.toString());
} }
} }
} }
......
...@@ -8,6 +8,7 @@ import io.dataease.base.mapper.DatasetTableTaskMapper; ...@@ -8,6 +8,7 @@ import io.dataease.base.mapper.DatasetTableTaskMapper;
import io.dataease.commons.constants.JobStatus; import io.dataease.commons.constants.JobStatus;
import io.dataease.commons.constants.ScheduleType; import io.dataease.commons.constants.ScheduleType;
import io.dataease.controller.request.dataset.DataSetTaskRequest; import io.dataease.controller.request.dataset.DataSetTaskRequest;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import io.dataease.service.ScheduleService; import io.dataease.service.ScheduleService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
...@@ -71,11 +72,11 @@ public class DataSetTableTaskService { ...@@ -71,11 +72,11 @@ public class DataSetTableTaskService {
if (datasetTableTask.getType().equalsIgnoreCase("add_scope")) { if (datasetTableTask.getType().equalsIgnoreCase("add_scope")) {
DatasetTable datasetTable = dataSetTableService.get(datasetTableTask.getTableId()); DatasetTable datasetTable = dataSetTableService.get(datasetTableTask.getTableId());
if (datasetTable.getLastUpdateTime() == 0 || datasetTable.getLastUpdateTime() == null) { if (datasetTable.getLastUpdateTime() == 0 || datasetTable.getLastUpdateTime() == null) {
throw new Exception(Translator.get("i18n_not_exec_add_sync")); DataEaseException.throwException(Translator.get("i18n_not_exec_add_sync"));
} }
} }
if (extractDataService.updateSyncStatusIsNone(dataSetTableService.get(datasetTableTask.getTableId()))) { if (extractDataService.updateSyncStatusIsNone(dataSetTableService.get(datasetTableTask.getTableId()))) {
throw new Exception(Translator.get("i18n_sync_job_exists")); DataEaseException.throwException(Translator.get("i18n_sync_job_exists"));
} else { } else {
//write log //write log
DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog(); DatasetTableTaskLog datasetTableTaskLog = new DatasetTableTaskLog();
......
...@@ -22,6 +22,7 @@ import io.dataease.datasource.provider.ProviderFactory; ...@@ -22,6 +22,7 @@ import io.dataease.datasource.provider.ProviderFactory;
import io.dataease.datasource.request.DatasourceRequest; import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.dto.dataset.DataSetTaskLogDTO; import io.dataease.dto.dataset.DataSetTaskLogDTO;
import io.dataease.dto.dataset.DataTableInfoDTO; import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.exception.DataEaseException;
import io.dataease.provider.QueryProvider; import io.dataease.provider.QueryProvider;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
...@@ -461,7 +462,7 @@ public class ExtractDataService { ...@@ -461,7 +462,7 @@ public class ExtractDataService {
if (jobStatus.getStatusDescription().equals("Finished")) { if (jobStatus.getStatusDescription().equals("Finished")) {
return; return;
} else { } else {
throw new Exception(jobStatus.getLoggingString()); DataEaseException.throwException((jobStatus.getLoggingString()));
} }
} }
......
...@@ -15,6 +15,7 @@ import io.dataease.dto.chart.ChartViewDTO; ...@@ -15,6 +15,7 @@ import io.dataease.dto.chart.ChartViewDTO;
import io.dataease.dto.dataset.DataSetGroupDTO; import io.dataease.dto.dataset.DataSetGroupDTO;
import io.dataease.dto.panel.PanelDesignDTO; import io.dataease.dto.panel.PanelDesignDTO;
import io.dataease.dto.panel.PanelGroupDTO; import io.dataease.dto.panel.PanelGroupDTO;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import io.dataease.service.chart.ChartViewService; import io.dataease.service.chart.ChartViewService;
import io.dataease.service.sys.SysAuthService; import io.dataease.service.sys.SysAuthService;
...@@ -128,7 +129,7 @@ public class PanelGroupService { ...@@ -128,7 +129,7 @@ public class PanelGroupService {
List<PanelGroup> checkResult = panelGroupMapper.selectByExample(groupExample); List<PanelGroup> checkResult = panelGroupMapper.selectByExample(groupExample);
if (CollectionUtils.isNotEmpty(checkResult)) { if (CollectionUtils.isNotEmpty(checkResult)) {
throw new RuntimeException(Translator.get("i18n_same_folder_can_not_repeat")); DataEaseException.throwException(Translator.get("i18n_same_folder_can_not_repeat"));
} }
} }
......
...@@ -9,6 +9,7 @@ import io.dataease.commons.utils.AuthUtils; ...@@ -9,6 +9,7 @@ import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils; import io.dataease.commons.utils.BeanUtils;
import io.dataease.controller.request.panel.PanelTemplateRequest; import io.dataease.controller.request.panel.PanelTemplateRequest;
import io.dataease.dto.panel.PanelTemplateDTO; import io.dataease.dto.panel.PanelTemplateDTO;
import io.dataease.exception.DataEaseException;
import io.dataease.i18n.Translator; import io.dataease.i18n.Translator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -71,7 +72,7 @@ public class PanelTemplateService { ...@@ -71,7 +72,7 @@ public class PanelTemplateService {
request.setPid(request.getTemplateType()); request.setPid(request.getTemplateType());
String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.INSERT,request.getName(),request.getPid(),null); String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.INSERT,request.getName(),request.getPid(),null);
if(CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)){ if(CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)){
throw new RuntimeException(Translator.get("i18n_same_folder_can_not_repeat")); DataEaseException.throwException(Translator.get("i18n_same_folder_can_not_repeat"));
} }
}else{//模板插入 相同文件夹同名的模板进行覆盖(先删除) }else{//模板插入 相同文件夹同名的模板进行覆盖(先删除)
PanelTemplateExample exampleDelete = new PanelTemplateExample(); PanelTemplateExample exampleDelete = new PanelTemplateExample();
...@@ -82,7 +83,7 @@ public class PanelTemplateService { ...@@ -82,7 +83,7 @@ public class PanelTemplateService {
} else { } else {
String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.UPDATE,request.getName(),request.getPid(),request.getId()); String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.UPDATE,request.getName(),request.getPid(),request.getId());
if(CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)){ if(CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)){
throw new RuntimeException(Translator.get("i18n_same_folder_can_not_repeat")); DataEaseException.throwException(Translator.get("i18n_same_folder_can_not_repeat"));
} }
panelTemplateMapper.updateByPrimaryKeySelective(request); panelTemplateMapper.updateByPrimaryKeySelective(request);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论