/** * Method {@code convertToMap} converts an {@code Environment} to a nested Map which represents a yml/json structure. * * @param input the environment to be converted * @return the nested map containing the environment's properties */ private Map<String, Object> convertToMap(Environment input) { // First use the current convertToProperties to get a flat Map from the environment Map<String, Object> properties = convertToProperties(input); // The root map which holds all the first level properties Map<String, Object> rootMap = new LinkedHashMap<>(); for (Map.Entry<String, Object> entry : properties.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); PropertyNavigator nav = new PropertyNavigator(key); nav.setMapValue(rootMap, value); } return rootMap; }
@RequestMapping("/{label}/{name}-{profiles}.properties") public ResponseEntity<String> labelledProperties(@PathVariable String name, @PathVariable String profiles, @PathVariable String label, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws IOException { validateProfiles(profiles); Environment environment = labelled(name, profiles, label); Map<String, Object> properties = convertToProperties(environment); String propertiesString = getPropertiesString(properties); if (resolvePlaceholders) { propertiesString = resolvePlaceholders(prepareEnvironment(environment), propertiesString); } return getSuccess(propertiesString); }