Class DirectoryValidator

java.lang.Object
net.adoptopenjdk.icedteaweb.validator.DirectoryValidator

public class DirectoryValidator extends Object
  • Field Details

    • LOG

      private static final Logger LOG
    • dirsToCheck

      private final List<File> dirsToCheck
  • Constructor Details

    • DirectoryValidator

      public DirectoryValidator(List<File> dirsToCheck)
      Creates DirectoryValidator to ensure given directories
      Parameters:
      dirsToCheck - dirs to check
  • Method Details

    • 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(List<File> dirs, boolean isDebug)
    • testDir

      public static DirectoryCheckResult testDir(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)