Search in sources :

Example 41 with Resource

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

the class XMLConfigAdmin method updateArchive.

void updateArchive(InputStream is, String name, boolean closeStream) throws IOException, PageException {
    Resource res = write(SystemUtil.getTempDirectory(), is, name, closeStream);
    // Resource res = write(DeployHandler.getDeployDirectory(config),is,name,closeStream);
    updateArchive(config, res);
}
Also used : Resource(lucee.commons.io.res.Resource)

Example 42 with Resource

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

the class XMLConfigAdmin method updateJar.

public static void updateJar(Config config, Resource resJar, boolean reloadWhenClassicJar) throws IOException, BundleException {
    BundleFile bf = new BundleFile(resJar);
    // resJar is a bundle
    if (bf.isBundle()) {
        bf = installBundle(config, bf);
        OSGiUtil.loadBundle(bf);
        return;
    }
    Resource lib = ((ConfigImpl) config).getLibraryDirectory();
    if (!lib.exists())
        lib.mkdir();
    Resource fileLib = lib.getRealResource(resJar.getName());
    // if there is a existing, has the file changed?
    if (fileLib.length() != resJar.length()) {
        IOUtil.closeEL(config.getClassLoader());
        ResourceUtil.copy(resJar, fileLib);
        if (reloadWhenClassicJar)
            ConfigWebUtil.reloadLib(config);
    }
}
Also used : Resource(lucee.commons.io.res.Resource) BundleFile(lucee.runtime.osgi.BundleFile)

Example 43 with Resource

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

the class XMLConfigAdmin method storageGet.

public Object storageGet(Config config, String key) throws ConverterException, IOException, SecurityException {
    checkReadAccess();
    Resource storageDir = getStoragDir(config);
    Resource storage = storageDir.getRealResource(key + ".wddx");
    if (!storage.exists())
        throw new IOException("there is no storage with name " + key);
    WDDXConverter converter = new WDDXConverter(config.getTimeZone(), true, true);
    return converter.deserialize(IOUtil.toString(storage, "UTF-8"), true);
}
Also used : WDDXConverter(lucee.runtime.converter.WDDXConverter) Resource(lucee.commons.io.res.Resource) IOException(java.io.IOException)

Example 44 with Resource

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

the class XMLConfigAdmin method checkForChangesInConfigFile.

public static void checkForChangesInConfigFile(Config config) {
    ConfigImpl ci = (ConfigImpl) config;
    if (!ci.checkForChangesInConfigFile())
        return;
    Resource file = config.getConfigFile();
    long diff = file.lastModified() - ci.lastModified();
    if (diff < 10 && diff > -10)
        return;
    // reload
    try {
        XMLConfigAdmin admin = XMLConfigAdmin.newInstance(ci, null);
        admin._reload();
        SystemOut.printDate(ci.getOutWriter(), "reloaded the configuration [" + file + "] automaticly");
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
}
Also used : Resource(lucee.commons.io.res.Resource)

Example 45 with Resource

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

the class XMLConfigFactory method doNew.

public static UpdateInfo doNew(CFMLEngine engine, Resource contextDir, boolean readOnly) {
    lucee.Info info = engine.getInfo();
    try {
        String strOldVersion;
        final Resource resOldVersion = contextDir.getRealResource("version");
        String strNewVersion = info.getVersion() + "-" + info.getRealeaseTime();
        // fresh install
        if (!resOldVersion.exists()) {
            if (!readOnly) {
                resOldVersion.createNewFile();
                IOUtil.write(resOldVersion, strNewVersion, SystemUtil.getCharset(), false);
            }
            return UpdateInfo.NEW_FRESH;
        } else // changed version
        if (!(strOldVersion = IOUtil.toString(resOldVersion, SystemUtil.getCharset())).equals(strNewVersion)) {
            if (!readOnly)
                IOUtil.write(resOldVersion, strNewVersion, SystemUtil.getCharset(), false);
            Version oldVersion = OSGiUtil.toVersion(strOldVersion);
            return new UpdateInfo(oldVersion, oldVersion.getMajor() < 5 ? NEW_FROM4 : NEW_MINOR);
        }
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
    return UpdateInfo.NEW_NONE;
}
Also used : Version(org.osgi.framework.Version) 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