Title: URLOrFileValidator Description: Validator for URLs or Files
| 241 | * <p>Description: Validator for URLs or Files</p> |
| 242 | */ |
| 243 | public static class URLOrFileValidator implements ArgValueValidator { |
| 244 | /** |
| 245 | * {@inheritDoc} |
| 246 | * @see net.opentsdb.tools.ArgValueValidator#validate(net.opentsdb.tools.ConfigArgP.ConfigurationItem) |
| 247 | */ |
| 248 | @Override |
| 249 | public void validate(final ConfigurationItem citem) { |
| 250 | try { |
| 251 | new URL(citem.getValue()); |
| 252 | } catch (Exception ex) { |
| 253 | File f = new File(citem.getValue()); |
| 254 | if(!f.exists() || !f.isFile() || !f.canRead()) { |
| 255 | throw new IllegalArgumentException("Invalid URL or File [" + citem.getValue() + "]", ex); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | |
| 262 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…