Package de.innovationgate.webgate.api

Examples of de.innovationgate.webgate.api.WGDatabase


        // Determining target language
       
        String targetLanguage = context.getpreferredlanguage(); // Fallback value
       
        try {
            WGDatabase targetDB = context.db(designdbKey);
            if (targetDB != null && targetDB.isSessionOpen()) {
                LanguageBehaviour langBehaviour = LanguageBehaviourTools.retrieve(targetDB);
                WGLanguage lang = langBehaviour.webtmlSelectDatabaseLanguage(targetDB, context);
                if (lang != null) {
                    targetLanguage = lang.getName();
                }
View Full Code Here


                url.append(context.db().getDbReference());
            }
           
            // Explicit database addressed
            else if (dbKey != null) {
                WGDatabase designDB = context.db(context.resolveDBKey(dbKey));
                       
                if (designDB != null) {
                    url.append(designDB.getDbReference());
                }
                else {
                    context.addwarning("Unknown design db: " + dbKey);
                    return null;
                }
            }
           
            // No database addressed. Try to find file in file container of design db. Else we use the current context db
            else {
                WGFileContainer container = null;
               
                WGDatabase designDB = context.designdb();
                if (designDB != null && designDB.isSessionOpen()) {
                    container = designDB.getFileContainer(containerName);
                }

                if (container != null) {
                    url.append(designDB.getDbReference());
                }
                else {
                    url.append(context.db().getDbReference());
                }
            }
View Full Code Here

    public void setModuleDatabase(String moduleDatabase) {
        _moduleDatabase = moduleDatabase;
    }
   
    private WGCSSJSModule retrieveModule(TMLContext context) throws WGException {
        WGDatabase db = context.db(getModuleDatabase());
        if (db == null) {
            throw new WGException("Database " + getModuleDatabase() + " not found");
        }
       
        if (!db.isSessionOpen()) {
            throw new WGException("User has no access to database " + getModuleDatabase());
        }
       
        WGCSSJSModule mod = db.getCSSJSModule(getModuleName(), WGScriptModule.CODETYPE_TMLSCRIPT);
        // Module not available or was deleted. We just return null.
        if (mod == null) {
            return null;
        }
       
View Full Code Here

        dbOptions.put(WGDatabase.COPTION_READERPROFILECREATION, "true");
        dbOptions.put(WGDatabase.COPTION_USERCACHELATENCY, String.valueOf(_wgaConfiguration.getUserCacheLatencyMinutes()));
        dbOptions.put(WGDatabase.COPTION_WORKFLOWENGINE, WGDefaultWorkflowEngine.class.getName()); // We do not want any real workflow here

       
        WGDatabase persdb = WGFactory.getInstance().openDatabase(null, de.innovationgate.webgate.api.hsql.WGDatabaseImpl.class.getName(), dbDir.getPath() + "/" + db.getDbReference(), "sa", "", dbOptions);
        db.setAttribute(DBATTRIB_EXTERNAL_SELF_PERSONALISATION_DB, persdb);
       
    }
View Full Code Here

       
        // 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() + "\"");
            try {
                log.info("Personalisation database of domain " + domainConfig.getName() + " is content store version " + db.getContentStoreVersion());
            }
            catch (WGAPIException e) {
                log.error("Exception determining content store version of personalisation database for domain " + domainConfig.getName(), e);
            }
        }

        // Set domain
        db.setAttribute(WGACore.DBATTRIB_DOMAIN, domainConfig.getUid());

        // Mark this database as fully connected
        db.setAttribute(DBATTRIB_FULLY_CONNECTED, "true");
       
        return db;
    }
View Full Code Here

        //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);
            }

            // Operations only for newly connected databases
            if (isNewDB) {
                performNewDBOperations(db);
View Full Code Here

            if (serverConfig != null && !serverConfig.isEnabled()) {
                continue;
            }

            // Get or retrieve db
          WGDatabase db = null;
            if (this.personalisationdbs.containsKey(domain.getUid())) {
                db = this.personalisationdbs.get(domain.getUid());
            }
            else {
                db = retrievePersonalisationDB(domain);
View Full Code Here

            WGHierarchicalDatabase.setDefaultStartupImpl(null);
            _hdbCoreListener = new WGHierarchicalDatabaseCoreListener() {

        public void databaseCreated(WGHierarchicalDatabase hdb) {         
          // Eventually load and initialize model
          WGDatabase db = hdb.getWrappedDB();
              try {
              HDBModel.createModelObject(WGACore.this, db);           
                  }
                  catch (Exception e) {
                      WGACore.this.log.error("Error initializing HDB model for database " + db.getDbReference(), e);
                  }
        }

        public void databaseRemoved(WGHierarchicalDatabase hdb) {         
        }
View Full Code Here

    public Map<String, WGDatabase> getDesigndbs() {

        Map<String, WGDatabase> mapDesigndbs = new HashMap<String, WGDatabase>();
        Map<String, WGDatabase> mapContentdbs = this.getContentdbs();
        Iterator<String> iter = mapContentdbs.keySet().iterator();
        WGDatabase db = null;

        while (iter.hasNext()) {
            db = mapContentdbs.get(iter.next());

            if (db.isDesignRole()) {
                mapDesigndbs.put((String) db.getAttribute(WGACore.DBATTRIB_DBKEY), db);
            }
        }

        if (mapDesigndbs != null) {
            return mapDesigndbs;
View Full Code Here

        Map<String, WGDatabase> designDBs = getDesigndbs();
        Iterator<String> it = designDBs.keySet().iterator();
        Map<String, WGDatabase> domainDesignDBs = new HashMap<String, WGDatabase>();
        while (it.hasNext()) {
            String currentDBKey = it.next();
            WGDatabase db = designDBs.get(currentDBKey);
            String currentDomain = (String) db.getAttribute(WGACore.DBATTRIB_DOMAIN);
            if (domain.equals(currentDomain)) {
                domainDesignDBs.put(currentDBKey, db);
            }
        }
        return domainDesignDBs;
View Full Code Here

TOP

Related Classes of de.innovationgate.webgate.api.WGDatabase

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.