Examples of WGCSSJSModule


Examples of de.innovationgate.webgate.api.WGCSSJSModule

        if (WGUtils.isEmpty(script)) {
            return;
        }
       
        try {
            WGCSSJSModule mod = db.getCSSJSModule(script, WGScriptModule.CODETYPE_TMLSCRIPT);
            if (mod != null) {
                _log.info("Running connection script of '" + db.getDbReference() + "'");
                TMLContext context = new TMLContext(db.getDummyContent(null), _core, null, null);
                ExpressionResult result = ExpressionEngineFactory.getTMLScriptEngine().evaluateExpression(mod.getCode(), context, ExpressionEngine.TYPE_SCRIPT, null);
                if (result.isError()) {
                    _log.error("Error running connection script '" + csConfig.getConnectionScript() + "' of '" + db.getDbReference() + "'", result.getException());
                }
            }
            else {
View Full Code Here

Examples of de.innovationgate.webgate.api.WGCSSJSModule

            return;
        }
       
        try {
           
            WGCSSJSModule mod = db.getCSSJSModule(script, WGScriptModule.CODETYPE_TMLSCRIPT);
            if (mod != null) {
                _log.info("Running disconnection script of '" + db.getDbReference() + "'");
                TMLContext context = new TMLContext(db.getDummyContent(null), _core, null, null);
                ExpressionResult result = ExpressionEngineFactory.getTMLScriptEngine().evaluateExpression(mod.getCode(), context, ExpressionEngine.TYPE_SCRIPT, null);
                if (result.isError()) {
                    _log.error("Error running disconnection script '" + script + "' of '" + db.getDbReference() + "'", result.getException());
                }
            }
            else {
View Full Code Here

Examples of de.innovationgate.webgate.api.WGCSSJSModule

                    // Process init script
                    if (fc != null && isEmptyContent) {

                        if (_info.getCsConfig() != null && !WGUtils.isEmpty(_info.getCsConfig().getInitScript())) {
                            try {
                                WGCSSJSModule mod = _db.getCSSJSModule(_info.getCsConfig().getInitScript(), WGScriptModule.CODETYPE_TMLSCRIPT);
                                if (mod != null) {
                                    _log.info("Running initialisation script of database '" + _db.getDbReference() + "'");
                                    TMLContext context = new TMLContext(_db.getDummyContent(null), _core, null, null);
                                    ExpressionResult result = ExpressionEngineFactory.getTMLScriptEngine().evaluateExpression(mod.getCode(), context, ExpressionEngine.TYPE_SCRIPT, null);
                                    if (result.isError()) {
                                        _log.error("Error running initialisation script '" + _info.getCsConfig().getInitScript() + "' of db '" + _db.getDbReference() + "'", result.getException());
                                    }
                                }
                                else {
View Full Code Here

Examples of de.innovationgate.webgate.api.WGCSSJSModule

        if (commaPos != -1) {
            type = libName.substring(commaPos+1).trim();
            libName = libName.substring(commaPos).trim();
        }
       
        WGCSSJSModule lib;
        if (type != null) {
            lib = db.getCSSJSModule(libName, type);
        }
        else {
            lib = db.getCSSJSModule(libName);
View Full Code Here

Examples of de.innovationgate.webgate.api.WGCSSJSModule

            Map newLoginInformation = new HashMap();
            Set newGroupInformation = new HashSet();

            // Get collect script
            WGCSSJSModule mod = db.getCSSJSModule(_scriptCollect, WGScriptModule.CODETYPE_TMLSCRIPT);
            if (mod == null) {
                throw new WGException("Database '" + _dbkey + "' does not contain a TMLScript module of name '" + _scriptCollect + "'");
            }

            if (!mod.getCodeType().equals(WGCSSJSModule.CODETYPE_TMLSCRIPT)) {
                throw new WGException("Script module '" + _scriptCollect + "' in Database '" + _dbkey + "' is not of type TMLScript");
            }

            // Build a TMLScript runtime
            ExpressionEngine engine = ExpressionEngineFactory.getTMLScriptEngine();
            TMLContext context = new TMLContext(db.getDummyContent(db.getDefaultLanguage()), _core, null, null);
            Map objects = new HashMap();
            objects.put("logins", newLoginInformation);
            objects.put("groups", newGroupInformation);

            // Execute script
            ExpressionResult result = engine.evaluateExpression(mod.getCode(), context, ExpressionEngine.TYPE_SCRIPT, objects);
            if (result.isError()) {
                throw new WGException("Error executing collect script", result.getException());
            }

            _loginInformation =  newLoginInformation;
View Full Code Here

Examples of de.innovationgate.webgate.api.WGCSSJSModule

    }
    else if (db.isSessionOpen() == false) {
      throw new TaskException("Cannot open database '" + _database + "'");
    }

    WGCSSJSModule module;
        try {
            module = db.getCSSJSModule(_module, WGScriptModule.CODETYPE_TMLSCRIPT);
            if (module == null) {
                throw new TaskException("Script module '" + _module + "' does not exist in database '" + _database + "'");
            }
        }
        catch (WGAPIException e) {
            throw new TaskException("Error retrieving script module '" + _module + "' from database '" + _database + "'", e);
        }
   
   
    ExpressionEngine engine = ExpressionEngineFactory.getTMLScriptEngine();
   
   
   
   
    // Create necessary context objects
        WGContent dummyContent;
        try {
            dummyContent = db.getDummyContent(db.getDefaultLanguage());
        }
        catch (WGAPIException e) {
            throw new TaskException("Unable to retrieve dummy content context from database " + db.getDbReference(), e);
        }
       
    TMLContext context;
        try {
            context = new TMLContext(dummyContent, jobContext.getWgaCore(), null, null);
        }
        catch (WGAPIException e) {
            throw new TaskException("Unable to create context." + db.getDbReference(), e);
        }
    Map objects = new HashMap();
    objects.put("jobContext", jobContext);
    objects.put(RhinoExpressionEngine.PARAM_SCRIPTNAME, "TMLScript-Task running module " + _database + "/" + _module + " for scheduler job '" +  jobContext.getCurrentJob().getName() + "'");
   
        String code;
        try {
            code = module.getCode();
        }
        catch (WGAPIException e) {
            throw new TaskException("Unable to retrieve code of module '" + _module + "' from database " + db.getDbReference(), e);
        }
       
View Full Code Here

Examples of de.innovationgate.webgate.api.WGCSSJSModule

     
    }
   
    private TMLScriptHDBListener retrieveCustomListener(WGHierarchicalDatabaseEvent event, String contentClass) throws WGAPIException {
      String moduleName = TMLSCRIPT_LISTENER_FOLDER + ":" + contentClass;
        WGCSSJSModule module = event.getDb().getWrappedDB().getScriptModule(moduleName, WGScriptModule.CODETYPE_TMLSCRIPT);
        if (module != null) {
          return new TMLScriptHDBListener(getModel(event).getCore(), moduleName);
        }
        return null;
    }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGCSSJSModule

        }       
    }
   
   
    private WGCSSJSModule retrieveModule() throws WGAPIException {
        WGCSSJSModule module = _db.getWrappedDB().getScriptModule(_moduleName, WGScriptModule.CODETYPE_TMLSCRIPT);
        if (module == null) {
            throw new WGIllegalArgumentException("Cannot find hdb process module '" + _moduleName + "'.");
        } else {
            return module;
        }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGCSSJSModule

            default:
                throw new HttpErrorException(500, "Invalid path type to dispatch a css/js request: " + path.getPathType(), path.getDatabaseKey());

        }

        WGCSSJSModule lib = database.getScriptModule(path.getCssjsKey(), codeType);
        if (lib == null) {
            throw new HttpErrorException(404, "No css/js resource of name " + path.getCssjsKey(), path.getDatabaseKey());
        }

        // determine mime type and encoding
        String mimeType;
        String libType = lib.getCodeType();
        if (libType.equals(WGCSSJSModule.CODETYPE_CSS)) {
            mimeType = "text/css";
        }
        else if (libType.equals(WGCSSJSModule.CODETYPE_JS)) {
            mimeType = "text/javascript";
        }
        else if (libType.equals(WGCSSJSModule.CODETYPE_VBS)) {
            mimeType = "text/vbscript";
        }
        else {
            mimeType = "text/" + libType;
        }
        response.setContentType(mimeType);

        // Set expiration time
        int fileExpirationMinutes = ((Integer) _core.readPublisherOptionOrDefault(database, WGACore.DBATTRIB_FILEEXPIRATION_MINUTES)).intValue();
        if (fileExpirationMinutes > 0) {
            int fileExpirationSeconds = fileExpirationMinutes * 60;
            response.setHeader("Cache-Control", "max-age=" + fileExpirationSeconds + ", must-revalidate");
        }

        // determine lastModified
        // - last modified of binary response depends only on resource change
        // date
        // - last change date of textual response additionally depends on
        // character encoding change date
        long lastModified;
        if (isBinary(response)) {
            lastModified = lib.getLastModified().getTime();
        }
        else {
            lastModified = Math.max(lib.getLastModified().getTime(), _core.getCharacterEncodingLastModified());
            lastModified = Math.max(lastModified, _core.getDesignEncodingLastModified(database.getDbReference()));
        }
        if (browserCacheIsValid(request, lastModified)) {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            return;
        }
        else {
            response.setDateHeader("Last-Modified", lastModified);
            response.setHeader("ETag", '"' + String.valueOf(lastModified) + '"');
        }

        // If this is a head request we are finished now
        if ("HEAD".equalsIgnoreCase(request.getMethod())) {
            return;
        }

        String code = lib.getCode();
        // response.setContentLength(code.length());

        try {
            java.io.Writer out = response.getWriter();
            out.write(code);
View Full Code Here

Examples of de.innovationgate.webgate.api.WGCSSJSModule

       
        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;
        }
       
        if (!mod.getCodeType().equals(WGCSSJSModule.CODETYPE_TMLSCRIPT)) {
            throw new WGException("Script module '" + getModuleName() + "' in database " + getModuleDatabase() + " is no TMLScript module");
        }
        return mod;
    }
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.