Search in sources :

Example 1 with ExtensionFilter

use of lucee.loader.util.ExtensionFilter in project Lucee by lucee.

the class ConfigServerImpl method getInstalledPatchesOld.

private String[] getInstalledPatchesOld(CFMLEngineFactory factory) throws IOException {
    File patchDir = new File(factory.getResourceRoot(), "patches");
    if (!patchDir.exists())
        patchDir.mkdirs();
    File[] patches = patchDir.listFiles(new ExtensionFilter(new String[] { "." + getCoreExtension() }));
    List<String> list = new ArrayList<String>();
    String name;
    int extLen = getCoreExtension().length() + 1;
    for (int i = 0; i < patches.length; i++) {
        name = patches[i].getName();
        name = name.substring(0, name.length() - extLen);
        list.add(name);
    }
    String[] arr = list.toArray(new String[list.size()]);
    Arrays.sort(arr);
    return arr;
}
Also used : ExtensionFilter(lucee.loader.util.ExtensionFilter) ArrayList(java.util.ArrayList) File(java.io.File)

Example 2 with ExtensionFilter

use of lucee.loader.util.ExtensionFilter in project Lucee by lucee.

the class CFMLEngineFactory method getInstalledPatches.

public String[] getInstalledPatches() throws ServletException, IOException {
    final File patchDir = getPatchDirectory();
    final File[] patches = patchDir.listFiles(new ExtensionFilter(new String[] { ".lco" }));
    final List<String> list = new ArrayList<String>();
    String name;
    final int extLen = "rc".length() + 1;
    for (final File patche : patches) {
        name = patche.getName();
        name = name.substring(0, name.length() - extLen);
        list.add(name);
    }
    final String[] arr = list.toArray(new String[list.size()]);
    Arrays.sort(arr);
    return arr;
}
Also used : ExtensionFilter(lucee.loader.util.ExtensionFilter) ArrayList(java.util.ArrayList) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 3 with ExtensionFilter

use of lucee.loader.util.ExtensionFilter in project Lucee by lucee.

the class CFMLEngineFactory method removeLatestUpdate.

private boolean removeLatestUpdate() throws IOException, ServletException {
    final File patchDir = getPatchDirectory();
    final File[] patches = patchDir.listFiles(new ExtensionFilter(new String[] { ".lco" }));
    File patch = null;
    for (final File patche : patches) if (patch == null || Util.isNewerThan(toVersion(patche.getName(), VERSION_ZERO), toVersion(patch.getName(), VERSION_ZERO)))
        patch = patche;
    if (patch != null && !patch.delete())
        patch.deleteOnExit();
    _restart();
    return true;
}
Also used : ExtensionFilter(lucee.loader.util.ExtensionFilter) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 4 with ExtensionFilter

use of lucee.loader.util.ExtensionFilter in project Lucee by lucee.

the class XMLConfigAdmin method changeVersionTo.

public void changeVersionTo(Version version, Password password, IdentificationWeb id) throws PageException {
    checkWriteAccess();
    ConfigServerImpl cs = (ConfigServerImpl) ConfigImpl.getConfigServer(config, password);
    try {
        CFMLEngineFactory factory = cs.getCFMLEngine().getCFMLEngineFactory();
        cleanUp(factory);
        // do we have the core file?
        final File patchDir = factory.getPatchDirectory();
        File localPath = new File(version.toString() + ".lco");
        if (!localPath.isFile()) {
            localPath = null;
            Version v;
            final File[] patches = patchDir.listFiles(new ExtensionFilter(new String[] { ".lco" }));
            for (final File patch : patches) {
                v = CFMLEngineFactory.toVersion(patch.getName(), null);
                // not a valid file get deleted
                if (v == null) {
                    patch.delete();
                } else {
                    if (v.equals(version)) {
                        // match!
                        localPath = patch;
                    } else // delete newer files
                    if (OSGiUtil.isNewerThan(v, version)) {
                        patch.delete();
                    }
                }
            }
        }
        // download patch
        if (localPath == null) {
            downloadCore(factory, version, id);
        }
        factory.restart(password);
    } catch (Exception e) {
        throw Caster.toPageException(e);
    }
}
Also used : Version(org.osgi.framework.Version) ExtensionFilter(lucee.loader.util.ExtensionFilter) BundleFile(lucee.runtime.osgi.BundleFile) File(java.io.File) IsZipFile(lucee.runtime.functions.system.IsZipFile) ZipFile(java.util.zip.ZipFile) FunctionLibException(lucee.transformer.library.function.FunctionLibException) PageException(lucee.runtime.exp.PageException) ConverterException(lucee.runtime.converter.ConverterException) SecurityException(lucee.runtime.exp.SecurityException) TagLibException(lucee.transformer.library.tag.TagLibException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) CFXTagException(lucee.runtime.cfx.CFXTagException) BundleException(org.osgi.framework.BundleException) SAXException(org.xml.sax.SAXException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ClassException(lucee.commons.lang.ClassException) DOMException(org.w3c.dom.DOMException) MalformedURLException(java.net.MalformedURLException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException) HTTPException(lucee.runtime.exp.HTTPException) CFMLEngineFactory(lucee.loader.engine.CFMLEngineFactory)

Example 5 with ExtensionFilter

use of lucee.loader.util.ExtensionFilter in project Lucee by lucee.

the class XMLConfigAdmin method cleanUp.

private void cleanUp(CFMLEngineFactory factory) throws IOException {
    final File patchDir = factory.getPatchDirectory();
    final File[] patches = patchDir.listFiles(new ExtensionFilter(new String[] { ".lco" }));
    for (final File patch : patches) {
        if (!IsZipFile.invoke(patch))
            patch.delete();
    }
}
Also used : ExtensionFilter(lucee.loader.util.ExtensionFilter) BundleFile(lucee.runtime.osgi.BundleFile) File(java.io.File) IsZipFile(lucee.runtime.functions.system.IsZipFile) ZipFile(java.util.zip.ZipFile)

Aggregations

File (java.io.File)7 ExtensionFilter (lucee.loader.util.ExtensionFilter)7 JarFile (java.util.jar.JarFile)4 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)2 ZipFile (java.util.zip.ZipFile)2 IsZipFile (lucee.runtime.functions.system.IsZipFile)2 BundleFile (lucee.runtime.osgi.BundleFile)2 BundleException (org.osgi.framework.BundleException)2 Version (org.osgi.framework.Version)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1