Search in sources :

Example 1 with DefaultGitRepositoryRegisteredServiceLocator

use of org.apereo.cas.services.locator.DefaultGitRepositoryRegisteredServiceLocator in project cas by apereo.

the class GitServiceRegistryConfiguration method gitServiceRegistry.

@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "gitServiceRegistry")
public ServiceRegistry gitServiceRegistry(final CasConfigurationProperties casProperties, final ObjectProvider<List<ServiceRegistryListener>> serviceRegistryListeners, final ConfigurableApplicationContext applicationContext, @Qualifier("gitServiceRegistryRepositoryInstance") final GitRepository gitServiceRegistryRepositoryInstance, @Qualifier("registeredServiceResourceNamingStrategy") final RegisteredServiceResourceNamingStrategy resourceNamingStrategy) {
    return BeanSupplier.of(ServiceRegistry.class).when(CONDITION.given(applicationContext.getEnvironment())).supply(() -> {
        val properties = casProperties.getServiceRegistry().getGit();
        val locators = new ArrayList<GitRepositoryRegisteredServiceLocator>();
        if (properties.isGroupByType()) {
            locators.add(new TypeAwareGitRepositoryRegisteredServiceLocator(resourceNamingStrategy, gitServiceRegistryRepositoryInstance.getRepositoryDirectory(), properties));
        }
        locators.add(new DefaultGitRepositoryRegisteredServiceLocator(resourceNamingStrategy, gitServiceRegistryRepositoryInstance.getRepositoryDirectory(), properties));
        return new GitServiceRegistry(applicationContext, gitServiceRegistryRepositoryInstance, CollectionUtils.wrapList(new RegisteredServiceJsonSerializer(), new RegisteredServiceYamlSerializer()), properties.isPushChanges(), properties.getRootDirectory(), Optional.ofNullable(serviceRegistryListeners.getIfAvailable()).orElseGet(ArrayList::new), locators);
    }).otherwiseProxy().get();
}
Also used : lombok.val(lombok.val) TypeAwareGitRepositoryRegisteredServiceLocator(org.apereo.cas.services.locator.TypeAwareGitRepositoryRegisteredServiceLocator) GitServiceRegistry(org.apereo.cas.services.GitServiceRegistry) RegisteredServiceJsonSerializer(org.apereo.cas.services.util.RegisteredServiceJsonSerializer) ArrayList(java.util.ArrayList) RegisteredServiceYamlSerializer(org.apereo.cas.services.util.RegisteredServiceYamlSerializer) DefaultGitRepositoryRegisteredServiceLocator(org.apereo.cas.services.locator.DefaultGitRepositoryRegisteredServiceLocator) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with DefaultGitRepositoryRegisteredServiceLocator

use of org.apereo.cas.services.locator.DefaultGitRepositoryRegisteredServiceLocator in project cas by apereo.

the class DefaultGitRepositoryRegisteredServiceLocatorTests method verifyOperation.

@Test
public void verifyOperation() throws Exception {
    val strategy = new DefaultRegisteredServiceResourceNamingStrategy();
    val locator = new DefaultGitRepositoryRegisteredServiceLocator(strategy, FileUtils.getTempDirectory(), new GitServiceRegistryProperties().setRootDirectory("sample-root"));
    val service = RegisteredServiceTestUtils.getRegisteredService();
    val file = locator.determine(service, "json");
    assertTrue(file.getCanonicalPath().endsWith("sample-root" + File.separator + strategy.build(service, "json")));
}
Also used : lombok.val(lombok.val) DefaultRegisteredServiceResourceNamingStrategy(org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy) GitServiceRegistryProperties(org.apereo.cas.configuration.model.support.git.services.GitServiceRegistryProperties) DefaultGitRepositoryRegisteredServiceLocator(org.apereo.cas.services.locator.DefaultGitRepositoryRegisteredServiceLocator) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)2 DefaultGitRepositoryRegisteredServiceLocator (org.apereo.cas.services.locator.DefaultGitRepositoryRegisteredServiceLocator)2 ArrayList (java.util.ArrayList)1 GitServiceRegistryProperties (org.apereo.cas.configuration.model.support.git.services.GitServiceRegistryProperties)1 GitServiceRegistry (org.apereo.cas.services.GitServiceRegistry)1 TypeAwareGitRepositoryRegisteredServiceLocator (org.apereo.cas.services.locator.TypeAwareGitRepositoryRegisteredServiceLocator)1 DefaultRegisteredServiceResourceNamingStrategy (org.apereo.cas.services.resource.DefaultRegisteredServiceResourceNamingStrategy)1 RegisteredServiceJsonSerializer (org.apereo.cas.services.util.RegisteredServiceJsonSerializer)1 RegisteredServiceYamlSerializer (org.apereo.cas.services.util.RegisteredServiceYamlSerializer)1 Test (org.junit.jupiter.api.Test)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1