Skip to content

Commit

Permalink
Merge branch 'main' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
sven1103 authored Jun 3, 2024
2 parents 846e47e + f33578d commit 734dfee
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>life.qbic</groupId>
<artifactId>data-processing</artifactId>
<version>0.3.2</version>
<version>0.4.1</version>
<name>data processing</name>
<description>A Java tool that scans file move events and triggers a cascade of dataset
pre-processing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,32 @@ public static void evaluateExistenceAndDirectory(File file) throws IOException {
}
}

/**
* Convenience method that checks if file can be read and executed by the application.
*
* @param file the path of the file of interest to evaluate
* @throws IOException if neither of the evaluated conditions are failing
* @since 1.0.0
*/
public static void evaluateReadAndExecutablePermission(Path file) throws IOException {
evaluateReadAndExecutablePermission(file.toFile());
}

/**
* Convenience method that checks if file can be read and executed by the application.
*
* @param file the file of interest to evaluate
* @throws IOException if neither of the evaluated conditions are failing
* @since 1.0.0
*/
public static void evaluateReadAndExecutablePermission(File file) throws IOException {
if (!file.canExecute()) {
throw new IOException("Cannot execute file " + file);
}
if (!file.canRead()) {
throw new IOException("Cannot read file " + file);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ScannerConfiguration(String scannerDirectory, int interval, String[] igno
throw new IllegalArgumentException("Interval must be greater than 0");
}
AccessRightsEvaluation.evaluateExistenceAndDirectory(this.scannerDirectory);
AccessRightsEvaluation.evaluateWriteAndExecutablePermission(this.scannerDirectory);
AccessRightsEvaluation.evaluateReadAndExecutablePermission(this.scannerDirectory);
this.scanInterval = interval;
this.ignore = Arrays.copyOf(Objects.requireNonNull(ignore), ignore.length);
}
Expand Down

0 comments on commit 734dfee

Please sign in to comment.