提交 29406b1d 编写于 作者: S Serge Rider

Connection properties refactoring


Former-commit-id: 02591ba4
上级 8b59a355
......@@ -777,7 +777,7 @@ public class DataSourceDescriptor
DBRShellCommand command = info.getEvent(eventType);
if (command != null && command.isEnabled()) {
Map<String, Object> variables = new HashMap<>();
for (Map.Entry<Object, Object> entry : info.getProperties().entrySet()) {
for (Map.Entry<String, String> entry : info.getProperties().entrySet()) {
variables.put(CommonUtils.toString(entry.getKey()), entry.getValue());
}
variables.put(RegistryConstants.VARIABLE_HOST, info.getHostName());
......
......@@ -685,7 +685,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
xml.addAttribute(RegistryConstants.ATTR_KEEP_ALIVE, connectionInfo.getKeepAliveInterval());
}
for (Map.Entry<Object, Object> entry : connectionInfo.getProperties().entrySet()) {
for (Map.Entry<String, String> entry : connectionInfo.getProperties().entrySet()) {
xml.startElement(RegistryConstants.TAG_PROPERTY);
xml.addAttribute(RegistryConstants.ATTR_NAME, CommonUtils.toString(entry.getKey()));
xml.addAttribute(RegistryConstants.ATTR_VALUE, CommonUtils.toString(entry.getValue()));
......@@ -997,7 +997,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
new DBPConnectionConfiguration());
} else {
// Clean settings - they have to be loaded later by parser
curDataSource.getConnectionConfiguration().setProperties(Collections.emptyMap());
curDataSource.getConnectionConfiguration().setProperties(Collections.<String, String>emptyMap());
curDataSource.getConnectionConfiguration().setHandlers(Collections.<DBWHandlerConfiguration>emptyList());
curDataSource.clearFilters();
}
......
......@@ -26,8 +26,10 @@ import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.registry.driver.DriverDescriptor;
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
import org.jkiss.utils.CommonUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
/**
* DriverPropertiesDialogPage
......@@ -111,7 +113,10 @@ public class DriverPropertiesDialogPage extends ConnectionPageAbstract
public void saveSettings(DBPDataSourceContainer dataSource)
{
if (propertySource != null) {
dataSource.getConnectionConfiguration().getProperties().putAll(propertySource.getProperties());
final Map<String, String> properties = dataSource.getConnectionConfiguration().getProperties();
for (Map.Entry<Object, Object> entry : propertySource.getProperties().entrySet()) {
properties.put(CommonUtils.toString(entry.getKey()), CommonUtils.toString(entry.getValue()));
}
}
}
......
......@@ -68,7 +68,7 @@ public class ExasolDataSourceProvider extends JDBCDataSourceProvider {
if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
port = ":" + connectionInfo.getHostPort();
}
Map<Object, Object> properties = connectionInfo.getProperties();
Map<String, String> properties = connectionInfo.getProperties();
StringBuilder url = new StringBuilder(128);
url.append("jdbc:exa:").append(connectionInfo.getHostName()).append(port);
......
......@@ -52,9 +52,9 @@ public class ExasolWizardPageSettings<WIZARD extends AbstractToolWizard> extends
String authUser = null;
String authPassword = null;
{
Object authValue = connectionInfo.getProperty(authProperty);
String authValue = connectionInfo.getProperty(authProperty);
if (authValue != null) {
String authCredentials = encrypter.decrypt(authValue.toString());
String authCredentials = encrypter.decrypt(authValue);
int divPos = authCredentials.indexOf(':');
if (divPos != -1) {
authUser = authCredentials.substring(0, divPos);
......
......@@ -38,7 +38,7 @@ public class ImportConnectionInfo {
private String database;
private String user;
private String password;
private Map<Object, Object> properties = new HashMap<>();
private Map<String, String> properties = new HashMap<>();
private Map<String, String> providerProperties = new HashMap<>();
private boolean checked = false;
......@@ -128,7 +128,7 @@ public class ImportConnectionInfo {
return password;
}
public Map<Object, Object> getProperties()
public Map<String, String> getProperties()
{
return properties;
}
......
......@@ -54,9 +54,9 @@ public abstract class PostgreWizardPageSettings<WIZARD extends AbstractToolWizar
String authUser = null;
String authPassword = null;
{
Object authValue = connectionInfo.getProperty(authProperty);
String authValue = connectionInfo.getProviderProperty(authProperty);
if (authValue != null) {
String authCredentials = encrypter.decrypt(authValue.toString());
String authCredentials = encrypter.decrypt(authValue);
int divPos = authCredentials.indexOf(':');
if (divPos != -1) {
authUser = authCredentials.substring(0, divPos);
......@@ -90,7 +90,7 @@ public abstract class PostgreWizardPageSettings<WIZARD extends AbstractToolWizar
wizard.setToolUserPassword(authDialog.getUserPassword());
if (authDialog.isSavePassword()) {
try {
connectionInfo.setProperty(
connectionInfo.setProviderProperty(
authProperty,
encrypter.encrypt(wizard.getToolUserName() + ':' + wizard.getToolUserPassword()));
} catch (EncryptionException e1) {
......@@ -107,7 +107,7 @@ public abstract class PostgreWizardPageSettings<WIZARD extends AbstractToolWizar
@Override
public void widgetSelected(SelectionEvent e)
{
connectionInfo.getProperties().remove(authProperty);
connectionInfo.getProviderProperties().remove(authProperty);
wizard.setToolUserName(connectionInfo.getUserName());
wizard.setToolUserPassword(connectionInfo.getUserPassword());
}
......
......@@ -40,7 +40,7 @@ public class DBPConnectionConfiguration implements DBPObject
private String url;
private String clientHomeId;
@NotNull
private final Map<Object, Object> properties;
private final Map<String, String> properties;
@NotNull
private final Map<String, String> providerProperties;
@NotNull
......@@ -171,23 +171,23 @@ public class DBPConnectionConfiguration implements DBPObject
////////////////////////////////////////////////////
// Properties (connection properties, usually used by driver)
public Object getProperty(Object name)
public String getProperty(String name)
{
return properties.get(name);
}
public void setProperty(Object name, Object value)
public void setProperty(String name, String value)
{
properties.put(name, value);
}
@NotNull
public Map<Object, Object> getProperties()
public Map<String, String> getProperties()
{
return properties;
}
public void setProperties(@NotNull Map<Object, Object> properties)
public void setProperties(@NotNull Map<String, String> properties)
{
this.properties.clear();
this.properties.putAll(properties);
......
......@@ -130,7 +130,7 @@ public abstract class JDBCDataSource
}
DBPConnectionConfiguration connectionInfo = container.getActualConnectionConfiguration();
for (Map.Entry<Object,Object> prop : connectionInfo.getProperties().entrySet()) {
for (Map.Entry<String, String> prop : connectionInfo.getProperties().entrySet()) {
connectProps.setProperty(CommonUtils.toString(prop.getKey()), CommonUtils.toString(prop.getValue()));
}
if (!CommonUtils.isEmpty(connectionInfo.getUserName())) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册