Search in sources :

Example 1 with UnauthorizedException

use of org.eclipse.che.ide.websocket.rest.exceptions.UnauthorizedException in project che by eclipse.

the class RequestCallback method onReply.

/**
     * Perform actions when response message was received.
     *
     * @param message
     *         message
     */
public void onReply(Message message) {
    if (loader != null) {
        loader.hide();
    }
    final String uuid = message.getStringField(MessageBuilder.UUID_FIELD);
    if (message.getResponseCode() == HTTPStatus.UNAUTHORIZED) {
        UnauthorizedException exception = new UnauthorizedException(message);
        if (statusHandler != null) {
            statusHandler.requestError(uuid, exception);
        }
        onFailure(exception);
        return;
    }
    if (isSuccessful(message)) {
        try {
            if (unmarshaller != null) {
                unmarshaller.unmarshal(message);
                payload = unmarshaller.getPayload();
            }
            if (statusHandler != null) {
                statusHandler.requestFinished(uuid);
            }
            onSuccess(payload);
        } catch (UnmarshallerException e) {
            if (statusHandler != null) {
                statusHandler.requestError(uuid, e);
            }
            onFailure(e);
        }
    } else {
        ServerException exception = new ServerException(message);
        if (statusHandler != null) {
            statusHandler.requestError(uuid, exception);
        }
        onFailure(exception);
    }
}
Also used : ServerException(org.eclipse.che.ide.websocket.rest.exceptions.ServerException) UnauthorizedException(org.eclipse.che.ide.websocket.rest.exceptions.UnauthorizedException) UnmarshallerException(org.eclipse.che.ide.commons.exception.UnmarshallerException)

Aggregations

UnmarshallerException (org.eclipse.che.ide.commons.exception.UnmarshallerException)1 ServerException (org.eclipse.che.ide.websocket.rest.exceptions.ServerException)1 UnauthorizedException (org.eclipse.che.ide.websocket.rest.exceptions.UnauthorizedException)1