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);
}
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);
}
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 + "]");
}
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()]));
}
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());
}
Aggregations