Class GitRepositoryHelper
- java.lang.Object
-
- org.craftercms.studio.api.v2.utils.GitRepositoryHelper
-
public class GitRepositoryHelper extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_KEY_FOLDER
static String
CONFIG_KEY_RESOURCE
-
Constructor Summary
Constructors Constructor Description GitRepositoryHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addGitIgnoreFiles(String siteId)
boolean
buildGlobalRepo()
Build the global repository as part of system startup and caches itPath
buildRepoPath(GitRepositories repoType)
Builds repository pathPath
buildRepoPath(GitRepositories repoType, String siteId)
Builds repository pathboolean
buildSiteRepo(String siteId)
String
commitFile(org.eclipse.jgit.lib.Repository repo, String site, String path, String comment, org.eclipse.jgit.lib.PersonIdent user)
boolean
copyContentFromBlueprint(String blueprintLocation, String site)
org.eclipse.jgit.lib.Repository
createGitRepository(Path path)
boolean
createGlobalRepo()
boolean
createPublishedRepository(String siteId, String sandboxBranch)
Create a site published git repository from scratchboolean
createSandboxRepository(String site, String sandboxBranch)
Create a site sandbox git repository from scratchboolean
createSiteCloneRemoteGitRepo(String siteId, String sandboxBranch, String remoteName, String remoteUrl, String remoteBranch, boolean singleBranch, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey, boolean createAsOrphan)
boolean
deleteSiteGitRepo(String site)
org.eclipse.jgit.lib.PersonIdent
getAuthorIdent(String author)
Return the author identity as a jgit PersonIdentorg.eclipse.jgit.lib.PersonIdent
getAuthorIdent(User user)
Return the author identity as a jgit PersonIdentString
getCommitMessage(String commitMessageKey)
org.eclipse.jgit.lib.PersonIdent
getCurrentUserIdent()
Return the current user identity as a jgit PersonIdentorg.craftercms.commons.crypto.TextEncryptor
getEncryptor()
List<String>
getFilesInCommit(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit commit)
GeneralLockService
getGeneralLockService()
String
getGitPath(String path)
org.eclipse.jgit.lib.Repository
getRepository(String siteId, GitRepositories gitRepository)
org.eclipse.jgit.lib.Repository
getRepository(String siteId, GitRepositories gitRepository, String sandboxBranch)
RetryingRepositoryOperationFacade
getRetryingRepositoryOperationFacade()
SecurityService
getSecurityService()
StudioConfiguration
getStudioConfiguration()
org.eclipse.jgit.revwalk.RevTree
getTreeForCommit(org.eclipse.jgit.lib.Repository repository, String commitId)
org.eclipse.jgit.revwalk.RevTree
getTreeForLastCommit(org.eclipse.jgit.lib.Repository repository)
UserServiceInternal
getUserServiceInternal()
boolean
isRemoteValid(org.eclipse.jgit.api.Git git, String remote, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey)
org.eclipse.jgit.lib.Repository
openRepository(Path repositoryPath)
Opens a git repositoryboolean
performInitialCommit(String site, String message, String sandboxBranch)
Perform an initial commit after large changes to a site.void
removeSandbox(String siteId)
boolean
replaceParameters(String siteId, Map<String,String> parameters)
protected boolean
replaceSiteNameVariable(String site, Path path)
void
setAuthConfiguratorFactory(org.craftercms.commons.git.utils.AuthConfiguratorFactory authConfiguratorFactory)
void
setAuthenticationForCommand(org.eclipse.jgit.api.TransportCommand<?,?> gitCommand, String authenticationType, String username, String password, String token, String privateKey, Path tempKey, boolean decrypt)
void
setEncryptor(org.craftercms.commons.crypto.TextEncryptor encryptor)
void
setGeneralLockService(GeneralLockService generalLockService)
void
setRetryingRepositoryOperationFacade(RetryingRepositoryOperationFacade retryingRepositoryOperationFacade)
void
setSecurityService(SecurityService securityService)
void
setStudioConfiguration(StudioConfiguration studioConfiguration)
void
setUserServiceInternal(UserServiceInternal userServiceInternal)
boolean
updateSiteNameConfigVar(String site)
boolean
writeFile(org.eclipse.jgit.lib.Repository repo, String site, String path, InputStream content)
-
-
-
Field Detail
-
CONFIG_KEY_RESOURCE
public static final String CONFIG_KEY_RESOURCE
- See Also:
- Constant Field Values
-
CONFIG_KEY_FOLDER
public static final String CONFIG_KEY_FOLDER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRepository
public org.eclipse.jgit.lib.Repository getRepository(String siteId, GitRepositories gitRepository)
-
getRepository
public org.eclipse.jgit.lib.Repository getRepository(String siteId, GitRepositories gitRepository, String sandboxBranch)
-
buildSiteRepo
public boolean buildSiteRepo(String siteId)
-
buildRepoPath
public Path buildRepoPath(GitRepositories repoType)
Builds repository path- Parameters:
repoType
- repository type- Returns:
- repository path
-
buildRepoPath
public Path buildRepoPath(GitRepositories repoType, String siteId)
Builds repository path- Parameters:
repoType
- repository typesiteId
- site Id (if empty it is global repository)- Returns:
- repository path
-
openRepository
public org.eclipse.jgit.lib.Repository openRepository(Path repositoryPath) throws IOException
Opens a git repository- Parameters:
repositoryPath
- path to repository to open (including .git)- Returns:
- repository object if successful
- Throws:
IOException
- IO error
-
isRemoteValid
public boolean isRemoteValid(org.eclipse.jgit.api.Git git, String remote, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey) throws org.craftercms.commons.crypto.CryptoException, IOException, ServiceLayerException, org.eclipse.jgit.api.errors.GitAPIException
- Throws:
org.craftercms.commons.crypto.CryptoException
IOException
ServiceLayerException
org.eclipse.jgit.api.errors.GitAPIException
-
setAuthenticationForCommand
public void setAuthenticationForCommand(org.eclipse.jgit.api.TransportCommand<?,?> gitCommand, String authenticationType, String username, String password, String token, String privateKey, Path tempKey, boolean decrypt) throws org.craftercms.commons.crypto.CryptoException, ServiceLayerException, IOException
- Throws:
org.craftercms.commons.crypto.CryptoException
ServiceLayerException
IOException
-
getAuthorIdent
public org.eclipse.jgit.lib.PersonIdent getAuthorIdent(User user)
Return the author identity as a jgit PersonIdent- Parameters:
user
- author- Returns:
- author user as a PersonIdent
-
getTreeForCommit
public org.eclipse.jgit.revwalk.RevTree getTreeForCommit(org.eclipse.jgit.lib.Repository repository, String commitId) throws IOException
- Throws:
IOException
-
getTreeForLastCommit
public org.eclipse.jgit.revwalk.RevTree getTreeForLastCommit(org.eclipse.jgit.lib.Repository repository) throws IOException
- Throws:
IOException
-
getFilesInCommit
public List<String> getFilesInCommit(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit commit)
-
createSandboxRepository
public boolean createSandboxRepository(String site, String sandboxBranch)
Create a site sandbox git repository from scratch- Parameters:
site
- site to createsandboxBranch
- sandbox branch name- Returns:
- true if successful, false otherwise
-
createPublishedRepository
public boolean createPublishedRepository(String siteId, String sandboxBranch)
Create a site published git repository from scratch- Parameters:
siteId
- site to createsandboxBranch
- sandbox branch name- Returns:
- true if successful, false otherwise
-
createGitRepository
public org.eclipse.jgit.lib.Repository createGitRepository(Path path)
-
copyContentFromBlueprint
public boolean copyContentFromBlueprint(String blueprintLocation, String site)
-
updateSiteNameConfigVar
public boolean updateSiteNameConfigVar(String site)
-
addGitIgnoreFiles
public boolean addGitIgnoreFiles(String siteId)
-
performInitialCommit
public boolean performInitialCommit(String site, String message, String sandboxBranch)
Perform an initial commit after large changes to a site. Will not work against the global config repo.- Parameters:
site
- site identifiermessage
- commit messagesandboxBranch
- sandbox branch name- Returns:
- true if successful, false otherwise
-
createSiteCloneRemoteGitRepo
public boolean createSiteCloneRemoteGitRepo(String siteId, String sandboxBranch, String remoteName, String remoteUrl, String remoteBranch, boolean singleBranch, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey, boolean createAsOrphan) throws InvalidRemoteRepositoryException, InvalidRemoteRepositoryCredentialsException, RemoteRepositoryNotFoundException, ServiceLayerException
-
removeSandbox
public void removeSandbox(String siteId)
-
buildGlobalRepo
public boolean buildGlobalRepo() throws IOException
Build the global repository as part of system startup and caches it- Returns:
- true if successful, false otherwise
- Throws:
IOException
- IO error
-
createGlobalRepo
public boolean createGlobalRepo()
-
deleteSiteGitRepo
public boolean deleteSiteGitRepo(String site)
-
writeFile
public boolean writeFile(org.eclipse.jgit.lib.Repository repo, String site, String path, InputStream content)
-
commitFile
public String commitFile(org.eclipse.jgit.lib.Repository repo, String site, String path, String comment, org.eclipse.jgit.lib.PersonIdent user)
-
getCurrentUserIdent
public org.eclipse.jgit.lib.PersonIdent getCurrentUserIdent() throws ServiceLayerException, UserNotFoundException
Return the current user identity as a jgit PersonIdent- Returns:
- current user as a PersonIdent
- Throws:
ServiceLayerException
- general service errorUserNotFoundException
- user not found
-
getAuthorIdent
public org.eclipse.jgit.lib.PersonIdent getAuthorIdent(String author) throws ServiceLayerException, UserNotFoundException
Return the author identity as a jgit PersonIdent- Parameters:
author
- author- Returns:
- author user as a PersonIdent
- Throws:
ServiceLayerException
- general service errorUserNotFoundException
- user not found error
-
getStudioConfiguration
public StudioConfiguration getStudioConfiguration()
-
setStudioConfiguration
public void setStudioConfiguration(StudioConfiguration studioConfiguration)
-
getEncryptor
public org.craftercms.commons.crypto.TextEncryptor getEncryptor()
-
setEncryptor
public void setEncryptor(org.craftercms.commons.crypto.TextEncryptor encryptor)
-
getSecurityService
public SecurityService getSecurityService()
-
setSecurityService
public void setSecurityService(SecurityService securityService)
-
getUserServiceInternal
public UserServiceInternal getUserServiceInternal()
-
setUserServiceInternal
public void setUserServiceInternal(UserServiceInternal userServiceInternal)
-
getGeneralLockService
public GeneralLockService getGeneralLockService()
-
setGeneralLockService
public void setGeneralLockService(GeneralLockService generalLockService)
-
getRetryingRepositoryOperationFacade
public RetryingRepositoryOperationFacade getRetryingRepositoryOperationFacade()
-
setRetryingRepositoryOperationFacade
public void setRetryingRepositoryOperationFacade(RetryingRepositoryOperationFacade retryingRepositoryOperationFacade)
-
setAuthConfiguratorFactory
public void setAuthConfiguratorFactory(org.craftercms.commons.git.utils.AuthConfiguratorFactory authConfiguratorFactory)
-
-