generated from qbicsoftware/spring-boot-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare release 0.4.0
- Loading branch information
Showing
16 changed files
with
171 additions
and
74 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
src/main/java/life/qbic/data/processing/AccessRightsEvaluation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package life.qbic.data.processing; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* <b>Access and File Evaluation helper class</b> | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public class AccessRightsEvaluation { | ||
|
||
/** | ||
* Convenience method that checks if the application has write and executable permission for the | ||
* given file. | ||
* | ||
* @param file the path of the file of interest to evaluate | ||
* @throws IOException if one or both of the evaluated conditions are failing | ||
* @since 1.0.0 | ||
*/ | ||
public static void evaluateWriteAndExecutablePermission(Path file) throws IOException { | ||
evaluateWriteAndExecutablePermission(file.toFile()); | ||
} | ||
|
||
/** | ||
* Convenience method that checks if the application has write and executable permission for the | ||
* given file. | ||
* | ||
* @param file the file of interest to evaluate | ||
* @throws IOException if one or both of the evaluated conditions are failing | ||
* @since 1.0.0 | ||
*/ | ||
public static void evaluateWriteAndExecutablePermission(File file) throws IOException { | ||
if (!file.canWrite()) { | ||
throw new IOException("Cannot write to file " + file); | ||
} | ||
if (!file.canExecute()) { | ||
throw new IOException("Cannot execute file " + file); | ||
} | ||
} | ||
|
||
/** | ||
* Convenience method that checks if file exists and is a directory. | ||
* | ||
* @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 evaluateExistenceAndDirectory(Path file) throws IOException { | ||
evaluateExistenceAndDirectory(file.toFile()); | ||
} | ||
|
||
/** | ||
* Convenience method that checks if file exists and is a directory. | ||
* | ||
* @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 evaluateExistenceAndDirectory(File file) throws IOException { | ||
if (!file.exists()) { | ||
throw new IOException("File does not exist " + file); | ||
} | ||
if (!file.isDirectory()) { | ||
throw new IOException("File is not a directory " + file); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.