Class JGitFileSystemProvider

  • All Implemented Interfaces:
    org.uberfire.commons.lifecycle.Disposable, org.uberfire.java.nio.file.spi.FileSystemProvider, GitHookSupport, org.uberfire.java.nio.security.SecuredFileSystemProvider

    public class JGitFileSystemProvider
    extends Object
    implements org.uberfire.java.nio.security.SecuredFileSystemProvider, org.uberfire.commons.lifecycle.Disposable, GitHookSupport
    • Constructor Detail

      • JGitFileSystemProvider

        public JGitFileSystemProvider()
        Creates a JGit filesystem provider which takes its configuration from system properties. In a normal production deployment of UberFire, this is the constructor that will be invoked by the ServiceLoader mechanism. For a list of properties that affect the configuration of JGitFileSystemProvider, see the DEBUG log output of this class during startup.
      • JGitFileSystemProvider

        public JGitFileSystemProvider​(Map<String,​String> gitPrefs)
        Creates a JGit filesystem provider which takes its configuration from the given map. For a list of properties that affect the configuration of JGitFileSystemProvider, see the DEBUG log output of this class during startup.
      • JGitFileSystemProvider

        public JGitFileSystemProvider​(org.uberfire.commons.config.ConfigProperties gitPrefs,
                                      ExecutorService executorService)
        Creates a JGit filesystem provider which takes its configuration from the given ConfigProperties instance. For a list of properties that affect the configuration of JGitFileSystemProvider, see the DEBUG log output of this class during startup.
    • Method Detail

      • removeRefsFromTree

        protected static String removeRefsFromTree​(String tree)
      • setupFileSystemsManager

        protected void setupFileSystemsManager()
      • onCloseFileSystem

        public void onCloseFileSystem​(JGitFileSystem fileSystem)
      • shutdownEventsManager

        protected void shutdownEventsManager()
      • onDisposeFileSystem

        public void onDisposeFileSystem​(JGitFileSystem fileSystem)
      • setAuthorizer

        public void setAuthorizer​(org.uberfire.java.nio.security.FileSystemAuthorizer authorizer)
        Specified by:
        setAuthorizer in interface org.uberfire.java.nio.security.SecuredFileSystemProvider
      • setJAASAuthenticator

        public void setJAASAuthenticator​(org.jboss.errai.security.shared.service.AuthenticationService authenticator)
        Specified by:
        setJAASAuthenticator in interface org.uberfire.java.nio.security.SecuredFileSystemProvider
      • setHTTPAuthenticator

        public void setHTTPAuthenticator​(org.jboss.errai.security.shared.service.AuthenticationService httpAuthenticator)
        Specified by:
        setHTTPAuthenticator in interface org.uberfire.java.nio.security.SecuredFileSystemProvider
      • setSSHAuthenticator

        public void setSSHAuthenticator​(org.uberfire.java.nio.security.SSHAuthenticator authenticator)
        Specified by:
        setSSHAuthenticator in interface org.uberfire.java.nio.security.SecuredFileSystemProvider
      • dispose

        public void dispose()
        Specified by:
        dispose in interface org.uberfire.commons.lifecycle.Disposable
      • addHostName

        public void addHostName​(String protocol,
                                String s)
      • updateCacheWithHostNames

        public void updateCacheWithHostNames()
      • getReceivePack

        public <T> org.eclipse.jgit.transport.ReceivePack getReceivePack​(String protocol,
                                                                         T req,
                                                                         org.eclipse.jgit.lib.Repository db)
      • shutdown

        public void shutdown()
        Closes and disposes all open filesystems and stops the Git and SSH daemons if they are running. This filesystem provider can be reactivated by attempting to open a new filesystem or by creating a new filesystem.
      • getGitRepoContainerDir

        public File getGitRepoContainerDir()
        Returns the directory that contains all the git repositories managed by this file system provider.
      • forceAsDefault

        public void forceAsDefault()
        Specified by:
        forceAsDefault in interface org.uberfire.java.nio.file.spi.FileSystemProvider
      • isDefault

        public boolean isDefault()
        Specified by:
        isDefault in interface org.uberfire.java.nio.file.spi.FileSystemProvider
      • getScheme

        public String getScheme()
        Specified by:
        getScheme in interface org.uberfire.java.nio.file.spi.FileSystemProvider
      • newFileSystem

        public org.uberfire.java.nio.file.FileSystem newFileSystem​(URI uri,
                                                                   Map<String,​?> env)
                                                            throws IllegalArgumentException,
                                                                   org.uberfire.java.nio.IOException,
                                                                   SecurityException,
                                                                   org.uberfire.java.nio.file.FileSystemAlreadyExistsException
        Specified by:
        newFileSystem in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        IllegalArgumentException
        org.uberfire.java.nio.IOException
        SecurityException
        org.uberfire.java.nio.file.FileSystemAlreadyExistsException
      • createNewGitRepo

        protected Git createNewGitRepo​(Map<String,​?> env,
                                       String fsName)
      • extractPath

        public String extractPath​(URI uri)
      • exists

        protected boolean exists​(org.uberfire.java.nio.file.Path path)
      • newDirectoryStream

        public org.uberfire.java.nio.file.DirectoryStream<org.uberfire.java.nio.file.Path> newDirectoryStream​(org.uberfire.java.nio.file.Path path,
                                                                                                              org.uberfire.java.nio.file.DirectoryStream.Filter<org.uberfire.java.nio.file.Path> pfilter)
                                                                                                       throws org.uberfire.java.nio.IOException,
                                                                                                              SecurityException
        Specified by:
        newDirectoryStream in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        org.uberfire.java.nio.IOException
        SecurityException
      • createSymbolicLink

        public void createSymbolicLink​(org.uberfire.java.nio.file.Path link,
                                       org.uberfire.java.nio.file.Path target,
                                       org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs)
                                throws UnsupportedOperationException,
                                       org.uberfire.java.nio.IOException,
                                       SecurityException
        Specified by:
        createSymbolicLink in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        UnsupportedOperationException
        org.uberfire.java.nio.IOException
        SecurityException
      • delete

        public void delete​(org.uberfire.java.nio.file.Path path,
                           org.uberfire.java.nio.file.DeleteOption... options)
                    throws org.uberfire.java.nio.IOException,
                           SecurityException
        Specified by:
        delete in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        org.uberfire.java.nio.IOException
        SecurityException
      • deleteFS

        protected boolean deleteFS​(org.uberfire.java.nio.file.FileSystem fileSystem)
      • deleteAsset

        public void deleteAsset​(JGitPathImpl path,
                                org.uberfire.java.nio.file.DeleteOption... options)
      • deleteBranch

        public void deleteBranch​(JGitPathImpl path)
      • deleteIfExists

        public boolean deleteIfExists​(org.uberfire.java.nio.file.Path path,
                                      org.uberfire.java.nio.file.DeleteOption... options)
                               throws org.uberfire.java.nio.IOException,
                                      SecurityException
        Specified by:
        deleteIfExists in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        org.uberfire.java.nio.IOException
        SecurityException
      • deleteBranchIfExists

        public boolean deleteBranchIfExists​(JGitPathImpl path)
      • deleteAssetIfExists

        public boolean deleteAssetIfExists​(JGitPathImpl path,
                                           org.uberfire.java.nio.file.DeleteOption... options)
      • move

        public void move​(org.uberfire.java.nio.file.Path source,
                         org.uberfire.java.nio.file.Path target,
                         org.uberfire.java.nio.file.CopyOption... options)
                  throws org.uberfire.java.nio.IOException,
                         SecurityException
        Specified by:
        move in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        org.uberfire.java.nio.IOException
        SecurityException
      • isSameFile

        public boolean isSameFile​(org.uberfire.java.nio.file.Path pathA,
                                  org.uberfire.java.nio.file.Path pathB)
                           throws org.uberfire.java.nio.IOException,
                                  SecurityException
        Specified by:
        isSameFile in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        org.uberfire.java.nio.IOException
        SecurityException
      • getFileStore

        public org.uberfire.java.nio.file.FileStore getFileStore​(org.uberfire.java.nio.file.Path path)
                                                          throws org.uberfire.java.nio.IOException,
                                                                 SecurityException
        Specified by:
        getFileStore in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        org.uberfire.java.nio.IOException
        SecurityException
      • getFileAttributeView

        public <V extends org.uberfire.java.nio.file.attribute.FileAttributeView> V getFileAttributeView​(org.uberfire.java.nio.file.Path path,
                                                                                                         Class<V> type,
                                                                                                         org.uberfire.java.nio.file.LinkOption... options)
                                                                                                  throws org.uberfire.java.nio.file.NoSuchFileException
        Specified by:
        getFileAttributeView in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        org.uberfire.java.nio.file.NoSuchFileException
      • readAttributes

        public <A extends org.uberfire.java.nio.file.attribute.BasicFileAttributes> A readAttributes​(org.uberfire.java.nio.file.Path path,
                                                                                                     Class<A> type,
                                                                                                     org.uberfire.java.nio.file.LinkOption... options)
                                                                                              throws UnsupportedOperationException,
                                                                                                     org.uberfire.java.nio.IOException,
                                                                                                     SecurityException
        Specified by:
        readAttributes in interface org.uberfire.java.nio.file.spi.FileSystemProvider
        Throws:
        UnsupportedOperationException
        org.uberfire.java.nio.IOException
        SecurityException
      • extractHostForPath

        public String extractHostForPath​(URI uri)
      • setDetectedFS

        public void setDetectedFS​(org.eclipse.jgit.util.FS detectedFS)