@SuppressWarnings("unchecked") public TokensPool(String dataFolder) { this.dataFolder = dataFolder; Path path = Paths.get(dataFolder, TOKENS_TEMP_FILENAME); this.tokens = (ConcurrentHashMap<String, BaseToken>) deserialize(path); FileUtils.deleteQuietly(path); }
private static void delete(String userReportingDir, int dashId, int deviceId, PinType pinType, short pin, GraphGranularityType reportGranularity) { Path userDataFile = Paths.get(userReportingDir, generateFilename(dashId, deviceId, pinType, pin, reportGranularity)); FileUtils.deleteQuietly(userDataFile); }
@SuppressWarnings("unchecked") public AverageAggregatorProcessor(String dataFolder) { this.dataFolder = dataFolder; Path path; path = Paths.get(dataFolder, MINUTE_TEMP_FILENAME); this.minute = (ConcurrentHashMap<AggregationKey, AggregationValue>) deserialize(path); FileUtils.deleteQuietly(path); path = Paths.get(dataFolder, HOURLY_TEMP_FILENAME); this.hourly = (ConcurrentHashMap<AggregationKey, AggregationValue>) deserialize(path); FileUtils.deleteQuietly(path); path = Paths.get(dataFolder, DAILY_TEMP_FILENAME); this.daily = (ConcurrentHashMap<AggregationKey, AggregationValue>) deserialize(path); FileUtils.deleteQuietly(path); }
public int delete(User user, Function<Path, Boolean> filter) { log.debug("Removing all reporting data for {}", user.email); Path reportingFolderPath = getUserReportingFolderPath(user); int removedFilesCounter = 0; try { if (Files.exists(reportingFolderPath)) { try (DirectoryStream<Path> reportingFolder = Files.newDirectoryStream(reportingFolderPath, "*")) { for (Path reportingFile : reportingFolder) { if (filter.apply(reportingFile)) { log.trace("Removing {}", reportingFile); FileUtils.deleteQuietly(reportingFile); removedFilesCounter++; } } } } } catch (Exception e) { log.error("Error removing file : {}.", reportingFolderPath); } return removedFilesCounter; }
public int delete(User user, int dashId, int deviceId) throws IOException { log.debug("Removing all pin data for dashId {}, deviceId {}.", dashId, deviceId); Path userReportingPath = getUserReportingFolderPath(user); int count = 0; if (Files.exists(userReportingPath)) { String fileNamePrefix = generateFilenamePrefix(dashId, deviceId); try (DirectoryStream<Path> userReportingFolder = Files.newDirectoryStream(userReportingPath, "*")) { for (Path reportingFile : userReportingFolder) { if (reportingFile.getFileName().toString().startsWith(fileNamePrefix)) { FileUtils.deleteQuietly(reportingFile); count++; } } } } return count; }
public int delete(User user, int dashId, int deviceId, String[] pins) throws IOException { log.debug("Removing selected pin data for dashId {}, deviceId {}.", dashId, deviceId); Path userReportingPath = getUserReportingFolderPath(user); int count = 0; List<String> prefixes = new ArrayList<>(); for (String pin : pins) { prefixes.add(generateFilenamePrefix(dashId, deviceId, pin)); } try (DirectoryStream<Path> userReportingFolder = Files.newDirectoryStream(userReportingPath, "*")) { for (Path reportingFile : userReportingFolder) { String userFileName = reportingFile.getFileName().toString(); if (containsPrefix(prefixes, userFileName)) { FileUtils.deleteQuietly(reportingFile); count++; } } } return count; }