Examples of WGDatabase


Examples of de.innovationgate.webgate.api.WGDatabase

    }
   
    public static String localLabel(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) throws JavaScriptException, WGException {
        TMLContext context = WGAGlobal.fetchInitialContext(cx);
        Arguments parsedArgs = _localLabelVarargs.parse(args);
        WGDatabase localDB = localDB(cx, thisObj, new Object[] {parsedArgs.get("currentObject")}, funObj);
        return context.label(localDB, (String) parsedArgs.get("container"), (String) parsedArgs.get("file"), (String) parsedArgs.get("key"), (List) parsedArgs.get("params"));

    }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase


    private void createCustomDB(Class implClass, WGDatabaseServer dbServer, Map<String, String> options) throws WGAPIException {
       
     // HSQL databases are created by just opening them
        WGDatabase db = openDatabase(implClass, dbServer, options, false);
        db.close();
       
    }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

           
        try {
                String taskDescr = "Anonymous TMLScript Master Function";
               
                // Open database in master thread
                WGDatabase db = _context.getdocument().getDatabase();
          db.openSession();
                db.getSessionContext().setTask(taskDescr);
               
                // Eventually open pers db too so profile is available
                TMLUserProfile profile = _context.getprofile();
               
                if (profile != null && !profile.getprofile().getDatabase().isSessionOpen()) {
                    WGDatabase persDB = profile.getprofile().getDatabase();
                    persDB.openSession();
                    persDB.getSessionContext().setTask(taskDescr);
                }
   
                RhinoContextAction contextAction = new RhinoContextAction(_context, _function, _overrideFunctionScope, _params);
                ExpressionResult result = (ExpressionResult) ContextFactory.getGlobal().call(contextAction);
               
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

        private WGSchemaDefinition _schema = null;
        public ContainerInfo(WGFileContainer con, ContainerInfo oldInfo) throws WGAPIException, IOException, InvalidCSConfigVersionException {
           
            // Determine if this system file container originates from another DB
            // which means we can bypass many operations for this DB, since the provider DB already enforced them
            WGDatabase db = con.getDatabase();
            _dbkey = db.getDbReference();
            if (db.getDesignProvider() != null && db.getDesignProvider() instanceof DBDesignProvider) {
                _fromProviderDB = true;
            }
           
            // Create the deployment dir where to put JARs that are to be loaded to classpath
            if (!_fromProviderDB) {
                _deploymentDir = createDeploymentDir(con, oldInfo);
            }
           
            // Look for a Java directory in the design provider
            if (db.getDesignProvider() instanceof FileSystemDesignProvider) {
                FileSystemDesignProvider fsProvider = (FileSystemDesignProvider) db.getDesignProvider();
                if (fsProvider.getJavaClassesPath() != null) {
                    _javaClassesDir = new File(fsProvider.getJavaClassesPath());
                }
            }
           
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

        Status status = (Status) getStatus();
       
        this.setResultOutput(false);

        // Get the db
        WGDatabase db = null;
        if ( (this.getDb() == null) || this.getDb().trim().startsWith("*") || this.getDb().indexOf(",") != -1){
            db = this.getTMLContext().getdocument().getDatabase();
        }
        else {
            try {
                db = (WGDatabase) this.openContentDB(getTMLContext().resolveDBKey(this.getDb().toLowerCase()));
            }
            catch (WGUnavailableException e) {
                this.addWarning("Database '" + getDb() + "' is currently unavailable");
                status.error = e;
                return;
            }
            catch (WGException e) {
                this.addWarning(e.getMessage());
                status.error = e;
                return;               
            }
            if (db == null) {
                this.addWarning("Could not find database to query: " + this.getDb(), true);
                status.error = new WGInvalidDatabaseException("Could not find database to query: " + this.getDb());
                return;
            }
            if (db.isSessionOpen() == false) {
                this.addWarning("User cannot open database " + this.getDb(), true);
                status.error = new WGAuthorisationException("User cannot open database " + this.getDb());
                return;
            }
        }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

       
        pluginsIt = _pluginsByInstallationKey.values().iterator();
        while (pluginsIt.hasNext()) {
            WGAPlugin plugin = (WGAPlugin) pluginsIt.next();
           
            WGDatabase db = null;
            if (plugin.isActive() && plugin.isValid()) {
                try {
                    db = _core.connectPlugin(plugin, domainConfig);
                }
                catch (InvalidPluginException e) {
                    if (e.getPlugin() == plugin) {
                        _core.getLog().error("Unable to connect plugin " + plugin.getPluginID().getUniqueName());
                    }
                    else {
                        _core.getLog().error("Unable to connect plugin " + plugin.getPluginID().getUniqueName() + " because of dependency plugin " + e.getPlugin().getPluginID().getUniqueName());
                    }
                    _core.getLog().error(e.getMessage(), e.getCause());
                }
                if (db == null) {
                    continue;
                }

                // db can be successfully connected
                pluginsDBs.add(db.getDbReference());
            }         
        }
       
        return pluginsDBs;
    }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

       
    }

    public String getValueTitle(String value, Locale locale) {
       
        WGDatabase pluginDB = _core.getContentdbs().get(value);
        CSConfig csConfig = (CSConfig) pluginDB.getAttribute(WGACore.DBATTRIB_CSCONFIG);
        if (csConfig != null && csConfig.getPluginConfig() != null) {
            return csConfig.getPluginConfig().getTitle() + " (" + csConfig.getPluginConfig().getId().getUniqueName() + ")";
        }
       
        return value;
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

       
    }

    public String getValueTitle(String value, Locale locale) {
       
        WGDatabase db = _core.getContentdbs().get(value);
        PluginID pid = (PluginID) db.getAttribute(WGACore.DBATTRIB_PLUGIN_ID);
        if (pid != null) {
            WGAPlugin plugin = _core.getPluginSet().getPluginByID(pid);
            if (plugin != null) {
                return "Plugin " + db.getTitle() + " (" + (plugin.getInstallationKey() + ")");
            }
            else {
                return "Plugin " + db.getTitle() + "(Installation key not retrievable)";
            }
        }
        else {
            return db.getTitle() + " (" + value + ")";
        }
       
    }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

                String targetDBKey = getTMLContext().resolveDBKey(getDb());
                if (targetDBKey == null) {
                    targetDBKey = getTMLContext().db().getDbReference();
                }
               
                WGDatabase targetDB = (WGDatabase) getTMLContext().getwgacore().getContentdbs().get(targetDBKey);
                if (targetDB != null) {
                    absolutePort = getTMLContext().getwgacore().getDefaultPort(targetDB, absoluteProtocol);
                }
                else {
                    addWarning("Cannot resolve target db " + targetDBKey + " to determine default port");
View Full Code Here

Examples of de.innovationgate.webgate.api.WGDatabase

                            return file.isDirectory();
                        }
                    });                   
                    for (File dbDirectory : dbDirectories) {
                        String dbkey = dbDirectory.getName();
                        WGDatabase db = _core.getContentdbs().get(dbkey);
                        if (db == null) {
                            if (!_core.getWgaConfiguration().hasContentDatabase(dbkey) || !_core.getWgaConfiguration().getContentDatabase(dbkey).isEnabled()) {
                                if (dbDirectory.exists()) {
                                    _core.getLog().info("Database '" + dbkey + "' is disabled or has been removed. Removing all cached entries from '" + dbDirectory.getAbsolutePath() + "'.");               
                                    WGUtils.delTree(dbDirectory);           
                                    if (dbDirectory.exists()) {
                                        _core.getLog().warn("External file cache maintenance failed. Unable to remove directory '" + dbDirectory.getAbsolutePath() + "'. Cache might serve protected file data.");           
                                    }
                                }
                            }
                        } else if (db.isConnected()) {
                            try {
                                db.openSession();
                                if (db.isSessionOpen()) {
                                    db.getSessionContext().setTask("ExternalFileServingMaintenanceTask");
                                    if (!db.isAnonymousAccessible()) {
                                        if (dbDirectory.exists()) {
                                            _core.getLog().info("Database '" + db.getDbReference() + "' is not accessible by anonymous users. Removing all cached entries from '" + dbDirectory.getAbsolutePath() + "'.");               
                                            WGUtils.delTree(dbDirectory);           
                                            if (dbDirectory.exists()) {
                                                _core.getLog().warn("External file cache maintenance failed. Unable to remove directory '" + dbDirectory.getAbsolutePath() + "'. Cache might serve protected file data.");           
                                            }
                                        }                                       
                                    } else if (!db.getBooleanAttribute(WGACore.DBATTRIB_EXTERNAL_FILE_SERVING_ENABLED, false)) {
                                        if (dbDirectory.exists()) {
                                            _core.getLog().info("External file serving has been disabled for database '" + db.getDbReference() + "'. Removing all cached entries from '" + dbDirectory.getAbsolutePath() + "'.");               
                                            WGUtils.delTree(dbDirectory);           
                                            if (dbDirectory.exists()) {
                                                _core.getLog().warn("External file cache maintenance failed. Unable to remove directory '" + dbDirectory.getAbsolutePath() + "'. Cache might serve stale file data.");           
                                            }
                                        }                                       
                                    } else {
                                        // perform file deletion checks
                                        if (dbDirectory.exists()) {
                                            File[] containers = dbDirectory.listFiles(new FileFilter() {                                               
                                                public boolean accept(File file) {
                                                    return file.isDirectory();
                                                }
                                            });
                                            for (File container : containers) {
                                                if (container.getName().startsWith("content:")) {
                                                    String contentKey = container.getName().substring("content:".length());
                                                    WGContent content = db.getContentByKey(contentKey);
                                                    if (content == null || !content.getStatus().equals(WGContent.STATUS_RELEASE)) {
                                                        // content has been deleted or archived - remove file data
                                                        _core.getLog().info("Content '" + contentKey + "' has been deleted or archived. Clearing external file serving cache.");
                                                        WGUtils.delTree(container);
                                                        if (container.exists()) {
                                                            _core.getLog().warn("External file cache maintenance failed. Unable to remove directory '" + container.getAbsolutePath() + "'. Cache might serve stale file data.");           
                                                        }
                                                    } else {
                                                        // check general access to content                                                   
                                                        if (content.getReaders().size() > 0) {
                                                            // delete all deployed files of content
                                                            _core.getLog().info("Content '" + content.getContentKey() + "' is not accessible by anonymous. Clearing external file serving cache.");
                                                            WGUtils.delTree(container)
                                                            if (container.exists()) {
                                                                _core.getLog().warn("External file cache maintenance failed. Unable to remove directory '" + container.getAbsolutePath() + "'. Cache might serve stale file data.");           
                                                            }
                                                        } else {
                                                            // check for existence and size of files
                                                            File[] deployedFiles = container.listFiles();
                                                            for (File deployedFile : deployedFiles) {
                                                                if (deployedFile.isFile()) {
                                                                    if (!content.hasFile(deployedFile.getName())) {
                                                                        _core.getLog().info("File '" + deployedFile.getName() + "' has been removed from content '" + content.getContentKey() + "' and will be removed from external file serving cache.");
                                                                        if (!deployedFile.delete()) {
                                                                            _core.getLog().warn("Unable to delete external file serving data '" + deployedFile.getAbsolutePath() + "'. File cache might serve stale data.");
                                                                        }
                                                                    } else if (deployedFile.length() < config.getThreshold()) {
                                                                        _core.getLog().info("Deployed file '" + deployedFile.getName() + "' of content '" + content.getContentKey() + "' deceeds current file size threashold and will be removed from external file serving cache.");
                                                                        if (!deployedFile.delete()) {
                                                                            _core.getLog().warn("Unable to delete external file serving data '" + deployedFile.getAbsolutePath() + "'. File cache might serve stale data.");
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                } else if (container.getName().startsWith("filecontainer:")) {
                                                    String fileContainerName = container.getName().substring("filecontainer:".length());
                                                    WGFileContainer fileContainer = db.getFileContainer(fileContainerName);
                                                    if (fileContainer == null) {
                                                        // content has been deleted remove file data
                                                        _core.getLog().info("File container '" + fileContainerName + "' has been deleted. Clearing external file serving cache.");
                                                        WGUtils.delTree(container);
                                                        if (container.exists()) {
                                                            _core.getLog().warn("External file cache maintenance failed. Unable to remove directory '" + container.getAbsolutePath() + "'. Cache might serve stale file data.");           
                                                        }
                                                    } else {
                                                        // check for existence and size of files
                                                        File[] deployedFiles = container.listFiles();
                                                        for (File deployedFile : deployedFiles) {
                                                            if (deployedFile.isFile()) {
                                                                if (!fileContainer.hasFile(deployedFile.getName())) {
                                                                    _core.getLog().info("File '" + deployedFile.getName() + "' has been removed from file container '" + fileContainer.getName() + "' and will be removed from external file serving cache.");
                                                                    if (!deployedFile.delete()) {
                                                                        _core.getLog().warn("Unable to delete external file serving data '" + deployedFile.getAbsolutePath() + "'. File cache might serve stale data.");
                                                                    }
                                                                } else if (deployedFile.length() < config.getThreshold()) {
                                                                    _core.getLog().info("Deployed file '" + deployedFile.getName() + "' of file container '" + fileContainer.getName() + "' deceeds current file size threashold and will be removed from external file serving cache.");
                                                                    if (!deployedFile.delete()) {
                                                                        _core.getLog().warn("Unable to delete external file serving data '" + deployedFile.getAbsolutePath() + "'. File cache might serve stale data.");
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                       
                                    }
                                } else {
                                    _core.getLog().warn("External file serving maintenance failed. Unable to open session on database '" + db.getDbReference() + "'. Cache might serve protected file data.");
                                }                               
                            }                                                                                   
                            catch (Throwable e) {
                                _core.getLog().warn("External file serving maintenance failed. Cache might serve protected file data.", e);
                            } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.