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);
}
}
Aggregations