Search in sources :

Example 1 with GatewayEntryImpl

use of lucee.runtime.gateway.GatewayEntryImpl 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();
    }
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) GatewayEngineImpl(lucee.runtime.gateway.GatewayEngineImpl) Element(org.w3c.dom.Element) lucee.aprint(lucee.aprint) DumpWriterEntry(lucee.runtime.dump.DumpWriterEntry) Entry(java.util.Map.Entry) GatewayEntry(lucee.runtime.gateway.GatewayEntry) GatewayEntry(lucee.runtime.gateway.GatewayEntry) GatewayEntryImpl(lucee.runtime.gateway.GatewayEntryImpl)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Entry (java.util.Map.Entry)1 lucee.aprint (lucee.aprint)1 DumpWriterEntry (lucee.runtime.dump.DumpWriterEntry)1 GatewayEngineImpl (lucee.runtime.gateway.GatewayEngineImpl)1 GatewayEntry (lucee.runtime.gateway.GatewayEntry)1 GatewayEntryImpl (lucee.runtime.gateway.GatewayEntryImpl)1 Element (org.w3c.dom.Element)1