/** * Creates the list of PatternCacheControl objects * @param properties - list of ServiceProperties from the configuration file * @return a list of PatternCacheControl objects */ private List<PatternCacheControl> buildPatternsList(ServiceProperties properties) { Map<String, PatternCacheControl> patterns = new LinkedHashMap<>(); List<ServiceProperties> locationsList = properties.getNested("location"); if (locationsList != null && locationsList.size() != 0) { for (ServiceProperties location : locationsList) { String directiveList = location.get("cache-control"); String[] patternList = location.get("patterns").split("\\s+"); for (String pattern : patternList) { patterns.put(pattern, new PatternCacheControl(pattern, directiveList)); } } resolvePatternSpecificity(patterns); return sortByMatchingPatternCount(patterns); } return new ArrayList<>(patterns.values()); }
isSimpleProperty = false; ServiceProperties newProperties = new DefaultServiceProperties(); properties.getNested(node.getLocalName(), true).add(newProperties); parseProperties(node, newProperties); break;
private static JSONObject asJSONObject(ServiceProperties properties) { JSONObject result = new JSONObject(); try { for (String name : properties.simplePropertyNames()) { result.put(name, properties.get(name)); } for (String name : properties.nestedPropertyNames()) { for (ServiceProperties nested : properties.getNested(name)) { result.append(name, asJSONObject(nested)); } } } catch (JSONException e) { // can't happen (unless ServiceProperties has a bug and incorrectly returns a null property name) throw new RuntimeException(e); } return result; } }
List<ServiceProperties> cookieDomainProperties = properties.getNested("cookie-domain-mapping"); for (ServiceProperties sp : cookieDomainProperties) { cookieDomainMap.put(sp.get("from"), sp.get("to")); List<ServiceProperties> cookiePathProperties = properties.getNested("cookie-path-mapping"); for (ServiceProperties sp : cookiePathProperties) { cookiePathMap.put(sp.get("from"), sp.get("to")); List<ServiceProperties> locationProperties = properties.getNested("location-mapping"); for (ServiceProperties sp : locationProperties) { locationMap.put(sp.get("from"), sp.get("to"));