Search in sources :

Example 1 with Mapping

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

the class Admin method doGetCustomTagMappings.

/**
 * @throws PageException
 */
private void doGetCustomTagMappings() throws PageException {
    Mapping[] mappings = config.getCustomTagMappings();
    lucee.runtime.type.Query qry = new QueryImpl(new String[] { "archive", "strarchive", "physical", "strphysical", "virtual", "hidden", "physicalFirst", "readonly", "inspect" }, mappings.length, "query");
    for (int i = 0; i < mappings.length; i++) {
        MappingImpl m = (MappingImpl) mappings[i];
        int row = i + 1;
        qry.setAt("archive", row, m.getArchive());
        qry.setAt("strarchive", row, m.getStrArchive());
        qry.setAt("physical", row, m.getPhysical());
        qry.setAt("strphysical", row, m.getStrPhysical());
        qry.setAt("virtual", row, m.getVirtual());
        qry.setAt("hidden", row, Caster.toBoolean(m.isHidden()));
        qry.setAt("physicalFirst", row, Caster.toBoolean(m.isPhysicalFirst()));
        qry.setAt("readonly", row, Caster.toBoolean(m.isReadonly()));
        qry.setAt("inspect", row, ConfigWebUtil.inspectTemplate(m.getInspectTemplateRaw(), ""));
    }
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Mapping(lucee.runtime.Mapping) MappingImpl(lucee.runtime.MappingImpl) Query(lucee.runtime.type.Query)

Example 2 with Mapping

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

the class CFTagCore method createInitFile.

public static InitFile createInitFile(PageContext pageContext, boolean isweb, String filename) {
    ConfigWebImpl config = (ConfigWebImpl) pageContext.getConfig();
    Mapping mapping = isweb ? config.getTagMapping() : config.getServerTagMapping();
    return new InitFile(pageContext, mapping.getPageSource(filename), filename);
}
Also used : ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) InitFile(lucee.runtime.customtag.InitFile) Mapping(lucee.runtime.Mapping)

Example 3 with Mapping

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

the class Admin method doGetMapping.

/**
 * @throws PageException
 */
private void doGetMapping() throws PageException {
    Mapping[] mappings = config.getMappings();
    Struct sct = new StructImpl();
    String virtual = getString("admin", action, "virtual");
    for (int i = 0; i < mappings.length; i++) {
        MappingImpl m = (MappingImpl) mappings[i];
        if (!m.getVirtual().equals(virtual))
            continue;
        sct.set("archive", m.getArchive());
        sct.set("strarchive", m.getStrArchive());
        sct.set("physical", m.getPhysical());
        sct.set("strphysical", m.getStrPhysical());
        sct.set("virtual", m.getVirtual());
        sct.set(KeyConstants._hidden, Caster.toBoolean(m.isHidden()));
        sct.set("physicalFirst", Caster.toBoolean(m.isPhysicalFirst()));
        sct.set("readonly", Caster.toBoolean(m.isReadonly()));
        sct.set("inspect", ConfigWebUtil.inspectTemplate(m.getInspectTemplateRaw(), ""));
        sct.set("toplevel", Caster.toBoolean(m.isTopLevel()));
        pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
        return;
    }
    throw new ApplicationException("there is no mapping with virtual [" + virtual + "]");
}
Also used : StructImpl(lucee.runtime.type.StructImpl) ApplicationException(lucee.runtime.exp.ApplicationException) Mapping(lucee.runtime.Mapping) MappingImpl(lucee.runtime.MappingImpl) Struct(lucee.runtime.type.Struct)

Example 4 with Mapping

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

the class XMLConfigWebFactory method loadRest.

private static void loadRest(ConfigServerImpl configServer, ConfigImpl config, Document doc) {
    // MUST
    boolean hasAccess = true;
    // ConfigWebUtil.hasAccess(config,SecurityManager.TYPE_REST);
    boolean hasCS = configServer != null;
    Element el = getChildByName(doc.getDocumentElement(), "rest");
    // list
    Boolean list = Caster.toBoolean(getAttr(el, "list"), null);
    if (list != null) {
        config.setRestList(list.booleanValue());
    } else if (hasCS) {
        config.setRestList(configServer.getRestList());
    }
    Element[] _mappings = getChildren(el, "mapping");
    // first get mapping defined in server admin (read-only)
    Map<String, lucee.runtime.rest.Mapping> mappings = new HashMap<String, lucee.runtime.rest.Mapping>();
    lucee.runtime.rest.Mapping tmp;
    if (configServer != null && config instanceof ConfigWeb) {
        lucee.runtime.rest.Mapping[] sm = configServer.getRestMappings();
        for (int i = 0; i < sm.length; i++) {
            if (!sm[i].isHidden()) {
                tmp = sm[i].duplicate(config, Boolean.TRUE);
                mappings.put(tmp.getVirtual(), tmp);
            }
        }
    }
    // get current mappings
    if (hasAccess) {
        for (int i = 0; i < _mappings.length; i++) {
            el = _mappings[i];
            String physical = el.getAttribute("physical");
            String virtual = getAttr(el, "virtual");
            boolean readonly = toBoolean(getAttr(el, "readonly"), false);
            boolean hidden = toBoolean(getAttr(el, "hidden"), false);
            boolean _default = toBoolean(getAttr(el, "default"), false);
            if (physical != null) {
                tmp = new lucee.runtime.rest.Mapping(config, virtual, physical, hidden, readonly, _default);
                mappings.put(tmp.getVirtual(), tmp);
            }
        }
    }
    config.setRestMappings(mappings.values().toArray(new lucee.runtime.rest.Mapping[mappings.size()]));
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) Element(org.w3c.dom.Element) Mapping(lucee.runtime.Mapping) lucee.aprint(lucee.aprint)

Example 5 with Mapping

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

the class CustomTagUtil method loadInitFile.

public static InitFile loadInitFile(PageContext pc, String name) throws PageException {
    InitFile initFile = loadInitFile(pc, name, null);
    if (initFile != null) {
        return initFile;
    }
    // EXCEPTION
    ConfigWeb config = pc.getConfig();
    // message
    StringBuilder msg = new StringBuilder("Custom tag \"").append(getDisplayName(config, name)).append("\" was not found.");
    List<String> dirs = new ArrayList();
    if (config.doLocalCustomTag()) {
        dirs.add(ResourceUtil.getResource(pc, pc.getCurrentPageSource()).getParent());
    }
    Mapping[] actms = pc.getApplicationContext().getCustomTagMappings();
    Mapping[] cctms = config.getCustomTagMappings();
    Resource r;
    if (actms != null) {
        for (Mapping m : actms) {
            r = m.getPhysical();
            if (r != null)
                dirs.add(r.toString());
        }
    }
    if (cctms != null) {
        for (Mapping m : cctms) {
            r = m.getPhysical();
            if (r != null)
                dirs.add(r.toString());
        }
    }
    if (!dirs.isEmpty()) {
        msg.append(" Directories searched: ");
        Iterator<String> it = dirs.iterator();
        while (it.hasNext()) {
            msg.append('"').append(it.next()).append('"');
            if (it.hasNext())
                msg.append(", ");
        }
    }
    throw new ExpressionException(msg.toString());
}
Also used : ArrayList(java.util.ArrayList) Resource(lucee.commons.io.res.Resource) Mapping(lucee.runtime.Mapping) ConfigWeb(lucee.runtime.config.ConfigWeb) ExpressionException(lucee.runtime.exp.ExpressionException)

Aggregations

Mapping (lucee.runtime.Mapping)30 MappingImpl (lucee.runtime.MappingImpl)11 PageSource (lucee.runtime.PageSource)7 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)7 ArrayList (java.util.ArrayList)6 PageContextImpl (lucee.runtime.PageContextImpl)6 Resource (lucee.commons.io.res.Resource)5 Struct (lucee.runtime.type.Struct)5 Iterator (java.util.Iterator)4 Entry (java.util.Map.Entry)4 lucee.aprint (lucee.aprint)4 Query (lucee.runtime.type.Query)4 QueryImpl (lucee.runtime.type.QueryImpl)4 Element (org.w3c.dom.Element)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 ApplicationException (lucee.runtime.exp.ApplicationException)3 ExpressionException (lucee.runtime.exp.ExpressionException)3 Key (lucee.runtime.type.Collection.Key)3 StructImpl (lucee.runtime.type.StructImpl)3