-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. 支持可插拔数据驱动配置 2. 修改登录验证状态码403 3. 修改组织邀请成员UI
- Loading branch information
1 parent
84edec4
commit bbf99e5
Showing
28 changed files
with
500 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## << | ||
## Davinci | ||
## == | ||
## Copyright (C) 2016 - 2018 EDP | ||
## == | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## >> | ||
|
||
## This file is used to add jdbc datasources that are not supported by the Davinci, | ||
## ignore this file if your datasource is already supported, | ||
## the jdbc datasources Davinci support by default are: | ||
## mysql: com.mysql.jdbc.Driver | ||
## oracle: oracle.jdbc.driver.OracleDriver | ||
## sqlserver: com.microsoft.sqlserver.jdbc.SQLServerDriver | ||
## h2: org.h2.Driver | ||
## phoenix: org.apache.phoenix.jdbc.PhoenixDriver | ||
## mongodb: mongodb.jdbc.MongoDriver | ||
## elasticSearch: nl.anchormen.sql4es.jdbc.ESDriver | ||
## presto: com.facebook.presto.jdbc.PrestoDriver | ||
## moonbox: moonbox.jdbc.MbDriver | ||
## cassandra: com.github.adejanovski.cassandra.jdbc.CassandraDriver | ||
## clickhouse: ru.yandex.clickhouse.ClickHouseDriver | ||
## kylin: org.apache.kylin.jdbc.Driver | ||
## vertica: com.vertica.jdbc.Driver | ||
## hana: com.sap.db.jdbc.Driver | ||
## impala: com.cloudera.impala.jdbc41.Driver | ||
## this means that if your datasource is in the above list, you don't need to use this method, | ||
## unless you know what you are doing. | ||
|
||
## How to use: | ||
## 1. configure your own datasource like examples below, | ||
## 2. add the corresponding dependency file (jar) in lib package, | ||
## 3. restart your Davinci server | ||
|
||
## If you have problems during use, please contact us. | ||
|
||
|
||
# mysql: | ||
# name: mysql | ||
# desc: mysql | ||
# driver: com.mysql.jdbc.Driver | ||
|
||
# oracle: | ||
# name: oracle | ||
# desc: oracle | ||
# driver: oracle.jdbc.driver.OracleDriver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* << | ||
* Davinci | ||
* == | ||
* Copyright (C) 2016 - 2018 EDP | ||
* == | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* >> | ||
*/ | ||
|
||
package edp.core.model; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class DataSourceDriver { | ||
private String name; | ||
private String desc; | ||
private String driver; | ||
} |
117 changes: 117 additions & 0 deletions
117
server/src/main/java/edp/core/utils/DataSourceDriverLoadUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* << | ||
* Davinci | ||
* == | ||
* Copyright (C) 2016 - 2018 EDP | ||
* == | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* >> | ||
*/ | ||
|
||
package edp.core.utils; | ||
|
||
import com.alibaba.druid.util.StringUtils; | ||
import edp.core.model.DataSourceDriver; | ||
import org.yaml.snakeyaml.Yaml; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileReader; | ||
import java.util.Map; | ||
|
||
public class DataSourceDriverLoadUtils { | ||
|
||
|
||
/** | ||
* 根据url 加载yaml中的数据源驱动 | ||
* | ||
* @param url | ||
* @return | ||
* @throws Exception | ||
*/ | ||
public static DataSourceDriver loadFromYaml(String yamlPath, String url) throws Exception { | ||
if (StringUtils.isEmpty(url)) { | ||
return null; | ||
} | ||
Map<String, DataSourceDriver> sourceDriverMap = loadAllFromYaml(yamlPath); | ||
if (null == sourceDriverMap || sourceDriverMap.size() < 1) { | ||
return null; | ||
} | ||
|
||
for (String key : sourceDriverMap.keySet()) { | ||
DataSourceDriver dataSourceDriver = sourceDriverMap.get(key); | ||
if (StringUtils.isEmpty(dataSourceDriver.getName()) || StringUtils.isEmpty(dataSourceDriver.getDriver())) { | ||
continue; | ||
} | ||
if ("null".equals(dataSourceDriver.getName().trim().toLowerCase())) { | ||
continue; | ||
} | ||
if ("null".equals(dataSourceDriver.getDriver().trim().toLowerCase())) { | ||
continue; | ||
} | ||
|
||
if (StringUtils.isEmpty(dataSourceDriver.getDesc())) { | ||
dataSourceDriver.setDesc(dataSourceDriver.getName()); | ||
} | ||
if ("null".equals(dataSourceDriver.getDesc().trim().toLowerCase())) { | ||
dataSourceDriver.setDesc(dataSourceDriver.getName()); | ||
} | ||
|
||
if (url.toLowerCase().indexOf(dataSourceDriver.getName().trim().toLowerCase()) > -1) { | ||
try { | ||
Class<?> aClass = Class.forName(dataSourceDriver.getDriver()); | ||
if (null == aClass) { | ||
throw new Exception("Unable to get driver instance for jdbcUrl: " + url); | ||
} | ||
} catch (ClassNotFoundException e) { | ||
throw new Exception("Unable to get driver instance: " + url); | ||
} | ||
return dataSourceDriver; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
private static Map<String, DataSourceDriver> loadAllFromYaml(String yamlPath) { | ||
if (StringUtils.isEmpty(yamlPath)) { | ||
return null; | ||
} | ||
File yamlFile = new File(yamlPath); | ||
if (!yamlFile.exists()) { | ||
return null; | ||
} | ||
if (!yamlFile.isFile()) { | ||
return null; | ||
} | ||
if (!yamlFile.canRead()) { | ||
return null; | ||
} | ||
|
||
FileReader fileReader = null; | ||
try { | ||
fileReader = new FileReader(yamlFile); | ||
} catch (FileNotFoundException e) { | ||
return null; | ||
} | ||
if (null == fileReader) { | ||
return null; | ||
} | ||
|
||
Yaml yaml = new Yaml(); | ||
Object load = yaml.load(new BufferedReader(fileReader)); | ||
Map<String, DataSourceDriver> dataTypeMap = null; | ||
if (null != load) { | ||
dataTypeMap = (Map<String, DataSourceDriver>) load; | ||
} | ||
return dataTypeMap; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.