use of lucee.runtime.gateway.GatewayEntry in project Lucee by lucee.
the class XMLConfigWebFactory method loadGateway.
private static void loadGateway(ConfigServerImpl configServer, ConfigImpl config, Document doc) {
boolean hasCS = configServer != null;
// ConfigWebImpl cw = (ConfigWebImpl) config;
GatewayEngineImpl engine = hasCS ? ((ConfigWebImpl) config).getGatewayEngine() : null;
Map<String, GatewayEntry> mapGateways = new HashMap<String, GatewayEntry>();
// get from server context
if (hasCS) {
Map<String, GatewayEntry> entries = configServer.getGatewayEntries();
if (entries != null && !entries.isEmpty()) {
Iterator<Entry<String, GatewayEntry>> it = entries.entrySet().iterator();
Entry<String, GatewayEntry> e;
while (it.hasNext()) {
e = it.next();
mapGateways.put(e.getKey(), ((GatewayEntryImpl) e.getValue()).duplicateReadOnly(engine));
}
}
}
Element eGateWay = getChildByName(doc.getDocumentElement(), "gateways");
boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManagerImpl.TYPE_GATEWAY);
GatewayEntry ge;
// cache connections
Element[] gateways = getChildren(eGateWay, "gateway");
// if(hasAccess) {
String id;
// caches
if (hasAccess) {
for (int i = 0; i < gateways.length; i++) {
Element eConnection = gateways[i];
id = getAttr(eConnection, "id").trim().toLowerCase();
ge = new GatewayEntryImpl(engine, id, getClassDefinition(eConnection, "", config.getIdentification()), eConnection.getAttribute("cfc-path"), eConnection.getAttribute("listener-cfc-path"), getAttr(eConnection, "startup-mode"), toStruct(getAttr(eConnection, "custom")), Caster.toBooleanValue(getAttr(eConnection, "read-only"), false));
if (!StringUtil.isEmpty(id)) {
mapGateways.put(id.toLowerCase(), ge);
} else
SystemOut.print(config.getErrWriter(), "missing id");
}
config.setGatewayEntries(mapGateways);
} else if (hasCS) {
((ConfigWebImpl) config).getGatewayEngine().clear();
}
}
use of lucee.runtime.gateway.GatewayEntry in project Lucee by lucee.
the class Admin method doGetGatewayEntries.
private void doGetGatewayEntries() throws PageException {
Map entries = ((ConfigWebImpl) config).getGatewayEngine().getEntries();
Iterator it = entries.entrySet().iterator();
lucee.runtime.type.Query qry = new QueryImpl(new String[] { "class", "bundleName", "bundleVersion", "id", "custom", "cfcPath", "listenerCfcPath", "startupMode", "state", "readOnly" }, 0, "entries");
Map.Entry entry;
GatewayEntry ge;
// Gateway g;
int row = 0;
while (it.hasNext()) {
row++;
entry = (Entry) it.next();
ge = (GatewayEntry) entry.getValue();
// g=ge.getGateway();
qry.addRow();
qry.setAtEL("class", row, ge.getClassDefinition().getClassName());
qry.setAtEL("bundleName", row, ge.getClassDefinition().getName());
qry.setAtEL("bundleVersion", row, ge.getClassDefinition().getVersionAsString());
qry.setAtEL("id", row, ge.getId());
qry.setAtEL("listenerCfcPath", row, ge.getListenerCfcPath());
qry.setAtEL("cfcPath", row, ge.getCfcPath());
qry.setAtEL("startupMode", row, GatewayEntryImpl.toStartup(ge.getStartupMode(), "automatic"));
qry.setAtEL("custom", row, ge.getCustom());
qry.setAtEL("readOnly", row, Caster.toBoolean(ge.isReadOnly()));
qry.setAtEL("state", row, GatewayEngineImpl.toStringState(GatewayUtil.getState(ge), "failed"));
}
pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
use of lucee.runtime.gateway.GatewayEntry in project Lucee by lucee.
the class Admin method doGetGatewayEntry.
private void doGetGatewayEntry() throws PageException {
String id = getString("admin", action, "id");
Map entries = ((ConfigWebImpl) config).getGatewayEngine().getEntries();
Iterator it = entries.keySet().iterator();
GatewayEntry ge;
// Gateway g;
Struct sct;
while (it.hasNext()) {
String key = (String) it.next();
if (key.equalsIgnoreCase(id)) {
ge = (GatewayEntry) entries.get(key);
// g=ge.getGateway();
sct = new StructImpl();
sct.setEL("id", ge.getId());
sct.setEL("class", ge.getClassDefinition().getClassName());
sct.setEL("bundleName", ge.getClassDefinition().getName());
sct.setEL("bundleVersion", ge.getClassDefinition().getVersionAsString());
sct.setEL("listenerCfcPath", ge.getListenerCfcPath());
sct.setEL("cfcPath", ge.getCfcPath());
sct.setEL("startupMode", GatewayEntryImpl.toStartup(ge.getStartupMode(), "automatic"));
sct.setEL("custom", ge.getCustom());
sct.setEL("readOnly", Caster.toBoolean(ge.isReadOnly()));
sct.setEL("state", GatewayEngineImpl.toStringState(GatewayUtil.getState(ge), "failed"));
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
return;
}
}
throw new ApplicationException("there is no gateway entry with id [" + id + "]");
}
use of lucee.runtime.gateway.GatewayEntry in project Lucee by lucee.
the class XMLConfigAdmin method _removeGatewayEntry.
protected void _removeGatewayEntry(String name) throws PageException {
if (StringUtil.isEmpty(name))
throw new ExpressionException("name for Gateway Id can be a empty value");
Element parent = _getRootElement("gateways");
// remove element
Element[] children = XMLConfigWebFactory.getChildren(parent, "gateway");
for (int i = 0; i < children.length; i++) {
String n = children[i].getAttribute("id");
if (n != null && n.equalsIgnoreCase(name)) {
Map conns = ((ConfigWebImpl) config).getGatewayEngine().getEntries();
GatewayEntry ge = (GatewayEntry) conns.get(n);
if (ge != null) {
((ConfigWebImpl) config).getGatewayEngine().remove(ge);
}
parent.removeChild(children[i]);
}
}
}
Aggregations