@Test public void testCacheDir() throws FileNotFoundException, IOException { File wrongDir = new File("wrongfolderfortests"); boolean isValid = GribUtilities.isValid(cacheDir); assertTrue(isValid); isValid = GribUtilities.isValid(wrongDir); assertFalse(isValid); final String name = "sample.grb2"; final String index = name + ".gbx9"; File sampleGrib = TestData.file(this, name).getCanonicalFile(); GRIBFormat format = new GRIBFormat(); AbstractGridCoverage2DReader reader = null; try { reader = format.getReader(sampleGrib); assertNotNull(reader); String cachePath = sampleGrib.getAbsolutePath(); if (cachePath.startsWith("/")) { cachePath = cachePath.substring(1); } if (cachePath.endsWith("/")) { cachePath = cachePath.substring(0, cachePath.length() - 1); } cachePath = StringUtil2.remove(cachePath, ':'); cachePath = cachePath.replace(name, index); final File sampleGribIndex = new File(cacheDir, cachePath); assertTrue(sampleGribIndex.exists()); } finally { if (reader != null) { try { reader.dispose(); } catch (Throwable t) { } } } }
public static boolean isValid(File file) { String dir = file.getAbsolutePath(); if (!file.exists()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to an existing folder. Please check the path: " + dir); } return false; } else if (!file.isDirectory()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to a directory. Please check the path: " + dir); } return false; } else if (!file.canWrite()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path refers to " + "a directory which can't be written. Please check the path and" + " the permissions for: " + dir); } return false; } return true; }
GribUtilities { public static boolean isValid(File file) { String dir = file.getAbsolutePath(); if (!file.exists()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to an existing folder. Please check the path: " + dir); } return false; } else if (!file.isDirectory()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to a directory. Please check the path: " + dir); } return false; } else if (!file.canWrite()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path refers to " + "a directory which can't be written. Please check the path and" + " the permissions for: " + dir); } return false; } return true; } }
GribUtilities { public static boolean isValid(File file) { String dir = file.getAbsolutePath(); if (!file.exists()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to an existing folder. Please check the path: " + dir); } return false; } else if (!file.isDirectory()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to a directory. Please check the path: " + dir); } return false; } else if (!file.canWrite()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path refers to " + "a directory which can't be written. Please check the path and" + " the permissions for: " + dir); } return false; } return true; }  }
GribUtilities { public static boolean isValid(File file) { String dir = file.getAbsolutePath(); if (!file.exists()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to an existing folder. Please check the path: " + dir); } return false; } else if (!file.isDirectory()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to a directory. Please check the path: " + dir); } return false; } else if (!file.canWrite()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path refers to " + "a directory which can't be written. Please check the path and" + " the permissions for: " + dir); } return false; } return true; }  static boolean isValid(File file); }
GribUtilities { public static boolean isValid(File file) { String dir = file.getAbsolutePath(); if (!file.exists()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to an existing folder. Please check the path: " + dir); } return false; } else if (!file.isDirectory()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path doesn't refer " + "to a directory. Please check the path: " + dir); } return false; } else if (!file.canWrite()) { if (LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning( "The specified path refers to " + "a directory which can't be written. Please check the path and" + " the permissions for: " + dir); } return false; } return true; }  static boolean isValid(File file); static final String GRIB_CACHE_DIR; }