Search in sources :

Example 16 with MappingImpl

use of lucee.runtime.MappingImpl in project Lucee by lucee.

the class ExportImportHandler method exportMapping.

private static List<Object> exportMapping(Mapping[] mappings, Resource dir, String pathAppendix, String filter) throws IOException {
    List<Object> list = new ArrayList<Object>();
    Map<String, Object> m;
    for (Mapping mapping : mappings) {
        MappingImpl mi = (MappingImpl) mapping;
        m = new HashMap<String, Object>();
        list.add(m);
        m.put("virtual", mapping.getVirtual());
        m.put("inspect", ConfigWebUtil.inspectTemplate(mi.getInspectTemplateRaw(), ""));
        m.put("toplevel", mapping.isTopLevel());
        m.put("readonly", mapping.isReadonly());
        m.put("hidden", mapping.isHidden());
        m.put("physicalFirst", mapping.isPhysicalFirst());
        m.put("hidden", mapping.isHidden());
        // archive
        if (mapping.hasArchive()) {
            Resource archive = mapping.getArchive();
            if (archive.isFile()) {
                Resource arcDir = dir.getRealResource("archive/");
                arcDir.mkdir();
                m.put("archive", pathAppendix + "archive/" + archive.getName());
                IOUtil.copy(archive, arcDir.getRealResource(archive.getName()));
            }
        }
        // physical
        if (mapping.hasPhysical()) {
            Resource physical = mi.getPhysical();
            if (physical.isDirectory()) {
                String id = CreateUniqueId.invoke();
                Resource phyDir = dir.getRealResource("physical/" + id);
                phyDir.mkdirs();
                m.put("physical", pathAppendix + "physical/" + id);
                ResourceFilter f = null;
                if (!StringUtil.isEmpty(filter)) {
                    f = new OrResourceFilter(new ResourceFilter[] { new WildcardPatternFilter(filter, ","), DirectoryResourceFilter.FILTER });
                }
                if (// PATCH this needs more digging
                !physical.getAbsolutePath().equals("/"))
                    ResourceUtil.copyRecursive(physical, phyDir, f);
            }
        }
    }
    return list;
}
Also used : OrResourceFilter(lucee.commons.io.res.filter.OrResourceFilter) ResourceFilter(lucee.commons.io.res.filter.ResourceFilter) DirectoryResourceFilter(lucee.commons.io.res.filter.DirectoryResourceFilter) OrResourceFilter(lucee.commons.io.res.filter.OrResourceFilter) ArrayList(java.util.ArrayList) Resource(lucee.commons.io.res.Resource) Mapping(lucee.runtime.Mapping) WildcardPatternFilter(lucee.commons.io.res.util.WildcardPatternFilter) MappingImpl(lucee.runtime.MappingImpl)

Example 17 with MappingImpl

use of lucee.runtime.MappingImpl in project Lucee by lucee.

the class GetUsageData method templateCacheElements.

private static long[] templateCacheElements(Mapping[] mappings) {
    long elements = 0, size = 0;
    PageSourcePool psp;
    String[] keys;
    PageSourceImpl ps;
    Resource res;
    MappingImpl mapping;
    for (int i = 0; i < mappings.length; i++) {
        mapping = (MappingImpl) mappings[i];
        psp = mapping.getPageSourcePool();
        keys = psp.keys();
        for (int y = 0; y < keys.length; y++) {
            ps = (PageSourceImpl) psp.getPageSource(keys[y], false);
            if (ps.isLoad()) {
                elements++;
                res = mapping.getClassRootDirectory().getRealResource(ps.getClassName().replace('.', '/') + ".class");
                size += res.length();
            }
        }
    }
    return new long[] { elements, size };
}
Also used : Resource(lucee.commons.io.res.Resource) PageSourceImpl(lucee.runtime.PageSourceImpl) MappingImpl(lucee.runtime.MappingImpl) PageSourcePool(lucee.runtime.PageSourcePool)

Example 18 with MappingImpl

use of lucee.runtime.MappingImpl in project Lucee by lucee.

the class PagePoolList method fill.

private static void fill(Array arr, Mapping[] mappings) throws PageException {
    if (mappings == null)
        return;
    MappingImpl mapping;
    for (int i = 0; i < mappings.length; i++) {
        mapping = (MappingImpl) mappings[i];
        toArray(arr, mapping.getPageSourcePool());
    }
}
Also used : MappingImpl(lucee.runtime.MappingImpl)

Aggregations

MappingImpl (lucee.runtime.MappingImpl)18 Mapping (lucee.runtime.Mapping)11 Iterator (java.util.Iterator)4 Resource (lucee.commons.io.res.Resource)4 Entry (java.util.Map.Entry)3 lucee.aprint (lucee.aprint)3 ExtensionResourceFilter (lucee.commons.io.res.filter.ExtensionResourceFilter)3 Query (lucee.runtime.type.Query)3 QueryImpl (lucee.runtime.type.QueryImpl)3 Element (org.w3c.dom.Element)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 DirectoryResourceFilter (lucee.commons.io.res.filter.DirectoryResourceFilter)2 OrResourceFilter (lucee.commons.io.res.filter.OrResourceFilter)2 ResourceFilter (lucee.commons.io.res.filter.ResourceFilter)2 ApplicationException (lucee.runtime.exp.ApplicationException)2 Struct (lucee.runtime.type.Struct)2 IOException (java.io.IOException)1