Package adams.core.git
Class GitSession
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.git.GitSession
-
- All Implemented Interfaces:
adams.core.CleanUpHandler,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.SizeOfHandler,Serializable
public class GitSession extends adams.core.logging.CustomLoggingLevelObject implements adams.core.CleanUpHandlerManages the repositories during a session.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<File,Object>m_Controlledthe file repo/false relation.protected Map<org.eclipse.jgit.transport.URIish,char[]>m_Passwordsfor keeping track of passwords per ssh key.protected Map<File,org.eclipse.jgit.api.Git>m_Reposthe git repos.protected static GitSessionm_Singletonthe singleton.
-
Constructor Summary
Constructors Modifier Constructor Description protectedGitSession()Initializes the session object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRepo(org.eclipse.jgit.api.Git git)Adds the git repo.voidcleanUp()Cleans up data structures, frees up memory.char[]getPassword(org.eclipse.jgit.transport.URIish uri)Returns the password for the ssh key.char[]getPasswordOrPrompt(org.eclipse.jgit.transport.URIish uri)Returns the password for the ssh key and prompts the user if not yet stored.static GitSessiongetSingleton()Returns the session singleton.org.eclipse.jgit.transport.sshd.SshdSessionFactorygetSshdSessionFactory()Returns a sshd session factory that will prompt the user for a password for each ssh key in use.booleanisWithinRepo(File path)Checks whether the dir/file is inside a git-managed directory sub-tree.org.eclipse.jgit.api.GitrepoFor(File path)Returns the repo for the specified dir/file.Collection<org.eclipse.jgit.api.Git>repos()Returns the currently managed repos.voidsetPassword(org.eclipse.jgit.transport.URIish uri, char[] password)Sets the password for the ssh key.-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Singleton
protected static GitSession m_Singleton
the singleton.
-
m_Passwords
protected Map<org.eclipse.jgit.transport.URIish,char[]> m_Passwords
for keeping track of passwords per ssh key.
-
-
Method Detail
-
addRepo
public void addRepo(org.eclipse.jgit.api.Git git)
Adds the git repo.- Parameters:
git- the repo to add
-
repos
public Collection<org.eclipse.jgit.api.Git> repos()
Returns the currently managed repos.- Returns:
- the repos
-
repoFor
public org.eclipse.jgit.api.Git repoFor(File path)
Returns the repo for the specified dir/file.- Parameters:
path- the dir/file to get the repo for- Returns:
- the repo, null if no repo (yet) available
-
isWithinRepo
public boolean isWithinRepo(File path)
Checks whether the dir/file is inside a git-managed directory sub-tree. Automatically callsaddRepo(Git)when it is within a git-controlled sub-tree.- Parameters:
path- the dir/file to check- Returns:
- true if under control
- See Also:
addRepo(Git)
-
getPassword
public char[] getPassword(org.eclipse.jgit.transport.URIish uri)
Returns the password for the ssh key.- Parameters:
uri- the URI of the ssh key- Returns:
- the password or null if none stored yet
-
getPasswordOrPrompt
public char[] getPasswordOrPrompt(org.eclipse.jgit.transport.URIish uri)
Returns the password for the ssh key and prompts the user if not yet stored.- Parameters:
uri- the URI of the ssh key- Returns:
- the key or null if none stored yet
-
getSshdSessionFactory
public org.eclipse.jgit.transport.sshd.SshdSessionFactory getSshdSessionFactory()
Returns a sshd session factory that will prompt the user for a password for each ssh key in use.- Returns:
- the factory
-
setPassword
public void setPassword(org.eclipse.jgit.transport.URIish uri, char[] password)Sets the password for the ssh key.- Parameters:
uri- the URI of the ssh keypassword- the password for the key
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceadams.core.CleanUpHandler
-
getSingleton
public static GitSession getSingleton()
Returns the session singleton.- Returns:
- the singleton
-
-