Commit 5997607e authored by Aurelien Pupier's avatar Aurelien Pupier

TAL-12: Support of pacthed plugins without some dependencies

parent 19131dbe
......@@ -6,3 +6,4 @@ Bundle-Version: 6.5.3.qualifier
Bundle-Vendor: BonitaSoft S.A.
Fragment-Host: org.bonitasoft.studio.connectors;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.bonitasoft.studio.connectors.database.drivers
......@@ -28,80 +28,56 @@ import org.bonitasoft.studio.common.repository.model.IRepositoryStore;
import org.bonitasoft.studio.connectors.ConnectorPlugin;
import org.bonitasoft.studio.connectors.repository.DatabaseConnectorPropertiesFileStore;
import org.bonitasoft.studio.connectors.repository.DatabaseConnectorPropertiesRepositoryStore;
import org.bonitasoft.studio.connectors.util.DriverConstants;
public class DriversAssociationFileStoreContribution implements
IFileStoreContribution {
private static final String GENERIC_DEFINITION_ID = "database-jdbc";
private static final String MYSQL_DEFINITION_ID = "database-mysql";
private static final String MYSQL_DRIVER_JARNAME = "mysql-connector-java-5.1.23-bin.jar";
private static final String POSTGRES_DEFINITION_84_ID = "database-postgresql84";
private static final String POSTGRES_DEFINITION_ID = "database-postgresql92";
private static final String POSTGRES_DRIVER_JARNAME = "postgresql-9.2-1002.jdbc4.jar";
private static final String SQLSERVER_2008_DEFINITION_ID = "database-mssqlserver2008";
private static final String SQLSERVER_DRIVER_JARNAME = "sqljdbc4.jar";
private static final String SQLSERVER_2012_DEFINITION_ID = "database-mssqlserver2012";
private static final String ORACLE_11G_DEFINITION_ID = "database-oracle11g";
private static final String ORACLE_10G_DEFINITION_ID = "database-oracle10g";
private static final String ORACLE_DRIVER_JARNAME = "ojdbc6.jar";
private static final String H2_DEFINITION_ID = "database-h2";
private static final String H2_DRIVER_JARNAME = "h2-1.3.170.jar";
private static final String HSQLDB_DEFINITION_ID = "database-hsqldb";
private static final String HSQLDB_DRIVER_JARNAME = "hsqldb.jar";
@Override
public boolean appliesTo(
IRepositoryStore<? extends IRepositoryFileStore> repository) {
public boolean appliesTo(
final IRepositoryStore<? extends IRepositoryFileStore> repository) {
return repository instanceof DatabaseConnectorPropertiesRepositoryStore;
}
@Override
public void execute(IRepositoryStore<? extends IRepositoryFileStore> repository) {
createDatabaseDriverAssociation(repository,MYSQL_DEFINITION_ID,MYSQL_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, POSTGRES_DEFINITION_ID, POSTGRES_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, POSTGRES_DEFINITION_84_ID, POSTGRES_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, SQLSERVER_2008_DEFINITION_ID, SQLSERVER_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, SQLSERVER_2012_DEFINITION_ID, SQLSERVER_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, ORACLE_11G_DEFINITION_ID, ORACLE_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, ORACLE_10G_DEFINITION_ID, ORACLE_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, H2_DEFINITION_ID, H2_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, HSQLDB_DEFINITION_ID, HSQLDB_DRIVER_JARNAME);
public void execute(final IRepositoryStore<? extends IRepositoryFileStore> repository) {
createDatabaseDriverAssociation(repository, DriverConstants.MYSQL_DEFINITION_ID, DriverConstants.MYSQL_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, DriverConstants.POSTGRES_DEFINITION_ID, DriverConstants.POSTGRES_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, DriverConstants.POSTGRES_DEFINITION_84_ID, DriverConstants.POSTGRES_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, DriverConstants.SQLSERVER_2008_DEFINITION_ID, DriverConstants.SQLSERVER_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, DriverConstants.SQLSERVER_2012_DEFINITION_ID, DriverConstants.SQLSERVER_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, DriverConstants.ORACLE_11G_DEFINITION_ID, DriverConstants.ORACLE_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, DriverConstants.ORACLE_10G_DEFINITION_ID, DriverConstants.ORACLE_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, DriverConstants.H2_DEFINITION_ID, DriverConstants.H2_DRIVER_JARNAME);
createDatabaseDriverAssociation(repository, DriverConstants.HSQLDB_DEFINITION_ID, DriverConstants.HSQLDB_DRIVER_JARNAME);
createGenericDriverList(repository);
}
private void createGenericDriverList(
IRepositoryStore<? extends IRepositoryFileStore> repository) {
Enumeration<URL> drivers = ConnectorPlugin.getDefault().getBundle().findEntries("drivers", "*.jar", false) ;
final List<String> jarList = new ArrayList<String>();
while(drivers.hasMoreElements()){
URL url = drivers.nextElement() ;
String file = url.getFile() ;
String[] segments = file.split("/") ;
String name = segments[segments.length -1] ;
jarList.add(name);
}
DatabaseConnectorPropertiesFileStore file = (DatabaseConnectorPropertiesFileStore) repository.createRepositoryFileStore(GENERIC_DEFINITION_ID);
file.setAutoAddDriver(false);
file.setJarList(jarList);
private void createGenericDriverList(final IRepositoryStore<? extends IRepositoryFileStore> repository) {
final Enumeration<URL> drivers = ConnectorPlugin.getDefault().getBundle().findEntries("drivers", "*.jar", false);
final List<String> jarList = new ArrayList<String>();
while (drivers.hasMoreElements()) {
final URL url = drivers.nextElement();
final String file = url.getFile();
final String[] segments = file.split("/");
final String name = segments[segments.length - 1];
jarList.add(name);
}
final DatabaseConnectorPropertiesFileStore file = (DatabaseConnectorPropertiesFileStore) repository
.createRepositoryFileStore(DriverConstants.GENERIC_DEFINITION_ID);
file.setAutoAddDriver(false);
file.setJarList(jarList);
}
private void createDatabaseDriverAssociation(IRepositoryStore<? extends IRepositoryFileStore> repository, String definitionId, String driverJarname) {
DatabaseConnectorPropertiesFileStore file = (DatabaseConnectorPropertiesFileStore) repository.createRepositoryFileStore(definitionId);
file.setAutoAddDriver(true);
file.setDefault(driverJarname);
file.setJarList(Collections.singletonList(driverJarname));
private void createDatabaseDriverAssociation(final IRepositoryStore<? extends IRepositoryFileStore> repository, final String definitionId, final String driverJarname) {
final Enumeration<URL> drivers = ConnectorPlugin.getDefault().getBundle().findEntries("drivers", driverJarname, false);
if (drivers != null && drivers.hasMoreElements()) {
final DatabaseConnectorPropertiesFileStore file = (DatabaseConnectorPropertiesFileStore) repository.createRepositoryFileStore(definitionId);
file.setAutoAddDriver(true);
file.setDefault(driverJarname);
file.setJarList(Collections.singletonList(driverJarname));
}
}
}
......@@ -38,16 +38,19 @@ Require-Bundle: org.eclipse.ui,
org.bonitasoft.studio.diagram.custom
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.connectors,org.bonitasoft.studio
.connectors.configuration,org.bonitasoft.studio.connectors.expression
,org.bonitasoft.studio.connectors.extension,org.bonitasoft.studio.con
nectors.i18n;x-friends:="org.bonitasoft.studio.tests.ex,org.bonitasof
t.studio.connectors.test",org.bonitasoft.studio.connectors.operation,
org.bonitasoft.studio.connectors.repository,org.bonitasoft.studio.con
nectors.ui.property.section,org.bonitasoft.studio.connectors.ui.provi
der,org.bonitasoft.studio.connectors.ui.wizard,org.bonitasoft.studio.
connectors.ui.wizard.page,org.bonitasoft.studio.connectors.ui.wizard.
page.sqlutil
Export-Package: org.bonitasoft.studio.connectors,
org.bonitasoft.studio.connectors.configuration,
org.bonitasoft.studio.connectors.expression,
org.bonitasoft.studio.connectors.extension,
org.bonitasoft.studio.connectors.i18n;x-friends:="org.bonitasoft.studio.tests.ex,org.bonitasoft.studio.connectors.test",
org.bonitasoft.studio.connectors.operation,
org.bonitasoft.studio.connectors.repository,
org.bonitasoft.studio.connectors.ui.property.section,
org.bonitasoft.studio.connectors.ui.provider,
org.bonitasoft.studio.connectors.ui.wizard,
org.bonitasoft.studio.connectors.ui.wizard.page,
org.bonitasoft.studio.connectors.ui.wizard.page.sqlutil,
org.bonitasoft.studio.connectors.util
Import-Package: org.bonitasoft.engine.api,
org.bonitasoft.engine.bpm,
org.bonitasoft.engine.bpm.bar,
......
/**
* Copyright (C) 2015 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.connectors.util;
public interface DriverConstants {
public static final String GENERIC_DEFINITION_ID = "database-jdbc";
public static final String MYSQL_DEFINITION_ID = "database-mysql";
public static final String MYSQL_DRIVER_JARNAME = "mysql-connector-java-5.1.23-bin.jar";
public static final String POSTGRES_DEFINITION_84_ID = "database-postgresql84";
public static final String POSTGRES_DEFINITION_ID = "database-postgresql92";
public static final String POSTGRES_DRIVER_JARNAME = "postgresql-9.2-1002.jdbc4.jar";
public static final String SQLSERVER_2008_DEFINITION_ID = "database-mssqlserver2008";
public static final String SQLSERVER_DRIVER_JARNAME = "sqljdbc4.jar";
public static final String SQLSERVER_2012_DEFINITION_ID = "database-mssqlserver2012";
public static final String ORACLE_11G_DEFINITION_ID = "database-oracle11g";
public static final String ORACLE_10G_DEFINITION_ID = "database-oracle10g";
public static final String ORACLE_DRIVER_JARNAME = "ojdbc6.jar";
public static final String H2_DEFINITION_ID = "database-h2";
public static final String H2_DRIVER_JARNAME = "h2-1.3.170.jar";
public static final String HSQLDB_DEFINITION_ID = "database-hsqldb";
public static final String HSQLDB_DRIVER_JARNAME = "hsqldb.jar";
}
/**
* Copyright (C) 2015 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.connectors.test;
import static org.assertj.core.api.Assertions.assertThat;
import java.net.URL;
import java.util.Enumeration;
import org.bonitasoft.studio.connectors.ConnectorPlugin;
import org.bonitasoft.studio.connectors.util.DriverConstants;
import org.junit.Test;
public class DriverAssociationContributionIT {
@Test
public void testProvidedJarsWithCorrectName() {
final String[] drivers = new String[] { DriverConstants.MYSQL_DRIVER_JARNAME,
DriverConstants.POSTGRES_DRIVER_JARNAME,
DriverConstants.SQLSERVER_DRIVER_JARNAME,
DriverConstants.ORACLE_DRIVER_JARNAME,
DriverConstants.H2_DRIVER_JARNAME,
DriverConstants.HSQLDB_DRIVER_JARNAME };
for (final String driver : drivers) {
final Enumeration<URL> driverEntries = ConnectorPlugin.getDefault().getBundle().findEntries("drivers", driver, false);
assertThat(driverEntries).as("Missing driver " + driver).isNotNull();
assertThat(driverEntries.hasMoreElements()).as("Missing driver " + driver).isTrue();
}
}
}
/**
* Copyright (C) 2009 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
*
* Copyright (C) 2009-2015 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.test.suite;
......@@ -27,6 +24,7 @@ import org.bonitasoft.studio.common.extension.BonitaStudioExtensionRegistryManag
import org.bonitasoft.studio.common.jface.FileActionDialog;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.configuration.test.synchronizer.TestConfigurationSynhronizer;
import org.bonitasoft.studio.connectors.test.DriverAssociationContributionIT;
import org.bonitasoft.studio.connectors.test.importer.TestImportConnector;
import org.bonitasoft.studio.decision.core.test.TestDecisionTableToGroovy;
import org.bonitasoft.studio.engine.test.TestJavaDoc;
......@@ -123,6 +121,7 @@ import org.junit.runners.Suite;
TestRepositoryLocation.class,
TestShowEngineLog.class,
TestAutoLogin.class,
DriverAssociationContributionIT.class,
CloseAllEditors.class
})
public class AllTests {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment