@Override public synchronized Path setAttributes( final Path path, final FileAttribute<?>... attrs ) throws UnsupportedOperationException, IllegalArgumentException, ClassCastException, IOException, SecurityException { checkNotNull( "path", path ); if ( Files.isDirectory( path ) ) { return internalCreateDirectory( path, true, attrs ); } return write( path, readAllBytes( path ), Collections.<OpenOption>emptySet(), attrs ); }
private void visitPaths( final DirectoryStream<org.kie.commons.java.nio.file.Path> directoryStream ) { for ( final org.kie.commons.java.nio.file.Path path : directoryStream ) { if ( Files.isDirectory( path ) ) { visitPaths( Files.newDirectoryStream( path ) ); } else if ( filter.accept( path ) ) { final String destinationPath = path.toUri().toString().substring( projectPrefix.length() + 1 ); final InputStream is = ioService.newInputStream( path ); final BufferedInputStream bis = new BufferedInputStream( is ); kieFileSystem.write( destinationPath, KieServices.Factory.get().getResources().newInputStreamResource( bis ) ); handles.put( destinationPath, paths.convert( path ) ); } } }
if ( !Files.isDirectory( pathToSearch ) ) { return discoveredFiles; discoveredFiles.add( path ); } else if ( recursive && Files.isDirectory( path ) ) { discoveredFiles.addAll( discoverFiles( path, filter,
public List<Path> loadScenarioPaths(final Path path) { // Check Path exists final List<Path> items = new ArrayList<Path>(); if (!Files.exists(paths.convert(path))) { return items; } // Ensure Path represents a Folder org.kie.commons.java.nio.file.Path pPath = paths.convert(path); if (!Files.isDirectory(pPath)) { pPath = pPath.getParent(); } LinkedFilter filter = new LinkedDotFileFilter(); filter.setNextFilter( new LinkedMetaInfFolderFilter() ); // Get list of immediate children final DirectoryStream<org.kie.commons.java.nio.file.Path> directoryStream = ioService .newDirectoryStream(pPath); for (final org.kie.commons.java.nio.file.Path p : directoryStream) { if (filter.accept(p)) { if (Files.isRegularFile(p)) { items.add(paths.convert(p)); } else if (Files.isDirectory(p)) { items.add(paths.convert(p)); } } } // Add ability to move up one level in the hierarchy //items.add(new ParentPackageItem(paths.convert(pPath.getParent()), "..")); return items; }
@Override public List<Item> load( final Path path, final Path projectRoot ) { //Check Path exists final List<Item> items = new ArrayList<Item>(); if ( !Files.exists( paths.convert( path ) ) ) { return items; } //Ensure Path represents a Folder org.kie.commons.java.nio.file.Path pPath = paths.convert( path ); if ( !Files.isDirectory( pPath ) ) { pPath = pPath.getParent(); } //Get list of immediate children final DirectoryStream<org.kie.commons.java.nio.file.Path> directoryStream = ioService.newDirectoryStream( pPath ); for ( final org.kie.commons.java.nio.file.Path p : directoryStream ) { if ( filter.accept( p ) ) { if ( Files.isRegularFile( p ) ) { items.add( new FileItem( paths.convert( p ) ) ); } else if ( Files.isDirectory( p ) ) { items.add( new PackageItem( paths.convert( p ) ) ); } } } //Add ability to move up one level in the hierarchy items.add( new ParentPackageItem( paths.convert( pPath.getParent() ), ".." ) ); return items; }
if ( !Files.isDirectory( pPath ) ) { pPath = pPath.getParent(); items.add( new FileItem( paths.convert( pChild ) ) ); } else if ( Files.isDirectory( pChild ) ) {
private Path doResolveTestPackage( final Path resource, final Path projectRoot ) { //The pom.xml and kmodule.xml files are not within a package if ( isPom( resource ) || isKModule( resource ) ) { return null; } //The Path must be within a Project's src/test/java or src/test/resources path boolean resolved = false; org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize(); final org.kie.commons.java.nio.file.Path testJavaPath = paths.convert( projectRoot ).resolve( TEST_JAVA_PATH ); final org.kie.commons.java.nio.file.Path testResourcesPath = paths.convert( projectRoot ).resolve( TEST_RESOURCES_PATH ); //Check if path resides within a Java or Resources path if ( path.startsWith( testJavaPath ) ) { resolved = true; } else if ( path.startsWith( testResourcesPath ) ) { resolved = true; } if ( !resolved ) { return null; } //If the Path is already a folder simply return it if ( Files.isDirectory( path ) ) { return resource; } path = path.getParent(); return paths.convert( path ); }
private Path doResolveSrcPackage( final Path resource, final Path projectRoot ) { //The pom.xml and kmodule.xml files are not within a package if ( isPom( resource ) || isKModule( resource ) ) { return null; } //The Path must be within a Project's src/main/java or src/main/resources path boolean resolved = false; org.kie.commons.java.nio.file.Path path = paths.convert( resource ).normalize(); final org.kie.commons.java.nio.file.Path srcJavaPath = paths.convert( projectRoot ).resolve( SOURCE_JAVA_PATH ); final org.kie.commons.java.nio.file.Path srcResourcesPath = paths.convert( projectRoot ).resolve( SOURCE_RESOURCES_PATH ); //Check if path resides within a Java or Resources path if ( path.startsWith( srcJavaPath ) ) { resolved = true; } else if ( path.startsWith( srcResourcesPath ) ) { resolved = true; } if ( !resolved ) { return null; } //If the Path is already a folder simply return it if ( Files.isDirectory( path ) ) { return resource; } path = path.getParent(); return paths.convert( path ); }