Search in sources :

Example 1 with ExtensionResourceFilter

use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.

the class DataSourceServiceImpl method getDrivers.

@Override
public Struct getDrivers() throws ServiceException, SecurityException {
    checkReadAccess();
    Struct rtn = new StructImpl();
    Struct driver;
    try {
        Resource luceeContext = ResourceUtil.toResourceExisting(pc(), "/lucee/admin/dbdriver/");
        Resource[] children = luceeContext.listResources(new ExtensionResourceFilter(Constants.getComponentExtensions()));
        String name;
        for (int i = 0; i < children.length; i++) {
            driver = new StructImpl();
            name = ListFirst.call(pc(), children[i].getName(), ".");
            driver.setEL(KeyConstants._name, name);
            driver.setEL("handler", children[i].getName());
            rtn.setEL(name, driver);
        }
    } catch (ExpressionException e) {
        throw new ServiceException(e.getMessage());
    }
    return rtn;
}
Also used : StructImpl(lucee.runtime.type.StructImpl) ServiceException(coldfusion.server.ServiceException) Resource(lucee.commons.io.res.Resource) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter) ExpressionException(lucee.runtime.exp.ExpressionException) Struct(lucee.runtime.type.Struct)

Example 2 with ExtensionResourceFilter

use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.

the class Admin method doGetDatasourceDriverList.

private void doGetDatasourceDriverList() throws PageException {
    Resource luceeContext = ResourceUtil.toResourceExisting(pageContext, "/lucee/admin/dbdriver/");
    Resource[] children = luceeContext.listResources(new ExtensionResourceFilter(Constants.getComponentExtensions()));
    String rtnVar = getString("admin", action, "returnVariable");
    lucee.runtime.type.Query qry = new QueryImpl(new String[] { "name" }, children.length, rtnVar);
    for (int i = 0; i < children.length; i++) {
        qry.setAt("name", i + 1, children[i].getName());
    }
    pageContext.setVariable(rtnVar, qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Resource(lucee.commons.io.res.Resource) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter) Query(lucee.runtime.type.Query)

Example 3 with ExtensionResourceFilter

use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.

the class ConfigImpl method setFunctionDirectory.

protected void setFunctionDirectory(Resource functionDirectory) {
    this.functionMapping = new MappingImpl(this, "/mapping-function/", functionDirectory.getAbsolutePath(), null, ConfigImpl.INSPECT_NEVER, true, true, true, true, false, true, null, -1, -1);
    FunctionLib flc = cfmlFlds[cfmlFlds.length - 1];
    FunctionLib fll = luceeFlds[luceeFlds.length - 1];
    // now overwrite with new data
    if (functionDirectory.isDirectory()) {
        String[] files = functionDirectory.list(new ExtensionResourceFilter(Constants.getTemplateExtensions()));
        for (int i = 0; i < files.length; i++) {
            if (flc != null)
                createFunction(flc, files[i]);
            if (fll != null)
                createFunction(fll, files[i]);
        }
        combinedCFMLFLDs = null;
        combinedLuceeFLDs = null;
    }
}
Also used : FunctionLib(lucee.transformer.library.function.FunctionLib) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter) MappingImpl(lucee.runtime.MappingImpl)

Example 4 with ExtensionResourceFilter

use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.

the class ConfigServerImpl method loadLocalExtensions.

@Override
public List<ExtensionDefintion> loadLocalExtensions() {
    Resource[] locReses = getLocalExtensionProviderDirectory().listResources(new ExtensionResourceFilter(".lex"));
    if (localExtensions == null || localExtSize != locReses.length || extHash(locReses) != localExtHash) {
        localExtensions = new ArrayList<ExtensionDefintion>();
        Map<String, String> map = new HashMap<String, String>();
        RHExtension ext;
        String v, fileName, uuid, version;
        ExtensionDefintion ed;
        for (int i = 0; i < locReses.length; i++) {
            ed = null;
            // we stay happy with the file name when it has the right pattern (uuid-version.lex)
            fileName = locReses[i].getName();
            if (fileName.length() > 39) {
                uuid = fileName.substring(0, 35);
                version = fileName.substring(36, fileName.length() - 4);
                if (Decision.isUUId(uuid)) {
                    ed = new ExtensionDefintion(uuid, version);
                    ed.setSource(this, locReses[i]);
                }
            }
            if (ed == null) {
                try {
                    ext = new RHExtension(this, locReses[i], false);
                    ed = new ExtensionDefintion(ext.getId(), ext.getVersion());
                    ed.setSource(ext);
                } catch (Exception e) {
                    SystemOut.printDate(e);
                }
            }
            if (ed != null) {
                // check if we already have an extension with the same id to avoid having more than once
                v = map.get(ed.getId());
                if (v != null && v.compareToIgnoreCase(ed.getId()) > 0)
                    continue;
                map.put(ed.getId(), ed.getVersion());
                localExtensions.add(ed);
            }
        }
        localExtHash = extHash(locReses);
        // we store the size because localExtensions size could be smaller because of duplicates
        localExtSize = locReses.length;
    }
    return localExtensions;
}
Also used : RHExtension(lucee.runtime.extension.RHExtension) ExtensionDefintion(lucee.runtime.extension.ExtensionDefintion) HashMap(java.util.HashMap) Resource(lucee.commons.io.res.Resource) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter) FunctionLibException(lucee.transformer.library.function.FunctionLibException) PageException(lucee.runtime.exp.PageException) TagLibException(lucee.transformer.library.tag.TagLibException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 5 with ExtensionResourceFilter

use of lucee.commons.io.res.filter.ExtensionResourceFilter in project Lucee by lucee.

the class MappingUtil method searchMappingRecursive.

public static PageSource searchMappingRecursive(Mapping mapping, String name, boolean onlyCFC) {
    if (name.indexOf('/') == -1) {
        // TODO handle this as well?
        Config config = mapping.getConfig();
        ExtensionResourceFilter ext = null;
        if (onlyCFC)
            ext = new ExtensionResourceFilter(Constants.getComponentExtensions(), true, true);
        else {
            ext = new ExtensionResourceFilter(Constants.getExtensions(), true, true);
        // ext.addExtension(config.getComponentExtension());
        }
        if (mapping.isPhysicalFirst()) {
            PageSource ps = searchPhysical(mapping, name, ext);
            if (ps != null)
                return ps;
            ps = searchArchive(mapping, name, onlyCFC);
            if (ps != null)
                return ps;
        } else {
            PageSource ps = searchArchive(mapping, name, onlyCFC);
            if (ps != null)
                return ps;
            ps = searchPhysical(mapping, name, ext);
            if (ps != null)
                return ps;
        }
    }
    return null;
}
Also used : Config(lucee.runtime.config.Config) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter) PageSource(lucee.runtime.PageSource)

Aggregations

ExtensionResourceFilter (lucee.commons.io.res.filter.ExtensionResourceFilter)16 Resource (lucee.commons.io.res.Resource)13 IOException (java.io.IOException)5 MappingImpl (lucee.runtime.MappingImpl)3 ApplicationException (lucee.runtime.exp.ApplicationException)3 Query (lucee.runtime.type.Query)3 QueryImpl (lucee.runtime.type.QueryImpl)3 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 OrResourceFilter (lucee.commons.io.res.filter.OrResourceFilter)2 ResourceFilter (lucee.commons.io.res.filter.ResourceFilter)2 CompressResource (lucee.commons.io.res.type.compress.CompressResource)2 ExpressionException (lucee.runtime.exp.ExpressionException)2 PageException (lucee.runtime.exp.PageException)2 FunctionLib (lucee.transformer.library.function.FunctionLib)2 FunctionLibException (lucee.transformer.library.function.FunctionLibException)2 TagLib (lucee.transformer.library.tag.TagLib)2 TagLibException (lucee.transformer.library.tag.TagLibException)2 ServiceException (coldfusion.server.ServiceException)1