Package org.uberfire.java.nio.file

Examples of org.uberfire.java.nio.file.FileSystem


    private RepositoryDescriptor buildAndRegister(Repository repository, String branchName) {
        String repoUri = repository.getRoot().toURI().replaceFirst("://.*?@", "://"+branchName+"@");
        URI root = URI.create(repoUri);

        FileSystem fs = ioService.getFileSystem(root);
        Path rootPath = fs.provider().getPath(root);

        RepositoryDescriptor descriptor = new RepositoryDescriptor(root, fs, rootPath);
        knownRepositories.put(branchName+"@"+repository.getAlias(), descriptor);

        return descriptor;
View Full Code Here


    @Override
    public Project newProject( final org.guvnor.structure.repositories.Repository repository,
                               final String projectName,
                               final POM pom,
                               final String baseUrl ) {
        final FileSystem fs = Paths.convert( repository.getRoot() ).getFileSystem();
        try {
            //Projects are always created in the FS root
            final Path fsRoot = repository.getRoot();
            final Path projectRootPath = Paths.convert( Paths.convert( fsRoot ).resolve( projectName ) );
View Full Code Here

        org.uberfire.java.nio.file.Path repositoryRootPath = null;

        final Iterator<FileSystem> fsIterator = ioService.getFileSystems().iterator();

        if ( fsIterator.hasNext() ) {
            final FileSystem fileSystem = fsIterator.next();
            logger.info( "-----FileSystem id--- :" + ( (org.uberfire.java.nio.base.FileSystemId) fileSystem ).id() );

            if ( repositoryName.equalsIgnoreCase( ( (org.uberfire.java.nio.base.FileSystemId) fileSystem ).id() ) ) {
                final Iterator<org.uberfire.java.nio.file.Path> rootIterator = fileSystem.getRootDirectories().iterator();
                if ( rootIterator.hasNext() ) {
                    repositoryRootPath = rootIterator.next();
                    logger.info( "-----rootPath--- :" + repositoryRootPath );

                    org.uberfire.java.nio.file.DirectoryStream<org.uberfire.java.nio.file.Path> paths = ioService
View Full Code Here

        if (!repo.isValid()) {
            throw new IllegalStateException("Repository " + repoConfig.getName() + " not valid");
        }

        FileSystem fs = null;
        URI uri = null;
        try {
            uri = URI.create(repo.getUri());
            fs = ioService.newFileSystem(uri, new HashMap<String, Object>(repo.getEnvironment()) {{
                if (!repo.getEnvironment().containsKey("origin")) {
                    put("init", true);
                }
            }});
        } catch (final FileSystemAlreadyExistsException e) {
            fs = ioService.getFileSystem(uri);
        } catch (final Throwable ex) {
            throw new RuntimeException(ex.getCause().getMessage(), ex);
        }

        org.uberfire.backend.vfs.Path defaultRoot = convert(fs.getRootDirectories().iterator().next());
        Map<String, org.uberfire.backend.vfs.Path> branches = getBranches(fs);
        if (branches.containsKey(branch)) {
            defaultRoot = branches.get(branch);
        }
        repo.setBranches(branches);

        repo.setRoot(defaultRoot);
        final String[] uris = fs.toString().split("\\r?\\n");
        final List<PublicURI> publicURIs = new ArrayList<PublicURI>(uris.length);

        for (final String s : uris) {
            final int protocolStart = s.indexOf("://");
            final PublicURI publicURI;
View Full Code Here

        final Path testSrcPath = parentPackage.getPackageTestSrcPath();
        final Path mainResourcesPath = parentPackage.getPackageMainResourcesPath();
        final Path testResourcesPath = parentPackage.getPackageTestResourcesPath();

        Path pkgPath = null;
        final FileSystem fs = Paths.convert( parentPackage.getPackageMainSrcPath() ).getFileSystem();

        try {

            if ( startBatch ) {
                ioService.startBatch( new FileSystem[]{fs}, makeCommentedOption( "New package [" + packageName + "]" ) );
View Full Code Here

    @Override
    public void save( final Path pathToPomXML,
            final ProjectStructureModel model,
            final String comment ) {
        final FileSystem fs = Paths.convert( pathToPomXML ).getFileSystem();
        try {
            pomService.save( pathToPomXML,
                    model.getPOM(),
                    model.getPOMMetaData(),
                    comment,
View Full Code Here

        if ( !repo.isValid() ) {
            throw new IllegalStateException( "Repository " + repoConfig.getName() + " not valid" );
        }

        FileSystem fs = null;
        URI uri = null;
        try {
            uri = URI.create( repo.getUri() );
            fs = ioService.newFileSystem( uri, new HashMap<String, Object>( repo.getEnvironment() ) {{
                if ( !repo.getEnvironment().containsKey( "origin" ) ) {
                    put( "init", true );
                }
            }} );
        } catch ( final FileSystemAlreadyExistsException e ) {
            fs = ioService.getFileSystem( uri );
        } catch ( final Throwable ex ) {
            throw new RuntimeException( ex.getCause().getMessage(), ex );
        }

        Path defaultRoot = fs.getRootDirectories().iterator().next();
        for ( final Path path : fs.getRootDirectories() ) {
            String gitBranch = getBranchName( path );
            if ( gitBranch.equals( branch ) ) {
                defaultRoot = path;
                break;
            }
        }
        Set<String> branches = new HashSet<String>();
        // collect all branches
        for ( final Path path : fs.getRootDirectories() ) {
            String gitBranch = getBranchName( path );
            branches.add( gitBranch );
        }
        repo.setBranches( branches );

        repo.setRoot( convert( defaultRoot ) );
        final String[] uris = fs.toString().split( "\\r?\\n" );
        final List<PublicURI> publicURIs = new ArrayList<PublicURI>( uris.length );

        for ( final String s : uris ) {
            final int protocolStart = s.indexOf( "://" );
            final PublicURI publicURI;
View Full Code Here

    final File[]             roots      = new File[]{ new File( "c:\\" ), new File( "a:\\" ) };

    @Test
    public void simpleTests() {

        final FileSystem fileSystem = new SimpleWindowsFileSystem( roots, fsProvider, "c:\\" );

        assertThat( fileSystem.isOpen() ).isTrue();
        assertThat( fileSystem.isReadOnly() ).isFalse();
        assertThat( fileSystem.getSeparator() ).isEqualTo( "\\" );
        assertThat( fileSystem.provider() ).isEqualTo( fsProvider );
        assertThat( fileSystem.supportedFileAttributeViews() ).isNotEmpty().hasSize( 1 ).contains( "basic" );

        assertThat( fileSystem.getPath( "c:\\path\\to\\file.txt" ) ).isNotNull().isEqualTo( GeneralPathImpl.create( fileSystem, "c:\\path\\to\\file.txt", false ) );
        assertThat( fileSystem.getPath( "c:\\path\\to\\file.txt", null ) ).isNotNull().isEqualTo( GeneralPathImpl.create( fileSystem, "c:\\path\\to\\file.txt", false ) );
        assertThat( fileSystem.getPath( "c:\\path", "to", "file.txt" ) ).isNotNull().isEqualTo( GeneralPathImpl.create( fileSystem, "c:\\path\\to\\file.txt", false ) );

        try {
            fileSystem.close();
            fail( "can't close this fileSystem" );
        } catch ( UnsupportedOperationException ex ) {
        }

        assertThat( fileSystem.getFileStores() ).isNotNull().hasSize( 2 );
        assertThat( fileSystem.getFileStores().iterator().next().name() ).isEqualTo( "c:\\" );

        assertThat( fileSystem.getRootDirectories() ).isNotNull().hasSize( 2 );
        assertThat( fileSystem.getRootDirectories().iterator().next().toString() ).isEqualTo( "c:\\" );
        assertThat( fileSystem.getRootDirectories().iterator().next().isAbsolute() ).isTrue();
    }
View Full Code Here

    final FileSystemProvider fsProvider = mock( FileSystemProvider.class );

    @Test
    public void simpleTests() {
        final FileSystem fileSystem = new SimpleUnixFileSystem( fsProvider, "/" );

        assertThat( fileSystem.isOpen() ).isTrue();
        assertThat( fileSystem.isReadOnly() ).isFalse();
        assertThat( fileSystem.getSeparator() ).isEqualTo( System.getProperty( "file.separator" ) );
        assertThat( fileSystem.provider() ).isEqualTo( fsProvider );
        assertThat( fileSystem.supportedFileAttributeViews() ).isNotEmpty().hasSize( 1 ).contains( "basic" );

        assertThat( fileSystem.getPath( "/path/to/file.txt" ) ).isNotNull().isEqualTo( GeneralPathImpl.create( fileSystem, "/path/to/file.txt", false ) );
        assertThat( fileSystem.getPath( "/path/to/file.txt", null ) ).isNotNull().isEqualTo( GeneralPathImpl.create( fileSystem, "/path/to/file.txt", false ) );
        assertThat( fileSystem.getPath( "/path", "to", "file.txt" ) ).isNotNull().isEqualTo( GeneralPathImpl.create( fileSystem, "/path/to/file.txt", false ) );

        try {
            fileSystem.close();
            fail( "can't close this fileSystem" );
        } catch ( UnsupportedOperationException ex ) {
        }

        assertThat( fileSystem.getFileStores() ).isNotNull().hasSize( 1 );
        assertThat( fileSystem.getFileStores().iterator().next().name() ).isEqualTo( "/" );

        assertThat( fileSystem.getRootDirectories() ).isNotNull().hasSize( 1 );
        assertThat( fileSystem.getRootDirectories().iterator().next().toString() ).isEqualTo( "/" );
        assertThat( fileSystem.getRootDirectories().iterator().next().isAbsolute() ).isTrue();
    }
View Full Code Here

    @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" );
View Full Code Here

TOP

Related Classes of org.uberfire.java.nio.file.FileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.