use of org.icij.datashare.tasks.TaskManagerRedis in project datashare by ICIJ.
the class ServerMode method configure.
@Override
protected void configure() {
super.configure();
String authUsersProviderClassName = propertiesProvider.get("authUsersProvider").orElse("org.icij.datashare.session.UsersInRedis");
String batchQueueType = propertiesProvider.get("batchQueueType").orElse("org.icij.datashare.extract.MemoryBlockingQueue");
bind(TaskManager.class).toInstance(new TaskManagerRedis(propertiesProvider, getBlockingQueue(propertiesProvider, batchQueueType, "ds:batchdownload:queue")));
Class<? extends UsersWritable> authUsersProviderClass = UsersInRedis.class;
try {
authUsersProviderClass = (Class<? extends UsersWritable>) Class.forName(authUsersProviderClassName);
logger.info("setting auth users provider to {}", authUsersProviderClass);
} catch (ClassNotFoundException e) {
logger.warn("\"{}\" auth users provider class not found. Setting provider to {}", authUsersProviderClassName, authUsersProviderClass);
}
bind(UsersWritable.class).to(authUsersProviderClass);
bind(SessionIdStore.class).to(RedisSessionIdStore.class);
bind(ApiKeyStore.class).to(ApiKeyStoreAdapter.class);
String authFilterClassName = propertiesProvider.get("authFilter").orElse("");
Class<? extends Filter> authFilterClass = OAuth2CookieFilter.class;
if (!authFilterClassName.isEmpty()) {
try {
authFilterClass = (Class<? extends Filter>) Class.forName(authFilterClassName);
logger.info("setting auth filter to {}", authFilterClass);
} catch (ClassNotFoundException e) {
logger.warn("\"{}\" auth filter class not found. Setting filter to {}", authFilterClassName, authFilterClass);
}
}
bind(Filter.class).to(authFilterClass);
if (authFilterClass.equals(BasicAuthAdaptorFilter.class)) {
bind(ApiKeyFilter.class).toInstance(new ApiKeyFilter(null, apiKey -> null) {
@Override
public Payload apply(String uri, Context context, PayloadSupplier nextFilter) throws Exception {
return nextFilter.get();
}
});
}
bind(StatusResource.class).asEagerSingleton();
configurePersistence();
}
use of org.icij.datashare.tasks.TaskManagerRedis in project datashare by ICIJ.
the class BatchDownloadMode method configure.
@Override
protected void configure() {
super.configure();
String batchQueueType = propertiesProvider.get("batchQueueType").orElse("org.icij.datashare.extract.MemoryBlockingQueue");
bind(TaskManager.class).toInstance(new TaskManagerRedis(propertiesProvider, getBlockingQueue(propertiesProvider, batchQueueType, "ds:batchdownload:queue")));
RepositoryFactoryImpl repositoryFactory = new RepositoryFactoryImpl(propertiesProvider);
bind(BatchSearchRepository.class).toInstance(repositoryFactory.createBatchSearchRepository());
bind(ApiKeyRepository.class).toInstance(repositoryFactory.createApiKeyRepository());
repositoryFactory.initDatabase();
}
Aggregations