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);
}
}
if (authImplClass != null) {
AuthenticationModule authModule = WGFactory.getAuthModuleFactory().getAuthModule(authImplClass, authOptions, db);
db.setAuthenticationModule(authModule);
}
}
// Enforce some plugin settings via db attributes
db.setAttribute(DBATTRIB_PERSMODE, String.valueOf(pc.getPersonalisationMode()));
db.setAttribute(DBATTRIB_PERSSTATMODE, String.valueOf(Constants.PERSSTATMODE_SESSION));
db.setAttribute(DBATTRIB_PLUGIN_FILETIME, new Long(plugin.getFileLastModified()));
db.setAttribute(DBATTRIB_PLUGIN_ID, plugin.getPluginID());
db.setAttribute(DBATTRIB_PLUGIN_VERSION, plugin.getPluginID().getVersion());
if (!pc.isUsageAsContentStore()) {
db.setAttribute(DBATTRIB_ALLOW_PUBLISHING, "false");
}
if (!pc.isShowOnStartPage()) {
db.setAttribute(DBATTRIB_STARTPAGE, "false");
}
// Configure design provider
DesignReference ref = new DesignReference(Constants.DESIGNCOL_PLUGIN, plugin.getInstallationKey(), null);