Search in sources :

Example 1 with PUBLISHED

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

the class GitContentRepository method publish.

@RetryingOperation
@Override
public void publish(String site, String sandboxBranch, List<DeploymentItemTO> deploymentItems, String environment, String author, String comment) throws DeploymentException {
    if (CollectionUtils.isEmpty(deploymentItems)) {
        return;
    }
    String commitId = EMPTY;
    String gitLockKey = SITE_PUBLISHED_REPOSITORY_GIT_LOCK.replaceAll(PATTERN_SITE, site);
    generalLockService.lock(gitLockKey);
    try {
        GitRepositoryHelper helper = GitRepositoryHelper.getHelper(studioConfiguration, securityService, userServiceInternal, encryptor, generalLockService, retryingRepositoryOperationFacade);
        Repository repo = helper.getRepository(site, PUBLISHED);
        boolean repoCreated = false;
        if (Objects.isNull(repo)) {
            helper.createPublishedRepository(site, sandboxBranch);
            repo = helper.getRepository(site, PUBLISHED);
            repoCreated = Objects.nonNull(repo);
        }
        String path = EMPTY;
        String sandboxBranchName = sandboxBranch;
        if (StringUtils.isEmpty(sandboxBranchName)) {
            sandboxBranchName = studioConfiguration.getProperty(REPO_SANDBOX_BRANCH);
        }
        synchronized (repo) {
            try (Git git = new Git(repo)) {
                String inProgressBranchName = environment + IN_PROGRESS_BRANCH_NAME_SUFFIX;
                // fetch "origin/master"
                logger.debug("Fetch from sandbox for site " + site);
                FetchCommand fetchCommand = git.fetch();
                retryingRepositoryOperationFacade.call(fetchCommand);
                // checkout master and pull from sandbox
                logger.debug("Checkout published/master branch for site " + site);
                try {
                    // First delete it in case it already exists (ignored if does not exist)
                    String currentBranch = repo.getBranch();
                    if (currentBranch.endsWith(IN_PROGRESS_BRANCH_NAME_SUFFIX)) {
                        ResetCommand resetCommand = git.reset().setMode(HARD);
                        retryingRepositoryOperationFacade.call(resetCommand);
                    }
                    Ref ref = repo.exactRef(R_HEADS + sandboxBranchName);
                    boolean createBranch = (ref == null);
                    CheckoutCommand checkoutCommand = git.checkout().setName(sandboxBranchName).setCreateBranch(createBranch);
                    retryingRepositoryOperationFacade.call(checkoutCommand);
                    logger.debug("Delete in-progress branch, in case it was not cleaned up for site " + site);
                    DeleteBranchCommand deleteBranchCommand = git.branchDelete().setBranchNames(inProgressBranchName).setForce(true);
                    retryingRepositoryOperationFacade.call(deleteBranchCommand);
                    PullCommand pullCommand = git.pull().setRemote(DEFAULT_REMOTE_NAME).setRemoteBranchName(sandboxBranchName).setStrategy(THEIRS);
                    retryingRepositoryOperationFacade.call(pullCommand);
                } catch (RefNotFoundException e) {
                    logger.error("Failed to checkout published master and to pull content from sandbox for site " + site, e);
                    throw new DeploymentException("Failed to checkout published master and to pull content from " + "sandbox for site " + site);
                }
                // checkout environment branch
                logger.debug("Checkout environment branch " + environment + " for site " + site);
                try {
                    CheckoutCommand checkoutCommand = git.checkout().setName(environment);
                    retryingRepositoryOperationFacade.call(checkoutCommand);
                } catch (RefNotFoundException e) {
                    logger.info("Not able to find branch " + environment + " for site " + site + ". Creating new branch");
                    // create new environment branch
                    // it will start as empty orphan branch
                    CheckoutCommand checkoutCommand = git.checkout().setOrphan(true).setForceRefUpdate(true).setStartPoint(sandboxBranchName).setUpstreamMode(TRACK).setName(environment);
                    retryingRepositoryOperationFacade.call(checkoutCommand);
                    // remove any content to create empty branch
                    RmCommand rmcmd = git.rm();
                    File[] toDelete = repo.getWorkTree().listFiles();
                    for (File toDel : toDelete) {
                        if (!repo.getDirectory().equals(toDel) && !StringUtils.equals(toDel.getName(), DOT_GIT_IGNORE)) {
                            rmcmd.addFilepattern(toDel.getName());
                        }
                    }
                    retryingRepositoryOperationFacade.call(rmcmd);
                    CommitCommand commitCommand = git.commit().setMessage(helper.getCommitMessage(REPO_INITIAL_COMMIT_COMMIT_MESSAGE)).setAllowEmpty(true);
                    retryingRepositoryOperationFacade.call(commitCommand);
                }
                // Create in progress branch
                try {
                    // Create in progress branch
                    logger.debug("Create in-progress branch for site " + site);
                    CheckoutCommand checkoutCommand = git.checkout().setCreateBranch(true).setForceRefUpdate(true).setStartPoint(environment).setUpstreamMode(TRACK).setName(inProgressBranchName);
                    retryingRepositoryOperationFacade.call(checkoutCommand);
                } catch (GitAPIException e) {
                    // TODO: DB: Error ?
                    logger.error("Failed to create in-progress published branch for site " + site);
                }
                Set<String> deployedCommits = new HashSet<String>();
                Set<String> deployedPackages = new HashSet<String>();
                logger.debug("Checkout deployed files started.");
                AddCommand addCommand = git.add();
                for (DeploymentItemTO deploymentItem : deploymentItems) {
                    commitId = deploymentItem.getCommitId();
                    path = helper.getGitPath(deploymentItem.getPath());
                    if (Objects.isNull(commitId) || !commitIdExists(site, PUBLISHED, commitId)) {
                        if (contentExists(site, path)) {
                            if (Objects.isNull(commitId)) {
                                logger.warn("Commit ID is NULL for content " + path + ". Was the git repo reset at some point?");
                            } else {
                                logger.warn("Commit ID " + commitId + " does not exist for content " + path + ". Was the git repo reset at some point?");
                            }
                            logger.info("Publishing content from HEAD for " + path);
                            commitId = getRepoLastCommitId(site);
                        } else {
                            logger.warn("Skipping file " + path + " because commit id is null");
                            continue;
                        }
                    }
                    logger.debug("Checking out file " + path + " from commit id " + commitId + " for site " + site);
                    CheckoutCommand checkout = git.checkout();
                    checkout.setStartPoint(commitId).addPath(path);
                    retryingRepositoryOperationFacade.call(checkout);
                    if (deploymentItem.isMove()) {
                        if (!StringUtils.equals(deploymentItem.getPath(), deploymentItem.getOldPath())) {
                            String oldPath = helper.getGitPath(deploymentItem.getOldPath());
                            RmCommand rmCommand = git.rm().addFilepattern(oldPath).setCached(false);
                            retryingRepositoryOperationFacade.call(rmCommand);
                            cleanUpMoveFolders(git, oldPath);
                        }
                    }
                    if (deploymentItem.isDelete()) {
                        String deletePath = helper.getGitPath(deploymentItem.getPath());
                        boolean isPage = deletePath.endsWith(FILE_SEPARATOR + INDEX_FILE);
                        RmCommand rmCommand = git.rm().addFilepattern(deletePath).setCached(false);
                        retryingRepositoryOperationFacade.call(rmCommand);
                        Path parentToDelete = Paths.get(path).getParent();
                        deleteParentFolder(git, parentToDelete, isPage);
                    }
                    deployedCommits.add(commitId);
                    String packageId = deploymentItem.getPackageId();
                    if (StringUtils.isNotEmpty(packageId)) {
                        deployedPackages.add(deploymentItem.getPackageId());
                    }
                    addCommand.addFilepattern(path);
                    objectMetadataManager.updateLastPublishedDate(site, deploymentItem.getPath(), ZonedDateTime.now(UTC));
                }
                logger.debug("Checkout deployed files completed.");
                // commit all deployed files
                String commitMessage = studioConfiguration.getProperty(REPO_PUBLISHED_COMMIT_MESSAGE);
                logger.debug("Get Author Ident started.");
                User user = userServiceInternal.getUserByIdOrUsername(-1, author);
                PersonIdent authorIdent = helper.getAuthorIdent(user);
                logger.debug("Get Author Ident completed.");
                logger.debug("Git add all published items started.");
                retryingRepositoryOperationFacade.call(addCommand);
                logger.debug("Git add all published items completed.");
                commitMessage = commitMessage.replace("{username}", author);
                commitMessage = commitMessage.replace("{datetime}", ZonedDateTime.now(UTC).format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HHmmssSSSX")));
                commitMessage = commitMessage.replace("{source}", "UI");
                commitMessage = commitMessage.replace("{message}", comment);
                StringBuilder sb = new StringBuilder();
                for (String c : deployedCommits) {
                    sb.append(c).append(" ");
                }
                StringBuilder sbPackage = new StringBuilder();
                for (String p : deployedPackages) {
                    sbPackage.append(p).append(" ");
                }
                commitMessage = commitMessage.replace("{commit_id}", sb.toString().trim());
                commitMessage = commitMessage.replace("{package_id}", sbPackage.toString().trim());
                logger.debug("Git commit all published items started.");
                String prologue = studioConfiguration.getProperty(REPO_COMMIT_MESSAGE_PROLOGUE);
                String postscript = studioConfiguration.getProperty(REPO_COMMIT_MESSAGE_POSTSCRIPT);
                StringBuilder sbCommitMessage = new StringBuilder();
                if (StringUtils.isNotEmpty(prologue)) {
                    sbCommitMessage.append(prologue).append("\n\n");
                }
                sbCommitMessage.append(commitMessage);
                if (StringUtils.isNotEmpty(postscript)) {
                    sbCommitMessage.append("\n\n").append(postscript);
                }
                CommitCommand commitCommand = git.commit().setMessage(sbCommitMessage.toString()).setAuthor(authorIdent);
                RevCommit revCommit = retryingRepositoryOperationFacade.call(commitCommand);
                logger.debug("Git commit all published items completed.");
                int commitTime = revCommit.getCommitTime();
                // tag
                ZonedDateTime tagDate2 = Instant.ofEpochSecond(commitTime).atZone(UTC);
                ZonedDateTime publishDate = ZonedDateTime.now(UTC);
                String tagName2 = tagDate2.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HHmmssSSSX")) + "_published_on_" + publishDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HHmmssSSSX"));
                logger.debug("Get Author Ident started.");
                PersonIdent authorIdent2 = helper.getAuthorIdent(user);
                logger.debug("Get Author Ident completed.");
                logger.debug("Git tag started.");
                TagCommand tagCommand = git.tag().setTagger(authorIdent2).setName(tagName2).setMessage(commitMessage);
                retryingRepositoryOperationFacade.call(tagCommand);
                logger.debug("Git tag completed.");
                // checkout environment
                logger.debug("Checkout environment " + environment + " branch for site " + site);
                CheckoutCommand checkoutCommand = git.checkout().setName(environment);
                retryingRepositoryOperationFacade.call(checkoutCommand);
                Ref branchRef = repo.findRef(inProgressBranchName);
                // merge in-progress branch
                logger.debug("Merge in-progress branch into environment " + environment + " for site " + site);
                MergeCommand mergeCommand = git.merge().setCommit(true).include(branchRef);
                retryingRepositoryOperationFacade.call(mergeCommand);
                // clean up
                logger.debug("Delete in-progress branch (clean up) for site " + site);
                DeleteBranchCommand deleteBranchCommand = git.branchDelete().setBranchNames(inProgressBranchName).setForce(true);
                retryingRepositoryOperationFacade.call(deleteBranchCommand);
                git.close();
                if (repoCreated) {
                    siteService.setPublishedRepoCreated(site);
                }
            }
        }
    } catch (Exception e) {
        logger.error("Error when publishing site " + site + " to environment " + environment, e);
        throw new DeploymentException("Error when publishing site " + site + " to environment " + environment + " [commit ID = " + commitId + "]");
    } finally {
        generalLockService.unlock(gitLockKey);
    }
}
Also used : CheckoutCommand(org.eclipse.jgit.api.CheckoutCommand) User(org.craftercms.studio.api.v2.dal.User) MergeCommand(org.eclipse.jgit.api.MergeCommand) TagCommand(org.eclipse.jgit.api.TagCommand) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) RefNotFoundException(org.eclipse.jgit.api.errors.RefNotFoundException) ZonedDateTime(java.time.ZonedDateTime) ResetCommand(org.eclipse.jgit.api.ResetCommand) RmCommand(org.eclipse.jgit.api.RmCommand) CommitCommand(org.eclipse.jgit.api.CommitCommand) GitRepositoryHelper(org.craftercms.studio.api.v2.utils.GitRepositoryHelper) HashSet(java.util.HashSet) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Path(java.nio.file.Path) DeleteBranchCommand(org.eclipse.jgit.api.DeleteBranchCommand) PullCommand(org.eclipse.jgit.api.PullCommand) DeploymentItemTO(org.craftercms.studio.api.v1.to.DeploymentItemTO) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) IOException(java.io.IOException) RefNotFoundException(org.eclipse.jgit.api.errors.RefNotFoundException) RemoteRepositoryNotFoundException(org.craftercms.studio.api.v1.exception.repository.RemoteRepositoryNotFoundException) UserNotFoundException(org.craftercms.studio.api.v1.exception.security.UserNotFoundException) DeploymentException(org.craftercms.studio.api.v1.service.deployment.DeploymentException) SiteNotFoundException(org.craftercms.studio.api.v1.exception.SiteNotFoundException) CryptoException(org.craftercms.commons.crypto.CryptoException) DuplicateKeyException(org.springframework.dao.DuplicateKeyException) InvalidRemoteRepositoryCredentialsException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryCredentialsException) InvalidRemoteRepositoryException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteRepositoryException) RemoteRepository(org.craftercms.studio.api.v2.dal.RemoteRepository) Repository(org.eclipse.jgit.lib.Repository) ContentRepository(org.craftercms.studio.api.v2.repository.ContentRepository) Ref(org.eclipse.jgit.lib.Ref) Git(org.eclipse.jgit.api.Git) FetchCommand(org.eclipse.jgit.api.FetchCommand) PersonIdent(org.eclipse.jgit.lib.PersonIdent) DeploymentException(org.craftercms.studio.api.v1.service.deployment.DeploymentException) File(java.io.File) AddCommand(org.eclipse.jgit.api.AddCommand) RetryingOperation(org.craftercms.studio.api.v2.annotation.RetryingOperation)

Example 2 with PUBLISHED

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

the class StudioClusterPublishedRepoSyncTask method updateContent.

protected void updateContent(long sId, String siteId, List<ClusterMember> clusterNodes, List<ClusterSiteRecord> clusterSiteRecords) throws IOException, CryptoException, ServiceLayerException {
    logger.debug("Update published repo for site " + siteId);
    Path siteSandboxPath = buildRepoPath(siteId).resolve(GIT_ROOT);
    FileRepositoryBuilder builder = new FileRepositoryBuilder();
    Repository repo = builder.setGitDir(siteSandboxPath.toFile()).readEnvironment().findGitDir().build();
    String gitLockKey = SITE_PUBLISHED_REPOSITORY_GIT_LOCK.replaceAll(PATTERN_SITE, siteId);
    logger.debug("Git Lock Key: " + gitLockKey);
    try (Git git = new Git(repo)) {
        Set<String> environments = getAllPublishingEnvironments(siteId);
        logger.debug("Update published repo from all active cluster members");
        if (generalLockService.tryLock(gitLockKey)) {
            try {
                for (ClusterMember remoteNode : clusterNodes) {
                    ClusterSiteRecord csr = clusterDao.getClusterSiteRecord(remoteNode.getId(), sId);
                    if (Objects.nonNull(csr) && csr.getPublishedRepoCreated() > 0) {
                        try {
                            logger.debug("Fetch from cluster member " + remoteNode.getLocalAddress());
                            final Path tempKey = Files.createTempFile(UUID.randomUUID().toString(), ".tmp");
                            FetchCommand fetch = git.fetch().setRemote(remoteNode.getGitRemoteName());
                            fetch = studioClusterUtils.configureAuthenticationForCommand(remoteNode, fetch, tempKey);
                            fetch.call();
                            Files.delete(tempKey);
                        } catch (GitAPIException e) {
                            logger.error("Error while fetching published repo for site " + siteId + " from remote " + remoteNode.getGitRemoteName());
                            logger.error(e.getMessage());
                        }
                    }
                }
                for (String branch : environments) {
                    for (ClusterMember remoteNode : clusterNodes) {
                        ClusterSiteRecord csr = clusterDao.getClusterSiteRecord(remoteNode.getId(), sId);
                        if (Objects.nonNull(csr) && csr.getPublishedRepoCreated() > 0) {
                            try {
                                updatePublishedBranch(siteId, git, remoteNode, branch);
                            } catch (GitAPIException e) {
                                logger.error("Error while updating published repo for site " + siteId + " from remote " + remoteNode.getGitRemoteName() + " environment " + branch);
                                logger.error(e.getMessage());
                            }
                        }
                    }
                }
            } finally {
                generalLockService.unlock(gitLockKey);
            }
        } else {
            logger.debug("Failed to get lock " + gitLockKey);
        }
    }
}
Also used : Path(java.nio.file.Path) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) ContentRepository(org.craftercms.studio.api.v1.repository.ContentRepository) Repository(org.eclipse.jgit.lib.Repository) ClusterMember(org.craftercms.studio.api.v2.dal.ClusterMember) Git(org.eclipse.jgit.api.Git) FetchCommand(org.eclipse.jgit.api.FetchCommand) ClusterSiteRecord(org.craftercms.studio.api.v2.dal.ClusterSiteRecord) FileRepositoryBuilder(org.eclipse.jgit.storage.file.FileRepositoryBuilder)

Example 3 with PUBLISHED

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

the class StudioClusterPublishedRepoSyncTask method updatePublishedBranch.

private void updatePublishedBranch(String siteId, Git git, ClusterMember remoteNode, String branch) throws CryptoException, GitAPIException, IOException, ServiceLayerException {
    logger.debug("Update published environment " + branch + " from " + remoteNode.getLocalAddress() + " for site " + siteId);
    final Path tempKey = Files.createTempFile(UUID.randomUUID().toString(), ".tmp");
    Repository repo = git.getRepository();
    Ref ref = repo.exactRef(Constants.R_HEADS + branch);
    boolean createBranch = (ref == null);
    logger.debug("Checkout " + branch);
    CheckoutCommand checkoutCommand = git.checkout().setName(branch).setCreateBranch(createBranch);
    if (createBranch) {
        checkoutCommand.setStartPoint(remoteNode.getGitRemoteName() + "/" + branch);
    }
    checkoutCommand.call();
    PullCommand pullCommand = git.pull();
    pullCommand.setRemote(remoteNode.getGitRemoteName());
    pullCommand.setRemoteBranchName(branch);
    pullCommand = studioClusterUtils.configureAuthenticationForCommand(remoteNode, pullCommand, tempKey);
    pullCommand.call();
    Files.delete(tempKey);
}
Also used : Path(java.nio.file.Path) ContentRepository(org.craftercms.studio.api.v1.repository.ContentRepository) Repository(org.eclipse.jgit.lib.Repository) Ref(org.eclipse.jgit.lib.Ref) CheckoutCommand(org.eclipse.jgit.api.CheckoutCommand) PullCommand(org.eclipse.jgit.api.PullCommand)

Example 4 with PUBLISHED

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

the class StudioClusterPublishedRepoSyncTask method checkIfSiteRepoExists.

protected boolean checkIfSiteRepoExists(String siteId) {
    boolean toRet = false;
    String firstCommitId = contentRepository.getRepoFirstCommitId(siteId);
    if (!StringUtils.isEmpty(firstCommitId)) {
        Repository repo = null;
        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        try {
            repo = builder.setMustExist(true).setGitDir(buildRepoPath(siteId).resolve(GIT_ROOT).toFile()).readEnvironment().findGitDir().build();
        } catch (IOException e) {
            logger.info("Failed to open PUBLISHED repo for site " + siteId);
        }
        toRet = Objects.nonNull(repo) && repo.getObjectDatabase().exists();
    }
    return toRet;
}
Also used : ContentRepository(org.craftercms.studio.api.v1.repository.ContentRepository) Repository(org.eclipse.jgit.lib.Repository) IOException(java.io.IOException) FileRepositoryBuilder(org.eclipse.jgit.storage.file.FileRepositoryBuilder)

Example 5 with PUBLISHED

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

the class StudioClusterPublishedRepoSyncTask method executeInternal.

@Override
protected void executeInternal(String siteId) {
    // Log start time
    long startTime = System.currentTimeMillis();
    logger.debug("Worker starts syncing cluster node published for site " + siteId);
    try {
        HierarchicalConfiguration<ImmutableNode> registrationData = studioClusterUtils.getClusterConfiguration();
        if (registrationData != null && !registrationData.isEmpty()) {
            String localAddress = studioClusterUtils.getClusterNodeLocalAddress();
            ClusterMember localNode = clusterDao.getMemberByLocalAddress(localAddress);
            List<ClusterMember> clusterNodes = studioClusterUtils.getClusterNodes(localAddress);
            SiteFeed siteFeed = siteService.getSite(siteId);
            List<ClusterSiteRecord> clusterSiteRecords = clusterDao.getSiteStateAcrossCluster(siteId);
            Optional<ClusterSiteRecord> localNodeRecord = clusterSiteRecords.stream().filter(x -> x.getClusterNodeId() == localNode.getId() && StringUtils.equals(x.getState(), STATE_CREATED)).findFirst();
            if (!localNodeRecord.isPresent()) {
                return;
            }
            long nodesCreated = clusterSiteRecords.stream().filter(x -> StringUtils.equals(x.getState(), STATE_CREATED)).count();
            if (nodesCreated < 1) {
                return;
            }
            // Check if site exists
            logger.debug("Check if site " + siteId + " exists in local repository");
            boolean success = true;
            int publishedReposCreated = clusterSiteRecords.stream().mapToInt(ClusterSiteRecord::getPublishedRepoCreated).sum();
            if (publishedReposCreated > 0 || siteFeed.getPublishedRepoCreated() > 0) {
                boolean siteCheck = checkIfSiteRepoExists(siteId);
                if (!siteCheck) {
                    // Site doesn't exist locally, create it
                    success = createSite(localNode.getId(), siteFeed.getId(), siteId, siteFeed.getSandboxBranch());
                } else {
                    clusterDao.setPublishedRepoCreated(localNode.getId(), siteFeed.getId());
                }
            } else {
                success = false;
            }
            if (success) {
                try {
                    // Add the remote repositories to the local repository to sync from if not added already
                    logger.debug("Add remotes for site " + siteId);
                    addRemotes(siteId, clusterNodes);
                } catch (InvalidRemoteUrlException | ServiceLayerException | CryptoException e) {
                    logger.error("Error while adding remotes on cluster node for site " + siteId);
                }
                try {
                    // Sync with remote and update the local cache with the last commit ID to speed things up
                    logger.debug("Update content for site " + siteId);
                    updateContent(siteFeed.getId(), siteId, clusterNodes, clusterSiteRecords);
                } catch (IOException | CryptoException | ServiceLayerException e) {
                    logger.error("Error while updating content for site " + siteId + " on cluster node.", e);
                }
            }
        }
    } catch (SiteNotFoundException e) {
        logger.error("Error while executing Cluster Node Sync Published for site " + siteId, e);
    }
    // Compute execution duration and log it
    long duration = System.currentTimeMillis() - startTime;
    logger.debug("Worker finished syncing cluster node for site " + siteId);
    logger.debug("Worker performed cluster node sync for site " + siteId + " in " + duration + "ms");
    logger.debug("Finished Cluster Node Sync task for site " + siteId);
}
Also used : RetryingRepositoryOperationFacade(org.craftercms.studio.api.v2.repository.RetryingRepositoryOperationFacade) PullCommand(org.eclipse.jgit.api.PullCommand) PUBLISHED_PATH(org.craftercms.studio.api.v2.utils.StudioConfiguration.PUBLISHED_PATH) UserServiceInternal(org.craftercms.studio.api.v2.service.security.internal.UserServiceInternal) TextEncryptor(org.craftercms.commons.crypto.TextEncryptor) URISyntaxException(java.net.URISyntaxException) StringUtils(org.apache.commons.lang3.StringUtils) InvalidRemoteUrlException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException) Config(org.eclipse.jgit.lib.Config) SITE_PUBLISHED_REPOSITORY_GIT_LOCK(org.craftercms.studio.api.v1.constant.StudioConstants.SITE_PUBLISHED_REPOSITORY_GIT_LOCK) ClusterSiteRecord(org.craftercms.studio.api.v2.dal.ClusterSiteRecord) Map(java.util.Map) URIish(org.eclipse.jgit.transport.URIish) ClusterDAO(org.craftercms.studio.api.v2.dal.ClusterDAO) RemoteAddCommand(org.eclipse.jgit.api.RemoteAddCommand) Path(java.nio.file.Path) STATE_CREATED(org.craftercms.studio.api.v1.dal.SiteFeed.STATE_CREATED) FileRepositoryBuilder(org.eclipse.jgit.storage.file.FileRepositoryBuilder) HierarchicalConfiguration(org.apache.commons.configuration2.HierarchicalConfiguration) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) SiteFeed(org.craftercms.studio.api.v1.dal.SiteFeed) Set(java.util.Set) SiteService(org.craftercms.studio.api.v1.service.site.SiteService) Constants(org.eclipse.jgit.lib.Constants) UUID(java.util.UUID) CONFIG_PARAMETER_URL(org.craftercms.studio.impl.v1.repository.git.GitContentRepositoryConstants.CONFIG_PARAMETER_URL) Objects(java.util.Objects) CONFIG_SECTION_REMOTE(org.craftercms.studio.impl.v1.repository.git.GitContentRepositoryConstants.CONFIG_SECTION_REMOTE) List(java.util.List) ServicesConfig(org.craftercms.studio.api.v1.service.configuration.ServicesConfig) StudioConfiguration(org.craftercms.studio.api.v2.utils.StudioConfiguration) PATTERN_SITE(org.craftercms.studio.api.v1.constant.StudioConstants.PATTERN_SITE) Ref(org.eclipse.jgit.lib.Ref) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) Optional(java.util.Optional) CLUSTER_NODE_REMOTE_NAME_PREFIX(org.craftercms.studio.impl.v1.repository.git.GitContentRepositoryConstants.CLUSTER_NODE_REMOTE_NAME_PREFIX) ClusterMember(org.craftercms.studio.api.v2.dal.ClusterMember) Logger(org.craftercms.studio.api.v1.log.Logger) HashMap(java.util.HashMap) FetchCommand(org.eclipse.jgit.api.FetchCommand) RemoteSetUrlCommand(org.eclipse.jgit.api.RemoteSetUrlCommand) HashSet(java.util.HashSet) ImmutableNode(org.apache.commons.configuration2.tree.ImmutableNode) LoggerFactory(org.craftercms.studio.api.v1.log.LoggerFactory) Files(java.nio.file.Files) StudioClusterUtils(org.craftercms.studio.impl.v2.service.cluster.StudioClusterUtils) IOException(java.io.IOException) SiteNotFoundException(org.craftercms.studio.api.v1.exception.SiteNotFoundException) ContentRepository(org.craftercms.studio.api.v1.repository.ContentRepository) CryptoException(org.craftercms.commons.crypto.CryptoException) CheckoutCommand(org.eclipse.jgit.api.CheckoutCommand) GIT_ROOT(org.craftercms.studio.impl.v1.repository.git.GitContentRepositoryConstants.GIT_ROOT) SecurityService(org.craftercms.studio.api.v1.service.security.SecurityService) GitRepositoryHelper(org.craftercms.studio.api.v2.utils.GitRepositoryHelper) Paths(java.nio.file.Paths) GeneralLockService(org.craftercms.studio.api.v1.service.GeneralLockService) Git(org.eclipse.jgit.api.Git) Repository(org.eclipse.jgit.lib.Repository) PUBLISHED(org.craftercms.studio.api.v1.constant.GitRepositories.PUBLISHED) ImmutableNode(org.apache.commons.configuration2.tree.ImmutableNode) ServiceLayerException(org.craftercms.studio.api.v1.exception.ServiceLayerException) IOException(java.io.IOException) ClusterSiteRecord(org.craftercms.studio.api.v2.dal.ClusterSiteRecord) InvalidRemoteUrlException(org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException) ClusterMember(org.craftercms.studio.api.v2.dal.ClusterMember) SiteFeed(org.craftercms.studio.api.v1.dal.SiteFeed) CryptoException(org.craftercms.commons.crypto.CryptoException) SiteNotFoundException(org.craftercms.studio.api.v1.exception.SiteNotFoundException)

Aggregations

Repository (org.eclipse.jgit.lib.Repository)14 ContentRepository (org.craftercms.studio.api.v1.repository.ContentRepository)11 IOException (java.io.IOException)10 CryptoException (org.craftercms.commons.crypto.CryptoException)10 GitRepositoryHelper (org.craftercms.studio.api.v2.utils.GitRepositoryHelper)10 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)9 RemoteRepository (org.craftercms.studio.api.v2.dal.RemoteRepository)9 Git (org.eclipse.jgit.api.Git)9 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)9 Path (java.nio.file.Path)7 CheckoutCommand (org.eclipse.jgit.api.CheckoutCommand)5 InvalidRemoteUrlException (org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException)4 UserNotFoundException (org.craftercms.studio.api.v1.exception.security.UserNotFoundException)4 PullCommand (org.eclipse.jgit.api.PullCommand)4 Ref (org.eclipse.jgit.lib.Ref)4 File (java.io.File)3 URISyntaxException (java.net.URISyntaxException)3 SiteNotFoundException (org.craftercms.studio.api.v1.exception.SiteNotFoundException)3 DeploymentException (org.craftercms.studio.api.v1.service.deployment.DeploymentException)3 ContentItemTO (org.craftercms.studio.api.v1.to.ContentItemTO)3