Skip to content

Commit

Permalink
TEIIDDES-1518: Fetch the driver version from the default server
Browse files Browse the repository at this point in the history
* ConnectivityUtil
 * Instead of hardcoding the driver version, base the version property on
   the server version supplied to its methods. This will usually be obtained
   from the default server.

* ITeiidServerVersion
 * Change the wildcard character from '*' to 'x'
  • Loading branch information
Paul Richardson committed Dec 18, 2012
1 parent 4584df7 commit 0f9104a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.datatools.connectivity.drivers.jdbc.IJDBCDriverDefinitionConstants;
import org.teiid.datatools.connectivity.security.impl.EquinoxSecureStorageProvider;
import org.teiid.datatools.connectivity.spi.ISecureStorageProvider;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;

/**
*
Expand All @@ -43,7 +44,7 @@ public class ConnectivityUtil {
public static final String TEIID_PREVIEW_DRIVER_DEFINITION_ID = "DriverDefn.org.teiid.datatools.connectivity.driver.serverDriverTemplate.Teiid Driver Default"; //$NON-NLS-1$
public static final String TEIID_PREVIEW_DRIVER_NAME = "Teiid Driver (default)"; //$NON-NLS-1$
public static final String TEIID_PREVIEW_DRIVER_DEFN_TYPE = "org.teiid.datatools.connectivity.driver.serverDriverTemplate"; //$NON-NLS-1$
public static final String TEIID_DATABASE_VERSION = "8.x"; //$NON-NLS-1$

public static final String TEIID_DRIVER_DEFINITION_ID_BASE = "DriverDefn.org.teiid.datatools.connectivity.driver.serverDriverTemplate."; //$NON-NLS-1$

/**
Expand All @@ -61,7 +62,8 @@ public class ConnectivityUtil {
*/
public static final String JDBC_PASSWORD = "jdbc_password"; //$NON-NLS-1$

public static Properties createDriverProps( String jarList,
public static Properties createDriverProps(ITeiidServerVersion serverVersion,
String jarList,
String driverURL,
String username,
String vdbName ) {
Expand All @@ -73,7 +75,7 @@ public static Properties createDriverProps( String jarList,
baseProperties.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID, username);
}
baseProperties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, TEIID_DATABASE_VENDOR_NAME);
baseProperties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, TEIID_DATABASE_VERSION);
baseProperties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, serverVersion.toString());
baseProperties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_NAME_PROP_ID, vdbName);
baseProperties.setProperty(IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, String.valueOf(true));
// baseProperties.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST,
Expand All @@ -83,7 +85,8 @@ public static Properties createDriverProps( String jarList,
return baseProperties;
}

public static IConnectionProfile createTransientTeiidProfile( String driverPath,
public static IConnectionProfile createTransientTeiidProfile( ITeiidServerVersion serverVersion,
String driverPath,
String connectionURL,
String username,
String password,
Expand All @@ -93,7 +96,7 @@ public static IConnectionProfile createTransientTeiidProfile( String driverPath,
try {
DriverInstance mDriver = DriverManager.getInstance().getDriverInstanceByID(TEIID_PREVIEW_DRIVER_DEFINITION_ID);
if (mDriver == null) {
createTeiidPreviewDriverInstance(driverPath, connectionURL, username);
createTeiidPreviewDriverInstance(serverVersion, driverPath, connectionURL, username);
} else {
// JBIDE-7493 Eclipse updates can break profiles because the driverPath is plugin version specific.
String jarList = mDriver.getJarList();
Expand All @@ -105,7 +108,8 @@ public static IConnectionProfile createTransientTeiidProfile( String driverPath,

storeJDBCPassword(connectionURL, password);

return pm.createTransientProfile(TEIID_PROFILE_PROVIDER_ID, createDriverProps(driverPath,
return pm.createTransientProfile(TEIID_PROFILE_PROVIDER_ID, createDriverProps(serverVersion,
driverPath,
connectionURL,
username,
vdbName));
Expand All @@ -116,7 +120,7 @@ public static IConnectionProfile createTransientTeiidProfile( String driverPath,

}

private static void createTeiidPreviewDriverInstance( String jarList,
private static void createTeiidPreviewDriverInstance( ITeiidServerVersion serverVersion, String jarList,
String driverURL, String username ) {
IPropertySet pset = new PropertySetImpl(TEIID_PREVIEW_DRIVER_NAME, TEIID_PREVIEW_DRIVER_DEFINITION_ID);
Properties baseProperties = new Properties();
Expand All @@ -129,7 +133,7 @@ private static void createTeiidPreviewDriverInstance( String jarList,
}

baseProperties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, TEIID_DATABASE_VENDOR_NAME);
baseProperties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, TEIID_DATABASE_VERSION);
baseProperties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, serverVersion.toString());
baseProperties.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, jarList);
baseProperties.setProperty(IDriverMgmtConstants.PROP_DEFN_TYPE, TEIID_PREVIEW_DRIVER_DEFN_TYPE);
baseProperties.setProperty(IDriverMgmtConstants.PROP_DEFN_CLASS, TEIID_DRIVER_NAME);
Expand Down Expand Up @@ -183,7 +187,8 @@ public static void deleteTransientTeiidProfile(IConnectionProfile profile) {
}


public static Properties createVDBTeiidProfileProperties(String driverPath,
public static Properties createVDBTeiidProfileProperties(ITeiidServerVersion serverVersion,
String driverPath,
String connectionURL,
String username,
String password,
Expand All @@ -192,7 +197,7 @@ public static Properties createVDBTeiidProfileProperties(String driverPath,

DriverInstance mDriver = DriverManager.getInstance().getDriverInstanceByID(TEIID_DRIVER_DEFINITION_ID_BASE + vdbName);
if (mDriver == null) {
createTeiidPreviewDriverInstance(driverPath, driverPath, username);
createTeiidPreviewDriverInstance(serverVersion, driverPath, driverPath, username);
} else {
// JBIDE-7493 Eclipse updates can break profiles because the driverPath is plugin version specific.
String jarList = mDriver.getJarList();
Expand All @@ -203,10 +208,11 @@ public static Properties createVDBTeiidProfileProperties(String driverPath,

storeJDBCPassword(connectionURL, password);

return createDriverProps(driverPath, connectionURL, username, vdbName);
return createDriverProps(serverVersion, driverPath, connectionURL, username, vdbName);
}

public static IConnectionProfile createVDBTeiidProfile( String driverPath,
public static IConnectionProfile createVDBTeiidProfile( ITeiidServerVersion serverVersion,
String driverPath,
String connectionURL,
String username,
String password,
Expand All @@ -216,7 +222,7 @@ public static IConnectionProfile createVDBTeiidProfile( String driverPath,
try {
DriverInstance mDriver = DriverManager.getInstance().getDriverInstanceByID(TEIID_PREVIEW_DRIVER_DEFINITION_ID);
if (mDriver == null) {
createTeiidPreviewDriverInstance(driverPath, connectionURL, username);
createTeiidPreviewDriverInstance(serverVersion, driverPath, connectionURL, username);
} else {
// JBIDE-7493 Eclipse updates can break profiles because the driverPath is plugin version specific.
String jarList = mDriver.getJarList();
Expand All @@ -234,7 +240,7 @@ public static IConnectionProfile createVDBTeiidProfile( String driverPath,

return pm.createProfile(profileName, "", //$NON-NLS-1$
TEIID_PROFILE_PROVIDER_ID,
createDriverProps(driverPath, connectionURL, username, vdbName));
createDriverProps(serverVersion, driverPath, connectionURL, username, vdbName));
} catch (ConnectionProfileException e) {
Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "error getting profile", e); //$NON-NLS-1$
throw new CoreException(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ private void internalRun( final EObject eObject,

// Note that this is a Transient profile, it is not visible in
// the UI and goes away when it is garbage collected.
IConnectionProfile profile = ConnectivityUtil.createTransientTeiidProfile(driverPath,
IConnectionProfile profile = ConnectivityUtil.createTransientTeiidProfile(defaultServer.getServerVersion(),
driverPath,
jdbcInfo.getUrl(),
jdbcInfo.getUsername(),
jdbcInfo.getPassword(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void processForDTP(ITeiidServer teiidServer, String vdbName)
|| null == jdbcInfo.getPassword()
|| jdbcInfo.getPassword().isEmpty()) {
Properties cpProps = ConnectivityUtil
.createVDBTeiidProfileProperties(driverPath,connectionURL, jdbcInfo.getUsername(),jdbcInfo.getPassword(), vdbName, profileName);
.createVDBTeiidProfileProperties(teiidServer.getServerVersion(), driverPath,connectionURL, jdbcInfo.getUsername(),jdbcInfo.getPassword(), vdbName, profileName);
NewTeiidFilteredCPWizard wiz = new NewTeiidFilteredCPWizard(profileName, null);
TeiidCPWizardDialog wizardDialog = new TeiidCPWizardDialog(Display.getCurrent().getActiveShell(), wiz);
wizardDialog.setProperties(cpProps);
Expand All @@ -172,9 +172,13 @@ public void processForDTP(ITeiidServer teiidServer, String vdbName)
}
// if we have all the info we create it w/o user interaction
} else {
profile = ConnectivityUtil.createVDBTeiidProfile(driverPath,
connectionURL, jdbcInfo.getUsername(),
jdbcInfo.getPassword(), vdbName, profileName);
profile = ConnectivityUtil.createVDBTeiidProfile(teiidServer.getServerVersion(),
driverPath,
connectionURL,
jdbcInfo.getUsername(),
jdbcInfo.getPassword(),
vdbName,
profileName);
}
}
IStatus connectionStatus = profile.connectWithoutJob();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface ITeiidServerVersion {

public static final String DOT = "."; //$NON-NLS-1$

public static final String WILDCARD = "*"; //$NON-NLS-1$
public static final String WILDCARD = "x"; //$NON-NLS-1$

public static final String ZERO = "0"; //$NON-NLS-1$

Expand Down
2 changes: 1 addition & 1 deletion plugins/teiid/org.teiid.7-7-2/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class="org.teiid772.runtime.ExecutionAdminFactory">
<version
major="7"
micro="*"
micro="x"
minor="7">
</version>
</runtimeFactory>
Expand Down
4 changes: 2 additions & 2 deletions plugins/teiid/org.teiid.8-2/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class="org.teiid82.runtime.ExecutionAdminFactory">
<version
major="8"
minor="*"
micro="*">
minor="x"
micro="x">
</version>
</runtimeFactory>
</extension>
Expand Down

0 comments on commit 0f9104a

Please sign in to comment.