Skip to content

Commit

Permalink
Fix issue Support a relative path to .jks file placed in Resources in
Browse files Browse the repository at this point in the history
iHub for .datadesign & rptdesign that using SSL connection to DS
  • Loading branch information
mwu authored and zhiqiangqian committed Jul 22, 2014
1 parent 4dd8177 commit 06c7f40
Show file tree
Hide file tree
Showing 17 changed files with 488 additions and 129 deletions.
Expand Up @@ -28,10 +28,10 @@
import org.eclipse.birt.report.data.oda.jdbc.ui.JdbcPlugin;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverInfo;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.IHelpConstants;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.JDBCDriverInformation;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.JarFile;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.JdbcToolKit;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.Utility;
import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInformation;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
Expand Down
Expand Up @@ -222,7 +222,7 @@ private void setDefaultPereferencesIfNeed( )

private void prepareJDBCMetaDataProvider( DataSetDesign dataSetDesign )
{
JdbcMetaDataProvider.createInstance( dataSetDesign );
JdbcMetaDataProvider.createInstance( dataSetDesign, this.getHostResourceIdentifiers( ) );

class TempThread extends Thread
{
Expand Down
Expand Up @@ -67,6 +67,7 @@ protected void createAndInitCustomControl( Composite parent,
m_pageHelper.addBidiSettingsButton( content, profileProps );
this.setPingButtonVisible( false );
m_pageHelper.initCustomControl( profileProps );
m_pageHelper.setResourceIdentifier( this.getHostResourceIdentifiers( ) );
}

/*
Expand Down
Expand Up @@ -29,14 +29,18 @@
import org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverLoader;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.ExceptionHandler;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.IHelpConstants;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.JDBCDriverInfoManager;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.JDBCDriverInformation;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.JdbcToolKit;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.PropertyElement;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.PropertyGroup;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.Utility;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.bidi.profile.BidiSettingsSupport;
import org.eclipse.birt.report.data.oda.jdbc.utils.DriverInfoConstants;
import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInfoManager;
import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInformation;
import org.eclipse.birt.report.data.oda.jdbc.utils.PropertyElement;
import org.eclipse.birt.report.data.oda.jdbc.utils.PropertyGroup;
import org.eclipse.birt.report.data.oda.jdbc.utils.ResourceLocator;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.design.ResourceIdentifiers;
import org.eclipse.datatools.connectivity.oda.design.ui.designsession.DesignSessionUtil;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.PreferencePage;
Expand Down Expand Up @@ -107,6 +111,7 @@ public class JDBCSelectionPageHelper
private final String ENCRYTPION_METHOD_DEFAULT_VALUE = "noEncryption"; //$NON-NLS-1$

private final String JDBC_EXTENSION_ID = "org.eclipse.birt.report.data.oda.jdbc"; //$NON-NLS-1$
private org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers resourceIdentifier;

JDBCSelectionPageHelper( WizardPage page )
{
Expand Down Expand Up @@ -152,7 +157,7 @@ Composite createCustomControl( Composite parent )
driverChooserCombo.getControl( ).setLayoutData( gridData );

List driverListTmp1 = JdbcToolKit.getJdbcDriversFromODADir( JDBC_EXTENSION_ID );
JDBCDriverInformation[] driverListTmp2 = JDBCDriverInfoManager.getDrivers( );
JDBCDriverInformation[] driverListTmp2 = JDBCDriverInfoManager.getInstance( ).getDriversInfo( );
List driverList = new ArrayList( );
for ( Object driverInfo : driverListTmp1 )
{
Expand Down Expand Up @@ -277,17 +282,17 @@ private void drawPropertyGroups( final JDBCDriverInformation info )
for ( int i = 0; i < propertyList.size( ); i++ )
{
final String propertyName = propertyList.get( i )
.getAttribute( Constants.DRIVER_INFO_PROPERTY_NAME );
.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_NAME );
Label propertyParam = new Label( propertyGroup,
SWT.NONE );
String propertyParamDisplayName = propertyList.get( i )
.getAttribute( Constants.DRIVER_INFO_PROPERTY_DISPLAYNAME );
.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_DISPLAYNAME );
if ( propertyParamDisplayName == null )
{
propertyParamDisplayName = propertyName;
}
propertyParam.setText( propertyParamDisplayName );
propertyParam.setToolTipText( propertyList.get( i ).getAttribute( Constants.DRIVER_INFO_PROPERTY_DEC ) );
propertyParam.setToolTipText( propertyList.get( i ).getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_DEC ) );
GridData gd = new GridData( );
gd.horizontalSpan = 2; // bidi_hcg
propertyParam.setLayoutData( gd );
Expand All @@ -299,8 +304,8 @@ private void drawPropertyGroups( final JDBCDriverInformation info )
propertyContent = getProfileproperty( propertyName );
}

if ( Constants.DRIVER_INFO_PROPERTY_TYPE_BOOLEN.equalsIgnoreCase( propertyList.get( i )
.getAttribute( Constants.DRIVER_INFO_PROPERTY_TYPE ) ) )
if ( DriverInfoConstants.DRIVER_INFO_PROPERTY_TYPE_BOOLEN.equalsIgnoreCase( propertyList.get( i )
.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_TYPE ) ) )
{
drawPropertyCombo( propertyGroup,
propertyName,
Expand All @@ -309,7 +314,7 @@ private void drawPropertyGroups( final JDBCDriverInformation info )
else
{
if ( Boolean.valueOf( propertyList.get( i )
.getAttribute( Constants.DRIVER_INFO_PROPERTY_ENCRYPT ) ) )
.getAttribute( DriverInfoConstants.DRIVER_INFO_PROPERTY_ENCRYPT ) ) )
{
drawPropertyText( propertyGroup,
propertyName,
Expand Down Expand Up @@ -340,7 +345,7 @@ private void drawPropertyText( Group propertyGroup,
propertyText = new Text( propertyGroup, SWT.BORDER );
}

boolean isEncryptionMethod = Constants.DRIVER_INFO_PROPERTY_ENCRYPTION_METHOD.equals( propertyName );
boolean isEncryptionMethod = DriverInfoConstants.DRIVER_INFO_PROPERTY_ENCRYPTION_METHOD.equals( propertyName );
if ( propertyContent != null )
{
propertyText.setText( propertyContent );
Expand Down Expand Up @@ -982,21 +987,29 @@ else if ( m_propertyPage instanceof JDBCPropertyPage )
bidiSupportObj = ( (JDBCPropertyPage) m_propertyPage ).getBidiSupport( );
}
}

Properties privateProperties = collectSpecifiedProperties( );
Map appContext = new HashMap( );
appContext.put( org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS, this.resourceIdentifier );
ResourceLocator.resolveConnectionProperties( privateProperties, driverName, appContext );

if ( bidiSupportObj != null )
{
return DriverLoader.testConnection( driverName,
url,
jndiNameValue,
userid,
passwd,
bidiSupportObj.getMetadataBidiFormat( ).toString( ),collectSpecifiedProperties( ) );
bidiSupportObj.getMetadataBidiFormat( ).toString( ),
privateProperties );
}

return DriverLoader.testConnection( driverName,
url,
jndiNameValue,
userid,
passwd,collectSpecifiedProperties( ) );
passwd,
privateProperties );
}

private Properties collectSpecifiedProperties( )
Expand Down Expand Up @@ -1239,4 +1252,11 @@ public void addBidiSettingsButton( Composite parent, Properties props )
bidiSupportObj.drawBidiSettingsButton( parent, props );
}

public void setResourceIdentifier( ResourceIdentifiers identifiers )
{
if ( identifiers != null )
{
this.resourceIdentifier = DesignSessionUtil.createRuntimeResourceIdentifiers( identifiers );
}
}
}
Expand Up @@ -55,7 +55,7 @@ public void createPageCustomControl( Composite parent )
m_pageHelper.initCustomControl( m_folderProperties ); // in case init was called before create
//bidi_hcg: add "Bidi Settings..." button to "Edit Data Source dialog"
m_pageHelper.addBidiSettingsButton( content, m_folderProperties );

m_pageHelper.setResourceIdentifier( this.getHostResourceIdentifiers( ) );
this.setPingButtonVisible( false );
}

Expand Down
Expand Up @@ -17,7 +17,9 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -26,9 +28,11 @@
import org.eclipse.birt.report.data.bidi.utils.core.BidiTransform;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.Constants;
import org.eclipse.birt.report.data.oda.jdbc.ui.util.DriverLoader;
import org.eclipse.birt.report.data.oda.jdbc.utils.ResourceLocator;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.design.DataSetDesign;
import org.eclipse.datatools.connectivity.oda.design.DataSourceDesign;
import org.eclipse.datatools.connectivity.oda.design.ResourceIdentifiers;
import org.eclipse.datatools.connectivity.oda.design.ui.designsession.DesignSessionUtil;

public class JdbcMetaDataProvider
Expand Down Expand Up @@ -69,7 +73,7 @@ private JdbcMetaDataProvider(String driverClass, String url, String userName, St
this.props = props;
}

public static void createInstance( DataSetDesign dataSetDesign )
public static void createInstance( DataSetDesign dataSetDesign, ResourceIdentifiers resourceIdentifiers )
{
release( );
DataSourceDesign dataSourceDesign = dataSetDesign.getDataSourceDesign( );
Expand All @@ -88,6 +92,20 @@ public static void createInstance( DataSetDesign dataSetDesign )
String url = props.getProperty( Constants.ODAURL );
String driverClass = props.getProperty( Constants.ODADriverClass );

Map appContext = new HashMap( );
if ( resourceIdentifiers != null )
{
appContext.put( org.eclipse.datatools.connectivity.oda.util.ResourceIdentifiers.ODA_APP_CONTEXT_KEY_CONSUMER_RESOURCE_IDS,
DesignSessionUtil.createRuntimeResourceIdentifiers( resourceIdentifiers ) );
}
try
{
ResourceLocator.resolveConnectionProperties( props, driverClass, appContext );
}
catch ( OdaException e )
{
}

//bidi_hcg: if Bidi format is defined - perform required Bidi transformations
String metadataBidiFormatStr = props.getProperty(BidiConstants.METADATA_FORMAT_PROP_NAME);
if (metadataBidiFormatStr != null){
Expand Down
Expand Up @@ -14,19 +14,4 @@ public class Constants
org.eclipse.birt.report.data.oda.jdbc.Connection.Constants.ODAJndiName;
public static final String ODAResourceIdentiers =
org.eclipse.birt.report.data.oda.jdbc.Connection.Constants.ODAResourceIdentiers;

public static final String DRIVER_INFO_PROPERTY_GROUP = "propertyGroup";
public static final String DRIVER_INFO_PROPERTY_GROUP_NAME = "displayName";
public static final String DRIVER_INFO_PROPERTY_GROUP_DEC = "description";
public static final String DRIVER_INFO_PROPERTY_ENCRYPTION_METHOD = "EncryptionMethod";

public static final String DRIVER_INFO_PROPERTY = "property";
public static final String DRIVER_INFO_PROPERTY_NAME = "propertyName";
public static final String DRIVER_INFO_PROPERTY_DISPLAYNAME = "displayName";
public static final String DRIVER_INFO_PROPERTY_DEC = "description";
public static final String DRIVER_INFO_PROPERTY_ENCRYPT= "encrypt";
public static final String DRIVER_INFO_PROPERTY_TYPE= "type";
public static final String DRIVER_INFO_PROPERTY_TYPE_BOOLEN= "boolean";
public static final String DRIVER_INFO_PROPERTY_TYPE_STRING= "string";
public static final String DRIVER_INFO_PROPERTY_TYPE_NUMBER= "number";
}

This file was deleted.

Expand Up @@ -31,6 +31,8 @@

import org.eclipse.birt.report.data.oda.jdbc.ui.JdbcPlugin;
import org.eclipse.birt.report.data.oda.jdbc.ui.dialogs.JdbcDriverManagerDialog;
import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInfoManager;
import org.eclipse.birt.report.data.oda.jdbc.utils.JDBCDriverInformation;
import org.eclipse.ui.PlatformUI;

public class JdbcToolKit
Expand Down Expand Up @@ -132,7 +134,7 @@ public synchronized static List getJdbcDriversFromODADir( String driverName )
JDBCDriverInformation ODBCJDBCInfo = null;

// Merge drivers from the driverInfo extension point
JDBCDriverInformation driverInfos[] = JDBCDriverInfoManager.getDrivers();
JDBCDriverInformation driverInfos[] = JDBCDriverInfoManager.getInstance( ).getDriversInfo( );
for (int i = 0; i < driverInfos.length; i++)
{
JDBCDriverInformation newInfo = driverInfos[i];
Expand Down
Expand Up @@ -147,7 +147,7 @@ The extension class must implement interface org.eclipse.birt.report.data.oda.jd
<attribute name="type">
<annotation>
<documentation>
The type of property. It should be boolean, number or string. string is its default value.
The type of property. It should be boolean, number, resource or string. string is its default value. If it is resource, it means it will locate to file path.
</documentation>
</annotation>
<simpleType>
Expand All @@ -158,6 +158,8 @@ The extension class must implement interface org.eclipse.birt.report.data.oda.jd
</enumeration>
<enumeration value="string">
</enumeration>
<enumeration value="resource">
</enumeration>
</restriction>
</simpleType>
</attribute>
Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.birt.report.data.oda.i18n.ResourceConstants;
import org.eclipse.birt.report.data.oda.jdbc.bidi.BidiCallStatement;
import org.eclipse.birt.report.data.oda.jdbc.bidi.BidiStatement;
import org.eclipse.birt.report.data.oda.jdbc.utils.ResourceLocator;
import org.eclipse.datatools.connectivity.oda.IConnection;
import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
import org.eclipse.datatools.connectivity.oda.IQuery;
Expand Down Expand Up @@ -210,6 +211,7 @@ protected void connectByUrl( String url, Properties connProperties )
String driverClass = connProperties.getProperty( Constants.ODADriverClass );
String jndiNameUrl = connProperties.getProperty( Constants.ODAJndiName );

ResourceLocator.resolveConnectionProperties( props, driverClass, this.appContext );
try
{
if ( ( jndiNameUrl == null || jndiNameUrl.trim( ).length( ) == 0 )
Expand Down
@@ -0,0 +1,21 @@
package org.eclipse.birt.report.data.oda.jdbc.utils;


public class DriverInfoConstants
{
public static final String DRIVER_INFO_PROPERTY_GROUP = "propertyGroup";
public static final String DRIVER_INFO_PROPERTY_GROUP_NAME = "displayName";
public static final String DRIVER_INFO_PROPERTY_GROUP_DEC = "description";
public static final String DRIVER_INFO_PROPERTY_ENCRYPTION_METHOD = "EncryptionMethod";

public static final String DRIVER_INFO_PROPERTY = "property";
public static final String DRIVER_INFO_PROPERTY_NAME = "propertyName";
public static final String DRIVER_INFO_PROPERTY_DISPLAYNAME = "displayName";
public static final String DRIVER_INFO_PROPERTY_DEC = "description";
public static final String DRIVER_INFO_PROPERTY_ENCRYPT= "encrypt";
public static final String DRIVER_INFO_PROPERTY_TYPE= "type";
public static final String DRIVER_INFO_PROPERTY_TYPE_BOOLEN= "boolean";
public static final String DRIVER_INFO_PROPERTY_TYPE_STRING= "string";
public static final String DRIVER_INFO_PROPERTY_TYPE_NUMBER= "number";
public static final String DRIVER_INFO_PROPERTY_TYPE_RESOURCE= "resource";
}

0 comments on commit 06c7f40

Please sign in to comment.