// First connect all mandatory plugins
try {
Iterator mandatoryPlugins = plugin.getMandatoryPlugins().values().iterator();
while (mandatoryPlugins.hasNext()) {
WGAPlugin mandatoryPlugin = (WGAPlugin) mandatoryPlugins.next();
connectPlugin(mandatoryPlugin, domainConfigs);
}
}
// A mandatory plugin is invalid. Cancel connect.
catch (InvalidPluginException e) {
throw e;
}
logCategoryInfo("Plugin " + plugin.getInstallationKey(), 2);
// Mandatory db options (for plugins)
Map<String, String> dbOptions = new HashMap<String, String>();
dbOptions.put(WGDatabase.COPTION_DBREFERENCE, dbKey.toLowerCase());
dbOptions.put(WGDatabase.COPTION_READERPROFILECREATION, "true");
dbOptions.put(WGDatabase.COPTION_USERCACHELATENCY, String.valueOf(_wgaConfiguration.getUserCacheLatencyMinutes()));
// We try to automatically migrate plugin content stores to CS5 format
dbOptions.put(WGDatabase.COPTION_CONTENT_STORE_VERSION, String.valueOf(WGDatabase.CSVERSION_WGA5));
// Clear the plugin database before connecting if the plugin is updated and should clear the db on update
if (plugin.getRuntimeContext().isUpdated()) {
if (plugin.getCsConfig().getPluginConfig() instanceof de.innovationgate.wga.common.beans.csconfig.v3.PluginConfig) {
de.innovationgate.wga.common.beans.csconfig.v3.PluginConfig v3Config = (de.innovationgate.wga.common.beans.csconfig.v3.PluginConfig) plugin.getCsConfig().getPluginConfig();
if (v3Config.isClearDatabaseOnUpdate()) {
getLog().info("Clearing plugin database for installation key " + plugin.getInstallationKey());
plugin.getParent().deletePluginDatabase(plugin);
}
}
plugin.getRuntimeContext().setUpdated(false);
}
// Connect
getLog().info("Connecting plugin " + plugin.getPluginID().getUniqueName() + " Version " + plugin.getPluginID().getVersion().toString());
try {
db = WGFactory.getInstance().openDatabase(null, de.innovationgate.webgate.api.hsql.WGDatabaseImpl.class.getName(), plugin.buildDatabasePath(), null, null, dbOptions);
}
catch (Throwable e1) {
throw new InvalidPluginException(plugin, "Could not connect plugin \"" + plugin.getPluginID().getUniqueName() + "\"", e1);
}
if (db == null || !db.isSessionOpen()) {
throw new InvalidPluginException(plugin, "Could not connect plugin \"" + plugin.getPluginID().getUniqueName() + "\" - Check logged messages above for error details");
}
try {
db.getSessionContext().setTask("Initializing database in WGA");
// Plugin dbs are always CS5 since they are automatically migrated
//getLog().info("Database of plugin " + plugin.getPluginID().getUniqueName() + " is content store version " + db.getContentStoreVersion());
PluginConfig pc = plugin.getCsConfig().getPluginConfig();
String auth = pc.getAuthentication();
db.setTitle(pc.getTitle());
// Set mandatory database attributes
initializeDBAttributes(db, dbKey, dbKey, new HashSet());
// Create authentication
if (auth != null) {
String authImplClass = null;
Map<String,String> authOptions = new HashMap<String, String>();
// Delegate authentication to the default domain
if (auth.equals(PluginConfig.AUTHSOURCE_DEFAULT_DOMAIN)) {
authImplClass = WGAAuthModuleFactory.AUTHMODULE_DELEGATE;
authOptions.put(DelegatingAuthModule.COPTION_DOMAIN, "default");
}
// Use some plugin for authentication
else {
WGAPlugin authPlugin = plugin.getParent().getPluginByUniqueName(auth);
if (authPlugin != null) {
authImplClass = CSAuthModule.class.getName();
authOptions.put(CSAuthModule.COPTION_DBKEY, authPlugin.buildDatabaseKey());
}
else {
getLog().error("Unable to find authentication plugin " + auth);
}
}