Search in sources :

Example 26 with ClusterMember

use of org.craftercms.studio.api.v2.dal.ClusterMember in project studio by craftercms.

the class SiteServiceImpl method setPublishedRepoCreated.

@Override
public void setPublishedRepoCreated(String siteId) {
    siteFeedMapper.setPublishedRepoCreated(siteId);
    try {
        ClusterMember clusterMember = clusterDao.getMemberByLocalAddress(studioClusterUtils.getClusterNodeLocalAddress());
        if (Objects.nonNull(clusterMember)) {
            SiteFeed siteFeed = getSite(siteId);
            clusterDao.setPublishedRepoCreated(clusterMember.getId(), siteFeed.getId());
        }
    } catch (SiteNotFoundException e) {
        logger.error("Site not found " + siteId);
    }
}
Also used : ClusterMember(org.craftercms.studio.api.v2.dal.ClusterMember) SiteFeed(org.craftercms.studio.api.v1.dal.SiteFeed) SiteNotFoundException(org.craftercms.studio.api.v1.exception.SiteNotFoundException)

Example 27 with ClusterMember

use of org.craftercms.studio.api.v2.dal.ClusterMember in project studio by craftercms.

the class DbEncryptionUpgradeOperation method upgradeClusterMembers.

protected void upgradeClusterMembers(NamedParameterJdbcTemplate jdbcTemplate) throws CryptoException {
    logger.debug("Looking for cluster members to upgrade");
    List<ClusterMember> members = jdbcTemplate.query(CLUSTER_MEMBERS_QUERY, new BeanPropertyRowMapper<>(ClusterMember.class));
    logger.debug("Found {0} cluster members", members.size());
    if (isEmpty(members)) {
        return;
    }
    for (ClusterMember member : members) {
        logger.debug("Upgrading cluster member with id: {0}", member.getId());
        switch(member.getGitAuthType()) {
            case RemoteRepository.AuthenticationType.BASIC:
                member.setGitPassword(upgradeValue(member.getGitPassword()));
                break;
            case RemoteRepository.AuthenticationType.TOKEN:
                member.setGitToken(upgradeValue(member.getGitToken()));
                break;
            case RemoteRepository.AuthenticationType.PRIVATE_KEY:
                member.setGitPrivateKey(upgradeValue(member.getGitPrivateKey()));
                break;
            default:
                logger.warn("Unknown authentication type {0} for cluster member with id {1}", member.getGitAuthType(), member.getId());
        }
    }
    jdbcTemplate.batchUpdate(CLUSTER_MEMBERS_UPDATE, members.stream().map(BeanPropertySqlParameterSource::new).toArray(BeanPropertySqlParameterSource[]::new));
}
Also used : ClusterMember(org.craftercms.studio.api.v2.dal.ClusterMember) BeanPropertySqlParameterSource(org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource)

Aggregations

ClusterMember (org.craftercms.studio.api.v2.dal.ClusterMember)26 SiteFeed (org.craftercms.studio.api.v1.dal.SiteFeed)10 IOException (java.io.IOException)9 Path (java.nio.file.Path)9 SiteNotFoundException (org.craftercms.studio.api.v1.exception.SiteNotFoundException)9 Git (org.eclipse.jgit.api.Git)9 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)9 ContentRepository (org.craftercms.studio.api.v1.repository.ContentRepository)8 Repository (org.eclipse.jgit.lib.Repository)8 ImmutableNode (org.apache.commons.configuration2.tree.ImmutableNode)7 RemoteRepository (org.craftercms.studio.api.v2.dal.RemoteRepository)7 FileRepositoryBuilder (org.eclipse.jgit.storage.file.FileRepositoryBuilder)7 HashMap (java.util.HashMap)6 ServiceLayerException (org.craftercms.studio.api.v1.exception.ServiceLayerException)6 InvalidRemoteUrlException (org.craftercms.studio.api.v1.exception.repository.InvalidRemoteUrlException)6 CryptoException (org.craftercms.commons.crypto.CryptoException)5 ClusterSiteRecord (org.craftercms.studio.api.v2.dal.ClusterSiteRecord)5 RemoteAddCommand (org.eclipse.jgit.api.RemoteAddCommand)5 URISyntaxException (java.net.URISyntaxException)4 File (java.io.File)3