Package de.innovationgate.wga.config

Examples of de.innovationgate.wga.config.PersonalisationDatabase


        }
    }
   

    public WGDatabase retrievePersonalisationDB(Domain domainConfig) {
      PersonalisationDatabase config = domainConfig.getPersonalisation();
     
        // Get basic information
        String strType = config.getImplClassName();

        // Look if impl class is reachable
        Class<WGDatabaseCore> typeClass;
        try {
            Class theClass = Class.forName(strType, true, WGFactory.getImplementationLoader());
            if (!WGDatabaseCore.class.isAssignableFrom(theClass)) {
                String message = "Cannot connect personalisation database for domain \"" + domainConfig.toString() + "\" - Database implementation class \"" + strType + "\" is no WGDatabaseCore implementation.";
                return null;
            }
            typeClass = theClass;
        }
        catch (ClassNotFoundException e) {
            log.error("Cannot attach personalisation database to domain \"" + domainConfig.toString() + "\" - Database implementation class \"" + strType + "\" not available.");
            return null;
        }
        catch (NoClassDefFoundError e) {
            log.error("Cannot attach personalisation database to domain \"" + domainConfig.toString() + "\" - Database implementation class or dependent class for type \"" + strType + "\" not found: \""
                    + e.getMessage());
            return null;
        }
        catch (VerifyError e) {
            log.error("Cannot attach personalisation database to domain \"" + domainConfig.toString() + "\" - Verify error: " + e.getMessage());
            return null;
        }

        // Look if license allows it
        if (!isPersonalisationDBAllowed(typeClass, domainConfig.getUid())) {
            log.error("Cannot attach personalisation database to domain \"" + domainConfig.toString() + "\" - Your server license type is not allowed to use this database type");
            return null;
        }

        // Retrieve server
        WGDatabaseServer server = getDatabaseServers().get(config.getDbServer());
        if (server == null) {
            log.error("Could not open personalisation database for domain '" + domainConfig.toString() + "': The server " + config.getDbServer() + " is unknown");
            return null;
        }
       
        // Merge db options from global, server, database
        HashMap<String, String> dbOptions = new HashMap<String, String>();
        dbOptions.putAll(_globalDbOptions);
        dbOptions.putAll(server.getOptions());
        dbOptions.putAll(config.getDatabaseOptions());
       
        // Mandatory db options
        dbOptions.put(WGDatabase.COPTION_DBREFERENCE , "personalisation_" + domainConfig.getUid());

        // get the database object
        WGDatabase db = null;
        try {
            if (config.isLazyConnecting()) {
                db = server.prepareDatabase(typeClass, dbOptions);
            }
            else {
                db = server.openDatabase(typeClass, dbOptions);
            }
        }
        catch (WGAPIException e) {
            getLog().error("Could not connect to database: " + e.getMessage());
        }
        catch (ModuleDependencyException e) {
            getLog().error("Could not connect to database because of missing dependency: " + e.getMessage());
        }

        if (db == null) {
            log.error("Could not open personalisation database for domain '" + domainConfig.getName() + " - Check logged messages above for error details");
            return null;
        }
        else if (!db.getRoles().contains(WGDatabase.ROLE_USERPROFILES)) {
            log.error("Could not open personalisation database \for domain '" + domainConfig.getName() + " - This type does not deliver user profiles");
            return null;

        }

        if (config.isLazyConnecting()) {
            log.info("Preparing personalisation database on path \"" + db.getPath() + "\" for domain \"" + domainConfig.getName() + "\"");
            db.addDatabaseConnectListener(this);
        }
        else {
            log.info("Attaching personalisation database on path \"" + db.getPath() + "\" to domain \"" + domainConfig.getName() + "\"");
View Full Code Here


        Set<String> currentDBs = new HashSet<String>();

        Iterator<Domain> domains = _wgaConfiguration.getDomains().iterator();
        while (domains.hasNext()) {
          Domain domain = domains.next();
            PersonalisationDatabase persDBConfig = domain.getPersonalisation();
           
            // Ignore disabled pers databases
            if (persDBConfig == null) {
                continue;
            }
            if (!persDBConfig.isEnabled()) {
                continue;
            }
            DatabaseServer serverConfig = (DatabaseServer) _wgaConfiguration.getByUid(persDBConfig.getDbServer());
            if (serverConfig != null && !serverConfig.isEnabled()) {
                continue;
            }

            // Get or retrieve db
View Full Code Here

TOP

Related Classes of de.innovationgate.wga.config.PersonalisationDatabase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.