diff --git a/src/main/java/life/qbic/data/processing/scanner/Scanner.java b/src/main/java/life/qbic/data/processing/scanner/Scanner.java index fa32692..c3b6f0a 100644 --- a/src/main/java/life/qbic/data/processing/scanner/Scanner.java +++ b/src/main/java/life/qbic/data/processing/scanner/Scanner.java @@ -102,16 +102,36 @@ public void run() { private List detectDataForRegistration() { return userProcessDirectories.parallelStream() .map(Path::toFile) + .filter(this::matchesAccessRightsCriteria) + .filter(this::matchesRegistrationCriteria) .map(file -> createRequests(file.listFiles(), file.toPath())).flatMap( Collection::stream).toList(); } + private boolean matchesAccessRightsCriteria(File file) { + if (!file.canWrite()) { + log.error("Cannot write to file '{}'", file); + return false; + } + if (!file.canExecute()) { + log.error("Cannot execute file '{}'", file); + return false; + } + return true; + } + + private boolean matchesRegistrationCriteria(File file) { + if (file.isHidden()) { + return false; + } + return file.isDirectory(); + } + private List createRequests(File[] files, Path userDirectory) { if (files == null || files.length == 0) { return new ArrayList<>(); } - return Arrays.stream(files).filter(file -> !file.isHidden()) - .map(file -> createRequest(file, userDirectory)).toList(); + return Arrays.stream(files).map(file -> createRequest(file, userDirectory)).toList(); } private RegistrationRequest createRequest(File file, Path userDirectory) {