From 6f3a8ff70c53044c7e0cbe5ac85da51a1eef077f Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Mon, 20 Feb 2023 11:51:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-90013=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=8D=E6=94=AF=E6=8C=81=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=9E=E6=8E=A5=E7=B1=BB=E5=9E=8B=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E3=80=91=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E4=B8=8B?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=98=BE=E7=A4=BA=E5=86=85=E5=AE=B9=E4=BB=8D?= =?UTF-8?q?=E4=B8=BA=E6=9C=AC=E5=9C=B0lic=E4=BF=A1=E6=81=AF=20=E3=80=90?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E4=B8=8B=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/connect/ConnectionListPane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index 15dba5d26b..185336baae 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -260,7 +260,8 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh } } if (!notSupportedConnections.isEmpty()) { - throw new DataBaseNotSupportedException(notSupportedConnections, BaseDataBaseTypePoint.getSupportedDatabaseType()); + List supportedDatabaseTypes = WorkContext.getCurrent().get(DataBaseTypeOperator.class).getSupportedDatabaseTypes(); + throw new DataBaseNotSupportedException(notSupportedConnections, supportedDatabaseTypes); } } From ccec9eef462ac3ad357f5ea6a3bcb6a1842b2be1 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Mon, 20 Feb 2023 16:52:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-90013=20=E4=BF=AE=E6=94=B9=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/connect/ConnectionListPane.java | 56 +++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index 185336baae..f836757399 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -22,6 +22,7 @@ import com.fr.file.ConnectionConfig; import com.fr.file.ConnectionOperator; import com.fr.general.NameObject; import com.fr.license.database.BaseDataBaseTypePoint; +import com.fr.license.database.DBTypes; import com.fr.license.exception.DataBaseNotSupportedException; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; @@ -34,6 +35,7 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.server.database.DataBaseTypeOperator; import org.jetbrains.annotations.NotNull; +import javax.swing.SwingWorker; import java.awt.Window; import java.sql.SQLException; import java.util.ArrayList; @@ -45,6 +47,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.concurrent.ExecutionException; /** * Connection List Pane. @@ -54,6 +57,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh private boolean isNamePermitted = true; private final HashMap renameMap = new HashMap<>(); private final Map populatedConnectionsSnapshot = new LinkedHashMap<>(); + private static List supportedDatabaseTypes = new ArrayList<>(); public ConnectionListPane() { renameMap.clear(); @@ -67,6 +71,30 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh rename(selectedName, getEditingName()); } }); + + getSupportedTypes(); + } + + /** + * 获取本地、远程环境lic中未受限制的数据库类型信息 + */ + private static void getSupportedTypes() { + SwingWorker, Void> getSupportedTypesWorker = new SwingWorker, Void>() { + @Override + protected List doInBackground() { + return WorkContext.getCurrent().get(DataBaseTypeOperator.class).getSupportedDatabaseTypes(); + } + + @Override + protected void done() { + try { + supportedDatabaseTypes = get(); + } catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + } + }; + getSupportedTypesWorker.execute(); } @Override @@ -250,20 +278,40 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh for (ConnectionBean bean : addedOrUpdatedConnections) { Connection connection = bean.getConnection(); // 仅校验jdbc连接,其他插件数据连接不进行校验 - boolean connectionIsNotSupported = connection instanceof JDBCDatabaseConnection && !WorkContext.getCurrent().get(DataBaseTypeOperator.class).supportDatabaseType(connection.getDriver(), connection.feature()); - if (connectionIsNotSupported) { + if (connection instanceof JDBCDatabaseConnection) { BaseDataBaseTypePoint dataBaseTypePoint = BaseDataBaseTypePoint.getDataBaseTypePoint(connection.getDriver(), connection.feature()); - if (dataBaseTypePoint != null && dataBaseTypePoint.getDataBaseType() != null) { + + if (connectionIsNotSupported(connection, dataBaseTypePoint)) { notSupportedConnections.addAll(dataBaseTypePoint.getDataBaseType()); } } } } + if (!notSupportedConnections.isEmpty()) { - List supportedDatabaseTypes = WorkContext.getCurrent().get(DataBaseTypeOperator.class).getSupportedDatabaseTypes(); throw new DataBaseNotSupportedException(notSupportedConnections, supportedDatabaseTypes); } + } + + /** + * 校验当前数据连接是否被限制 + */ + private static boolean connectionIsNotSupported(Connection connection, BaseDataBaseTypePoint dataBaseTypePoint) { + return !validateFRDemo(connection.getDriver(), connection.feature()) && + (dataBaseTypePoint != null && !supportedDatabaseTypes.containsAll(dataBaseTypePoint.getDatabaseType())); + } + + /** + * 校验当前是否为FRDemo,不对其进行限制 + */ + private static boolean validateFRDemo(String driver, String url) { + if (DBTypes.Sqlite.getDriver().equals(driver) && url.contains(DBTypes.Sqlite.getUrlKey())) { + // 产品:对sqlite类型只允许示例连接FRDemo + String databaseName = url.substring(url.lastIndexOf("/") + 1); + return StringUtils.equals("FRDemo.db", databaseName); + } + return false; }