Search in sources :

Example 81 with ConflictException

use of org.eclipse.che.api.core.ConflictException 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;
    }
}
Also used : ForbiddenException(org.eclipse.che.api.core.ForbiddenException) ServerException(org.eclipse.che.api.core.ServerException) ConflictException(org.eclipse.che.api.core.ConflictException) UnauthorizedException(org.eclipse.che.api.core.UnauthorizedException) NotFoundException(org.eclipse.che.api.core.NotFoundException) BadRequestException(org.eclipse.che.api.core.BadRequestException) UriBuilder(javax.ws.rs.core.UriBuilder) Link(org.eclipse.che.api.core.rest.shared.dto.Link)

Aggregations

ConflictException (org.eclipse.che.api.core.ConflictException)81 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)28 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)25 ServerException (org.eclipse.che.api.core.ServerException)24 Test (org.junit.Test)24 NotFoundException (org.eclipse.che.api.core.NotFoundException)17 Path (org.eclipse.che.api.vfs.Path)12 IOException (java.io.IOException)10 NewProjectConfig (org.eclipse.che.api.core.model.project.NewProjectConfig)8 Unlocker (org.eclipse.che.commons.lang.concurrent.Unlocker)8 ArrayList (java.util.ArrayList)7 BadRequestException (org.eclipse.che.api.core.BadRequestException)7 MachineException (org.eclipse.che.api.machine.server.exception.MachineException)7 File (java.io.File)6 ProjectConfig (org.eclipse.che.api.core.model.project.ProjectConfig)6 CommandImpl (org.eclipse.che.api.machine.server.model.impl.CommandImpl)6 List (java.util.List)5 Map (java.util.Map)5 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)5 String.format (java.lang.String.format)4