[204343] Profiles loaded from a profile store file for UI Selection are no longer added to ProfileManager cache
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/META-INF/MANIFEST.MF
index 534e2be..20dbca3 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.datatools.connectivity.oda.design.ui; singleton:=true
-Bundle-Version: 3.0.6.200801101
+Bundle-Version: 3.0.6.200801141
Bundle-Vendor: Eclipse.org
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/designsession/DataSourceDesignSessionBase.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/designsession/DataSourceDesignSessionBase.java
index e3c369f..52cab3a 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/designsession/DataSourceDesignSessionBase.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/designsession/DataSourceDesignSessionBase.java
@@ -1,6 +1,6 @@
/*
*************************************************************************
- * Copyright (c) 2006, 2007 Actuate Corporation.
+ * Copyright (c) 2006, 2008 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -671,7 +671,7 @@
DataSourceEditorPage editorPage = null;
try
{
- editorPage = getExtendedEditorPage();
+ editorPage = getAdaptableEditorPage();
}
catch( OdaException ex )
{
@@ -833,8 +833,23 @@
private OdaConnectionProfile getInstanceById()
{
- return (OdaConnectionProfile) OdaProfileExplorer.getInstance().
- getProfile( m_instanceId );
+ OdaConnectionProfile profileInstance = null;
+ try
+ {
+ profileInstance =
+ (OdaConnectionProfile) OdaProfileExplorer.getInstance()
+ .getProfileById( m_instanceId, m_storageFile );
+ }
+ catch( OdaException ex )
+ {
+ // log as warning
+ ex.printStackTrace();
+ DesignerLogger logger = DesignerLogger.getInstance();
+ logger.warning( sm_className, "ProfileReferenceBase.getInstanceById", //$NON-NLS-1$
+ "Caught exception while getting an instance of connection profile by id (" + //$NON-NLS-1$
+ m_instanceId + ") from " + m_storageFile + " .", ex ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return profileInstance;
}
private OdaConnectionProfile getInstanceByName()
@@ -843,15 +858,15 @@
try
{
profileInstance =
- (OdaConnectionProfile) OdaProfileExplorer.getInstance().getProfileByName(
- m_instanceName, m_storageFile ); // use default store if null is specified
+ (OdaConnectionProfile) OdaProfileExplorer.getInstance()
+ .getProfileByName( m_instanceName, m_storageFile ); // use default store if null is specified
}
catch( OdaException ex )
{
// log as warning
ex.printStackTrace();
DesignerLogger logger = DesignerLogger.getInstance();
- logger.warning( sm_className, "getInstanceByName", //$NON-NLS-1$
+ logger.warning( sm_className, "ProfileReferenceBase.getInstanceByName", //$NON-NLS-1$
"Caught exception while getting an instance of connection profile by name (" + //$NON-NLS-1$
m_instanceName + ") from " + m_storageFile + " .", ex ); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/OdaProfileUIExplorer.java b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/OdaProfileUIExplorer.java
index 2a56393..0fdb850 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/OdaProfileUIExplorer.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.design.ui/src/org/eclipse/datatools/connectivity/oda/design/internal/ui/OdaProfileUIExplorer.java
@@ -1,6 +1,6 @@
/*
*************************************************************************
- * Copyright (c) 2006 Actuate Corporation.
+ * Copyright (c) 2006, 2008 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,8 +14,11 @@
package org.eclipse.datatools.connectivity.oda.design.internal.ui;
+import java.io.File;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.internal.ui.ConnectionProfileManagerUI;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.design.ui.manifest.DataSetUIElement;
@@ -58,6 +61,7 @@
* @return the ODA custom wizard, or null if no wizard is provided
* @throws OdaException if the profile provider has not implemented
* the expected Oda wizard type
+ * @deprecated As of DTP 1.6, replaced by {@link #getNewDataSourceWizard(String, File)}
*/
public NewDataSourceWizard getNewDataSourceWizard( String profileInstanceId )
throws OdaException
@@ -72,6 +76,34 @@
* Returns the ODA custom wizard provided by an
* ODA data source designer that implements the
* connection profile extension point.
+ * @param profileInstanceId the instance id of a connection profile
+ * @param storageFile a file that stores profile instances;
+ * may be null, which would use the default store
+ * of the Connectivity plugin
+ * @return the ODA custom wizard, or null if no wizard is provided
+ * @throws OdaException if the specified profile is not found, or
+ * if the profile provider has not implemented
+ * the expected ODA wizard
+ * @since DTP 1.6
+ */
+ public NewDataSourceWizard getNewDataSourceWizard( String profileInstanceId,
+ File storageFile )
+ throws OdaException
+ {
+ IConnectionProfile profile =
+ OdaProfileExplorer.getInstance().getProfileById( profileInstanceId, storageFile );
+ if( profile == null )
+ throw new OdaException( new IllegalArgumentException( profileInstanceId ) );
+
+ // ODA profiles use the odaDataSourceId as its profile identifier
+ String odaDataSourceId = profile.getProviderId();
+ return getNewDataSourceWizardByType( odaDataSourceId );
+ }
+
+ /**
+ * Returns the ODA custom wizard provided by an
+ * ODA data source designer that implements the
+ * connection profile extension point.
* @param odaDataSourceId the ODA runtime data source element id
* @return the ODA custom wizard, or null if no wizard is provided
* @throws OdaException if the profile provider has not implemented
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.profile/META-INF/MANIFEST.MF b/plugins/org.eclipse.datatools.connectivity.oda.profile/META-INF/MANIFEST.MF
index 753f9b5..5cbd259 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.profile/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.datatools.connectivity.oda.profile/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.datatools.connectivity.oda.profile;singleton:=true
-Bundle-Version: 3.0.6.200801021
+Bundle-Version: 3.0.6.200801141
Bundle-Vendor: Eclipse.org
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/OdaProfileExplorer.java b/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/OdaProfileExplorer.java
index e3edd77..e2471f9 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/OdaProfileExplorer.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda.profile/src/org/eclipse/datatools/connectivity/oda/profile/OdaProfileExplorer.java
@@ -1,6 +1,6 @@
/*
*************************************************************************
- * Copyright (c) 2005, 2007 Actuate Corporation.
+ * Copyright (c) 2005, 2008 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -169,23 +169,20 @@
}
/**
- * Returns a collection of identifiers of all connection profile
- * instances of a given ODA data source extension type.
- * The profile instances are searched in the given profile storage file.
- * It also caches the matching profiles and saves in the
- * current profile storage file for subsequent use.
+ * Returns a collection of identifiers of all connection profile instances
+ * of the given ODA data source extension type.
+ * The profile instances are searched from the specified profile storage file.
* @param odaDataSourceId the unique id of the data source element
* in an ODA data source extension.
* @param storageFile a file that stores profile instances; may be null, which
- * will use the default store of the Connectivity plugin
+ * will use the default store path of the Connectivity plugin
* @return a <code>Map</code> containing the instance Id
* and display name of all existing profiles of given odaDataSourceId.
* The connection profiles' instance Id and display name
* are stored as the key and value strings in the returned <code>Map</code> instance.
* Returns an empty collection if there are
* no matching connection profiles found in specified store.
- * @throws OdaException if unable to read from given storageFile,
- * or to cache the found profiles
+ * @throws OdaException if unable to read from the given storageFile
* @since DTP 1.6
*/
public Map getProfileIdentifiersByOdaProviderId( String odaDataSourceId, File storageFile )
@@ -195,22 +192,19 @@
}
/**
- * Returns a collection of identifiers of all connection profile
- * instances under the specified profile category id.
- * The profile instances are searched in the given profile storage file.
- * It also caches the matching profiles and saves in the
- * current profile storage file for subsequent use.
+ * Returns a collection of identifiers of all connection profile instances
+ * under the specified profile category id.
+ * The profile instances are searched from the specified profile storage file.
* @param categoryId the unique id of a connection profile category
* @param storageFile a file that stores profile instances; may be null, which
- * will use the default store of the Connectivity plugin
+ * will use the default store path of the Connectivity plugin
* @return a <code>Map</code> containing the instance Id
* and display name of all existing profiles of given odaDataSourceId.
* The connection profiles' instance Id and display name
* are stored as the key and value strings in the returned <code>Map</code> instance.
* Returns an empty collection if there are
* no matching connection profiles found in specified store.
- * @throws OdaException if unable to read from given storageFile,
- * or to cache the found profiles
+ * @throws OdaException if unable to read from the given storageFile
* @since DTP 1.6
*/
public Map getProfileIdentifiersByCategory( String categoryId, File storageFile )
@@ -224,10 +218,7 @@
throws OdaException
{
// first get all profiles found in given storage file, load the file if necessary
- IConnectionProfile[] profilesInFile = getLoadedProfiles( storageFile );
- final boolean isNotCached = ( profilesInFile == null );
- if( isNotCached )
- profilesInFile = loadProfiles( storageFile );
+ IConnectionProfile[] profilesInFile = loadProfiles( storageFile );
// return those profile ids that match given oda data source type,
// and add them in the ProfileManager's profiles cache
@@ -252,11 +243,9 @@
continue;
// found a profile for the specified category or odaDataSourceId,
- // adds matched profile to the identifiers Map and to ProfileManager's profiles cache
+ // adds matched profile found in storageFile to the identifiers Map
addProfileIdentifier( aProfile, profileIds );
- if( isNotCached )
- addToProfileManagerCache( aProfile );
}
return profileIds;
@@ -346,7 +335,9 @@
/*
* Adds given profile to ProfileManager's profiles cache, so that it can find
- * the profile by its instance id.
+ * the profile by its instance id.
+ * This has the side effect in which the added profile instance shows up
+ * in DSE automatically.
*/
private void addToProfileManagerCache( IConnectionProfile profile )
throws OdaException
@@ -368,6 +359,7 @@
* @param profileInstanceId the instance id of a connection profile
* @return the properties of a connection profile instance
* @throws IllegalArgumentException if instance is not found.
+ * @deprecated As of DTP 1.6, replaced by {@link #getProfileProperties(String, File)}
*/
public Properties getProfileProperties( String profileInstanceId )
{
@@ -376,12 +368,43 @@
}
/**
- * Returns the profile in cache with given instance id.
+ * Returns the profile properties with values collected
+ * in the specified connection profile instance in the storageFile.
+ * @param profileInstanceId the unique static id of
+ * a connection profile instance
+ * @param storageFile a file that stores profile instances;
+ * may be null, which would use the default store
+ * of the Connectivity plugin
+ * @return the properties of a connection profile instance
+ * @throws IllegalArgumentException if connection profile instance is not found.
+ * @since DTP 1.6
+ */
+ public Properties getProfileProperties( String profileInstanceId,
+ File storageFile )
+ {
+ IConnectionProfile profile = null;
+ try
+ {
+ profile = getProfileById( profileInstanceId, storageFile );
+ }
+ catch( OdaException ex )
+ {
+ throw new IllegalArgumentException( ex.toString() );
+ }
+ if( profile == null )
+ throw new IllegalArgumentException( profileInstanceId );
+
+ return profile.getBaseProperties();
+ }
+
+ /**
+ * Returns the profile with given instance id found in ProfileManager cache.
* @param profileInstanceId the unique instance id of a profile
* in cache, as found in the collection
* returned by the getProfiles methods
* @return the instance of matching profile
* @throws IllegalArgumentException if instance is not found.
+ * @deprecated As of DTP 1.6, replaced by {@link #getProfileById(String, File)}
*/
public IConnectionProfile getProfile( String profileInstanceId )
{
@@ -394,9 +417,37 @@
/**
* Finds and returns the profile instance in given storage file
+ * that matches the given profile's static instance id.
+ * @param profileInstanceId the unique static id of
+ * a connection profile instance
+ * @param storageFile a file that stores profile instances;
+ * may be null, which would use the default store
+ * of the Connectivity plugin
+ * @return the matching profile instance, or null if not found
+ * @since DTP 1.6
+ */
+ public IConnectionProfile getProfileById( String profileInstanceId,
+ File storageFile )
+ throws OdaException
+ {
+ // first load all profiles found in given storage file, if necessary
+ IConnectionProfile[] profilesInFile = loadProfiles( storageFile );
+
+ for( int i = 0; i < profilesInFile.length; i++ )
+ {
+ if( profilesInFile[i].getInstanceID().equals( profileInstanceId ) )
+ return createOdaWrapper( profilesInFile[i] ); // a match
+ }
+ return null; // no match is found
+ }
+
+ /**
+ * Finds and returns the profile instance in given storage file
* that matches the given profile instance name.
* @param profileName The unique name of a connection profile instance.
- * @param storageFile a file that stores profile instances
+ * @param storageFile a file that stores profile instances;
+ * may be null, which would use the default store
+ * of the Connectivity plugin
* @return the matching profile instance, or null if not found
*/
public IConnectionProfile getProfileByName( String profileName,
diff --git a/tests/org.eclipse.datatools.connectivity.oda.profile.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/META-INF/MANIFEST.MF
index b30edc2..fa47c01 100644
--- a/tests/org.eclipse.datatools.connectivity.oda.profile.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/META-INF/MANIFEST.MF
@@ -2,10 +2,10 @@
Bundle-ManifestVersion: 2
Bundle-Name: DTP ODA Profile Tests Suite
Bundle-SymbolicName: org.eclipse.datatools.connectivity.oda.profile.tests
-Bundle-Version: 3.0.4.200702081
+Bundle-Version: 3.0.6.200801141
Bundle-Localization: plugin
Require-Bundle: org.junit;bundle-version="[3.8.1,4.0.0)",
- org.eclipse.datatools.connectivity.oda.profile;bundle-version="[3.0.4,4.0.0)",
+ org.eclipse.datatools.connectivity.oda.profile;bundle-version="[3.0.6,4.0.0)",
org.eclipse.datatools.connectivity.oda.consumer;bundle-version="[3.0.4,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)"
Bundle-Vendor: Eclipse.org
diff --git a/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ProfileExplorerPluginTest.java b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ProfileExplorerPluginTest.java
index d800f89..13e476c 100644
--- a/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ProfileExplorerPluginTest.java
+++ b/tests/org.eclipse.datatools.connectivity.oda.profile.tests/src/org/eclipse/datatools/connectivity/oda/profile/tests/ProfileExplorerPluginTest.java
@@ -1,6 +1,6 @@
/*
*************************************************************************
- * Copyright (c) 2005, 2007 Actuate Corporation.
+ * Copyright (c) 2005, 2008 Actuate Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,6 +24,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.internal.ConnectionProfileMgmt;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.profile.OdaProfileExplorer;
@@ -52,7 +53,9 @@
if( m_testStoreLocation == null )
m_testStoreLocation = new Path( TestUtil.getPluginTestDirectory() );
- ConnectionProfileMgmt.setStorageLocation( m_testStoreLocation );
+
+ if ( getName().equals( "testGetProfiles" ) )
+ ConnectionProfileMgmt.setStorageLocation( m_testStoreLocation );
if ( getName().equals( "testGetProfilesFromFile" ) )
m_testFileStore = TestUtil.copyTestStoreFileFromTemplate(
@@ -80,7 +83,9 @@
Map profiles = null;
try
{
- profiles = m_profileExplorer.getProfiles( OdaFlatFileId );
+ // use profile store in path specified in setup by ConnectionProfileMgmt.setStorageLocation
+ profiles = m_profileExplorer.getProfileIdentifiersByOdaProviderId(
+ OdaFlatFileId, null );
}
catch( OdaException e )
{
@@ -100,7 +105,8 @@
Map profiles;
try
{
- profiles = m_profileExplorer.getProfiles( OdaFlatFileId, storeFilePath );
+ profiles = m_profileExplorer.getProfileIdentifiersByOdaProviderId(
+ OdaFlatFileId, storeFilePath );
}
catch( OdaException e )
{
@@ -116,7 +122,8 @@
public void testGetProfileProperties() throws Exception
{
String profileInstId = getFlatFileProfileInstanceId();
- Properties connProps = m_profileExplorer.getProfileProperties( profileInstId );
+ Properties connProps = m_profileExplorer.getProfileProperties(
+ profileInstId, m_testFileStore );
assertNotNull( connProps );
// FlatFile has 5 custom properties
assertEquals( 5, connProps.size() );
@@ -129,13 +136,16 @@
{
// test that either approach finds the same profile instance
String profileInstId = getFlatFileProfileInstanceId( FlatFileProfileName );
- String profileInstName = m_profileExplorer.getProfile( profileInstId ).getName();
- assertEquals( m_profileExplorer.getProfile( profileInstId ),
- m_profileExplorer.getProfileByName( profileInstName, m_testFileStore ) );
+ IConnectionProfile profile =
+ m_profileExplorer.getProfileById( profileInstId, m_testFileStore );
+ String profileInstName = profile.getName();
+ IConnectionProfile namedProfile =
+ m_profileExplorer.getProfileByName( profileInstName, m_testFileStore );
+ assertEquals( profile.getInstanceID(), namedProfile.getInstanceID() );
}
/*
- * TODO - move to oda.design.ui.profile.wizards
+ * TODO - move to oda.design.ui.profile.wizards tests
*/
/* public void testGetCustomWizard() throws Exception
{
@@ -152,7 +162,8 @@
private String getFlatFileProfileInstanceId( String profileName ) throws OdaException
{
- Map profiles = m_profileExplorer.getProfiles( OdaFlatFileId );
+ Map profiles = m_profileExplorer.getProfileIdentifiersByOdaProviderId(
+ OdaFlatFileId, m_testFileStore );
Collection profileInstanceIds = profiles.keySet();
assertNotNull( profileInstanceIds );
assertTrue( profileInstanceIds.size() > 0 );
@@ -161,7 +172,8 @@
while( iter.hasNext() )
{
String instanceId = (String) iter.next();
- if( OdaFlatFileId.equals( m_profileExplorer.getProfile( instanceId ).getProviderId() ))
+ if( OdaFlatFileId.equals( m_profileExplorer.getProfileById(
+ instanceId, m_testFileStore ).getProviderId() ))
{
assertEquals( profileName, (String) profiles.get( instanceId ) );
return instanceId;