Search in sources :

Example 11 with ExtensionResourceFilter

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

the class Controler method checkOldClientFile.

private void checkOldClientFile(ConfigWeb config) {
    ExtensionResourceFilter filter = new ExtensionResourceFilter(".script", false);
    // move old structured file in new structure
    try {
        Resource dir = config.getClientScopeDir(), trgres;
        Resource[] children = dir.listResources(filter);
        String src, trg;
        int index;
        for (int i = 0; i < children.length; i++) {
            src = children[i].getName();
            index = src.indexOf('-');
            trg = StorageScopeFile.getFolderName(src.substring(0, index), src.substring(index + 1), false);
            trgres = dir.getRealResource(trg);
            if (!trgres.exists()) {
                trgres.createFile(true);
                ResourceUtil.copy(children[i], trgres);
            }
            // children[i].moveTo(trgres);
            children[i].delete();
        }
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
}
Also used : Resource(lucee.commons.io.res.Resource) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter)

Example 12 with ExtensionResourceFilter

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

the class ConfigImpl method setTagDirectory.

protected void setTagDirectory(Resource tagDirectory) {
    // this.tagDirectory=tagDirectory;
    this.tagMapping = new MappingImpl(this, "/mapping-tag/", tagDirectory.getAbsolutePath(), null, ConfigImpl.INSPECT_NEVER, true, true, true, true, false, true, null, -1, -1);
    TagLib tlc = getCoreTagLib(CFMLEngine.DIALECT_CFML);
    TagLib tll = getCoreTagLib(CFMLEngine.DIALECT_LUCEE);
    // now overwrite with new data
    if (tagDirectory.isDirectory()) {
        String[] files = tagDirectory.list(new ExtensionResourceFilter(getMode() == ConfigImpl.MODE_STRICT ? Constants.getComponentExtensions() : Constants.getExtensions()));
        for (int i = 0; i < files.length; i++) {
            if (tlc != null)
                createTag(tlc, files[i]);
            if (tll != null)
                createTag(tll, files[i]);
        }
    }
}
Also used : TagLib(lucee.transformer.library.tag.TagLib) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter) MappingImpl(lucee.runtime.MappingImpl)

Example 13 with ExtensionResourceFilter

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

the class ConfigImpl method setFldFile.

protected void setFldFile(Resource fileFld, int dialect) throws FunctionLibException {
    if (dialect == CFMLEngine.DIALECT_BOTH) {
        setFldFile(fileFld, CFMLEngine.DIALECT_CFML);
        setFldFile(fileFld, CFMLEngine.DIALECT_LUCEE);
        return;
    }
    FunctionLib[] flds = dialect == CFMLEngine.DIALECT_CFML ? cfmlFlds : luceeFlds;
    // merge all together (backward compatibility)
    if (flds.length > 1)
        for (int i = 1; i < flds.length; i++) {
            overwrite(flds[0], flds[i]);
        }
    flds = new FunctionLib[] { flds[0] };
    if (dialect == CFMLEngine.DIALECT_CFML) {
        cfmlFlds = flds;
        // TODO improve check
        if (cfmlFlds != flds)
            combinedCFMLFLDs = null;
    } else {
        luceeFlds = flds;
        // TODO improve check
        if (luceeFlds != flds)
            combinedLuceeFLDs = null;
    }
    if (fileFld == null)
        return;
    this.fldFile = fileFld;
    // overwrite with addional functions
    FunctionLib fl;
    if (fileFld.isDirectory()) {
        Resource[] files = fileFld.listResources(new ExtensionResourceFilter(new String[] { "fld", "fldx" }));
        for (int i = 0; i < files.length; i++) {
            try {
                fl = FunctionLibFactory.loadFromFile(files[i], getIdentification());
                overwrite(flds[0], fl);
            } catch (FunctionLibException fle) {
                SystemOut.printDate(out, "can't load fld " + files[i]);
                fle.printStackTrace(getErrWriter());
            }
        }
    } else {
        fl = FunctionLibFactory.loadFromFile(fileFld, getIdentification());
        overwrite(flds[0], fl);
    }
}
Also used : FunctionLibException(lucee.transformer.library.function.FunctionLibException) Resource(lucee.commons.io.res.Resource) CompressResource(lucee.commons.io.res.type.compress.CompressResource) FunctionLib(lucee.transformer.library.function.FunctionLib) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter)

Example 14 with ExtensionResourceFilter

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

the class ConfigImpl method setTldFile.

/**
 * set the optional directory of the tag library deskriptors
 * @param fileTld directory of the tag libray deskriptors
 * @throws TagLibException
 */
protected void setTldFile(Resource fileTld, int dialect) throws TagLibException {
    if (dialect == CFMLEngine.DIALECT_BOTH) {
        setTldFile(fileTld, CFMLEngine.DIALECT_CFML);
        setTldFile(fileTld, CFMLEngine.DIALECT_LUCEE);
        return;
    }
    TagLib[] tlds = dialect == CFMLEngine.DIALECT_CFML ? cfmlTlds : luceeTlds;
    if (fileTld == null)
        return;
    this.tldFile = fileTld;
    String key;
    Map<String, TagLib> map = new HashMap<String, TagLib>();
    // First fill existing to set
    for (int i = 0; i < tlds.length; i++) {
        key = getKey(tlds[i]);
        map.put(key, tlds[i]);
    }
    TagLib tl;
    // now overwrite with new data
    if (fileTld.isDirectory()) {
        Resource[] files = fileTld.listResources(new ExtensionResourceFilter(new String[] { "tld", "tldx" }));
        for (int i = 0; i < files.length; i++) {
            try {
                tl = TagLibFactory.loadFromFile(files[i], getIdentification());
                key = getKey(tl);
                if (!map.containsKey(key))
                    map.put(key, tl);
                else
                    overwrite(map.get(key), tl);
            } catch (TagLibException tle) {
                SystemOut.printDate(out, "can't load tld " + files[i]);
                tle.printStackTrace(getErrWriter());
            }
        }
    } else if (fileTld.isFile()) {
        tl = TagLibFactory.loadFromFile(fileTld, getIdentification());
        key = getKey(tl);
        if (!map.containsKey(key))
            map.put(key, tl);
        else
            overwrite(map.get(key), tl);
    }
    // now fill back to array
    tlds = new TagLib[map.size()];
    if (dialect == CFMLEngine.DIALECT_CFML)
        cfmlTlds = tlds;
    else
        luceeTlds = tlds;
    int index = 0;
    Iterator<TagLib> it = map.values().iterator();
    while (it.hasNext()) {
        tlds[index++] = it.next();
    }
}
Also used : HashMap(java.util.HashMap) TagLib(lucee.transformer.library.tag.TagLib) Resource(lucee.commons.io.res.Resource) CompressResource(lucee.commons.io.res.type.compress.CompressResource) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter) TagLibException(lucee.transformer.library.tag.TagLibException)

Example 15 with ExtensionResourceFilter

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

the class TagLibFactory method loadFromDirectory.

/**
 * Laedt mehrere TagLib's die innerhalb eines Verzeichnisses liegen.
 * @param dir Verzeichnis im dem die TagLib's liegen.
 * @param saxParser Definition des Sax Parser mit dem die TagLib's eingelesen werden sollen.
 * @return TagLib's als Array
 * @throws TagLibException
 */
public static TagLib[] loadFromDirectory(Resource dir, Identification id) throws TagLibException {
    if (!dir.isDirectory())
        return new TagLib[0];
    ArrayList<TagLib> arr = new ArrayList<TagLib>();
    Resource[] files = dir.listResources(new ExtensionResourceFilter(new String[] { "tld", "tldx" }));
    for (int i = 0; i < files.length; i++) {
        if (files[i].isFile())
            arr.add(TagLibFactory.loadFromFile(files[i], id));
    }
    return arr.toArray(new TagLib[arr.size()]);
}
Also used : ArrayList(java.util.ArrayList) Resource(lucee.commons.io.res.Resource) ExtensionResourceFilter(lucee.commons.io.res.filter.ExtensionResourceFilter)

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