@VisibleForTesting
public static AwsConfiguration parseAwsConfigurations(
Map<Path, String> configurationData, ParseVendorConfigurationAnswerElement pvcae) {
AwsConfiguration config = new AwsConfiguration();
for (Entry<Path, String> configFile : configurationData.entrySet()) {
Path path = configFile.getKey();
int pathLength = configFile.getKey().getNameCount();
String fileText = configFile.getValue();
String regionName = path.getName(pathLength - 2).toString();
String fileName = path.subpath(pathLength - 3, pathLength).toString();
pvcae.getFileMap().put(BfConsts.RELPATH_AWS_CONFIGS_FILE, fileName);
JSONObject jsonObj = null;
try {
jsonObj = new JSONObject(fileText);
} catch (JSONException e) {
pvcae.addRedFlagWarning(
BfConsts.RELPATH_AWS_CONFIGS_FILE,
new Warning(String.format("AWS file %s is not valid JSON", fileName), "AWS"));
}
if (jsonObj != null) {
try {
config.addConfigElement(regionName, jsonObj, fileName, pvcae);
} catch (JSONException e) {
throw new BatfishException("Problems parsing JSON in " + fileName, e);
}
}
}
return config;
}