List of usage examples for java.nio.file Path toUri
URI toUri();
From source file:org.eclipse.jdt.ls.core.internal.JDTUtilsTest.java
@Test public void testGetPackageNameNoSrc() throws Exception { Path foo = getTmpFile("projects/eclipse/hello/Foo.java"); foo.toFile().getParentFile().mkdirs(); FileUtils.copyFile(Paths.get("projects", "eclipse", "hello", "Foo.java").toFile(), foo.toFile()); URI uri = foo.toUri(); ICompilationUnit cu = JDTUtils.resolveCompilationUnit(uri.toString()); String packageName = JDTUtils.getPackageName(cu.getJavaProject(), uri); assertEquals("", packageName); }
From source file:org.eclipse.jdt.ls.core.internal.JDTUtilsTest.java
@Test public void testGetPackageNameSrc() throws Exception { Path foo = getTmpFile("projects/eclipse/hello/src/Foo.java"); foo.toFile().getParentFile().mkdirs(); FileUtils.copyFile(Paths.get("projects", "eclipse", "hello", "src", "Foo.java").toFile(), foo.toFile()); URI uri = foo.toUri(); ICompilationUnit cu = JDTUtils.resolveCompilationUnit(uri.toString()); String packageName = JDTUtils.getPackageName(cu.getJavaProject(), uri); assertEquals("", packageName); }
From source file:org.apache.rya.indexing.pcj.fluo.client.command.LoadTriplesCommand.java
@Override public void execute(final Connector accumulo, final String ryaTablePrefix, final RyaSailRepository rya, final FluoClient fluo, final String[] args) throws ArgumentsException, ExecutionException { checkNotNull(accumulo);//from w w w . ja v a 2s.c o m checkNotNull(fluo); checkNotNull(args); log.trace("Executing the Load Triples Command..."); // Parse the command line arguments. final Parameters params = new Parameters(); try { new JCommander(params, args); } catch (final ParameterException e) { throw new ArgumentsException( "Could not load the Triples file because of invalid command line parameters.", e); } // Iterate over the Statements that are in the input file and write them to Fluo. log.trace("Loading RDF Statements from the Triples file '" + params.nTriplesFile + "'."); final Path triplesPath = Paths.get(params.nTriplesFile); try { final RDFParser parser = makeParser(triplesPath); final FluoLoader loader = new FluoLoader(fluo, new InsertTriples()); parser.setRDFHandler(loader); parser.parse(Files.newInputStream(triplesPath), triplesPath.toUri().toString()); } catch (UnsupportedFormatException | RDFParseException | RDFHandlerException | IOException e) { throw new ExecutionException("Could not load the RDF file into the Fluo app.", e); } log.trace("Finished executing the Load Triples Command."); }
From source file:com.splicemachine.storage.HNIOFileSystem.java
private org.apache.hadoop.fs.Path toHPath(Path path) { return new org.apache.hadoop.fs.Path(path.toUri()); }
From source file:org.apache.taverna.robundle.manifest.Manifest.java
public PathMetadata getAggregation(Path file) { URI fileUri = file.toUri(); return getAggregation(fileUri); }
From source file:com.romeikat.datamessie.core.base.util.FileUtil.java
private Path createZipFile(final String dir, String filename, final List<Path> files) throws IOException { filename = normalizeFilename(filename); // Create ZIP file Path zipFile = Paths.get(dir, filename + ".zip"); zipFile = getNonExisting(zipFile);/*from w w w. j a v a2 s . c om*/ Files.createFile(zipFile); final URI zipUri = URI.create("jar:file:" + zipFile.toUri().getPath()); Files.delete(zipFile); final Map<String, String> zipProperties = new HashMap<String, String>(); zipProperties.put("create", "true"); zipProperties.put("encoding", "UTF-8"); final FileSystem zipFS = FileSystems.newFileSystem(zipUri, zipProperties); // Copy TXT files to ZIP file for (final Path file : files) { final Path fileToZip = file; final Path pathInZipfile = zipFS.getPath(file.getFileName().toString()); Files.copy(fileToZip, pathInZipfile); } // Done zipFS.close(); return zipFile; }
From source file:org.apache.sentry.cli.tools.TestPermissionsMigrationToolSolr.java
private void verifySentryPolicyFile(Set<String> groups, Map<String, Set<String>> privilegeMapping, Path policyFilePath) throws IOException { SimpleFileProviderBackend policyFileBackend = new SimpleFileProviderBackend(conf, new org.apache.hadoop.fs.Path(policyFilePath.toUri())); policyFileBackend.initialize(new ProviderBackendContext()); Table<String, String, Set<String>> groupRolePrivilegeTable = policyFileBackend.getGroupRolePrivilegeTable(); assertEquals(groups, groupRolePrivilegeTable.rowKeySet()); assertEquals(privilegeMapping.keySet(), groupRolePrivilegeTable.columnKeySet()); for (String groupName : groupRolePrivilegeTable.rowKeySet()) { for (String roleName : groupRolePrivilegeTable.columnKeySet()) { if (groupRolePrivilegeTable.contains(groupName, roleName)) { Set<String> privileges = groupRolePrivilegeTable.get(groupName, roleName); assertEquals(privilegeMapping.get(roleName), privileges); }/*from www . j a v a2s . c o m*/ } } }
From source file:org.kitodo.serviceloader.KitodoServiceLoader.java
/** * If the found jar files have frontend files, they will be extracted and * copied into the frontend folder of the core module. Before copying, * existing frontend files of the same module will be deleted from the core * module. Afterwards the created temporary folder will be deleted as well. *//* www.java2 s . c o m*/ private void loadFrontendFilesIntoCore() { Path moduleFolder = FileSystems.getDefault().getPath(modulePath); try (DirectoryStream<Path> stream = Files.newDirectoryStream(moduleFolder, JAR)) { for (Path f : stream) { File loc = new File(f.toString()); try (JarFile jarFile = new JarFile(loc)) { if (hasFrontendFiles(jarFile)) { Path temporaryFolder = Files.createTempDirectory(SYSTEM_TEMP_FOLDER, TEMP_DIR_PREFIX); File tempDir = new File(Paths.get(temporaryFolder.toUri()).toAbsolutePath().toString()); extractFrontEndFiles(loc.getAbsolutePath(), tempDir); String moduleName = extractModuleName(tempDir); if (!moduleName.isEmpty()) { FacesContext facesContext = FacesContext.getCurrentInstance(); HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false); String filePath = session.getServletContext().getRealPath(File.separator + PAGES_FOLDER) + File.separator + moduleName; FileUtils.deleteDirectory(new File(filePath)); String resourceFolder = String.join(File.separator, Arrays.asList(tempDir.getAbsolutePath(), META_INF_FOLDER, RESOURCES_FOLDER)); copyFrontEndFiles(resourceFolder, filePath); } else { logger.info("No module found in JarFile '" + jarFile.getName() + "'."); } FileUtils.deleteDirectory(tempDir); } } } } catch (Exception e) { logger.error(ERROR, e.getMessage()); } }
From source file:at.ac.univie.isc.asio.platform.FileSystemConfigStore.java
@Override public URI save(final String qualifier, final String identifier, final ByteSource content) { requireNonNull(content, "file content"); final Path file = resolve(qualifier, identifier); try {// w w w.j av a 2s . co m log.debug(Scope.SYSTEM.marker(), "saving item as <{}>", file); lock(); try (final OutputStream sink = Files.newOutputStream(file)) { content.copyTo(sink); } return file.toUri(); } catch (IOException e) { throw new FileSystemAccessFailure("failed to save to <" + file + ">", e); } finally { lock.unlock(); } }
From source file:com.marklogic.entityservices.examples.ExamplesBase.java
private void importOrDescend(Path directory, WriteHostBatcher batcher, String collection, Format format) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory)) { for (Path entry : stream) { if (entry.toFile().isDirectory()) { logger.info("Reading subdirectory " + entry.getFileName().toString()); importOrDescend(entry, batcher, collection, format); } else { logger.debug("Adding " + entry.getFileName().toString()); String uri = entry.toUri().toString(); if (collection != null) { DocumentMetadataHandle metadata = new DocumentMetadataHandle().withCollections(collection) // .withPermission("race-reader", Capability.READ) // .withPermission("race-writer", Capability.INSERT, Capability.UPDATE); batcher.add(uri, metadata, new FileHandle(entry.toFile()).withFormat(format)); } else { batcher.add(uri, new FileHandle(entry.toFile()).withFormat(format)); }/*from ww w .j a v a 2 s.co m*/ logger.debug("Inserted " + format.toString() + " document " + uri); } } } catch (IOException e) { e.printStackTrace(); } }