Search in sources :

Example 31 with Resource

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

the class XMLConfigAdmin method _updateWebContexts.

private static void _updateWebContexts(Config config, InputStream is, String realpath, boolean closeStream, List<Resource> filesDeployed, boolean store) throws PageException, IOException, SAXException, BundleException {
    if (!(config instanceof ConfigServer))
        throw new ApplicationException("invalid context, you can only call this method from server context");
    ConfigServer cs = (ConfigServer) config;
    Resource wcd = cs.getConfigDir().getRealResource("web-context-deployment");
    Resource trg = wcd.getRealResource(realpath);
    if (trg.exists())
        trg.remove(true);
    Resource p = trg.getParentResource();
    if (!p.isDirectory())
        p.createDirectory(true);
    IOUtil.copy(is, trg.getOutputStream(false), closeStream, true);
    filesDeployed.add(trg);
    if (store)
        _storeAndReload((ConfigImpl) config);
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) Resource(lucee.commons.io.res.Resource)

Example 32 with Resource

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

the class XMLConfigAdmin method _removeComponent.

private boolean _removeComponent(Config config, String realpath, boolean _store) throws PageException, IOException, SAXException, BundleException {
    // MUST get dyn
    Resource context = config.getConfigDir().getRealResource("components");
    Resource trg = context.getRealResource(realpath);
    if (trg.exists()) {
        trg.remove(true);
        if (_store)
            XMLConfigAdmin._storeAndReload((ConfigImpl) config);
        ResourceUtil.removeEmptyFolders(context, null);
        return true;
    }
    return false;
}
Also used : Resource(lucee.commons.io.res.Resource)

Example 33 with Resource

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

the class XMLConfigAdmin method updateApplication.

Resource[] updateApplication(InputStream is, String realpath, boolean closeStream) throws PageException, IOException, SAXException {
    List<Resource> filesDeployed = new ArrayList<Resource>();
    Resource dir;
    // server context
    if (config instanceof ConfigServer)
        dir = config.getConfigDir().getRealResource("web-deployment");
    else
        // if web context we simply deploy to that webcontext, that's all
        dir = config.getRootDirectory();
    deployFilesFromStream(config, dir, is, realpath, closeStream, filesDeployed);
    return filesDeployed.toArray(new Resource[filesDeployed.size()]);
}
Also used : Resource(lucee.commons.io.res.Resource) ArrayList(java.util.ArrayList)

Example 34 with Resource

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

the class XMLConfigAdmin method write.

private static Resource write(Resource dir, InputStream is, String name, boolean closeStream) throws IOException {
    if (!dir.exists())
        dir.createDirectory(true);
    Resource file = dir.getRealResource(name);
    Resource p = file.getParentResource();
    if (!p.exists())
        p.createDirectory(true);
    IOUtil.copy(is, file.getOutputStream(), closeStream, true);
    return file;
}
Also used : Resource(lucee.commons.io.res.Resource)

Example 35 with Resource

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

the class XMLConfigAdmin method updateCPPCFX.

public void updateCPPCFX(String name, String procedure, String strServerLibrary, boolean keepAlive) throws PageException {
    checkWriteAccess();
    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_CFX_SETTING);
    if (!hasAccess)
        throw new SecurityException("no access to change cfx settings");
    // name
    if (StringUtil.isEmpty(name))
        throw new ExpressionException("name cannot be a empty value");
    // serverLibrary
    if (StringUtil.isEmpty(strServerLibrary))
        throw new ExpressionException("serverLibrary cannot be a empty value");
    Resource serverLibrary = ResourceUtil.toResourceExisting(config, strServerLibrary);
    // procedure
    if (StringUtil.isEmpty(procedure))
        throw new ExpressionException("procedure cannot be a empty value");
    renameOldstyleCFX();
    Element tags = _getRootElement("ext-tags");
    // Update
    Element[] children = XMLConfigWebFactory.getChildren(tags, "ext-tag");
    for (int i = 0; i < children.length; i++) {
        String n = children[i].getAttribute("name");
        if (n != null && n.equalsIgnoreCase(name)) {
            Element el = children[i];
            if (!"cpp".equalsIgnoreCase(el.getAttribute("type")))
                throw new ExpressionException("there is already a java cfx tag with this name");
            el.setAttribute("server-library", serverLibrary.getAbsolutePath());
            el.setAttribute("procedure", procedure);
            el.setAttribute("keep-alive", Caster.toString(keepAlive));
            el.setAttribute("type", "cpp");
            return;
        }
    }
    // Insert
    Element el = doc.createElement("ext-tag");
    tags.appendChild(el);
    el.setAttribute("server-library", serverLibrary.getAbsolutePath());
    el.setAttribute("procedure", procedure);
    el.setAttribute("keep-alive", Caster.toString(keepAlive));
    el.setAttribute("name", name);
    el.setAttribute("type", "cpp");
}
Also used : Element(org.w3c.dom.Element) Resource(lucee.commons.io.res.Resource) SecurityException(lucee.runtime.exp.SecurityException) ExpressionException(lucee.runtime.exp.ExpressionException)

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