MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / URLOrFileValidator

Class URLOrFileValidator

src/tools/ConfigMetaType.java:243–259  ·  view source on GitHub ↗

Title: URLOrFileValidator Description: Validator for URLs or Files

Source from the content-addressed store, hash-verified

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 /**

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…