use of org.eclipse.che.api.core.NotFoundException in project che by eclipse.
the class JpaAccountDao method getById.
@Override
@Transactional
public AccountImpl getById(String id) throws NotFoundException, ServerException {
requireNonNull(id, "Required non-null account id");
final EntityManager manager = managerProvider.get();
try {
AccountImpl account = manager.find(AccountImpl.class, id);
if (account == null) {
throw new NotFoundException(format("Account with id '%s' was not found", id));
}
return account;
} catch (RuntimeException x) {
throw new ServerException(x.getLocalizedMessage(), x);
}
}
use of org.eclipse.che.api.core.NotFoundException in project che by eclipse.
the class RemoteOAuthTokenProvider method getToken.
/** {@inheritDoc} */
@Override
public OAuthToken getToken(String oauthProviderName, String userId) throws IOException {
if (userId.isEmpty()) {
return null;
}
try {
UriBuilder ub = UriBuilder.fromUri(apiEndpoint).path(OAuthAuthenticationService.class).path(OAuthAuthenticationService.class, "token").queryParam("oauth_provider", oauthProviderName);
Link getTokenLink = DtoFactory.newDto(Link.class).withHref(ub.build().toString()).withMethod("GET");
return httpJsonRequestFactory.fromLink(getTokenLink).request().asDto(OAuthToken.class);
} catch (NotFoundException ne) {
LOG.warn("Token not found for user {}", userId);
return null;
} catch (ServerException | UnauthorizedException | ForbiddenException | ConflictException | BadRequestException e) {
LOG.warn("Exception on token retrieval, message : {}", e.getLocalizedMessage());
return null;
}
}
Aggregations