use of org.broadinstitute.consent.http.service.ApprovalExpirationTimeService in project consent by DataBiosphere.
the class ConsentApplication method run.
@Override
public void run(ConsentConfiguration config, Environment env) {
try {
initializeLiquibase(config);
} catch (LiquibaseException | SQLException e) {
LOGGER.error("Exception initializing liquibase: " + e);
}
// TODO: Update all services to use an injector.
// Previously, this code was working around a dropwizard+Guice issue with singletons and JDBI.
final Injector injector = Guice.createInjector(new ConsentModule(config, env));
// Clients
final HttpClientUtil clientUtil = new HttpClientUtil();
final GCSStore googleStore = injector.getProvider(GCSStore.class).get();
// Services
final ApprovalExpirationTimeService approvalExpirationTimeService = injector.getProvider(ApprovalExpirationTimeService.class).get();
final ConsentService consentService = injector.getProvider(ConsentService.class).get();
final DarCollectionService darCollectionService = injector.getProvider(DarCollectionService.class).get();
final DacService dacService = injector.getProvider(DacService.class).get();
final DataAccessRequestService dataAccessRequestService = injector.getProvider(DataAccessRequestService.class).get();
final DatasetAssociationService datasetAssociationService = injector.getProvider(DatasetAssociationService.class).get();
final DatasetService datasetService = injector.getProvider(DatasetService.class).get();
final ElectionService electionService = injector.getProvider(ElectionService.class).get();
final EmailNotifierService emailNotifierService = injector.getProvider(EmailNotifierService.class).get();
final GCSService gcsService = injector.getProvider(GCSService.class).get();
final InstitutionService institutionService = injector.getProvider(InstitutionService.class).get();
final MetricsService metricsService = injector.getProvider(MetricsService.class).get();
final PendingCaseService pendingCaseService = injector.getProvider(PendingCaseService.class).get();
final UserService userService = injector.getProvider(UserService.class).get();
final VoteService voteService = injector.getProvider(VoteService.class).get();
final AuditService auditService = injector.getProvider(AuditService.class).get();
final SummaryService summaryService = injector.getProvider(SummaryService.class).get();
final ReviewResultsService reviewResultsService = injector.getProvider(ReviewResultsService.class).get();
final UseRestrictionValidator useRestrictionValidator = injector.getProvider(UseRestrictionValidator.class).get();
final MatchService matchService = injector.getProvider(MatchService.class).get();
final OAuthAuthenticator authenticator = injector.getProvider(OAuthAuthenticator.class).get();
final LibraryCardService libraryCardService = injector.getProvider(LibraryCardService.class).get();
final SamService samService = injector.getProvider(SamService.class).get();
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
configureCors(env);
// Health Checks
env.healthChecks().register(GCS_CHECK, new GCSHealthCheck(gcsService));
env.healthChecks().register(ES_CHECK, new ElasticSearchHealthCheck(config.getElasticSearchConfiguration()));
env.healthChecks().register(ONTOLOGY_CHECK, new OntologyHealthCheck(clientUtil, config.getServicesConfiguration()));
env.healthChecks().register(SAM_CHECK, new SamHealthCheck(clientUtil, config.getServicesConfiguration()));
env.healthChecks().register(SG_CHECK, new SendGridHealthCheck(clientUtil, config.getMailConfiguration()));
final StoreOntologyService storeOntologyService = new StoreOntologyService(googleStore, config.getStoreOntologyConfiguration().getBucketSubdirectory(), config.getStoreOntologyConfiguration().getConfigurationFileName());
final ResearcherService researcherService = injector.getProvider(ResearcherService.class).get();
final NihService nihService = injector.getProvider(NihService.class).get();
final IndexOntologyService indexOntologyService = new IndexOntologyService(config.getElasticSearchConfiguration());
final IndexerService indexerService = new IndexerServiceImpl(storeOntologyService, indexOntologyService);
// Custom Error handling. Expand to include other codes when necessary
final ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
errorHandler.addErrorPage(404, "/error/404");
env.getApplicationContext().setErrorHandler(errorHandler);
env.jersey().register(ResponseServerFilter.class);
env.jersey().register(ErrorResource.class);
// Register standard application resources.
env.jersey().register(new ApprovalExpirationTimeResource(approvalExpirationTimeService, userService));
env.jersey().register(new DataAccessRequestResourceVersion2(dataAccessRequestService, emailNotifierService, gcsService, userService, matchService));
env.jersey().register(new DataAccessRequestResource(dataAccessRequestService, userService, consentService, electionService));
env.jersey().register(new DatasetResource(consentService, datasetService, userService, dataAccessRequestService));
env.jersey().register(new DatasetAssociationsResource(datasetAssociationService));
env.jersey().register(new ConsentResource(auditService, userService, consentService, matchService, useRestrictionValidator));
env.jersey().register(new ConsentAssociationResource(consentService, userService));
env.jersey().register(new ConsentElectionResource(consentService, dacService, emailNotifierService, voteService, electionService));
env.jersey().register(new ConsentManageResource(consentService));
env.jersey().register(new ConsentVoteResource(emailNotifierService, electionService, voteService));
env.jersey().register(new ConsentCasesResource(electionService, pendingCaseService, summaryService));
env.jersey().register(new DacResource(dacService, userService));
env.jersey().register(new DACUserResource(userService));
env.jersey().register(new DarCollectionResource(dataAccessRequestService, darCollectionService, userService));
env.jersey().register(new DataRequestElectionResource(dataAccessRequestService, emailNotifierService, summaryService, voteService, electionService));
env.jersey().register(new DataRequestVoteResource(dataAccessRequestService, datasetAssociationService, emailNotifierService, voteService, datasetService, electionService, userService));
env.jersey().register(new DataRequestCasesResource(electionService, pendingCaseService, summaryService));
env.jersey().register(new DataRequestReportsResource(dataAccessRequestService));
env.jersey().register(new DataUseLetterResource(auditService, googleStore, userService, consentService));
env.jersey().register(new ElectionResource(voteService, electionService));
env.jersey().register(new ElectionReviewResource(dataAccessRequestService, consentService, electionService, reviewResultsService));
env.jersey().register(new EmailNotifierResource(emailNotifierService));
env.jersey().register(new IndexerResource(indexerService, googleStore));
env.jersey().register(new InstitutionResource(userService, institutionService));
env.jersey().register(new LibraryCardResource(userService, libraryCardService));
env.jersey().register(new MatchResource(matchService));
env.jersey().register(new MetricsResource(metricsService));
env.jersey().register(new NihAccountResource(nihService, userService));
env.jersey().register(new ResearcherResource(researcherService));
env.jersey().register(new SamResource(samService));
env.jersey().register(new SwaggerResource(config.getGoogleAuthentication()));
env.jersey().register(new StatusResource(env.healthChecks()));
env.jersey().register(new UserResource(researcherService, samService, userService));
env.jersey().register(new TosResource(samService));
env.jersey().register(injector.getInstance(VersionResource.class));
env.jersey().register(new VoteResource(userService, voteService));
// Authentication filters
final UserRoleDAO userRoleDAO = injector.getProvider(UserRoleDAO.class).get();
AuthFilter defaultAuthFilter = new DefaultAuthFilter.Builder<AuthUser>().setAuthenticator(new DefaultAuthenticator()).setRealm(" ").buildAuthFilter();
List<AuthFilter> filters = Lists.newArrayList(defaultAuthFilter, new BasicCustomAuthFilter(new BasicAuthenticator(config.getBasicAuthentication())), new OAuthCustomAuthFilter(authenticator, userRoleDAO));
env.jersey().register(new AuthDynamicFeature(new ChainedAuthFilter(filters)));
env.jersey().register(RolesAllowedDynamicFeature.class);
env.jersey().register(new AuthValueFactoryProvider.Binder<>(AuthUser.class));
}
Aggregations