Class DirectoryValidator


  • public class DirectoryValidator
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.io.File> dirsToCheck  
      private static Logger LOG  
    • Constructor Summary

      Constructors 
      Constructor Description
      DirectoryValidator​(java.util.List<java.io.File> dirsToCheck)
      Creates DirectoryValidator to ensure given directories
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DirectoryCheckResults ensureDirs​(boolean isDebug)
      This method is ensuring, that specified directories will exists after call and will have enough permissions.
      private static DirectoryCheckResults ensureDirs​(java.util.List<java.io.File> dirs, boolean isDebug)  
      static DirectoryCheckResult testDir​(java.io.File f, boolean verbose, boolean testSubdir, boolean isDebug)
      This method is package private for testing purposes only.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final Logger LOG
      • dirsToCheck

        private final java.util.List<java.io.File> dirsToCheck
    • Constructor Detail

      • DirectoryValidator

        public DirectoryValidator​(java.util.List<java.io.File> dirsToCheck)
        Creates DirectoryValidator to ensure given directories
        Parameters:
        dirsToCheck - dirs to check
    • Method Detail

      • ensureDirs

        public DirectoryCheckResults ensureDirs​(boolean isDebug)
        This method is ensuring, that specified directories will exists after call and will have enough permissions.

        This methods is trying to create the directories if they are not present and is testing if can be written inside. All checks are done in bulk. If one or more defect is found, user is warned via dialogue in gui mode (again in bulk). In headless mode stdout/stderr is enough, as application (both gui and headless) should not stop to work, but continue to run with hope that corrupted dirs will not be necessary

        Parameters:
        isDebug - output debug information
        Returns:
        result of directory checks
      • ensureDirs

        private static DirectoryCheckResults ensureDirs​(java.util.List<java.io.File> dirs,
                                                        boolean isDebug)
      • testDir

        public static DirectoryCheckResult testDir​(java.io.File f,
                                                   boolean verbose,
                                                   boolean testSubdir,
                                                   boolean isDebug)
        This method is package private for testing purposes only.

        This method verify that directory exists, is directory, file and directory can be created, file can be written into, and subdirectory can be written into.

        Some steps may looks like redundant, but some permission settings really allow to create file but not directory and vice versa. Also some settings can allow to create file or directory which can not be written into. (eg ACL or network disks)