Search in sources :

Example 1 with GitRepositories

use of org.craftercms.studio.api.v1.constant.GitRepositories in project studio by craftercms.

the class RepositoryManagementServiceInternalImpl method unlockRepository.

@Override
public boolean unlockRepository(String siteId, GitRepositories repositoryType) throws CryptoException {
    boolean toRet = false;
    GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration, securityService, userServiceInternal, encryptor, generalLockService, retryingRepositoryOperationFacade);
    Repository repo = helper.getRepository(siteId, repositoryType);
    if (Objects.nonNull(repo)) {
        toRet = FileUtils.deleteQuietly(Paths.get(repo.getDirectory().getAbsolutePath(), LOCK_FILE).toFile());
    }
    return toRet;
}
Also used : RemoteRepository(org.craftercms.studio.api.v2.dal.RemoteRepository) Repository(org.eclipse.jgit.lib.Repository) ContentRepository(org.craftercms.studio.api.v1.repository.ContentRepository) GitRepositoryHelper(org.craftercms.studio.api.v2.utils.GitRepositoryHelper)

Example 2 with GitRepositories

use of org.craftercms.studio.api.v1.constant.GitRepositories in project studio by craftercms.

the class GitContentRepository method cleanup.

protected void cleanup(String siteId, GitRepositories repository) {
    try {
        GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration, securityService, userServiceInternal, encryptor, generalLockService, retryingRepositoryOperationFacade);
        Repository sandbox = helper.getRepository(siteId, repository);
        try (Git git = new Git(sandbox)) {
            GarbageCollectCommand garbageCollectCommand = git.gc();
            retryingRepositoryOperationFacade.call(garbageCollectCommand);
        }
    } catch (Exception e) {
        logger.warn("Error cleaning up repository for site " + siteId, e);
    }
}
Also used : RemoteRepository(org.craftercms.studio.api.v2.dal.RemoteRepository) Repository(org.eclipse.jgit.lib.Repository) ContentRepository(org.craftercms.studio.api.v1.repository.ContentRepository) GarbageCollectCommand(org.eclipse.jgit.api.GarbageCollectCommand) Git(org.eclipse.jgit.api.Git) GitRepositoryHelper(org.craftercms.studio.api.v2.utils.GitRepositoryHelper) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) JSchException(com.jcraft.jsch.JSchException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) RefNotFoundException(org.eclipse.jgit.api.errors.RefNotFoundException) RemoteRepositoryNotFoundException(org.craftercms.studio.api.v1.exception.repository.RemoteRepositoryNotFoundException) URISyntaxException(java.net.URISyntaxException) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) InvalidRemoteUrlException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException) ContentNotFoundException(org.craftercms.studio.api.v1.exception.ContentNotFoundException) RemoteAlreadyExistsException(org.craftercms.studio.api.v1.exception.repository.RemoteAlreadyExistsException) DeploymentException(org.craftercms.studio.api.v1.service.deployment.DeploymentException) CryptoException(org.craftercms.commons.crypto.CryptoException) TransportException(org.eclipse.jgit.api.errors.TransportException) RemoteRepositoryNotBareException(org.craftercms.studio.api.v1.exception.repository.RemoteRepositoryNotBareException) InvalidRemoteException(org.eclipse.jgit.api.errors.InvalidRemoteException) JGitInternalException(org.eclipse.jgit.api.errors.JGitInternalException) InvalidRemoteRepositoryCredentialsException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryCredentialsException) InvalidRemoteRepositoryException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryException)

Aggregations

ContentRepository (org.craftercms.studio.api.v1.repository.ContentRepository)2 RemoteRepository (org.craftercms.studio.api.v2.dal.RemoteRepository)2 GitRepositoryHelper (org.craftercms.studio.api.v2.utils.GitRepositoryHelper)2 Repository (org.eclipse.jgit.lib.Repository)2 JSchException (com.jcraft.jsch.JSchException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 CryptoException (org.craftercms.commons.crypto.CryptoException)1 ContentNotFoundException (org.craftercms.studio.api.v1.exception.ContentNotFoundException)1 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)1 InvalidRemoteRepositoryCredentialsException (org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryCredentialsException)1 InvalidRemoteRepositoryException (org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryException)1 InvalidRemoteUrlException (org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException)1 RemoteAlreadyExistsException (org.craftercms.studio.api.v1.exception.repository.RemoteAlreadyExistsException)1 RemoteRepositoryNotBareException (org.craftercms.studio.api.v1.exception.repository.RemoteRepositoryNotBareException)1 RemoteRepositoryNotFoundException (org.craftercms.studio.api.v1.exception.repository.RemoteRepositoryNotFoundException)1 UserNotFoundException (org.craftercms.studio.api.v1.exception.security.UserNotFoundException)1 DeploymentException (org.craftercms.studio.api.v1.service.deployment.DeploymentException)1 GarbageCollectCommand (org.eclipse.jgit.api.GarbageCollectCommand)1