Package de.innovationgate.webgate.api.servers

Examples of de.innovationgate.webgate.api.servers.WGDatabaseServer


           
            List<DatabaseServerInfo> infos = new ArrayList<DatabaseServerInfo>();
            try {
                Iterator<WGDatabaseServer> servers = _core.getDatabaseServers().values().iterator();
                while (servers.hasNext()) {
                    WGDatabaseServer server = servers.next();               
                    Iterator<ModuleDefinition> csTypes = server.getContentStoreTypes().iterator();
                                       
                    if (csTypes.hasNext()) {
                        DatabaseServerInfo info = new DatabaseServerInfo();
                        info.setUid(server.getUid());
                        info.setTitle(server.getTitle(Locale.ENGLISH));
                        infos.add(info);
                       
                        while (csTypes.hasNext()) {
                            ModuleDefinition csType = csTypes.next();                       
                            if (server.isDatabaseTypeCreatable((Class<? extends WGDatabaseCore>)csType.getImplementationClass())) {
                                info.getCreateableContentStoreImplemenations().add(csType.getImplementationClass().getName());                           
                            }
                        }
                    }                   
                }
View Full Code Here


        if (!isAdminSession(session)) {
            throw new WGAServiceException("You need an administrative login to access this service.");
        }
       
        Iterator<WGDatabaseServer> servers = _core.getDatabaseServers().values().iterator();
        WGDatabaseServer requestedServer = null;
        while (servers.hasNext()) {
            WGDatabaseServer server = servers.next();
            if (server.getUid().equals(dbServerInfo.getUid())) {
                requestedServer = server;
            }
        }
       
        if (requestedServer != null) {
View Full Code Here

        }
       
        List<DatabaseInformation> result = new ArrayList<DatabaseInformation>();
       
        Iterator<WGDatabaseServer> servers = _core.getDatabaseServers().values().iterator();
        WGDatabaseServer requestedServer = null;
        while (servers.hasNext()) {
            WGDatabaseServer server = servers.next();
            if (server.getUid().equals(dbServerInfo.getUid())) {
                requestedServer = server;
            }
        }
       
        if (requestedServer != null) {
View Full Code Here

        // Get basic information
        String strType = config.getImplClassName();       
        String strKey = config.getKey();
       
        // retrieve dbserver for db
        WGDatabaseServer server = getDatabaseServers().get(config.getDbServer());
        if (server == null) {
            log.error("Could not open database for key " + strKey.toLowerCase() + ": The server " + config.getDbServer() + " is unknown");
            return null;
        }
        
        // TODO this should be done in configuration validation not here
        if (strKey.equalsIgnoreCase("start") || strKey.equalsIgnoreCase("bi") || strKey.equalsIgnoreCase("static") || strKey.equalsIgnoreCase("statictml")) {
          String message = "Cannot map " + dbType + " to key \"" + strKey + "\" - This is a predefined key not available for content databases";
            log.error(message);
            dbConnectionFailures.put(strKey, message);
            return null;
        }
       
        // TODO this should be done in configuration validation not here       
        if (strKey.startsWith(PluginConfig.PLUGIN_DBKEY_PREFIX)) {
          String message = "Cannot map " + dbType + " to key \"" + strKey + "\" - The key prefix \"" + PluginConfig.PLUGIN_DBKEY_PREFIX + "\" is reserved for WGA plugins";
            log.error(message);
            dbConnectionFailures.put(strKey, message);
            return null;
        }

        // Look if the server is able and allowed to instantiate this db type
        Class<WGDatabaseCore> typeClass;
        try {
            Class theClass = WGFactory.getImplementationLoader().loadClass(strType);
            if (!WGDatabaseCore.class.isAssignableFrom(theClass)) {
                String message = "Cannot map " + dbType + " to key \"" + strKey + "\" - Database implementation class \"" + strType + "\" is no WGDatabaseCore implementation.";
                return null;
            }
            typeClass = theClass;
        }
        catch (ClassNotFoundException e) {
          String message = "Cannot map " + dbType + " to key \"" + strKey + "\" - Database implementation class \"" + strType + "\" not available.";
            log.error(message);
            dbConnectionFailures.put(strKey, message);
            return null;
        }
        catch (NoClassDefFoundError e) {
          String message = "Cannot map " + dbType + " to key \"" + strKey + "\" - Database implementation class or dependent class for type \"" + strType + "\" not found: \"" + e.getMessage();
            log.error(message);
            dbConnectionFailures.put(strKey, message);
            return null;
        }
        catch (VerifyError e) {
          String message = "Cannot map " + dbType + "to key \"" + strKey + "\" - Verify error: " + e.getMessage();
            log.error(message);
            dbConnectionFailures.put(strKey, message);
            return null;
        }

        if (!isDBAllowed(typeClass, strKey)) {
          String message = "Cannot map " + dbType + " to key \"" + strKey + "\" - Your server license type is not allowed to use this database type";
            log.error(message);
            dbConnectionFailures.put(strKey, message);
            return null;
        }

        // Evaluate title
        String title = config.getTitle();

        // Evaluate domain
        /*
        Element domainElement = (Element) databaseElement.selectSingleNode("domain");
        DomainConfiguration domainConfig = new DomainConfiguration();

        if (domainElement != null) {
            domainConfig = getDomainConfig(domainElement.getStringValue());
        }*/
        Domain domain = getWgaConfiguration().getDomain(config.getDomain());
        DomainConfiguration domainConfig = getDomainConfig(domain);

        // Collect db options from global, server, database
        HashMap<String, String> dbOptions = new HashMap<String, String>();
        dbOptions.put(WGDatabase.COPTION_USERCACHELATENCY, String.valueOf(_wgaConfiguration.getUserCacheLatencyMinutes()));
        dbOptions.putAll(_globalDbOptions);
        dbOptions.putAll(config.getDatabaseOptions());
       
        // We collect those options that were added on database level in here
        // and add this set as database attribute
        // so we can tell them later from lower priority options
        Set<String> firstLevelDBOptions = new HashSet<String>();
        firstLevelDBOptions.addAll(config.getDatabaseOptions().keySet());
        // Mandatory db options
        dbOptions.put(WGDatabase.COPTION_DBREFERENCE, strKey.toLowerCase());
       
        // get the database object
        WGDatabase db = null;
        try {
            if (config.isLazyConnecting()) {
                db = server.prepareDatabase(typeClass, dbOptions);
            }
            else {
                db = server.openDatabase(typeClass, dbOptions);
            }
        }
        catch (Throwable e1) {
          String message = "Could not open database for key " + strKey.toLowerCase();
            log.error(message, e1);
View Full Code Here

            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());
        }
View Full Code Here

                   getLog().error("Database server type '" + serverDefinition.getTitle(Locale.getDefault()) + "' (" + serverDefinition.getImplementationClass().getName() + ") is invalid, misses neccessary properties definition");
            }
            else if (properties.isSingleton()) {
                try {
                    serverDefinition.testDependencies();
                    WGDatabaseServer server = (WGDatabaseServer) getModuleRegistry().instantiate(serverDefinition);
                    server.init(WGAConfiguration.SINGLETON_SERVER_PREFIX + server.getClass().getName(), null, new HashMap<String,String>());
                    newServers.put(server.getUid(), server);
                    getLog().info("Registering database server '" + server.getTitle(Locale.getDefault()) + "' (Automatically created)");
                }
                catch (ModuleDependencyException e) {
                    getLog().error("Database server " + serverDefinition.getTitle(Locale.getDefault()) + " deactivated in current WGA runtime: " + e.getMessage());
                }
                catch (Exception e) {
                    getLog().error("Exception instantiating  database server", e);
                }
            }
           
        }
       
        // Add servers from configuration
        Iterator<DatabaseServer> servers = getWgaConfiguration().getDatabaseServers().iterator();
        while (servers.hasNext()) {
            DatabaseServer databaseServer = servers.next();
            if (databaseServer.isEnabled()) {
                try {
                    Class serverClass = getLibraryLoader().loadClass(databaseServer.getImplClassName());
                    WGDatabaseServer server = (WGDatabaseServer) getModuleRegistry().instantiate(serverClass);
                    server.init(databaseServer.getUid(), databaseServer.getTitle(), databaseServer.getOptions());
                    newServers.put(server.getUid(), server);
                    getLog().info("Registering database server '" + server.getTitle(Locale.getDefault()) + "'");
                }
                catch (Exception e) {
                    getLog().error("Exception instantiating database server", e);
                }
            }
View Full Code Here

TOP

Related Classes of de.innovationgate.webgate.api.servers.WGDatabaseServer

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.