Search in sources :

Example 51 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class XMLConfigWebFactory method loadExeLog.

private static void loadExeLog(ConfigServerImpl configServer, ConfigImpl config, Document doc) {
    boolean hasServer = configServer != null;
    Element el = getChildByName(doc.getDocumentElement(), "execution-log");
    // enabled
    Boolean bEnabled = Caster.toBoolean(getAttr(el, "enabled"), null);
    if (bEnabled == null) {
        if (hasServer)
            config.setExecutionLogEnabled(configServer.getExecutionLogEnabled());
    } else
        config.setExecutionLogEnabled(bEnabled.booleanValue());
    boolean hasChanged = false;
    String val = Caster.toString(config.getExecutionLogEnabled());
    try {
        Resource contextDir = config.getConfigDir();
        Resource exeLog = contextDir.getRealResource("exe-log");
        if (!exeLog.exists()) {
            exeLog.createNewFile();
            IOUtil.write(exeLog, val, SystemUtil.getCharset(), false);
            hasChanged = true;
        } else if (!IOUtil.toString(exeLog, SystemUtil.getCharset()).equals(val)) {
            IOUtil.write(exeLog, val, SystemUtil.getCharset(), false);
            hasChanged = true;
        }
    } catch (IOException e) {
        e.printStackTrace(config.getErrWriter());
    }
    if (hasChanged) {
        try {
            if (config.getClassDirectory().exists())
                config.getClassDirectory().remove(true);
        } catch (IOException e) {
            e.printStackTrace(config.getErrWriter());
        }
    }
    // class
    String strClass = getAttr(el, "class");
    Class clazz;
    if (!StringUtil.isEmpty(strClass)) {
        try {
            if ("console".equalsIgnoreCase(strClass))
                clazz = ConsoleExecutionLog.class;
            else {
                ClassDefinition cd = getClassDefinition(el, "", config.getIdentification());
                Class c = cd.getClazz();
                if ((c.newInstance() instanceof ExecutionLog)) {
                    clazz = c;
                } else {
                    clazz = ConsoleExecutionLog.class;
                    SystemOut.printDate(config.getErrWriter(), "class [" + strClass + "] must implement the interface " + ExecutionLog.class.getName());
                }
            }
        } catch (Exception e) {
            SystemOut.printDate(e);
            clazz = ConsoleExecutionLog.class;
        }
        if (clazz != null)
            SystemOut.printDate(config.getOutWriter(), "loaded ExecutionLog class " + clazz.getName());
        // arguments
        String strArgs = getAttr(el, "arguments");
        if (StringUtil.isEmpty(strArgs))
            strArgs = getAttr(el, "class-arguments");
        Map<String, String> args = toArguments(strArgs, true);
        config.setExecutionLogFactory(new ExecutionLogFactory(clazz, args));
    } else {
        if (hasServer)
            config.setExecutionLogFactory(configServer.getExecutionLogFactory());
        else
            config.setExecutionLogFactory(new ExecutionLogFactory(ConsoleExecutionLog.class, new HashMap<String, String>()));
    }
}
Also used : ConsoleExecutionLog(lucee.runtime.engine.ConsoleExecutionLog) Element(org.w3c.dom.Element) Resource(lucee.commons.io.res.Resource) IOException(java.io.IOException) ClassDefinition(lucee.runtime.db.ClassDefinition) FunctionLibException(lucee.transformer.library.function.FunctionLibException) PageException(lucee.runtime.exp.PageException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SecurityException(lucee.runtime.exp.SecurityException) TagLibException(lucee.transformer.library.tag.TagLibException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SQLException(java.sql.SQLException) IOException(java.io.IOException) BundleException(org.osgi.framework.BundleException) SAXException(org.xml.sax.SAXException) ClassException(lucee.commons.lang.ClassException) MalformedURLException(java.net.MalformedURLException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException) ConsoleExecutionLog(lucee.runtime.engine.ConsoleExecutionLog) ExecutionLog(lucee.runtime.engine.ExecutionLog) CFXTagClass(lucee.runtime.cfx.customtag.CFXTagClass) CPPCFXTagClass(lucee.runtime.cfx.customtag.CPPCFXTagClass) JavaCFXTagClass(lucee.runtime.cfx.customtag.JavaCFXTagClass) ExecutionLogFactory(lucee.runtime.engine.ExecutionLogFactory)

Example 52 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class XMLConfigWebFactory method loadApplication.

/**
 * @param configServer
 * @param config
 * @param doc
 * @throws IOException
 * @throws PageException
 */
private static void loadApplication(ConfigServerImpl configServer, ConfigImpl config, Document doc, int mode) throws IOException, PageException {
    boolean hasCS = configServer != null;
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_SETTING);
    Element application = getChildByName(doc.getDocumentElement(), "application");
    Element scope = getChildByName(doc.getDocumentElement(), "scope");
    // Listener type
    ApplicationListener listener;
    if (mode == ConfigImpl.MODE_STRICT) {
        listener = new ModernAppListener();
    } else {
        listener = ConfigWebUtil.loadListener(getAttr(application, "listener-type"), null);
        if (listener == null) {
            if (hasCS && configServer.getApplicationListener() != null)
                listener = ConfigWebUtil.loadListener(configServer.getApplicationListener().getType(), null);
            if (listener == null)
                listener = new MixedAppListener();
        }
    }
    String[] strTypes = new String[] { "function", "include", "query", "resource", "http", "file", "webservice" };
    int[] types = new int[] { Config.CACHEDWITHIN_FUNCTION, Config.CACHEDWITHIN_INCLUDE, Config.CACHEDWITHIN_QUERY, Config.CACHEDWITHIN_RESOURCE, Config.CACHEDWITHIN_HTTP, Config.CACHEDWITHIN_FILE, Config.CACHEDWITHIN_WEBSERVICE };
    // cachedwithin
    for (int i = 0; i < types.length; i++) {
        String cw = getAttr(application, "cached-within-" + strTypes[i]);
        if (!StringUtil.isEmpty(cw, true))
            config.setCachedWithin(types[i], cw);
        else if (hasCS)
            config.setCachedWithin(types[i], configServer.getCachedWithin(types[i]));
    }
    // Type Checking
    Boolean typeChecking = Caster.toBoolean(getAttr(application, "type-checking"), null);
    if (typeChecking != null)
        config.setTypeChecking(typeChecking.booleanValue());
    else if (hasCS)
        config.setTypeChecking(configServer.getTypeChecking());
    // Listener Mode
    int listenerMode = ConfigWebUtil.toListenerMode(getAttr(application, "listener-mode"), -1);
    if (listenerMode == -1) {
        if (hasCS)
            listenerMode = configServer.getApplicationListener() == null ? ApplicationListener.MODE_CURRENT2ROOT : configServer.getApplicationListener().getMode();
        else
            listenerMode = ApplicationListener.MODE_CURRENT2ROOT;
    }
    listener.setMode(listenerMode);
    config.setApplicationListener(listener);
    // Req Timeout URL
    if (mode == ConfigImpl.MODE_STRICT) {
        config.setAllowURLRequestTimeout(false);
    } else {
        String allowURLReqTimeout = getAttr(application, "allow-url-requesttimeout");
        if (hasAccess && !StringUtil.isEmpty(allowURLReqTimeout)) {
            config.setAllowURLRequestTimeout(Caster.toBooleanValue(allowURLReqTimeout, false));
        } else if (hasCS)
            config.setAllowURLRequestTimeout(configServer.isAllowURLRequestTimeout());
    }
    // Req Timeout
    TimeSpan ts = null;
    if (hasAccess) {
        String reqTimeoutApplication = getAttr(application, "requesttimeout");
        // deprecated
        String reqTimeoutScope = getAttr(scope, "requesttimeout");
        if (!StringUtil.isEmpty(reqTimeoutApplication))
            ts = Caster.toTimespan(reqTimeoutApplication);
        if (ts == null && !StringUtil.isEmpty(reqTimeoutScope))
            ts = Caster.toTimespan(reqTimeoutScope);
    }
    if (ts != null && ts.getMillis() > 0)
        config.setRequestTimeout(ts);
    else if (hasCS)
        config.setRequestTimeout(configServer.getRequestTimeout());
    // script-protect
    String strScriptProtect = getAttr(application, "script-protect");
    if (hasAccess && !StringUtil.isEmpty(strScriptProtect)) {
        // print.err("sp:"+strScriptProtect);
        config.setScriptProtect(AppListenerUtil.translateScriptProtect(strScriptProtect));
    } else if (hasCS)
        config.setScriptProtect(configServer.getScriptProtect());
    // classic-date-parsing
    if (config instanceof ConfigServer) {
        if (mode == ConfigImpl.MODE_STRICT) {
            DateCaster.classicStyle = true;
        } else {
            String strClassicDateParsing = getAttr(application, "classic-date-parsing");
            if (!StringUtil.isEmpty(strClassicDateParsing)) {
                DateCaster.classicStyle = Caster.toBooleanValue(strClassicDateParsing, false);
            }
        }
    }
    // Cache
    Resource configDir = config.getConfigDir();
    String strCacheDirectory = application.getAttribute("cache-directory");
    if (hasAccess && !StringUtil.isEmpty(strCacheDirectory)) {
        strCacheDirectory = ConfigWebUtil.translateOldPath(strCacheDirectory);
        Resource res = ConfigWebUtil.getFile(configDir, strCacheDirectory, "cache", configDir, FileUtil.TYPE_DIR, config);
        config.setCacheDir(res);
    } else {
        config.setCacheDir(configDir.getRealResource("cache"));
    }
    String strMax = getAttr(application, "cache-directory-max-size");
    if (hasAccess && !StringUtil.isEmpty(strMax)) {
        config.setCacheDirSize(ByteSizeParser.parseByteSizeDefinition(strMax, config.getCacheDirSize()));
    } else if (hasCS)
        config.setCacheDirSize(configServer.getCacheDirSize());
    // admin sync
    ClassDefinition asc = getClassDefinition(application, "admin-sync-", config.getIdentification());
    if (!asc.hasClass())
        asc = getClassDefinition(application, "admin-synchronisation-", config.getIdentification());
    if (hasAccess && asc.hasClass()) {
        try {
            Class clazz = asc.getClazz();
            if (!Reflector.isInstaneOf(clazz, AdminSync.class))
                throw new ApplicationException("class [" + clazz.getName() + "] does not implement interface [" + AdminSync.class.getName() + "]");
            config.setAdminSyncClass(clazz);
        } catch (Exception e) {
            SystemOut.printDate(e);
        }
    } else if (hasCS)
        config.setAdminSyncClass(configServer.getAdminSyncClass());
}
Also used : ModernAppListener(lucee.runtime.listener.ModernAppListener) Element(org.w3c.dom.Element) Resource(lucee.commons.io.res.Resource) ClassDefinition(lucee.runtime.db.ClassDefinition) lucee.aprint(lucee.aprint) FunctionLibException(lucee.transformer.library.function.FunctionLibException) PageException(lucee.runtime.exp.PageException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SecurityException(lucee.runtime.exp.SecurityException) TagLibException(lucee.transformer.library.tag.TagLibException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SQLException(java.sql.SQLException) IOException(java.io.IOException) BundleException(org.osgi.framework.BundleException) SAXException(org.xml.sax.SAXException) ClassException(lucee.commons.lang.ClassException) MalformedURLException(java.net.MalformedURLException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException) TimeSpan(lucee.runtime.type.dt.TimeSpan) ApplicationException(lucee.runtime.exp.ApplicationException) ApplicationListener(lucee.runtime.listener.ApplicationListener) CFXTagClass(lucee.runtime.cfx.customtag.CFXTagClass) CPPCFXTagClass(lucee.runtime.cfx.customtag.CPPCFXTagClass) JavaCFXTagClass(lucee.runtime.cfx.customtag.JavaCFXTagClass) MixedAppListener(lucee.runtime.listener.MixedAppListener)

Example 53 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class XMLConfigWebFactory method loadScheduler.

/**
 * @param configServer
 * @param config
 * @param doc
 * @param isEventGatewayContext
 * @throws IOException
 * @throws PageException
 */
private static void loadScheduler(ConfigServer configServer, ConfigImpl config, Document doc) throws PageException, IOException {
    if (config instanceof ConfigServer)
        return;
    Resource configDir = config.getConfigDir();
    Element scheduler = getChildByName(doc.getDocumentElement(), "scheduler");
    // set scheduler
    Resource file = ConfigWebUtil.getFile(config.getRootDirectory(), scheduler.getAttribute("directory"), "scheduler", configDir, FileUtil.TYPE_DIR, config);
    config.setScheduler(configServer.getCFMLEngine(), file);
}
Also used : Element(org.w3c.dom.Element) Resource(lucee.commons.io.res.Resource)

Example 54 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class XMLConfigWebFactory method createContextFiles.

/**
 * Creates all files for Lucee Context
 *
 * @param configDir
 * @throws IOException
 * @throws IOException
 */
private static void createContextFiles(Resource configDir, ServletConfig servletConfig, boolean doNew) throws IOException {
    // NICE dies muss dynamisch erstellt werden, da hier der admin hinkommt
    // und dieser sehr viele files haben wird
    Resource contextDir = configDir.getRealResource("context");
    if (!contextDir.exists())
        contextDir.mkdirs();
    // custom locale files
    {
        Resource dir = configDir.getRealResource("locales");
        if (!dir.exists())
            dir.mkdirs();
        Resource file = dir.getRealResource("pt-PT-date.df");
        if (!file.exists())
            createFileFromResourceEL("/resource/locales/pt-PT-date.df", file);
    }
    // video
    Resource videoDir = configDir.getRealResource("video");
    if (!videoDir.exists())
        videoDir.mkdirs();
    Resource video = videoDir.getRealResource("video.xml");
    if (!video.exists())
        createFileFromResourceEL("/resource/video/video.xml", video);
    // bin
    Resource binDir = configDir.getRealResource("bin");
    if (!binDir.exists())
        binDir.mkdirs();
    Resource ctDir = configDir.getRealResource("customtags");
    if (!ctDir.exists())
        ctDir.mkdirs();
    // Jacob
    if (SystemUtil.isWindows()) {
        String name = (SystemUtil.getJREArch() == SystemUtil.ARCH_64) ? "jacob-x64.dll" : "jacob-i586.dll";
        Resource jacob = binDir.getRealResource(name);
        if (!jacob.exists()) {
            createFileFromResourceEL("/resource/bin/windows" + ((SystemUtil.getJREArch() == SystemUtil.ARCH_64) ? "64" : "32") + "/" + name, jacob);
        }
    }
    Resource storDir = configDir.getRealResource("storage");
    if (!storDir.exists())
        storDir.mkdirs();
    Resource compDir = configDir.getRealResource("components");
    if (!compDir.exists())
        compDir.mkdirs();
    // remove old cacerts files, they are now only in the server context
    Resource secDir = configDir.getRealResource("security");
    Resource f = null;
    if (secDir.exists()) {
        f = secDir.getRealResource("cacerts");
        if (f.exists())
            f.delete();
    } else
        secDir.mkdirs();
    f = secDir.getRealResource("antisamy-basic.xml");
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/security/antisamy-basic.xml", f);
    // lucee-context
    f = contextDir.getRealResource("lucee-context.lar");
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/lucee-context.lar", f);
    else
        createFileFromResourceCheckSizeDiffEL("/resource/context/lucee-context.lar", f);
    // lucee-admin
    f = contextDir.getRealResource("lucee-admin.lar");
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/lucee-admin.lar", f);
    else
        createFileFromResourceCheckSizeDiffEL("/resource/context/lucee-admin.lar", f);
    // lucee-doc
    f = contextDir.getRealResource("lucee-doc.lar");
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/lucee-doc.lar", f);
    else
        createFileFromResourceCheckSizeDiffEL("/resource/context/lucee-doc.lar", f);
    f = contextDir.getRealResource("component-dump." + TEMPLATE_EXTENSION);
    if (!f.exists())
        createFileFromResourceEL("/resource/context/component-dump." + TEMPLATE_EXTENSION, f);
    // Base Component
    String badContent = "<cfcomponent displayname=\"Component\" hint=\"This is the Base Component\">\n</cfcomponent>";
    String badVersion = "704b5bd8597be0743b0c99a644b65896";
    f = contextDir.getRealResource("Component." + COMPONENT_EXTENSION);
    if (!f.exists())
        createFileFromResourceEL("/resource/context/Component." + COMPONENT_EXTENSION, f);
    else if (doNew && badVersion.equals(ConfigWebUtil.createMD5FromResource(f))) {
        createFileFromResourceEL("/resource/context/Component." + COMPONENT_EXTENSION, f);
    } else if (doNew && badContent.equals(createContentFromResource(f).trim())) {
        createFileFromResourceEL("/resource/context/Component." + COMPONENT_EXTENSION, f);
    }
    // Component.lucee
    f = contextDir.getRealResource("Component." + COMPONENT_EXTENSION_LUCEE);
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/Component." + COMPONENT_EXTENSION_LUCEE, f);
    f = contextDir.getRealResource(Constants.CFML_APPLICATION_EVENT_HANDLER);
    if (!f.exists())
        createFileFromResourceEL("/resource/context/Application." + COMPONENT_EXTENSION, f);
    f = contextDir.getRealResource("form." + TEMPLATE_EXTENSION);
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/form." + TEMPLATE_EXTENSION, f);
    f = contextDir.getRealResource("graph." + TEMPLATE_EXTENSION);
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/graph." + TEMPLATE_EXTENSION, f);
    f = contextDir.getRealResource("wddx." + TEMPLATE_EXTENSION);
    if (!f.exists())
        createFileFromResourceEL("/resource/context/wddx." + TEMPLATE_EXTENSION, f);
    f = contextDir.getRealResource("lucee-applet." + TEMPLATE_EXTENSION);
    if (!f.exists())
        createFileFromResourceEL("/resource/context/lucee-applet." + TEMPLATE_EXTENSION, f);
    f = contextDir.getRealResource("lucee-applet.jar");
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/lucee-applet.jar", f);
    // f=new BinaryFile(contextDir,"lucee_context.ra");
    // if(!f.exists())createFileFromResource("/resource/context/lucee_context.ra",f);
    f = contextDir.getRealResource("admin." + TEMPLATE_EXTENSION);
    if (!f.exists())
        createFileFromResourceEL("/resource/context/admin." + TEMPLATE_EXTENSION, f);
    // Video
    f = contextDir.getRealResource("swfobject.js");
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/video/swfobject.js", f);
    f = contextDir.getRealResource("swfobject.js." + TEMPLATE_EXTENSION);
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/video/swfobject.js." + TEMPLATE_EXTENSION, f);
    f = contextDir.getRealResource("mediaplayer.swf");
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/video/mediaplayer.swf", f);
    f = contextDir.getRealResource("mediaplayer.swf." + TEMPLATE_EXTENSION);
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/video/mediaplayer.swf." + TEMPLATE_EXTENSION, f);
    Resource adminDir = contextDir.getRealResource("admin");
    if (!adminDir.exists())
        adminDir.mkdirs();
    // Plugin
    Resource pluginDir = adminDir.getRealResource("plugin");
    if (!pluginDir.exists())
        pluginDir.mkdirs();
    f = pluginDir.getRealResource("Plugin." + COMPONENT_EXTENSION);
    if (!f.exists())
        createFileFromResourceEL("/resource/context/admin/plugin/Plugin." + COMPONENT_EXTENSION, f);
    // Plugin Note
    Resource note = pluginDir.getRealResource("Note");
    if (!note.exists())
        note.mkdirs();
    f = note.getRealResource("language.xml");
    if (!f.exists())
        createFileFromResourceEL("/resource/context/admin/plugin/Note/language.xml", f);
    f = note.getRealResource("overview." + TEMPLATE_EXTENSION);
    if (!f.exists())
        createFileFromResourceEL("/resource/context/admin/plugin/Note/overview." + TEMPLATE_EXTENSION, f);
    f = note.getRealResource("Action." + COMPONENT_EXTENSION);
    if (!f.exists())
        createFileFromResourceEL("/resource/context/admin/plugin/Note/Action." + COMPONENT_EXTENSION, f);
    // gateway
    Resource componentsDir = configDir.getRealResource("components");
    if (!componentsDir.exists())
        componentsDir.mkdirs();
    Resource gwDir = componentsDir.getRealResource("lucee/extension/gateway/");
    create("/resource/context/gateway/", new String[] { "TaskGateway." + COMPONENT_EXTENSION, "DummyGateway." + COMPONENT_EXTENSION, "DirectoryWatcher." + COMPONENT_EXTENSION, "DirectoryWatcherListener." + COMPONENT_EXTENSION, "MailWatcher." + COMPONENT_EXTENSION, "MailWatcherListener." + COMPONENT_EXTENSION }, gwDir, doNew);
    // resources/language
    Resource langDir = adminDir.getRealResource("resources/language");
    create("/resource/context/admin/resources/language/", new String[] { "en.xml", "de.xml" }, langDir, doNew);
    // add Debug
    Resource debug = adminDir.getRealResource("debug");
    create("/resource/context/admin/debug/", new String[] { "Debug." + COMPONENT_EXTENSION, "Field." + COMPONENT_EXTENSION, "Group." + COMPONENT_EXTENSION }, debug, doNew);
    // add Cache Drivers
    Resource cDir = adminDir.getRealResource("cdriver");
    create("/resource/context/admin/cdriver/", new String[] { "Cache." + COMPONENT_EXTENSION, "Field." + COMPONENT_EXTENSION, "Group." + COMPONENT_EXTENSION }, cDir, doNew);
    // add DB Drivers types
    Resource dbDir = adminDir.getRealResource("dbdriver");
    Resource typesDir = dbDir.getRealResource("types");
    create("/resource/context/admin/dbdriver/types/", new String[] { "IDriver." + COMPONENT_EXTENSION, "Driver." + COMPONENT_EXTENSION, "IDatasource." + COMPONENT_EXTENSION, "IDriverSelector." + COMPONENT_EXTENSION, "Field." + COMPONENT_EXTENSION }, typesDir, doNew);
    // add Gateway Drivers
    Resource gDir = adminDir.getRealResource("gdriver");
    create("/resource/context/admin/gdriver/", new String[] { "Gateway." + COMPONENT_EXTENSION, "Field." + COMPONENT_EXTENSION, "Group." + COMPONENT_EXTENSION }, gDir, doNew);
    // add Logging/appender
    Resource app = adminDir.getRealResource("logging/appender");
    create("/resource/context/admin/logging/appender/", new String[] { "Appender." + COMPONENT_EXTENSION, "Field." + COMPONENT_EXTENSION, "Group." + COMPONENT_EXTENSION }, app, doNew);
    // Logging/layout
    Resource lay = adminDir.getRealResource("logging/layout");
    create("/resource/context/admin/logging/layout/", new String[] { "Layout." + COMPONENT_EXTENSION, "Field." + COMPONENT_EXTENSION, "Group." + COMPONENT_EXTENSION }, lay, doNew);
    Resource templatesDir = contextDir.getRealResource("templates");
    if (!templatesDir.exists())
        templatesDir.mkdirs();
    Resource errorDir = templatesDir.getRealResource("error");
    if (!errorDir.exists())
        errorDir.mkdirs();
    f = errorDir.getRealResource("error." + TEMPLATE_EXTENSION);
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/templates/error/error." + TEMPLATE_EXTENSION, f);
    f = errorDir.getRealResource("error-neo." + TEMPLATE_EXTENSION);
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/templates/error/error-neo." + TEMPLATE_EXTENSION, f);
    f = errorDir.getRealResource("error-public." + TEMPLATE_EXTENSION);
    if (!f.exists() || doNew)
        createFileFromResourceEL("/resource/context/templates/error/error-public." + TEMPLATE_EXTENSION, f);
    Resource displayDir = templatesDir.getRealResource("display");
    if (!displayDir.exists())
        displayDir.mkdirs();
}
Also used : Resource(lucee.commons.io.res.Resource)

Example 55 with Resource

use of lucee.commons.io.res.Resource in project Lucee by lucee.

the class XMLConfigWebFactory method createFunctionFiles.

private static void createFunctionFiles(Config config, Resource configDir, Resource dir, boolean doNew) {
    if (config instanceof ConfigServer) {
        Resource f = dir.getRealResource("writeDump." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/writeDump." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("dump." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/dump." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("location." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/location." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("threadJoin." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/threadJoin." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("threadTerminate." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/threadTerminate." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("throw." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/throw." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("trace." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/trace." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("queryExecute." + TEMPLATE_EXTENSION);
        // createFileFromResourceEL("/resource/library/function/queryExecute."+TEMPLATE_EXTENSION, f);
        if (// FUTURE add this instead if(updateType=NEW_FRESH || updateType=NEW_FROM4)
        f.exists())
            delete(dir, "queryExecute." + TEMPLATE_EXTENSION);
        f = dir.getRealResource("transactionCommit." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/transactionCommit." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("transactionRollback." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/transactionRollback." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("transactionSetsavepoint." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/transactionSetsavepoint." + TEMPLATE_EXTENSION, f);
        f = dir.getRealResource("writeLog." + TEMPLATE_EXTENSION);
        if (!f.exists() || doNew)
            createFileFromResourceEL("/resource/library/function/writeLog." + TEMPLATE_EXTENSION, f);
        AjaxFactory.deployFunctions(dir, doNew);
    }
}
Also used : Resource(lucee.commons.io.res.Resource)

Aggregations

Resource (lucee.commons.io.res.Resource)309 IOException (java.io.IOException)100 ApplicationException (lucee.runtime.exp.ApplicationException)54 PageException (lucee.runtime.exp.PageException)40 ArrayList (java.util.ArrayList)31 Struct (lucee.runtime.type.Struct)28 ByteArrayInputStream (java.io.ByteArrayInputStream)21 InputStream (java.io.InputStream)21 ExpressionException (lucee.runtime.exp.ExpressionException)19 StructImpl (lucee.runtime.type.StructImpl)18 MalformedURLException (java.net.MalformedURLException)17 PageContextImpl (lucee.runtime.PageContextImpl)17 PageSource (lucee.runtime.PageSource)16 FileResource (lucee.commons.io.res.type.file.FileResource)15 SecurityException (lucee.runtime.exp.SecurityException)15 BundleException (org.osgi.framework.BundleException)15 ZipEntry (java.util.zip.ZipEntry)13 ExtensionResourceFilter (lucee.commons.io.res.filter.ExtensionResourceFilter)13 Array (lucee.runtime.type.Array)13 File (java.io.File)12