use of com.google.gerrit.exceptions.NotSignedInException in project gerrit by GerritCodeReview.
the class ThreadLocalRequestContext method module.
public static Module module() {
return new AbstractModule() {
@Override
protected void configure() {
bind(ThreadLocalRequestContext.class);
bind(RequestContext.class).annotatedWith(Names.named(FALLBACK)).to(FallbackRequestContext.class);
}
@Provides
RequestContext provideRequestContext(@Named(FALLBACK) RequestContext fallback) {
return MoreObjects.firstNonNull(local.get(), fallback);
}
@Provides
CurrentUser provideCurrentUser(RequestContext ctx) {
return ctx.getUser();
}
@Provides
IdentifiedUser provideCurrentUser(CurrentUser user) {
if (user.isIdentifiedUser()) {
return user.asIdentifiedUser();
}
throw new ProvisionException(NotSignedInException.MESSAGE, new NotSignedInException());
}
};
}
Aggregations