Package org.uberfire.java.nio.fs.jgit
Class JGitFileSystemProvider
- java.lang.Object
-
- org.uberfire.java.nio.fs.jgit.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classJGitFileSystemProvider.RepositoryResolverImpl<T>
-
Constructor Summary
Constructors Constructor Description JGitFileSystemProvider()Creates a JGit filesystem provider which takes its configuration from system properties.JGitFileSystemProvider(Map<String,String> gitPrefs)Creates a JGit filesystem provider which takes its configuration from the given map.JGitFileSystemProvider(org.uberfire.commons.config.ConfigProperties gitPrefs, ExecutorService executorService)Creates a JGit filesystem provider which takes its configuration from the given ConfigProperties instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHostName(String protocol, String s)voidcheckAccess(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.AccessMode... modes)voidcopy(org.uberfire.java.nio.file.Path source, org.uberfire.java.nio.file.Path target, org.uberfire.java.nio.file.CopyOption... options)voidcreateDirectory(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs)voidcreateLink(org.uberfire.java.nio.file.Path link, org.uberfire.java.nio.file.Path existing)protected GitcreateNewGitRepo(Map<String,?> env, String fsName)protected GitcreateNewGitRepo(Map<String,?> env, String fsName, File repoDest)voidcreateSymbolicLink(org.uberfire.java.nio.file.Path link, org.uberfire.java.nio.file.Path target, org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs)voiddelete(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.DeleteOption... options)voiddeleteAsset(JGitPathImpl path, org.uberfire.java.nio.file.DeleteOption... options)booleandeleteAssetIfExists(JGitPathImpl path, org.uberfire.java.nio.file.DeleteOption... options)voiddeleteBranch(JGitPathImpl path)booleandeleteBranchIfExists(JGitPathImpl path)protected booleandeleteFS(org.uberfire.java.nio.file.FileSystem fileSystem)booleandeleteIfExists(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.DeleteOption... options)voiddispose()voidexecutePostCommitHook(JGitFileSystem fileSystem)protected booleanexists(org.uberfire.java.nio.file.Path path)StringextractHostForPath(URI uri)StringextractPath(URI uri)voidforceAsDefault()JGitFileSystemProviderConfigurationgetConfig()<V extends org.uberfire.java.nio.file.attribute.FileAttributeView>
VgetFileAttributeView(org.uberfire.java.nio.file.Path path, Class<V> type, org.uberfire.java.nio.file.LinkOption... options)org.uberfire.java.nio.file.FileStoregetFileStore(org.uberfire.java.nio.file.Path path)org.uberfire.java.nio.file.FileSystemgetFileSystem(URI uri)JGitFileSystemsManagergetFsManager()Map<String,String>getFullHostNames()FilegetGitRepoContainerDir()Returns the directory that contains all the git repositories managed by this file system provider.org.uberfire.java.nio.file.PathgetPath(URI uri)<T> org.eclipse.jgit.transport.ReceivePackgetReceivePack(String protocol, T req, org.eclipse.jgit.lib.Repository db)<T> JGitFileSystemProvider.RepositoryResolverImpl<T>getRepositoryResolver()StringgetScheme()booleanisDefault()booleanisHidden(org.uberfire.java.nio.file.Path path)booleanisSameFile(org.uberfire.java.nio.file.Path pathA, org.uberfire.java.nio.file.Path pathB)voidmove(org.uberfire.java.nio.file.Path source, org.uberfire.java.nio.file.Path target, org.uberfire.java.nio.file.CopyOption... options)org.uberfire.java.nio.channels.AsynchronousFileChannelnewAsynchronousFileChannel(org.uberfire.java.nio.file.Path path, Set<? extends org.uberfire.java.nio.file.OpenOption> options, ExecutorService executor, org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs)org.uberfire.java.nio.channels.SeekableByteChannelnewByteChannel(org.uberfire.java.nio.file.Path path, Set<? extends org.uberfire.java.nio.file.OpenOption> options, org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs)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)FileChannelnewFileChannel(org.uberfire.java.nio.file.Path path, Set<? extends org.uberfire.java.nio.file.OpenOption> options, org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs)org.uberfire.java.nio.file.FileSystemnewFileSystem(URI uri, Map<String,?> env)org.uberfire.java.nio.file.FileSystemnewFileSystem(org.uberfire.java.nio.file.Path path, Map<String,?> env)InputStreamnewInputStream(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.OpenOption... options)OutputStreamnewOutputStream(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.OpenOption... options)voidonCloseFileSystem(JGitFileSystem fileSystem)voidonDisposeFileSystem(JGitFileSystem fileSystem)<A extends org.uberfire.java.nio.file.attribute.BasicFileAttributes>
AreadAttributes(org.uberfire.java.nio.file.Path path, Class<A> type, org.uberfire.java.nio.file.LinkOption... options)Map<String,Object>readAttributes(org.uberfire.java.nio.file.Path path, String attributes, org.uberfire.java.nio.file.LinkOption... options)org.uberfire.java.nio.file.PathreadSymbolicLink(org.uberfire.java.nio.file.Path link)protected static StringremoveRefsFromTree(String tree)voidsetAttribute(org.uberfire.java.nio.file.Path path, String attribute, Object value, org.uberfire.java.nio.file.LinkOption... options)voidsetAuthorizer(org.uberfire.java.nio.security.FileSystemAuthorizer authorizer)voidsetDetectedFS(org.eclipse.jgit.util.FS detectedFS)voidsetHTTPAuthenticator(org.jboss.errai.security.shared.service.AuthenticationService httpAuthenticator)voidsetJAASAuthenticator(org.jboss.errai.security.shared.service.AuthenticationService authenticator)voidsetSSHAuthenticator(org.uberfire.java.nio.security.SSHAuthenticator authenticator)protected voidsetupFileSystemsManager()voidshutdown()Closes and disposes all open filesystems and stops the Git and SSH daemons if they are running.protected voidshutdownEventsManager()voidupdateCacheWithHostNames()
-
-
-
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
-
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:
setAuthorizerin interfaceorg.uberfire.java.nio.security.SecuredFileSystemProvider
-
setJAASAuthenticator
public void setJAASAuthenticator(org.jboss.errai.security.shared.service.AuthenticationService authenticator)
- Specified by:
setJAASAuthenticatorin interfaceorg.uberfire.java.nio.security.SecuredFileSystemProvider
-
setHTTPAuthenticator
public void setHTTPAuthenticator(org.jboss.errai.security.shared.service.AuthenticationService httpAuthenticator)
- Specified by:
setHTTPAuthenticatorin interfaceorg.uberfire.java.nio.security.SecuredFileSystemProvider
-
setSSHAuthenticator
public void setSSHAuthenticator(org.uberfire.java.nio.security.SSHAuthenticator authenticator)
- Specified by:
setSSHAuthenticatorin interfaceorg.uberfire.java.nio.security.SecuredFileSystemProvider
-
dispose
public void dispose()
- Specified by:
disposein interfaceorg.uberfire.commons.lifecycle.Disposable
-
updateCacheWithHostNames
public void updateCacheWithHostNames()
-
getReceivePack
public <T> org.eclipse.jgit.transport.ReceivePack getReceivePack(String protocol, T req, org.eclipse.jgit.lib.Repository db)
-
getRepositoryResolver
public <T> JGitFileSystemProvider.RepositoryResolverImpl<T> getRepositoryResolver()
-
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:
forceAsDefaultin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider
-
isDefault
public boolean isDefault()
- Specified by:
isDefaultin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider
-
getScheme
public String getScheme()
- Specified by:
getSchemein interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider
-
newFileSystem
public org.uberfire.java.nio.file.FileSystem newFileSystem(org.uberfire.java.nio.file.Path path, Map<String,?> env) throws IllegalArgumentException, UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
newFileSystemin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionUnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
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:
newFileSystemin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionorg.uberfire.java.nio.IOExceptionSecurityExceptionorg.uberfire.java.nio.file.FileSystemAlreadyExistsException
-
getFileSystem
public org.uberfire.java.nio.file.FileSystem getFileSystem(URI uri) throws IllegalArgumentException, org.uberfire.java.nio.file.FileSystemNotFoundException, SecurityException
- Specified by:
getFileSystemin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionorg.uberfire.java.nio.file.FileSystemNotFoundExceptionSecurityException
-
getPath
public org.uberfire.java.nio.file.Path getPath(URI uri) throws IllegalArgumentException, org.uberfire.java.nio.file.FileSystemNotFoundException, SecurityException
- Specified by:
getPathin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionorg.uberfire.java.nio.file.FileSystemNotFoundExceptionSecurityException
-
newInputStream
public InputStream newInputStream(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.OpenOption... options) throws IllegalArgumentException, UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException
- Specified by:
newInputStreamin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionUnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
newOutputStream
public OutputStream newOutputStream(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.OpenOption... options) throws IllegalArgumentException, UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException
- Specified by:
newOutputStreamin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionUnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
newFileChannel
public FileChannel newFileChannel(org.uberfire.java.nio.file.Path path, Set<? extends org.uberfire.java.nio.file.OpenOption> options, org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException
- Specified by:
newFileChannelin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionUnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
newAsynchronousFileChannel
public org.uberfire.java.nio.channels.AsynchronousFileChannel newAsynchronousFileChannel(org.uberfire.java.nio.file.Path path, Set<? extends org.uberfire.java.nio.file.OpenOption> options, ExecutorService executor, org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
newAsynchronousFileChannelin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionUnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
newByteChannel
public org.uberfire.java.nio.channels.SeekableByteChannel newByteChannel(org.uberfire.java.nio.file.Path path, Set<? extends org.uberfire.java.nio.file.OpenOption> options, org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs) throws IllegalArgumentException, UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
newByteChannelin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionUnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
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:
newDirectoryStreamin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
org.uberfire.java.nio.IOExceptionSecurityException
-
createDirectory
public void createDirectory(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.attribute.FileAttribute<?>... attrs) throws UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
createDirectoryin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
UnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
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:
createSymbolicLinkin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
UnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
createLink
public void createLink(org.uberfire.java.nio.file.Path link, org.uberfire.java.nio.file.Path existing) throws UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
createLinkin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
UnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
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:
deletein interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
org.uberfire.java.nio.IOExceptionSecurityException
-
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:
deleteIfExistsin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
org.uberfire.java.nio.IOExceptionSecurityException
-
deleteBranchIfExists
public boolean deleteBranchIfExists(JGitPathImpl path)
-
deleteAssetIfExists
public boolean deleteAssetIfExists(JGitPathImpl path, org.uberfire.java.nio.file.DeleteOption... options)
-
readSymbolicLink
public org.uberfire.java.nio.file.Path readSymbolicLink(org.uberfire.java.nio.file.Path link) throws UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
readSymbolicLinkin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
UnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
copy
public void copy(org.uberfire.java.nio.file.Path source, org.uberfire.java.nio.file.Path target, org.uberfire.java.nio.file.CopyOption... options) throws UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
copyin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
UnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
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:
movein interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
org.uberfire.java.nio.IOExceptionSecurityException
-
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:
isSameFilein interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
org.uberfire.java.nio.IOExceptionSecurityException
-
isHidden
public boolean isHidden(org.uberfire.java.nio.file.Path path) throws IllegalArgumentException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
isHiddenin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
IllegalArgumentExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
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:
getFileStorein interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
org.uberfire.java.nio.IOExceptionSecurityException
-
checkAccess
public void checkAccess(org.uberfire.java.nio.file.Path path, org.uberfire.java.nio.file.AccessMode... modes) throws UnsupportedOperationException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
checkAccessin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
UnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
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:
getFileAttributeViewin interfaceorg.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:
readAttributesin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
UnsupportedOperationExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
readAttributes
public Map<String,Object> readAttributes(org.uberfire.java.nio.file.Path path, String attributes, org.uberfire.java.nio.file.LinkOption... options) throws UnsupportedOperationException, IllegalArgumentException, org.uberfire.java.nio.IOException, SecurityException
- Specified by:
readAttributesin interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
UnsupportedOperationExceptionIllegalArgumentExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
setAttribute
public void setAttribute(org.uberfire.java.nio.file.Path path, String attribute, Object value, org.uberfire.java.nio.file.LinkOption... options) throws UnsupportedOperationException, IllegalArgumentException, ClassCastException, org.uberfire.java.nio.IOException, SecurityException- Specified by:
setAttributein interfaceorg.uberfire.java.nio.file.spi.FileSystemProvider- Throws:
UnsupportedOperationExceptionIllegalArgumentExceptionClassCastExceptionorg.uberfire.java.nio.IOExceptionSecurityException
-
executePostCommitHook
public void executePostCommitHook(JGitFileSystem fileSystem)
- Specified by:
executePostCommitHookin interfaceGitHookSupport
-
getConfig
public JGitFileSystemProviderConfiguration getConfig()
-
setDetectedFS
public void setDetectedFS(org.eclipse.jgit.util.FS detectedFS)
-
getFsManager
public JGitFileSystemsManager getFsManager()
-
-