public void save(long locationId, String shapeFile, Map<String, Double> parameterMap) { if (!isValidInput(locationId, shapeFile, parameterMap)) return; File file = getParameterFile(locationId, shapeFile); if (!file.exists()) if (!create(file)) return; try (FileWriter writer = new FileWriter(file)) { gson.toJson(parameterMap, MapType.get(), writer); } catch (IOException e) { log.warn("Error saving file to parameter repository", e); } }
public Map<String, Double> load(long locationId, String shapeFile) { if (!contains(locationId, shapeFile)) // also checks that input // is valid return null; File file = getParameterFile(locationId, shapeFile); try (FileReader reader = new FileReader(file)) { return gson.fromJson(reader, MapType.get()); } catch (IOException e) { log.warn("Error loading file from parameter repository", e); return null; } }