MCPcopy
hub / github.com/OpenTSDB/opentsdb / DirFileSystemValidator

Class DirFileSystemValidator

src/tools/ConfigMetaType.java:370–383  ·  view source on GitHub ↗

Title: DirFileSystemValidator Description: Validator for fully qualified file names where the parent directory must exist but the file is optional

Source from the content-addressed store, hash-verified

368 * must exist but the file is optional</p>
369 */
370 public static class DirFileSystemValidator implements ArgValueValidator {
371
372 @Override
373 public void validate(final ConfigurationItem citem) {
374 final String name = citem.getValue();
375 if(name==null || name.trim().isEmpty()) return;
376 final File f = new File(citem.getValue()).getAbsoluteFile();
377 final File dir = f.getParentFile();
378 if(dir.exists() && dir.isDirectory()) return;
379 if(!dir.exists()) throw new IllegalArgumentException("No directory named [" + dir + "] exists. Invalid value for config item:" + citem.getKey());
380 if(!dir.isDirectory()) throw new IllegalArgumentException("Specified parent directory [" + dir + "] is not a directory. Invalid value for config item:" + citem.getKey());
381 }
382
383 }
384
385
386 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…