List of usage examples for java.nio.file Files isReadable
public static boolean isReadable(Path path)
From source file:io.anserini.search.SearchWebCollection.java
public SearchWebCollection(String indexDir) throws IOException { Path indexPath = Paths.get(indexDir); if (!Files.exists(indexPath) || !Files.isDirectory(indexPath) || !Files.isReadable(indexPath)) { throw new IllegalArgumentException(indexDir + " does not exist or is not a directory."); }/*from ww w . j a v a2s. c o m*/ this.reader = DirectoryReader.open(FSDirectory.open(indexPath)); }
From source file:at.tfr.securefs.ws.FileServiceBean.java
@MTOM(enabled = true, threshold = 10240) @WebMethod/*from w w w.j a v a2s .co m*/ @WebResult(name = "bytes") @Override public byte[] read(@WebParam(name = "relativePath") String relPath) throws IOException { try { Path path = SecureFileSystemBean.resolvePath(relPath, configuration.getBasePath(), configuration.isRestrictedToBasePath()); if (!Files.isRegularFile(path) || !Files.isReadable(path)) { throw new IOException("invalid path: " + relPath); } log.debug("read File: " + relPath + " from " + path); InputStream decrypter = crypterProvider.getDecrypter(path); try { return IOUtils.toByteArray(decrypter); } finally { decrypter.close(); logInfo("read File: " + path, null); } } catch (Exception e) { logInfo("read File failed: " + relPath, e); log.warn("read File failed: " + relPath + e); throw e; } }
From source file:org.apache.ranger.common.PropertiesUtil.java
@Override protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) throws BeansException { // First let's add the system properties Set<Object> keySet = System.getProperties().keySet(); for (Object key : keySet) { String keyStr = key.toString(); propertiesMap.put(keyStr, System.getProperties().getProperty(keyStr).trim()); }/*from w w w. j a va 2 s . co m*/ // Let's add our properties now keySet = props.keySet(); for (Object key : keySet) { String keyStr = key.toString(); propertiesMap.put(keyStr, props.getProperty(keyStr).trim()); } // update system trust store path with custom trust store. if (propertiesMap != null && propertiesMap.containsKey("ranger.truststore.file")) { if (!StringUtils.isEmpty(propertiesMap.get("ranger.truststore.file"))) { System.setProperty("javax.net.ssl.trustStore", propertiesMap.get("ranger.truststore.file")); System.setProperty("javax.net.ssl.trustStoreType", KeyStore.getDefaultType()); Path trustStoreFile = Paths.get(propertiesMap.get("ranger.truststore.file")); if (!Files.exists(trustStoreFile) || !Files.isReadable(trustStoreFile)) { logger.debug("Could not find or read truststore file '" + propertiesMap.get("ranger.truststore.file") + "'"); } else { if (propertiesMap != null && propertiesMap.containsKey("ranger.credential.provider.path")) { String path = propertiesMap.get("ranger.credential.provider.path"); String trustStoreAlias = getProperty("ranger.truststore.alias", "trustStoreAlias"); if (path != null && trustStoreAlias != null) { String trustStorePassword = CredentialReader.getDecryptedString(path.trim(), trustStoreAlias.trim()); if (trustStorePassword != null && !trustStorePassword.trim().isEmpty() && !trustStorePassword.trim().equalsIgnoreCase("none")) { propertiesMap.put("ranger.truststore.password", trustStorePassword); props.put("ranger.truststore.password", trustStorePassword); } else { logger.info( "trustStorePassword password not applied; clear text password shall be applicable"); } } } } } System.setProperty("javax.net.ssl.trustStorePassword", propertiesMap.get("ranger.truststore.password")); } // update system key store path with custom key store. if (propertiesMap != null && propertiesMap.containsKey("ranger.keystore.file")) { if (!StringUtils.isEmpty(propertiesMap.get("ranger.keystore.file"))) { System.setProperty("javax.net.ssl.keyStore", propertiesMap.get("ranger.keystore.file")); System.setProperty("javax.net.ssl.keyStoreType", KeyStore.getDefaultType()); Path keyStoreFile = Paths.get(propertiesMap.get("ranger.keystore.file")); if (!Files.exists(keyStoreFile) || !Files.isReadable(keyStoreFile)) { logger.debug("Could not find or read keystore file '" + propertiesMap.get("ranger.keystore.file") + "'"); } else { if (propertiesMap != null && propertiesMap.containsKey("ranger.credential.provider.path")) { String path = propertiesMap.get("ranger.credential.provider.path"); String keyStoreAlias = getProperty("ranger.keystore.alias", "keyStoreAlias"); if (path != null && keyStoreAlias != null) { String keyStorePassword = CredentialReader.getDecryptedString(path.trim(), keyStoreAlias.trim()); if (keyStorePassword != null && !keyStorePassword.trim().isEmpty() && !keyStorePassword.trim().equalsIgnoreCase("none")) { propertiesMap.put("ranger.keystore.password", keyStorePassword); props.put("ranger.keystore.password", keyStorePassword); } else { logger.info( "keyStorePassword password not applied; clear text password shall be applicable"); } } } } } System.setProperty("javax.net.ssl.keyStorePassword", propertiesMap.get("ranger.keystore.password")); } //update unixauth keystore and truststore credentials if (propertiesMap != null && propertiesMap.containsKey("ranger.credential.provider.path")) { String path = propertiesMap.get("ranger.credential.provider.path"); if (path != null) { String unixAuthKeyStoreAlias = getProperty("ranger.unixauth.keystore.alias", "unixAuthKeyStoreAlias"); if (unixAuthKeyStoreAlias != null) { String unixAuthKeyStorePass = CredentialReader.getDecryptedString(path.trim(), unixAuthKeyStoreAlias.trim()); if (unixAuthKeyStorePass != null && !unixAuthKeyStorePass.trim().isEmpty() && !unixAuthKeyStorePass.trim().equalsIgnoreCase("none")) { propertiesMap.put("ranger.unixauth.keystore.password", unixAuthKeyStorePass); props.put("ranger.unixauth.keystore.password", unixAuthKeyStorePass); } else { logger.info( "unixauth keystore password not applied; clear text password shall be applicable"); } } // String unixAuthTrustStoreAlias = getProperty("ranger.unixauth.truststore.alias", "unixAuthTrustStoreAlias"); if (unixAuthTrustStoreAlias != null) { String unixAuthTrustStorePass = CredentialReader.getDecryptedString(path.trim(), unixAuthTrustStoreAlias.trim()); if (unixAuthTrustStorePass != null && !unixAuthTrustStorePass.trim().isEmpty() && !unixAuthTrustStorePass.trim().equalsIgnoreCase("none")) { propertiesMap.put("ranger.unixauth.truststore.password", unixAuthTrustStorePass); props.put("ranger.unixauth.truststore.password", unixAuthTrustStorePass); } else { logger.info( "unixauth truststore password not applied; clear text password shall be applicable"); } } } } //update credential from keystore if (propertiesMap != null && propertiesMap.containsKey("ranger.credential.provider.path") && propertiesMap.containsKey("ranger.jpa.jdbc.credential.alias")) { String path = propertiesMap.get("ranger.credential.provider.path"); String alias = propertiesMap.get("ranger.jpa.jdbc.credential.alias"); if (path != null && alias != null) { String xaDBPassword = CredentialReader.getDecryptedString(path.trim(), alias.trim()); if (xaDBPassword != null && !xaDBPassword.trim().isEmpty() && !"none".equalsIgnoreCase(xaDBPassword.trim())) { propertiesMap.put("ranger.jpa.jdbc.password", xaDBPassword); props.put("ranger.jpa.jdbc.password", xaDBPassword); } else { logger.info( "Credential keystore password not applied for Ranger DB; clear text password shall be applicable"); } } } if (propertiesMap != null && propertiesMap.containsKey("ranger.credential.provider.path") && propertiesMap.containsKey("ranger.jpa.audit.jdbc.credential.alias")) { String path = propertiesMap.get("ranger.credential.provider.path"); String alias = propertiesMap.get("ranger.jpa.audit.jdbc.credential.alias"); if (path != null && alias != null) { String auditDBPassword = CredentialReader.getDecryptedString(path.trim(), alias.trim()); if (auditDBPassword != null && !auditDBPassword.trim().isEmpty() && !"none".equalsIgnoreCase(auditDBPassword.trim())) { propertiesMap.put("ranger.jpa.audit.jdbc.password", auditDBPassword); props.put("ranger.jpa.audit.jdbc.password", auditDBPassword); } else { logger.info( "Credential keystore password not applied for Audit DB; clear text password shall be applicable"); } } } if (propertiesMap != null && propertiesMap.containsKey("ranger.authentication.method")) { String authenticationMethod = propertiesMap.get("ranger.authentication.method"); if (authenticationMethod != null && ("ACTIVE_DIRECTORY".equalsIgnoreCase(authenticationMethod) || "AD".equalsIgnoreCase(authenticationMethod))) { if (propertiesMap != null && propertiesMap.containsKey("ranger.credential.provider.path") && propertiesMap.containsKey("ranger.ldap.ad.binddn.credential.alias")) { String path = propertiesMap.get("ranger.credential.provider.path"); String alias = propertiesMap.get("ranger.ldap.ad.binddn.credential.alias"); if (path != null && alias != null) { String bindDNPassword = CredentialReader.getDecryptedString(path.trim(), alias.trim()); if (bindDNPassword != null && !bindDNPassword.trim().isEmpty() && !"none".equalsIgnoreCase(bindDNPassword.trim())) { propertiesMap.put("ranger.ldap.ad.bind.password", bindDNPassword); props.put("ranger.ldap.ad.bind.password", bindDNPassword); } else { logger.info( "Credential keystore password not applied for AD Bind DN; clear text password shall be applicable"); } } } } } if (propertiesMap != null && propertiesMap.containsKey("ranger.authentication.method")) { String authenticationMethod = propertiesMap.get("ranger.authentication.method"); if (authenticationMethod != null && ("LDAP".equalsIgnoreCase(authenticationMethod))) { if (propertiesMap != null && propertiesMap.containsKey("ranger.credential.provider.path") && propertiesMap.containsKey("ranger.ldap.binddn.credential.alias")) { String path = propertiesMap.get("ranger.credential.provider.path"); String alias = propertiesMap.get("ranger.ldap.binddn.credential.alias"); if (path != null && alias != null) { String bindDNPassword = CredentialReader.getDecryptedString(path.trim(), alias.trim()); if (bindDNPassword != null && !bindDNPassword.trim().isEmpty() && !"none".equalsIgnoreCase(bindDNPassword.trim())) { propertiesMap.put("ranger.ldap.bind.password", bindDNPassword); props.put("ranger.ldap.bind.password", bindDNPassword); } else { logger.info( "Credential keystore password not applied for LDAP Bind DN; clear text password shall be applicable"); } } } } } if (propertiesMap != null && propertiesMap.containsKey("ranger.audit.source.type")) { String auditStore = propertiesMap.get("ranger.audit.source.type"); if (auditStore != null && ("solr".equalsIgnoreCase(auditStore))) { if (propertiesMap != null && propertiesMap.containsKey("ranger.credential.provider.path") && propertiesMap.containsKey("ranger.solr.audit.credential.alias")) { String path = propertiesMap.get("ranger.credential.provider.path"); String alias = propertiesMap.get("ranger.solr.audit.credential.alias"); if (path != null && alias != null) { String solrAuditPassword = CredentialReader.getDecryptedString(path.trim(), alias.trim()); if (solrAuditPassword != null && !solrAuditPassword.trim().isEmpty() && !"none".equalsIgnoreCase(solrAuditPassword.trim())) { propertiesMap.put("ranger.solr.audit.user.password", solrAuditPassword); props.put("ranger.solr.audit.user.password", solrAuditPassword); } else { logger.info( "Credential keystore password not applied for Solr; clear text password shall be applicable"); } } } } } if (propertiesMap != null) { String sha256PasswordUpdateDisable = "false"; if (propertiesMap.containsKey("ranger.sha256Password.update.disable")) { sha256PasswordUpdateDisable = propertiesMap.get("ranger.sha256Password.update.disable"); if (sha256PasswordUpdateDisable == null || sha256PasswordUpdateDisable.trim().isEmpty() || !"true".equalsIgnoreCase(sha256PasswordUpdateDisable)) { sha256PasswordUpdateDisable = "false"; } } propertiesMap.put("ranger.sha256Password.update.disable", sha256PasswordUpdateDisable); props.put("ranger.sha256Password.update.disable", sha256PasswordUpdateDisable); } if (RangerBizUtil.getDBFlavor() == AppConstants.DB_FLAVOR_MYSQL) { if (propertiesMap != null && propertiesMap.containsKey("ranger.db.ssl.enabled")) { String db_ssl_enabled = propertiesMap.get("ranger.db.ssl.enabled"); if (StringUtils.isEmpty(db_ssl_enabled) || !"true".equalsIgnoreCase(db_ssl_enabled)) { db_ssl_enabled = "false"; } db_ssl_enabled = db_ssl_enabled.toLowerCase(); if ("true".equalsIgnoreCase(db_ssl_enabled)) { String db_ssl_required = propertiesMap.get("ranger.db.ssl.required"); if (StringUtils.isEmpty(db_ssl_required) || !"true".equalsIgnoreCase(db_ssl_required)) { db_ssl_required = "false"; } db_ssl_required = db_ssl_required.toLowerCase(); String db_ssl_verifyServerCertificate = propertiesMap .get("ranger.db.ssl.verifyServerCertificate"); if (StringUtils.isEmpty(db_ssl_verifyServerCertificate) || !"true".equalsIgnoreCase(db_ssl_verifyServerCertificate)) { db_ssl_verifyServerCertificate = "false"; } db_ssl_verifyServerCertificate = db_ssl_verifyServerCertificate.toLowerCase(); propertiesMap.put("ranger.db.ssl.enabled", db_ssl_enabled); props.put("ranger.db.ssl.enabled", db_ssl_enabled); propertiesMap.put("ranger.db.ssl.required", db_ssl_required); props.put("ranger.db.ssl.required", db_ssl_required); propertiesMap.put("ranger.db.ssl.verifyServerCertificate", db_ssl_verifyServerCertificate); props.put("ranger.db.ssl.verifyServerCertificate", db_ssl_verifyServerCertificate); String ranger_jpa_jdbc_url = propertiesMap.get("ranger.jpa.jdbc.url"); if (!StringUtils.isEmpty(ranger_jpa_jdbc_url)) { StringBuffer ranger_jpa_jdbc_url_ssl = new StringBuffer(ranger_jpa_jdbc_url); ranger_jpa_jdbc_url_ssl.append("?useSSL=" + db_ssl_enabled + "&requireSSL=" + db_ssl_required + "&verifyServerCertificate=" + db_ssl_verifyServerCertificate); propertiesMap.put("ranger.jpa.jdbc.url", ranger_jpa_jdbc_url_ssl.toString()); props.put("ranger.jpa.jdbc.url", ranger_jpa_jdbc_url_ssl.toString()); logger.info("ranger.jpa.jdbc.url=" + ranger_jpa_jdbc_url_ssl.toString()); } } } } super.processProperties(beanFactory, props); }
From source file:org.rdswicthboard.utils.xml.split.Properties.java
public static Configuration fromArgs(String[] args) throws Exception { CommandLineParser parser = new DefaultParser(); // create the Options Options options = new Options(); options.addOption("i", PROPERTY_INPUT_FILE, true, "input RDF file"); options.addOption("P", PROPERTY_OUTPUT_PREFIX, true, "output files prefix (default is " + DEFAULT_OUTPUT_PREFIX + "N.xml)"); options.addOption("c", PROPERTY_CONFIG_FILE, true, "configuration file (optional)"); options.addOption("I", PROPERTY_INPUT_ENCODING, true, "input file encoding (default is " + DEFAULT_ENCODING + ")"); options.addOption("O", PROPERTY_OUTPUT_ENCODING, true, "output file encoding (default is " + DEFAULT_ENCODING + ")"); options.addOption("r", PROPERTY_ROOT_NODE, true, "root node (with namespace if needed)"); options.addOption("f", PROPERTY_FORMAT_OUTPUT, false, "format output encoding"); options.addOption("h", PROPERTY_HELP, false, "print this message"); // parse the command line arguments CommandLine line = parser.parse(options, args); if (line.hasOption(PROPERTY_HELP)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar oai-combine-[verion].jar [PARAMETERS]", options); System.exit(0);//from ww w . j a v a 2 s .c o m } // variables to store program properties CompositeConfiguration config = new CompositeConfiguration(); config.setProperty(PROPERTY_INPUT_FILE, "publications.xml"); config.setProperty(PROPERTY_ROOT_NODE, "OAI-PMH"); config.setProperty(PROPERTY_OUTPUT_PREFIX, "nii/oai_"); // config.setProperty( PROPERTY_OUTPUT_PREFIX, DEFAULT_OUTPUT_PREFIX ); config.setProperty(PROPERTY_INPUT_ENCODING, DEFAULT_ENCODING); config.setProperty(PROPERTY_OUTPUT_ENCODING, DEFAULT_ENCODING); config.setProperty(PROPERTY_FORMAT_OUTPUT, DEFAULT_FORMAT_OUTPUT); // check if arguments has input file properties if (line.hasOption(PROPERTY_CONFIG_FILE)) { // if it does, load the specified configuration file Path defaultConfig = Paths.get(line.getOptionValue(PROPERTY_CONFIG_FILE)); if (Files.isRegularFile(defaultConfig) && Files.isReadable(defaultConfig)) { config.addConfiguration(new PropertiesConfiguration(defaultConfig.toFile())); } else throw new Exception("Invalid configuration file: " + defaultConfig.toString()); } // copy properties from the command line for (String property : new String[] { PROPERTY_INPUT_FILE, PROPERTY_OUTPUT_PREFIX, PROPERTY_INPUT_ENCODING, PROPERTY_OUTPUT_ENCODING, PROPERTY_ROOT_NODE }) { if (line.hasOption(property)) config.setProperty(property, line.getOptionValue(property)); } // check if arguments has output encoding if (line.hasOption(PROPERTY_FORMAT_OUTPUT)) config.setProperty(PROPERTY_FORMAT_OUTPUT, "yes"); // the program has default output file, but input file must be presented if (!config.containsKey(PROPERTY_INPUT_FILE)) throw new Exception("Please specify input file"); // the program has default output file, but input file must be presented if (!config.containsKey(PROPERTY_ROOT_NODE)) throw new Exception("Please specify root node"); return config; }
From source file:io.anserini.search.SearchCollection.java
public SearchCollection(SearchArgs args) throws IOException { this.args = args; Path indexPath = Paths.get(args.index); if (!Files.exists(indexPath) || !Files.isDirectory(indexPath) || !Files.isReadable(indexPath)) { throw new IllegalArgumentException(args.index + " does not exist or is not a directory."); }/*from w w w . ja va 2s .c o m*/ LOG.info("Reading index at " + args.index); this.reader = DirectoryReader.open(FSDirectory.open(indexPath)); // Figure out which scoring model to use. if (args.ql) { LOG.info("Using QL scoring model"); this.similarity = new LMDirichletSimilarity(args.mu); } else if (args.bm25) { LOG.info("Using BM25 scoring model"); this.similarity = new BM25Similarity(args.k1, args.b); } else if (args.f2log) { LOG.info("Using F2Log scoring model"); this.similarity = new F2LogSimilarity(args.f2log_s); } else { throw new IllegalArgumentException("Error: Must specify scoring model!"); } // Are we searching tweets? if (args.searchtweets) { analyzer = new TweetAnalyzer(); } else { analyzer = args.keepstop ? new EnglishAnalyzer(CharArraySet.EMPTY_SET) : new EnglishAnalyzer(); } isRerank = args.rm3 || args.axiom; // Set up the ranking cascade. cascade = new RerankerCascade(); if (args.rm3) { cascade.add(new Rm3Reranker(analyzer, FIELD_BODY, args)); } else if (args.axiom) { cascade.add(new AxiomReranker(FIELD_BODY, args)); } cascade.add(new ScoreTiesAdjusterReranker()); }
From source file:org.rdswicthboard.utils.xml.split.Processor.java
public int process() throws Exception { // test if source is an regular file and it is readable Path source = Paths.get(inputFile); if (!Files.isRegularFile(source)) throw new Exception("The input file: " + source.toString() + " is not an regular file"); if (!Files.isReadable(source)) throw new Exception("The input file: " + source.toString() + " is not readable"); // extrat parent path Path targetPrefix = Paths.get(outputPrefix); Path parent = targetPrefix.getParent(); // try to create parent path if it exists if (null != parent) Files.createDirectories(parent); // create file template String template = targetPrefix.getFileName().toString() + "%d.xml"; // generate expression String expression = String.format( "<\\?\\s*xml(\\s+version=\"[\\d\\.]+\")?(\\s+encoding=\"[-\\w]+\")?(\\s+standalone=\"(yes|no)\")?\\s*\\?>\\s*<\\s*%s[^>]*>[\\s\\S]*?<\\s*\\/\\s*%s\\s*>", rootNode, rootNode);/* ww w . jav a 2 s . c o m*/ // create pattern Pattern pattern = Pattern.compile(expression); // read file into a string String content = new String(Files.readAllBytes(source), inputEncoding); // create matcher and apply it to the content Matcher matcher = pattern.matcher(content); // init file number int fileNumber = 0; // process all records while (matcher.find()) { String fileName = String.format(template, fileNumber++); Path path = null == parent ? Paths.get(fileName) : Paths.get(parent.toString(), fileName); Files.write(path, matcher.group()/*.replaceAll("\\?><", "?>\n<")*/.getBytes(outputEncoding)); } return fileNumber; }
From source file:org.application.backupsync.PathName.java
public List<PathName> walk() throws IOException { final List<PathName> result; result = new ArrayList<>(); if (Files.isReadable(this.path)) { Files.walkFileTree(this.path, new SimpleFileVisitor<Path>() { @Override/*from ww w . ja v a2 s . c o m*/ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { result.add(new PathName(file)); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException ex) { result.add(new PathName(dir)); return FileVisitResult.CONTINUE; } }); } else { throw new IllegalArgumentException("Directory cannot be read: " + this.path.toString()); } return result; }
From source file:com.dianping.resource.io.PathResource.java
/** * This implementation checks whether the underlying file is marked as readable * (and corresponds to an actual file with content, not to a directory). * @see java.nio.file.Files#isReadable(java.nio.file.Path) * @see java.nio.file.Files#isDirectory(java.nio.file.Path, java.nio.file.LinkOption...) *//* w w w .j a va 2 s. c o m*/ @Override public boolean isReadable() { return (Files.isReadable(this.path) && !Files.isDirectory(this.path)); }
From source file:misc.FileHandler.java
/** * Copies the source file with the given options to the target file. The * source is first copied to the system's default temporary directory and * the temporary copy is then moved to the target file. In order to avoid * performance problems, the file is directly copied from the source to a * temporary file in the target directory first, if the temporary directory * and the target file lie on a different <code>FileStore</code>. The * temporary file is also moved to the target file. * //from w w w. ja v a2 s. c o m * @param source * the file to copy. * @param target * the target location where the file should be stored. Must not * be identical with source. The file might or might not exist. * The parent directory must exist. * @param replaceExisting * <code>true</code>, if the target file may be overwritten. * Otherwise, <code>false</code>. * @return <code>true</code>, if the file was successfully copied. * Otherwise, <code>false</code>. */ public static boolean copyFile(Path source, Path target, boolean replaceExisting) { if ((source == null) || !Files.isReadable(source)) { throw new IllegalArgumentException("source must exist and be readable!"); } if (target == null) { throw new IllegalArgumentException("target may not be null!"); } if (source.toAbsolutePath().normalize().equals(target.toAbsolutePath().normalize())) { throw new IllegalArgumentException("source and target must not match!"); } boolean success = false; Path tempFile = null; target = target.normalize(); try { tempFile = FileHandler.getTempFile(target); if (tempFile != null) { Files.copy(source, tempFile, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING); if (replaceExisting) { Files.move(tempFile, target, StandardCopyOption.REPLACE_EXISTING); } else { Files.move(tempFile, target); } success = true; } } catch (IOException e) { Logger.logError(e); } finally { if (tempFile != null) { try { Files.deleteIfExists(tempFile); } catch (IOException eDelete) { Logger.logError(eDelete); } } } return success; }
From source file:org.osiam.OsiamHome.java
public void initialize() { try {/*from w ww .jav a 2 s . co m*/ if (Files.notExists(osiamHome)) { Files.createDirectories(osiamHome); } else { checkState(Files.isDirectory(osiamHome), "'osiam.home' (%s) is not a directory", osiamHome); checkState(Files.isReadable(osiamHome), "'osiam.home' (%s) is not readable", osiamHome); checkState(Files.isExecutable(osiamHome), "'osiam.home' (%s) is not accessible", osiamHome); } if (!isEmpty(osiamHome)) { return; } checkState(Files.isWritable(osiamHome), "'osiam.home' (%s) is not writable", osiamHome); Resource[] resources = new PathMatchingResourcePatternResolver().getResources("classpath:/home/**/*"); for (Resource resource : resources) { // don't process directories if (resource.getURL().toString().endsWith("/")) { continue; } copyToHome(resource, osiamHome); } if (Files.notExists(osiamHome.resolve("data"))) { Files.createDirectories(osiamHome.resolve("data")); } hasInitializedHome = true; } catch (IOException e) { throw new IllegalStateException("Could not initialize osiam.home", e); } }