/** * Verify that a file exists * @param file file * @param errorlog log for output on an error * @throws FileNotFoundException */ public static void verifyFileExists(File file, Logger errorlog) throws FileNotFoundException { if (!file.exists()) { errorlog.warn("contents of {}: {}", file, listDir(file.getParentFile())); throw new FileNotFoundException(file.toString()); } if (!file.isFile()) { throw new FileNotFoundException("Not a file: " + file.toString()); } }
/** * Verify that a path refers to a directory. If not * logs the parent dir then throws an exception * @param dir the directory * @param errorlog log for output on an error * @throws FileNotFoundException if it is not a directory */ public static void verifyIsDir(File dir, Logger errorlog) throws FileNotFoundException { if (!dir.exists()) { errorlog.warn("contents of {}: {}", dir, listDir(dir.getParentFile())); throw new FileNotFoundException(dir.toString()); } if (!dir.isDirectory()) { errorlog.info("contents of {}: {}", dir, listDir(dir.getParentFile())); throw new FileNotFoundException( "Not a directory: " + dir); } }
/** * Verify that a file exists * @param file file * @param errorlog log for output on an error * @throws FileNotFoundException */ public static void verifyFileExists(File file, Logger errorlog) throws FileNotFoundException { if (!file.exists()) { errorlog.warn("contents of {}: {}", file, listDir(file.getParentFile())); throw new FileNotFoundException(file.toString()); } if (!file.isFile()) { throw new FileNotFoundException("Not a file: " + file.toString()); } }
/** * Verify that a path refers to a directory. If not * logs the parent dir then throws an exception * @param dir the directory * @param errorlog log for output on an error * @throws FileNotFoundException if it is not a directory */ public static void verifyIsDir(File dir, Logger errorlog) throws FileNotFoundException { if (!dir.exists()) { errorlog.warn("contents of {}: {}", dir, listDir(dir.getParentFile())); throw new FileNotFoundException(dir.toString()); } if (!dir.isDirectory()) { errorlog.info("contents of {}: {}", dir, listDir(dir.getParentFile())); throw new FileNotFoundException( "Not a directory: " + dir); } }
/** * Load a specific XML configuration file for the provider config * @param confDir configuration directory * @param siteXMLFilename provider-specific filename * @return a configuration to be included in status * @throws BadCommandArgumentsException argument problems * @throws IOException IO problems */ protected Configuration loadProviderConfigurationInformation(File confDir, String siteXMLFilename) throws BadCommandArgumentsException, IOException { Configuration siteConf; File siteXML = new File(confDir, siteXMLFilename); if (!siteXML.exists()) { throw new BadCommandArgumentsException( "Configuration directory %s doesn't contain %s - listing is %s", confDir, siteXMLFilename, SliderUtils.listDir(confDir)); } //now read it in siteConf = ConfigHelper.loadConfFromFile(siteXML); log.info("{} file is at {}", siteXMLFilename, siteXML); log.info(ConfigHelper.dumpConfigToString(siteConf)); return siteConf; }
/** * Load a specific XML configuration file for the provider config * @param confDir configuration directory * @param siteXMLFilename provider-specific filename * @return a configuration to be included in status * @throws BadCommandArgumentsException argument problems * @throws IOException IO problems */ protected Configuration loadProviderConfigurationInformation(File confDir, String siteXMLFilename) throws BadCommandArgumentsException, IOException { Configuration siteConf; File siteXML = new File(confDir, siteXMLFilename); if (!siteXML.exists()) { throw new BadCommandArgumentsException( "Configuration directory %s doesn't contain %s - listing is %s", confDir, siteXMLFilename, SliderUtils.listDir(confDir)); } //now read it in siteConf = ConfigHelper.loadConfFromFile(siteXML); log.info("{} file is at {}", siteXMLFilename, siteXML); log.info(ConfigHelper.dumpConfigToString(siteConf)); return siteConf; }
throw new BadCommandArgumentsException( "Configuration directory %s doesn't contain %s - listing is %s", confDir, siteXMLFilename, SliderUtils.listDir(confDir));
log.info("Conf dir {} does not exist.", confDir); File parentFile = confDir.getParentFile(); log.info("Parent dir {}:\n{}", parentFile, SliderUtils.listDir(parentFile));
log.info("Conf dir {} does not exist.", confDir); File parentFile = confDir.getParentFile(); log.info("Parent dir {}:\n{}", parentFile, SliderUtils.listDir(parentFile));