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();
}
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")));
}
Aggregations