protected URL followRedirects(URL aUrl) throws IOException { URL url = aUrl; // If the model points to a properties file, try to find a new location in that // file. If that points to a properties file again, repeat the process. // If at some point the location is marked as not required return null. while (url != null && url.getPath().endsWith(".properties")) { Properties tmpResourceMetaData = PropertiesLoaderUtils.loadProperties(new UrlResource( url)); // Values in the redirecting properties override values in the redirected-to // properties - except LOCATION resourceMetaData.remove(LOCATION); mergeProperties(resourceMetaData, tmpResourceMetaData); String redirect = resourceMetaData.getProperty(LOCATION); if (redirect == null) { throw new IOException("Model URL resolves to properties at [" + url + "] but no redirect property [" + LOCATION + "] found there."); } else if (redirect.startsWith(NOT_REQUIRED)) { url = null; } else { url = resolveLocation(redirect, loader, null); } } return url; }
mergeProperties(resourceMetaData, modelMetaData);