private static void loadMappings(ConfigServerImpl configServer, ConfigImpl config, Document doc, int mode, Log log) throws IOException {
	try {
	    boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_MAPPING);
	    Element el = getChildByName(doc.getDocumentElement(), "mappings");
	    Element[] _mappings = getChildren(el, "mapping");

	    Map<String, Mapping> mappings = MapFactory.<String, Mapping>getConcurrentMap();
	    Mapping tmp;

	    boolean finished = false;

	    if (configServer != null && config instanceof ConfigWeb) {
		Mapping[] sm = configServer.getMappings();
		if (sm != null) {
		    for (int i = 0; i < sm.length; i++) {
			if (!sm[i].isHidden()) {
			    if ("/".equals(sm[i].getVirtual())) finished = true;
			    if (sm[i] instanceof MappingImpl) {
				tmp = ((MappingImpl) sm[i]).cloneReadOnly(config);
				mappings.put(tmp.getVirtualLowerCase(), tmp);

			    }
			    else {
				tmp = sm[i];
				mappings.put(tmp.getVirtualLowerCase(), tmp);
			    }
			}
		    }
		}
	    }

	    if (hasAccess) {
		boolean hasServerContext = false;
		for (int i = 0; i < _mappings.length; i++) {
		    el = _mappings[i];

		    String physical = el.getAttribute("physical");
		    String archive = el.getAttribute("archive");
		    String virtual = getAttr(el, "virtual");
		    String listType = getAttr(el, "listener-type");
		    String listMode = getAttr(el, "listener-mode");

		    boolean readonly = toBoolean(getAttr(el, "readonly"), false);
		    boolean hidden = toBoolean(getAttr(el, "hidden"), false);
		    boolean toplevel = toBoolean(getAttr(el, "toplevel"), true);

		    if (config instanceof ConfigServer && (virtual.equalsIgnoreCase("/lucee-server/") || virtual.equalsIgnoreCase("/lucee-server-context/"))) {
			hasServerContext = true;
		    }

		    // lucee
		    if (virtual.equalsIgnoreCase("/lucee/")) {
			if (StringUtil.isEmpty(listType, true)) listType = "modern";
			if (StringUtil.isEmpty(listMode, true)) listMode = "curr2root";
			toplevel = true;
		    }

		    int listenerMode = ConfigWebUtil.toListenerMode(listMode, -1);
		    int listenerType = ConfigWebUtil.toListenerType(listType, -1);
		    ApplicationListener listener = ConfigWebUtil.loadListener(listenerType, null);
		    if (listener != null || listenerMode != -1) {
			// type
			if (mode == ConfigImpl.MODE_STRICT) listener = new ModernAppListener();
			else if (listener == null) listener = ConfigWebUtil.loadListener(ConfigWebUtil.toListenerType(config.getApplicationListener().getType(), -1), null);
			if (listener == null)// this should never be true
			    listener = new ModernAppListener();

			// mode
			if (listenerMode == -1) {
			    listenerMode = config.getApplicationListener().getMode();
			}
			listener.setMode(listenerMode);

		    }

		    // physical!=null &&
		    if ((physical != null || archive != null)) {

			short insTemp = inspectTemplate(el);
			if ("/lucee/".equalsIgnoreCase(virtual) || "/lucee".equalsIgnoreCase(virtual) || "/lucee-server/".equalsIgnoreCase(virtual)
				|| "/lucee-server-context".equalsIgnoreCase(virtual))
			    insTemp = ConfigImpl.INSPECT_ONCE;

			String primary = getAttr(el, "primary");
			boolean physicalFirst = primary == null || !primary.equalsIgnoreCase("archive");

			tmp = new MappingImpl(config, virtual, physical, archive, insTemp, physicalFirst, hidden, readonly, toplevel, false, false, listener, listenerMode,
				listenerType);
			mappings.put(tmp.getVirtualLowerCase(), tmp);
			if (virtual.equals("/")) {
			    finished = true;
			    // break;
			}
		    }
		}

		// set default lucee-server-context
		if (config instanceof ConfigServer && !hasServerContext) {
		    ApplicationListener listener = ConfigWebUtil.loadListener(ApplicationListener.TYPE_MODERN, null);
		    listener.setMode(ApplicationListener.MODE_CURRENT2ROOT);

		    tmp = new MappingImpl(config, "/lucee-server", "{lucee-server}/context/", null, ConfigImpl.INSPECT_ONCE, true, false, true, true, false, false, listener,
			    ApplicationListener.MODE_CURRENT2ROOT, ApplicationListener.TYPE_MODERN);
		    mappings.put(tmp.getVirtualLowerCase(), tmp);
		}
	    }

	    if (!finished) {

		if ((config instanceof ConfigWebImpl) && ResourceUtil.isUNCPath(config.getRootDirectory().getPath())) {

		    tmp = new MappingImpl(config, "/", config.getRootDirectory().getPath(), null, ConfigImpl.INSPECT_UNDEFINED, true, true, true, true, false, false, null, -1, -1);
		}
		else {

		    tmp = new MappingImpl(config, "/", "/", null, ConfigImpl.INSPECT_UNDEFINED, true, true, true, true, false, false, null, -1, -1);
		}

		mappings.put("/", tmp);
	    }

	    Mapping[] arrMapping = new Mapping[mappings.size()];
	    int index = 0;
	    Iterator it = mappings.keySet().iterator();
	    while (it.hasNext()) {
		arrMapping[index++] = mappings.get(it.next());
	    }
	    config.setMappings(arrMapping);
	    // config.setMappings((Mapping[]) mappings.toArray(new
	    // Mapping[mappings.size()]));
	}
	catch (Exception e) {
	    log(config, log, e);
	}
    }
private static void loadMappings ( ConfigServerImpl configServer , ConfigImpl config , Document doc , int mode , Log log ) throws IOException { try { boolean hasAccess = ConfigWebUtil . hasAccess ( config , SecurityManager . TYPE_MAPPING ) ; Element el = getChildByName ( doc . getDocumentElement ( ) , "mappings" ) ; Element [ ] _mappings = getChildren ( el , "mapping" ) ; Map < String , Mapping > mappings = MapFactory . < String , Mapping > getConcurrentMap ( ) ; Mapping tmp ; boolean finished = false ; if ( configServer != null && config instanceof ConfigWeb ) { Mapping [ ] sm = configServer . getMappings ( ) ; if ( sm != null ) { for ( int i = 0 ; i < sm . length ; i ++ ) { if ( ! sm [ i ] . isHidden ( ) ) { if ( "/" . equals ( sm [ i ] . getVirtual ( ) ) ) finished = true ; if ( sm [ i ] instanceof MappingImpl ) { tmp = ( ( MappingImpl ) sm [ i ] ) . cloneReadOnly ( config ) ; mappings . put ( tmp . getVirtualLowerCase ( ) , tmp ) ; } else { tmp = sm [ i ] ; mappings . put ( tmp . getVirtualLowerCase ( ) , tmp ) ; } } } } } if ( hasAccess ) { boolean hasServerContext = false ; for ( int i = 0 ; i < _mappings . length ; i ++ ) { el = _mappings [ i ] ; String physical = el . getAttribute ( "physical" ) ; String archive = el . getAttribute ( "archive" ) ; String virtual = getAttr ( el , "virtual" ) ; String listType = getAttr ( el , "listener-type" ) ; String listMode = getAttr ( el , "listener-mode" ) ; boolean readonly = toBoolean ( getAttr ( el , "readonly" ) , false ) ; boolean hidden = toBoolean ( getAttr ( el , "hidden" ) , false ) ; boolean toplevel = toBoolean ( getAttr ( el , "toplevel" ) , true ) ; if ( config instanceof ConfigServer && ( virtual . equalsIgnoreCase ( "/lucee-server/" ) || virtual . equalsIgnoreCase ( "/lucee-server-context/" ) ) ) { hasServerContext = true ; } if ( virtual . equalsIgnoreCase ( "/lucee/" ) ) { if ( StringUtil . isEmpty ( listType , true ) ) listType = "modern" ; if ( StringUtil . isEmpty ( listMode , true ) ) listMode = "curr2root" ; toplevel = true ; } int listenerMode = ConfigWebUtil . toListenerMode ( listMode , - 1 ) ; int listenerType = ConfigWebUtil . toListenerType ( listType , - 1 ) ; ApplicationListener listener = ConfigWebUtil . loadListener ( listenerType , null ) ; if ( listener != null || listenerMode != - 1 ) { if ( mode == ConfigImpl . MODE_STRICT ) listener = new ModernAppListener ( ) ; else if ( listener == null ) listener = ConfigWebUtil . loadListener ( ConfigWebUtil . toListenerType ( config . getApplicationListener ( ) . getType ( ) , - 1 ) , null ) ; if ( listener == null ) listener = new ModernAppListener ( ) ; if ( listenerMode == - 1 ) { listenerMode = config . getApplicationListener ( ) . getMode ( ) ; } listener . setMode ( listenerMode ) ; } if ( ( physical != null || archive != null ) ) { short insTemp = inspectTemplate ( el ) ; if ( "/lucee/" . equalsIgnoreCase ( virtual ) || "/lucee" . equalsIgnoreCase ( virtual ) || "/lucee-server/" . equalsIgnoreCase ( virtual ) || "/lucee-server-context" . equalsIgnoreCase ( virtual ) ) insTemp = ConfigImpl . INSPECT_ONCE ; String primary = getAttr ( el , "primary" ) ; boolean physicalFirst = primary == null || ! primary . equalsIgnoreCase ( "archive" ) ; tmp = new MappingImpl ( config , virtual , physical , archive , insTemp , physicalFirst , hidden , readonly , toplevel , false , false , listener , listenerMode , listenerType ) ; mappings . put ( tmp . getVirtualLowerCase ( ) , tmp ) ; if ( virtual . equals ( "/" ) ) { finished = true ; } } } if ( config instanceof ConfigServer && ! hasServerContext ) { ApplicationListener listener = ConfigWebUtil . loadListener ( ApplicationListener . TYPE_MODERN , null ) ; listener . setMode ( ApplicationListener . MODE_CURRENT2ROOT ) ; tmp = new MappingImpl ( config , "/lucee-server" , "{lucee-server}/context/" , null , ConfigImpl . INSPECT_ONCE , true , false , true , true , false , false , listener , ApplicationListener . MODE_CURRENT2ROOT , ApplicationListener . TYPE_MODERN ) ; mappings . put ( tmp . getVirtualLowerCase ( ) , tmp ) ; } } if ( ! finished ) { if ( ( config instanceof ConfigWebImpl ) && ResourceUtil . isUNCPath ( config . getRootDirectory ( ) . getPath ( ) ) ) { tmp = new MappingImpl ( config , "/" , config . getRootDirectory ( ) . getPath ( ) , null , ConfigImpl . INSPECT_UNDEFINED , true , true , true , true , false , false , null , - 1 , - 1 ) ; } else { tmp = new MappingImpl ( config , "/" , "/" , null , ConfigImpl . INSPECT_UNDEFINED , true , true , true , true , false , false , null , - 1 , - 1 ) ; } mappings . put ( "/" , tmp ) ; } Mapping [ ] arrMapping = new Mapping [ mappings . size ( ) ] ; int index = 0 ; Iterator it = mappings . keySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { arrMapping [ index ++ ] = mappings . get ( it . next ( ) ) ; } config . setMappings ( arrMapping ) ; } catch ( Exception e ) { log ( config , log , e ) ; } }
load mappings from XML Document

@param configServer
@param config
@param doc
@throws IOException