Search in sources :

Example 1 with GeneralLockService

use of org.craftercms.studio.api.v1.service.GeneralLockService in project studio by craftercms.

the class RepositoryManagementServiceInternalImpl method listRemotes.

@Override
public List<RemoteRepositoryInfo> listRemotes(String siteId, String sandboxBranch) throws ServiceLayerException, CryptoException {
    List<RemoteRepositoryInfo> res = new ArrayList<RemoteRepositoryInfo>();
    Map<String, String> unreachableRemotes = new HashMap<String, String>();
    GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration, securityService, userServiceInternal, encryptor, generalLockService, retryingRepositoryOperationFacade);
    try (Repository repo = helper.getRepository(siteId, SANDBOX)) {
        try (Git git = new Git(repo)) {
            List<RemoteConfig> resultRemotes = git.remoteList().call();
            if (CollectionUtils.isNotEmpty(resultRemotes)) {
                for (RemoteConfig conf : resultRemotes) {
                    try {
                        fetchRemote(siteId, git, conf);
                    } catch (Exception e) {
                        logger.warn("Failed to fetch from remote repository " + conf.getName());
                        unreachableRemotes.put(conf.getName(), e.getMessage());
                    }
                }
                Map<String, List<String>> remoteBranches = getRemoteBranches(git);
                String sandboxBranchName = sandboxBranch;
                if (StringUtils.isEmpty(sandboxBranchName)) {
                    sandboxBranchName = studioConfiguration.getProperty(REPO_SANDBOX_BRANCH);
                }
                res = getRemoteRepositoryInfo(resultRemotes, remoteBranches, unreachableRemotes, sandboxBranchName);
            }
        } catch (GitAPIException e) {
            logger.error("Error getting remote repositories for site " + siteId, e);
        }
    }
    return res;
}
Also used : RemoteRepositoryInfo(org.craftercms.studio.api.v2.dal.RemoteRepositoryInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) IOException(java.io.IOException) RemoteNotRemovableException(org.craftercms.studio.api.v1.exception.repository.RemoteNotRemovableException) URISyntaxException(java.net.URISyntaxException) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) InvalidRemoteUrlException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException) RemoteAlreadyExistsException(org.craftercms.studio.api.v1.exception.repository.RemoteAlreadyExistsException) CryptoException(org.craftercms.commons.crypto.CryptoException) InvalidRemoteException(org.eclipse.jgit.api.errors.InvalidRemoteException) JGitInternalException(org.eclipse.jgit.api.errors.JGitInternalException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) RemoteRepository(org.craftercms.studio.api.v2.dal.RemoteRepository) Repository(org.eclipse.jgit.lib.Repository) ContentRepository(org.craftercms.studio.api.v1.repository.ContentRepository) Git(org.eclipse.jgit.api.Git) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) GitRepositoryHelper(org.craftercms.studio.api.v2.utils.GitRepositoryHelper) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig)

Example 2 with GeneralLockService

use of org.craftercms.studio.api.v1.service.GeneralLockService in project studio by craftercms.

the class RepositoryManagementServiceInternalImpl method removeRemote.

@RetryingOperation
@Override
public boolean removeRemote(String siteId, String remoteName) throws CryptoException, RemoteNotRemovableException {
    if (!isRemovableRemote(siteId, remoteName)) {
        throw new RemoteNotRemovableException("Remote repository " + remoteName + " is not removable");
    }
    logger.debug("Remove remote " + remoteName + " from the sandbox repo for the site " + siteId);
    GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration, securityService, userServiceInternal, encryptor, generalLockService, retryingRepositoryOperationFacade);
    Repository repo = helper.getRepository(siteId, SANDBOX);
    String gitLockKey = SITE_SANDBOX_REPOSITORY_GIT_LOCK.replaceAll(PATTERN_SITE, siteId);
    generalLockService.lock(gitLockKey);
    try (Git git = new Git(repo)) {
        RemoteRemoveCommand remoteRemoveCommand = git.remoteRemove();
        remoteRemoveCommand.setRemoteName(remoteName);
        retryingRepositoryOperationFacade.call(remoteRemoveCommand);
        List<Ref> resultRemoteBranches = git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call();
        List<String> branchesToDelete = new ArrayList<String>();
        for (Ref remoteBranchRef : resultRemoteBranches) {
            if (remoteBranchRef.getName().startsWith(Constants.R_REMOTES + remoteName)) {
                branchesToDelete.add(remoteBranchRef.getName());
            }
        }
        if (CollectionUtils.isNotEmpty(branchesToDelete)) {
            DeleteBranchCommand delBranch = git.branchDelete();
            String[] array = new String[branchesToDelete.size()];
            delBranch.setBranchNames(branchesToDelete.toArray(array));
            delBranch.setForce(true);
            retryingRepositoryOperationFacade.call(delBranch);
        }
    } catch (GitAPIException e) {
        logger.error("Failed to remove remote " + remoteName + " for site " + siteId, e);
        return false;
    } finally {
        generalLockService.unlock(gitLockKey);
    }
    logger.debug("Remove remote record from database for remote " + remoteName + " and site " + siteId);
    Map<String, String> params = new HashMap<String, String>();
    params.put("siteId", siteId);
    params.put("remoteName", remoteName);
    remoteRepositoryDao.deleteRemoteRepository(params);
    return true;
}
Also used : RemoteNotRemovableException(org.craftercms.studio.api.v1.exception.repository.RemoteNotRemovableException) DeleteBranchCommand(org.eclipse.jgit.api.DeleteBranchCommand) HashMap(java.util.HashMap) RemoteRemoveCommand(org.eclipse.jgit.api.RemoteRemoveCommand) ArrayList(java.util.ArrayList) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) RemoteRepository(org.craftercms.studio.api.v2.dal.RemoteRepository) Repository(org.eclipse.jgit.lib.Repository) ContentRepository(org.craftercms.studio.api.v1.repository.ContentRepository) Ref(org.eclipse.jgit.lib.Ref) Git(org.eclipse.jgit.api.Git) GitRepositoryHelper(org.craftercms.studio.api.v2.utils.GitRepositoryHelper) RetryingOperation(org.craftercms.studio.api.v2.annotation.RetryingOperation)

Example 3 with GeneralLockService

use of org.craftercms.studio.api.v1.service.GeneralLockService in project studio by craftercms.

the class RepositoryManagementServiceInternalImpl method pullFromRemote.

@Override
public boolean pullFromRemote(String siteId, String remoteName, String remoteBranch, String mergeStrategy) throws InvalidRemoteUrlException, ServiceLayerException, CryptoException {
    logger.debug("Get remote data from database for remote " + remoteName + " and site " + siteId);
    String gitLockKey = SITE_SANDBOX_REPOSITORY_GIT_LOCK.replaceAll(PATTERN_SITE, siteId);
    RemoteRepository remoteRepository = getRemoteRepository(siteId, remoteName);
    logger.debug("Prepare pull command");
    GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration, securityService, userServiceInternal, encryptor, generalLockService, retryingRepositoryOperationFacade);
    Repository repo = helper.getRepository(siteId, SANDBOX);
    generalLockService.lock(gitLockKey);
    try (Git git = new Git(repo)) {
        PullResult pullResult = null;
        PullCommand pullCommand = git.pull();
        logger.debug("Set remote " + remoteName);
        pullCommand.setRemote(remoteRepository.getRemoteName());
        logger.debug("Set branch to be " + remoteBranch);
        pullCommand.setRemoteBranchName(remoteBranch);
        Path tempKey = Files.createTempFile(UUID.randomUUID().toString(), ".tmp");
        pullCommand = helper.setAuthenticationForCommand(pullCommand, remoteRepository.getAuthenticationType(), remoteRepository.getRemoteUsername(), remoteRepository.getRemotePassword(), remoteRepository.getRemoteToken(), remoteRepository.getRemotePrivateKey(), tempKey, true);
        switch(mergeStrategy) {
            case THEIRS:
                pullCommand.setStrategy(MergeStrategy.THEIRS);
                break;
            case OURS:
                pullCommand.setStrategy(MergeStrategy.OURS);
                break;
            default:
                break;
        }
        pullCommand.setFastForward(MergeCommand.FastForwardMode.NO_FF);
        pullResult = retryingRepositoryOperationFacade.call(pullCommand);
        String pullResultMessage = pullResult.toString();
        if (StringUtils.isNotEmpty(pullResultMessage)) {
            logger.info(pullResultMessage);
        }
        Files.delete(tempKey);
        if (!pullResult.isSuccessful() && conflictNotificationEnabled()) {
            List<String> conflictFiles = new ArrayList<String>();
            if (pullResult.getMergeResult() != null) {
                pullResult.getMergeResult().getConflicts().forEach((m, v) -> {
                    conflictFiles.add(m);
                });
            }
            notificationService.notifyRepositoryMergeConflict(siteId, conflictFiles, Locale.ENGLISH);
        }
        if (pullResult.isSuccessful()) {
            String lastCommitId = contentRepository.getRepoLastCommitId(siteId);
            contentRepositoryV2.upsertGitLogList(siteId, Arrays.asList(lastCommitId), false, false);
            List<String> newMergedCommits = extractCommitIdsFromPullResult(siteId, repo, pullResult);
            List<String> commitIds = new ArrayList<String>();
            if (Objects.nonNull(newMergedCommits) && newMergedCommits.size() > 0) {
                logger.debug("Really pulled commits:");
                int cnt = 0;
                for (int i = 0; i < newMergedCommits.size(); i++) {
                    String commitId = newMergedCommits.get(i);
                    logger.debug(commitId);
                    if (!StringUtils.equals(lastCommitId, commitId)) {
                        commitIds.add(commitId);
                        if (cnt++ >= batchSizeGitLog) {
                            contentRepositoryV2.upsertGitLogList(siteId, commitIds, true, true);
                            cnt = 0;
                            commitIds.clear();
                        }
                    }
                }
                if (Objects.nonNull(commitIds) && commitIds.size() > 0) {
                    contentRepositoryV2.upsertGitLogList(siteId, commitIds, true, true);
                }
            }
            siteService.updateLastCommitId(siteId, lastCommitId);
        }
        return pullResult != null && pullResult.isSuccessful();
    } catch (InvalidRemoteException e) {
        logger.error("Remote is invalid " + remoteName, e);
        throw new InvalidRemoteUrlException();
    } catch (GitAPIException e) {
        logger.error("Error while pulling from remote " + remoteName + " branch " + remoteBranch + " for site " + siteId, e);
        throw new ServiceLayerException("Error while pulling from remote " + remoteName + " branch " + remoteBranch + " for site " + siteId, e);
    } catch (CryptoException | IOException e) {
        throw new ServiceLayerException(e);
    } finally {
        generalLockService.unlock(gitLockKey);
    }
}
Also used : Path(java.nio.file.Path) PullCommand(org.eclipse.jgit.api.PullCommand) ArrayList(java.util.ArrayList) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) RemoteRepository(org.craftercms.studio.api.v2.dal.RemoteRepository) IOException(java.io.IOException) InvalidRemoteUrlException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException) PullResult(org.eclipse.jgit.api.PullResult) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) RemoteRepository(org.craftercms.studio.api.v2.dal.RemoteRepository) Repository(org.eclipse.jgit.lib.Repository) ContentRepository(org.craftercms.studio.api.v1.repository.ContentRepository) Git(org.eclipse.jgit.api.Git) InvalidRemoteException(org.eclipse.jgit.api.errors.InvalidRemoteException) GitRepositoryHelper(org.craftercms.studio.api.v2.utils.GitRepositoryHelper) CryptoException(org.craftercms.commons.crypto.CryptoException)

Example 4 with GeneralLockService

use of org.craftercms.studio.api.v1.service.GeneralLockService 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 5 with GeneralLockService

use of org.craftercms.studio.api.v1.service.GeneralLockService in project studio by craftercms.

the class GitContentRepository method deleteParentFolder.

private String deleteParentFolder(Git git, Path parentFolder, boolean wasPage) throws GitAPIException, IOException {
    String parent = parentFolder.toString();
    String toRet = parent;
    try {
        GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration, securityService, userServiceInternal, encryptor, generalLockService, retryingRepositoryOperationFacade);
        String folderToDelete = helper.getGitPath(parent);
        Path toDelete = Paths.get(git.getRepository().getDirectory().getParent(), parent);
        if (Files.exists(toDelete)) {
            List<String> dirs = Files.walk(toDelete).filter(x -> !x.equals(toDelete)).filter(Files::isDirectory).map(y -> y.getFileName().toString()).collect(Collectors.toList());
            List<String> files = Files.walk(toDelete, 1).filter(x -> !x.equals(toDelete)).filter(Files::isRegularFile).map(y -> y.getFileName().toString()).collect(Collectors.toList());
            if (wasPage || (CollectionUtils.isEmpty(dirs) && (CollectionUtils.isEmpty(files) || files.size() < 2 && files.get(0).equals(EMPTY_FILE)))) {
                if (CollectionUtils.isNotEmpty(dirs)) {
                    for (String child : dirs) {
                        Path childToDelete = Paths.get(folderToDelete, child);
                        deleteParentFolder(git, childToDelete, false);
                        RmCommand rmCommand = git.rm().addFilepattern(folderToDelete + FILE_SEPARATOR + child + FILE_SEPARATOR + "*").setCached(false);
                        retryingRepositoryOperationFacade.call(rmCommand);
                    }
                }
                if (CollectionUtils.isNotEmpty(files)) {
                    for (String child : files) {
                        RmCommand rmCommand = git.rm().addFilepattern(folderToDelete + FILE_SEPARATOR + child).setCached(false);
                        retryingRepositoryOperationFacade.call(rmCommand);
                    }
                }
            }
        }
    } catch (CryptoException e) {
        logger.error("Error deleting parent folder " + parentFolder.toString(), e);
    }
    return toRet;
}
Also used : Path(java.nio.file.Path) UserServiceInternal(org.craftercms.studio.api.v2.service.security.internal.UserServiceInternal) TextEncryptor(org.craftercms.commons.crypto.TextEncryptor) ZonedDateTime(java.time.ZonedDateTime) OBJ_TREE(org.eclipse.jgit.lib.Constants.OBJ_TREE) StringUtils(org.apache.commons.lang3.StringUtils) RevWalk(org.eclipse.jgit.revwalk.RevWalk) User(org.craftercms.studio.api.v2.dal.User) MOVE(org.craftercms.studio.api.v2.dal.RepoOperation.Action.MOVE) ResetCommand(org.eclipse.jgit.api.ResetCommand) Matcher(java.util.regex.Matcher) Map(java.util.Map) CommitTimeRevFilter(org.eclipse.jgit.revwalk.filter.CommitTimeRevFilter) ClusterDAO(org.craftercms.studio.api.v2.dal.ClusterDAO) Path(java.nio.file.Path) TagCommand(org.eclipse.jgit.api.TagCommand) INDEX_FILE(org.craftercms.studio.api.v1.constant.StudioConstants.INDEX_FILE) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) CommitCommand(org.eclipse.jgit.api.CommitCommand) Set(java.util.Set) HEAD(org.eclipse.jgit.lib.Constants.HEAD) SiteService(org.craftercms.studio.api.v1.service.site.SiteService) Constants(org.eclipse.jgit.lib.Constants) RevTree(org.eclipse.jgit.revwalk.RevTree) PersonIdent(org.eclipse.jgit.lib.PersonIdent) MASTER(org.eclipse.jgit.lib.Constants.MASTER) FILE_SEPARATOR(org.craftercms.studio.api.v1.constant.StudioConstants.FILE_SEPARATOR) PATTERN_SITE(org.craftercms.studio.api.v1.constant.StudioConstants.PATTERN_SITE) REPO_COMMIT_MESSAGE_POSTSCRIPT(org.craftercms.studio.api.v2.utils.StudioConfiguration.REPO_COMMIT_MESSAGE_POSTSCRIPT) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) RemoteRepositoryDAO(org.craftercms.studio.api.v2.dal.RemoteRepositoryDAO) HARD(org.eclipse.jgit.api.ResetCommand.ResetType.HARD) DeploymentItemTO(org.craftercms.studio.api.v1.to.DeploymentItemTO) SiteFeedMapper(org.craftercms.studio.api.v1.dal.SiteFeedMapper) RetryingOperationFacade(org.craftercms.studio.api.v2.dal.RetryingOperationFacade) RevCommit(org.eclipse.jgit.revwalk.RevCommit) ClusterMember(org.craftercms.studio.api.v2.dal.ClusterMember) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) EMPTY_FILE(org.craftercms.studio.impl.v1.repository.git.GitContentRepositoryConstants.EMPTY_FILE) MergeCommand(org.eclipse.jgit.api.MergeCommand) DmFilterWrapper(org.craftercms.studio.api.v1.util.filter.DmFilterWrapper) ImmutableNode(org.apache.commons.configuration2.tree.ImmutableNode) GitLogDAO(org.craftercms.studio.api.v2.dal.GitLogDAO) StudioUtils(org.craftercms.studio.impl.v2.utils.StudioUtils) IGNORE_FILES(org.craftercms.studio.impl.v1.repository.git.GitContentRepositoryConstants.IGNORE_FILES) RemoteRepository(org.craftercms.studio.api.v2.dal.RemoteRepository) MessageRevFilter(org.eclipse.jgit.revwalk.filter.MessageRevFilter) TreeWalk(org.eclipse.jgit.treewalk.TreeWalk) RevFilter(org.eclipse.jgit.revwalk.filter.RevFilter) Files(java.nio.file.Files) REPO_SYNC_DB_COMMIT_MESSAGE_NO_PROCESSING(org.craftercms.studio.api.v2.utils.StudioConfiguration.REPO_SYNC_DB_COMMIT_MESSAGE_NO_PROCESSING) ReverseListIterator(org.apache.commons.collections4.iterators.ReverseListIterator) IOException(java.io.IOException) CLUSTERING_NODE_REGISTRATION(org.craftercms.studio.api.v2.utils.StudioConfiguration.CLUSTERING_NODE_REGISTRATION) File(java.io.File) RefNotFoundException(org.eclipse.jgit.api.errors.RefNotFoundException) RetryingOperation(org.craftercms.studio.api.v2.annotation.RetryingOperation) R_HEADS(org.eclipse.jgit.lib.Constants.R_HEADS) SecurityService(org.craftercms.studio.api.v1.service.security.SecurityService) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) ObjectMetadataManager(org.craftercms.studio.api.v1.service.content.ObjectMetadataManager) RemoteRepositoryNotFoundException(org.craftercms.studio.api.v1.exception.repository.RemoteRepositoryNotFoundException) ObjectReader(org.eclipse.jgit.lib.ObjectReader) Repository(org.eclipse.jgit.lib.Repository) RingBuffer(org.craftercms.studio.impl.v2.utils.RingBuffer) PUBLISHED(org.craftercms.studio.api.v1.constant.GitRepositories.PUBLISHED) DELETE(org.craftercms.studio.api.v2.dal.RepoOperation.Action.DELETE) RetryingRepositoryOperationFacade(org.craftercms.studio.api.v2.repository.RetryingRepositoryOperationFacade) PullCommand(org.eclipse.jgit.api.PullCommand) PublishingHistoryItem(org.craftercms.studio.api.v2.dal.PublishingHistoryItem) RemoteRemoveCommand(org.eclipse.jgit.api.RemoteRemoveCommand) REPO_COMMIT_MESSAGE_PROLOGUE(org.craftercms.studio.api.v2.utils.StudioConfiguration.REPO_COMMIT_MESSAGE_PROLOGUE) DeploymentSyncHistory(org.craftercms.studio.api.v1.dal.DeploymentSyncHistory) AddCommand(org.eclipse.jgit.api.AddCommand) CREATE(org.craftercms.studio.api.v2.dal.RepoOperation.Action.CREATE) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) SITE_PUBLISHED_REPOSITORY_GIT_LOCK(org.craftercms.studio.api.v1.constant.StudioConstants.SITE_PUBLISHED_REPOSITORY_GIT_LOCK) RepoOperation(org.craftercms.studio.api.v2.dal.RepoOperation) REPO_PUBLISHED_COMMIT_MESSAGE(org.craftercms.studio.api.v2.utils.StudioConfiguration.REPO_PUBLISHED_COMMIT_MESSAGE) GLOBAL(org.craftercms.studio.api.v1.constant.GitRepositories.GLOBAL) TRACK(org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode.TRACK) ContentRepository(org.craftercms.studio.api.v2.repository.ContentRepository) HierarchicalConfiguration(org.apache.commons.configuration2.HierarchicalConfiguration) DeleteBranchCommand(org.eclipse.jgit.api.DeleteBranchCommand) COPY(org.craftercms.studio.api.v2.dal.RepoOperation.Action.COPY) REPO_SANDBOX_BRANCH(org.craftercms.studio.api.v2.utils.StudioConfiguration.REPO_SANDBOX_BRANCH) Instant(java.time.Instant) SITE_SANDBOX_REPOSITORY_GIT_LOCK(org.craftercms.studio.api.v1.constant.StudioConstants.SITE_SANDBOX_REPOSITORY_GIT_LOCK) Collectors(java.util.stream.Collectors) REVERSE(org.eclipse.jgit.revwalk.RevSort.REVERSE) Objects(java.util.Objects) List(java.util.List) StudioConfiguration(org.craftercms.studio.api.v2.utils.StudioConfiguration) IN_PROGRESS_BRANCH_NAME_SUFFIX(org.craftercms.studio.api.v1.constant.StudioConstants.IN_PROGRESS_BRANCH_NAME_SUFFIX) Ref(org.eclipse.jgit.lib.Ref) UTC(java.time.ZoneOffset.UTC) ListBranchCommand(org.eclipse.jgit.api.ListBranchCommand) Pattern(java.util.regex.Pattern) FilenameUtils(org.apache.commons.io.FilenameUtils) RmCommand(org.eclipse.jgit.api.RmCommand) UPDATE(org.craftercms.studio.api.v2.dal.RepoOperation.Action.UPDATE) THEIRS(org.eclipse.jgit.merge.MergeStrategy.THEIRS) CanonicalTreeParser(org.eclipse.jgit.treewalk.CanonicalTreeParser) GitLog(org.craftercms.studio.api.v2.dal.GitLog) Logger(org.craftercms.studio.api.v1.log.Logger) ArrayUtils(org.apache.commons.lang3.ArrayUtils) HashMap(java.util.HashMap) FetchCommand(org.eclipse.jgit.api.FetchCommand) HashSet(java.util.HashSet) REPO_INITIAL_COMMIT_COMMIT_MESSAGE(org.craftercms.studio.api.v2.utils.StudioConfiguration.REPO_INITIAL_COMMIT_COMMIT_MESSAGE) CLUSTER_MEMBER_LOCAL_ADDRESS(org.craftercms.studio.api.v1.constant.StudioConstants.CLUSTER_MEMBER_LOCAL_ADDRESS) AndRevFilter(org.eclipse.jgit.revwalk.filter.AndRevFilter) LoggerFactory(org.craftercms.studio.api.v1.log.LoggerFactory) EMPTY(org.apache.commons.lang3.StringUtils.EMPTY) AuthorRevFilter(org.eclipse.jgit.revwalk.filter.AuthorRevFilter) ObjectLoader(org.eclipse.jgit.lib.ObjectLoader) NotRevFilter(org.eclipse.jgit.revwalk.filter.NotRevFilter) Iterator(java.util.Iterator) DeploymentException(org.craftercms.studio.api.v1.service.deployment.DeploymentException) SiteNotFoundException(org.craftercms.studio.api.v1.exception.SiteNotFoundException) CryptoException(org.craftercms.commons.crypto.CryptoException) CheckoutCommand(org.eclipse.jgit.api.CheckoutCommand) ObjectId(org.eclipse.jgit.lib.ObjectId) DEFAULT_REMOTE_NAME(org.eclipse.jgit.lib.Constants.DEFAULT_REMOTE_NAME) DOT_GIT_IGNORE(org.eclipse.jgit.lib.Constants.DOT_GIT_IGNORE) DuplicateKeyException(org.springframework.dao.DuplicateKeyException) SANDBOX(org.craftercms.studio.api.v1.constant.GitRepositories.SANDBOX) DeploymentHistoryProvider(org.craftercms.studio.api.v2.service.deployment.DeploymentHistoryProvider) GitRepositoryHelper(org.craftercms.studio.api.v2.utils.GitRepositoryHelper) GeneralLockService(org.craftercms.studio.api.v1.service.GeneralLockService) DateTimeFormatter(java.time.format.DateTimeFormatter) InvalidRemoteRepositoryCredentialsException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryCredentialsException) Git(org.eclipse.jgit.api.Git) DiffEntry(org.eclipse.jgit.diff.DiffEntry) InvalidRemoteRepositoryException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryException) GitRepositories(org.craftercms.studio.api.v1.constant.GitRepositories) RmCommand(org.eclipse.jgit.api.RmCommand) GitRepositoryHelper(org.craftercms.studio.api.v2.utils.GitRepositoryHelper) Files(java.nio.file.Files) CryptoException(org.craftercms.commons.crypto.CryptoException)

Aggregations

GitRepositoryHelper (org.craftercms.studio.api.v2.utils.GitRepositoryHelper)49 Repository (org.eclipse.jgit.lib.Repository)48 RemoteRepository (org.craftercms.studio.api.v2.dal.RemoteRepository)47 ContentRepository (org.craftercms.studio.api.v1.repository.ContentRepository)42 CryptoException (org.craftercms.commons.crypto.CryptoException)39 IOException (java.io.IOException)38 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)35 Git (org.eclipse.jgit.api.Git)33 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)30 Path (java.nio.file.Path)17 UserNotFoundException (org.craftercms.studio.api.v1.exception.security.UserNotFoundException)17 ArrayList (java.util.ArrayList)14 RevTree (org.eclipse.jgit.revwalk.RevTree)13 InvalidRemoteUrlException (org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException)11 ObjectId (org.eclipse.jgit.lib.ObjectId)11 RevCommit (org.eclipse.jgit.revwalk.RevCommit)11 File (java.io.File)10 InvalidRemoteException (org.eclipse.jgit.api.errors.InvalidRemoteException)10 TreeWalk (org.eclipse.jgit.treewalk.TreeWalk)10 HashMap (java.util.HashMap)8