Search in sources :

Example 1 with TaskManagerRedis

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();
}
Also used : SessionIdStore(net.codestory.http.security.SessionIdStore) Routes(net.codestory.http.routes.Routes) Logger(org.slf4j.Logger) Properties(java.util.Properties) Context(net.codestory.http.Context) Payload(net.codestory.http.payload.Payload) LoggerFactory(org.slf4j.LoggerFactory) org.icij.datashare.web(org.icij.datashare.web) PayloadSupplier(net.codestory.http.filters.PayloadSupplier) TaskManager(org.icij.datashare.tasks.TaskManager) Map(java.util.Map) Filter(net.codestory.http.filters.Filter) TaskManagerRedis(org.icij.datashare.tasks.TaskManagerRedis) org.icij.datashare.session(org.icij.datashare.session) Context(net.codestory.http.Context) TaskManagerRedis(org.icij.datashare.tasks.TaskManagerRedis) TaskManager(org.icij.datashare.tasks.TaskManager) SessionIdStore(net.codestory.http.security.SessionIdStore) PayloadSupplier(net.codestory.http.filters.PayloadSupplier) Filter(net.codestory.http.filters.Filter) Payload(net.codestory.http.payload.Payload)

Example 2 with TaskManagerRedis

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();
}
Also used : TaskManagerRedis(org.icij.datashare.tasks.TaskManagerRedis) RepositoryFactoryImpl(org.icij.datashare.db.RepositoryFactoryImpl) TaskManager(org.icij.datashare.tasks.TaskManager) ApiKeyRepository(org.icij.datashare.user.ApiKeyRepository) BatchSearchRepository(org.icij.datashare.batch.BatchSearchRepository)

Aggregations

TaskManager (org.icij.datashare.tasks.TaskManager)2 TaskManagerRedis (org.icij.datashare.tasks.TaskManagerRedis)2 Map (java.util.Map)1 Properties (java.util.Properties)1 Context (net.codestory.http.Context)1 Filter (net.codestory.http.filters.Filter)1 PayloadSupplier (net.codestory.http.filters.PayloadSupplier)1 Payload (net.codestory.http.payload.Payload)1 Routes (net.codestory.http.routes.Routes)1 SessionIdStore (net.codestory.http.security.SessionIdStore)1 BatchSearchRepository (org.icij.datashare.batch.BatchSearchRepository)1 RepositoryFactoryImpl (org.icij.datashare.db.RepositoryFactoryImpl)1 org.icij.datashare.session (org.icij.datashare.session)1 ApiKeyRepository (org.icij.datashare.user.ApiKeyRepository)1 org.icij.datashare.web (org.icij.datashare.web)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1