Package de.innovationgate.wga.config

Examples of de.innovationgate.wga.config.ContentDatabase


  public List<ContentStore> getContentStoresWithDesign(WGAConfiguration wgaConf, String designName) throws IncompatibleWGAConfigVersion, IOException {
    List<ContentStore> css = new ArrayList<ContentStore>();
    Iterator<ContentDatabase> contentDbs = wgaConf.getContentDatabases().iterator();

    while (contentDbs.hasNext()) {
      ContentDatabase currentDB = contentDbs.next();
      if (currentDB instanceof ContentStore) {
        ContentStore currentCS = (ContentStore) currentDB;
        if (currentCS.getDesign() != null && currentCS.getDesign().getName().equals(designName)) {
          css.add(currentCS);
        }
View Full Code Here


        // first try - check if default db is requested
        if (vHost.getDefaultDatabase() != null) {
            ConfigBean bean = (ConfigBean) config.getByUid(vHost.getDefaultDatabase());
            if (bean != null && bean instanceof ContentDatabase) {
                ContentDatabase database = (ContentDatabase) bean;
                if (dbkey.equalsIgnoreCase(database.getKey())) {
                    return 0;
                }
            }
        }
       
        // second try - check allowed db keys
        int i = 0;
        for (String uid : vHost.getAllowedDatabases()) {
            i++;
            if (uid.equals(VirtualHost.UID_ALL_DATABASES)) {
                return Integer.MAX_VALUE;
            }
            ConfigBean dbBean = (ConfigBean) config.getByUid(uid);
            if (dbBean != null && dbBean instanceof ContentDatabase) {
                ContentDatabase database = (ContentDatabase) dbBean;
                if (dbkey.equalsIgnoreCase(database.getKey())) {
                    return i;
                }      
            }
        }       
       
View Full Code Here

    public static String getDefaultDBKey(WGACore core, VirtualHost vHost) {
        String defaultDBKey = null;
        if (vHost.getDefaultDatabase() != null) {
            ConfigBean bean = (ConfigBean) core.getWgaConfiguration().getByUid(vHost.getDefaultDatabase());
            if (bean != null && bean instanceof ContentDatabase) {
                ContentDatabase database = (ContentDatabase) bean;
                defaultDBKey = database.getKey();
            }
        }
        return defaultDBKey;
    }
View Full Code Here

    public List<String> getProvidedValues() {
        List<String> dbKeys = new ArrayList<String>();
        Iterator<ContentDatabase> dbs = _config.getContentDatabases().iterator();
        while (dbs.hasNext()) {
            ContentDatabase contentDatabase = (ContentDatabase) dbs.next();
            if (contentDatabase.isEnabled() && (!_csOnly || contentDatabase instanceof ContentStore)) {
                dbKeys.add(contentDatabase.getKey());
            }
        }
        return dbKeys;
    }
View Full Code Here

        }
        return dbKeys;
    }

    public String getValueTitle(String value, Locale locale) {
        ContentDatabase db = _config.getContentDatabase(value);
        return db.getKey() + (db.getTitle() != null ? " (" + db.getTitle() + ")" : "");
    }
View Full Code Here

        WGFactory.getInstance().closeSessions();

        //Element databaseRoot = (Element) this.configDocument.getRootElement().selectSingleNode("contentdbs");
        //List databaseElements = databaseRoot.selectNodes("contentdb");
        //Element databaseElement;
        ContentDatabase databaseConfig;
        WGDatabase db;
        Set<String> currentDBs = new HashSet<String>();

        // db connection errors mapped by dbkey
        Map<String, Serializable> dbConnectionFailures = new HashMap<String, Serializable>();
       
        List<ContentDatabase> databases = _wgaConfiguration.getContentDatabases();
       
        // Map new databases and update current databases
        for (int idxDB = 0; idxDB < databases.size(); idxDB++) {

            databaseConfig = databases.get(idxDB);
            String dbKey = databaseConfig.getKey();

            // ignore disabled dbs
            if (!databaseConfig.isEnabled()) {
                continue;
            }
            DatabaseServer serverConfig = (DatabaseServer) _wgaConfiguration.getByUid(databaseConfig.getDbServer());
            if (serverConfig != null && !serverConfig.isEnabled()) {
                continue;
            }

            // Get or create database object
            boolean isNewDB = false;
            if (this.contentdbs.containsKey(dbKey) == false) {
                try {
                    db = retrieveContentDB(databaseConfig, dbConnectionFailures);
                    if (db == null) {
                        continue;
                    }
   
                    this.contentdbs.put(dbKey, db);
   
                    isNewDB = true;
                    newConnectedDBKeys.add(dbKey);
                }
                catch (Throwable e) {
                    getLog().error("Exception connecting database " + dbKey, e);
                    if (this.contentdbs.containsKey(dbKey)) {
                        this.contentdbs.remove(dbKey);
                    }
                    continue;
                }
            }
            else {
                db = this.contentdbs.get(dbKey);
            }
            currentDBs.add(dbKey);

            // Update stored queries
            /*
            Element queryRoot = (Element) databaseElement.selectSingleNode("storedqueries");
            if (queryRoot != null) {
                updateStoredQueries(db, queryRoot);
            }*/

            // Update field mappings
            /*
            Element mappingRoot = (Element) databaseElement.selectSingleNode("fieldmappings");
            if (mappingRoot != null) {
               
            }*/
            updateFieldMappings(db, databaseConfig.getFieldMappings());
           
            // Update client restrictions
            if (databaseConfig.isClientRestrictionsEnabled()) {
              db.setAttribute(DBATTRIB_CLIENTRESTRICTIONS, IPv4Restriction.getRestrictions(databaseConfig.getClientRestrictions(), databaseConfig.getKey(), getLog()));
            } else {
                // if not enabled remove clientRestrictions from db
                db.removeAttribute(DBATTRIB_CLIENTRESTRICTIONS);
            }

View Full Code Here

TOP

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

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.