|
|
|
@ -21,6 +21,8 @@ import com.fr.event.EventDispatcher;
|
|
|
|
|
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.exception.DataBaseNotSupportedException; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
import com.fr.stable.Nameable; |
|
|
|
@ -30,12 +32,14 @@ import com.fr.transaction.Configurations;
|
|
|
|
|
import com.fr.transaction.WorkerFacade; |
|
|
|
|
import com.fr.workspace.WorkContext; |
|
|
|
|
import com.fr.workspace.server.database.DataBaseTypeOperator; |
|
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
|
|
|
|
|
import java.awt.Window; |
|
|
|
|
import java.sql.SQLException; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
@ -232,10 +236,35 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
this.validateDatabaseType(addedOrUpdatedConnections); |
|
|
|
|
this.validateConnections(addedOrUpdatedConnections); |
|
|
|
|
this.alterConnections(removedConnNames, addedOrUpdatedConnections); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 校验是否支持所有新增和修改数据连接的数据库类型 |
|
|
|
|
*/ |
|
|
|
|
public void validateDatabaseType(@NotNull List<ConnectionBean> addedOrUpdatedConnections) { |
|
|
|
|
Set<String> notSupportedConnections = new HashSet<>(); |
|
|
|
|
if (!addedOrUpdatedConnections.isEmpty()) { |
|
|
|
|
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) { |
|
|
|
|
BaseDataBaseTypePoint dataBaseTypePoint = BaseDataBaseTypePoint.getDataBaseTypePoint(connection.getDriver(), connection.feature()); |
|
|
|
|
if (dataBaseTypePoint != null && dataBaseTypePoint.getDataBaseType() != null) { |
|
|
|
|
notSupportedConnections.addAll(dataBaseTypePoint.getDataBaseType()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!notSupportedConnections.isEmpty()) { |
|
|
|
|
throw new DataBaseNotSupportedException(notSupportedConnections, BaseDataBaseTypePoint.getSupportedDatabaseType()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void validateConnections(List<ConnectionBean> addedOrUpdatedConnections) throws Exception { |
|
|
|
|
|
|
|
|
|