private List<String> loadWorkItemImages( final Path resourcePath ) { final Path projectRoot = projectService.resolveProject( resourcePath ); final org.kie.commons.java.nio.file.Path nioProjectPath = paths.convert( projectRoot ); final org.kie.commons.java.nio.file.Path nioResourceParent = paths.convert( resourcePath ).getParent(); final Collection<org.kie.commons.java.nio.file.Path> imagePaths = fileDiscoveryService.discoverFiles( nioProjectPath, imageFilter, true ); final List<String> images = new ArrayList<String>(); for ( org.kie.commons.java.nio.file.Path imagePath : imagePaths ) { final org.kie.commons.java.nio.file.Path relativePath = nioResourceParent.relativize( imagePath ); images.add( relativePath.toString() ); } return images; }
@Override public Path pathToRelatedKModuleFileIfAny( final Path pathToPomXML ) { final org.kie.commons.java.nio.file.Path directory = paths.convert( pathToPomXML ).getParent(); final org.kie.commons.java.nio.file.Path pathToKModuleXML = directory.resolve( "src/main/resources/META-INF/kmodule.xml" ); if ( ioService.exists( pathToKModuleXML ) ) { return paths.convert( pathToKModuleXML ); } else { return null; } }
public List<BreadCrumb> makeBreadCrumbs( final Path path, final List<org.kie.commons.java.nio.file.Path> exclusions, final Map<org.kie.commons.java.nio.file.Path, String> captionSubstitutions ) { final List<BreadCrumb> breadCrumbs = new ArrayList<BreadCrumb>(); org.kie.commons.java.nio.file.Path nioPath = paths.convert( path ); org.kie.commons.java.nio.file.Path nioFileName = nioPath.getFileName(); while ( nioFileName != null ) { if ( includePath( nioPath, exclusions ) ) { String caption = nioFileName.toString(); if ( captionSubstitutions.containsKey( nioPath ) ) { caption = captionSubstitutions.get( nioPath ); } final BreadCrumb breadCrumb = new BreadCrumb( paths.convert( nioPath ), caption ); breadCrumbs.add( 0, breadCrumb ); } nioPath = nioPath.getParent(); nioFileName = nioPath.getFileName(); } breadCrumbs.add( 0, new BreadCrumb( paths.convert( nioPath ), getRootDirectory( nioPath ) ) ); return breadCrumbs; }
@Test public void testParent() throws URISyntaxException { final URL parentUrl = this.getClass().getResource( "/" ); final org.kie.commons.java.nio.file.Path parentNioPath = fs.getPath( parentUrl.toURI() ); final URL childUrl = this.getClass().getResource( "/ExplorerBackendTestProjectStructureValid" ); final org.kie.commons.java.nio.file.Path childNioPath = fs.getPath( childUrl.toURI() ); final org.kie.commons.java.nio.file.Path childParentNioPath = childNioPath.getParent(); assertEquals( parentNioPath, childParentNioPath ); }
Iterable<Path> availableForms = null; Path processPath = fileService.getPath(processAssetPath); Path formsPath = fileService.getPath(processPath.getParent().toUri().toString() + "/forms/"); try {
@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; }
@Test public void simpleRootTests() throws URISyntaxException { final SimpleFileSystemProvider fs = new SimpleFileSystemProvider(); final FileSystem fileSystem = new SimpleUnixFileSystem( fsProvider, "/" ); assertThat( fileSystem.getPath( "/" ) ).isEqualTo( fileSystem.getPath( "/path" ).getParent() ); final URL parentUrl = this.getClass().getResource( "/" ); final Path parentNioPath = fs.getPath( parentUrl.toURI() ); final URL childUrl = this.getClass().getResource( "/Folder" ); final Path childNioPath = fs.getPath( childUrl.toURI() ); final Path childParentNioPath = childNioPath.getParent(); System.out.println( parentNioPath ); assertThat( parentNioPath ).isEqualTo( childParentNioPath ); }
public static Path createDirectories( final Path dir, final FileAttribute<?>... attrs ) throws UnsupportedOperationException, FileAlreadyExistsException, IOException, SecurityException { checkNotNull( "dir", dir ); final Path absoluteDir = dir.toAbsolutePath(); if ( !notExists( absoluteDir ) ) { throw new FileAlreadyExistsException( absoluteDir.toString() ); } Path parent = absoluteDir.getParent(); while ( parent != null ) { try { providerOf( parent ).checkAccess( parent ); break; } catch ( NoSuchFileException x ) { } parent = parent.getParent(); } if ( parent == null ) { throw new IOException( "Root directory does not exist" ); } // create directories Path child = parent; for ( final Path name : parent.relativize( dir ) ) { child = child.resolve( name ); providerOf( child ).createDirectory( child, attrs ); } return dir; }
if(processAssetPath != null && !processAssetPath.equals("")){ processPath = fileService.getPath(processAssetPath); Path formsPath = fileService.getPath(processPath.getParent().toUri().toString() + "/forms/"); if(fileService.exists(formsPath)){ availableForms = fileService.loadFilesByType(formsPath, "ftl");
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; }
items.add( new ParentFolderItem( paths.convert( pRoot.getParent() ), ".." ) );
nioResource = nioResource.getParent();
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 ); }
@Test public void createDirectories() { final Path dir = getComposedDirectoryPath(); assertFalse( ioService().exists( dir ) ); ioService().createDirectories( dir, new FileAttribute<Object>() { @Override public String name() { return "custom"; } @Override public Object value() { return dateValue; } } ); assertTrue( ioService().exists( dir ) ); assertTrue( ioService().exists( dir.getParent() ) ); assertNotNull( ioService().exists( dir.getParent().getFileName() ) ); Map<String, Object> attrs = ioService().readAttributes( dir ); assertEquals( createDirectoriesAttrSize(), attrs.size() ); ioService().delete( dir ); ioService().exists( dir.getParent() ); }