本文整理汇总了Java中com.google.gwt.http.client.Response.getStatusCode方法的典型用法代码示例。如果您正苦于以下问题:Java Response.getStatusCode方法的具体用法?Java Response.getStatusCode怎么用?Java Response.getStatusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.http.client.Response
的用法示例。
在下文中一共展示了Response.getStatusCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getErrorCallback
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
protected RestErrorCallback getErrorCallback() {
return new RestErrorCallback() {
@Override
public boolean error(Request request, Throwable throwable) {
autoMessageBox.hide();
String message = "";
int defaultCodeError = Response.SC_NOT_MODIFIED;
try {
throw throwable;
} catch (ResponseException e) {
Response response = e.getResponse();
message = response.getStatusText();
defaultCodeError = response.getStatusCode();
} catch (Throwable t) {
message = t.getMessage();
}
messageDialogBuilder.createError(UIMessages.INSTANCE.warning() + " " + defaultCodeError, message).show();
return false;
}
};
}
示例2: getErrorCallback
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
private RestErrorCallback getErrorCallback() {
return new RestErrorCallback() {
@Override
public boolean error(Request request, Throwable throwable) {
autoMessageBox.hide();
String message = "";
int defaultCodeError = Response.SC_NOT_MODIFIED;
try {
throw throwable;
} catch (ResponseException e) {
Response response = e.getResponse();
message = response.getStatusText();
defaultCodeError = response.getStatusCode();
} catch (Throwable t) {
message = t.getMessage();
}
messageDialogBuilder.createError(UIMessages.INSTANCE.warning() + " " + defaultCodeError, message).show();
return false;
}
};
}
示例3: onResponseReceived
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
@Override
public void onResponseReceived(Request request, Response response) {
if (isSuccessStatusCode(response)) {
if (null != callback) {
R result;
if (null != responseConverter && null != response.getText() && !response.getText().isEmpty()) {
try {
result = responseConverter.read(response.getText());
} catch (Exception e) {
onError(request, e);
return;
}
} else {
result = null;
}
callback.onSuccess(response, result);
}
} else {
if (null != callback) {
callback.onError(response);
} else {
throw new RestException("An error occured. Status : " + response.getStatusCode());
}
}
}
示例4: onResponseReceived
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
/**
* @see
* com.google.gwt.http.client.RequestCallback#onResponseReceived(com.google.gwt.http.client.Request,
* com.google.gwt.http.client.Response)
*/
@Override
public final void onResponseReceived(Request request, Response response) {
if (loader != null) {
loader.hide();
}
// If there is no connection to the server then status equals 0 ( In Internet Explorer status is
// 12029 )
if (response.getStatusCode() == 0 || response.getStatusCode() == 12029) {
onServerDisconnected();
return;
}
if (response.getStatusCode() == HTTPStatus.UNAUTHORIZED) {
onUnauthorized(response);
return;
}
if (isSuccessful(response)) {
handleSuccess(response);
} else {
handleFailure(response);
}
}
示例5: isSuccessful
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
protected final boolean isSuccessful(Response response) {
if (successCodes == null) {
successCodes = DEFAULT_SUCCESS_CODES;
}
if ("Authentication-required".equals(response.getHeader(HTTPHeader.JAXRS_BODY_PROVIDED))) {
return false;
}
for (int code : successCodes) {
if (response.getStatusCode() == code) {
return true;
}
}
return false;
}
示例6: afterClientErrorHandled
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
@Override public void afterClientErrorHandled(Method method, Request request, Response response) {
String errorMessage;
switch (response.getStatusCode()) {
case 0:
return; // Ignore
case 401: // Unauthorized
placeManager.revealDefaultPlace();
errorMessage = "Для просмотра данной страницы необходимо войти в систему.";
break;
case 404: // Not found
errorMessage = "Объект не найден.";
break;
default:
errorMessage = "HTTP response error: " + response.getText();
Window.alert("Обработка запроса завершилась ошибкой. " +
"Подробная информация об ошибке доступна в консоли браузера. " +
"Пожалуйста, обновите текущую страницу или начните с главной.");
}
log.severe(errorMessage);
}
示例7: onResponseReceived
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
public final void onResponseReceived(final Request request, final Response response) {
final String text = response.getText();
if (text.isEmpty()) {
final int code = response.getStatusCode();
final String errmsg;
if (code == 0) { // Happens when a cross-domain request fails to connect.
errmsg = ("Failed to connect to " + server + ", check that the server"
+ " is up and that you can connect to it.");
} else {
errmsg = ("Empty response from server: code=" + code
+ " status=" + response.getStatusText());
}
onError(request, new RuntimeException(errmsg));
} else {
JSONValue value;
try {
value = JSONParser.parseStrict(text);
} catch (JSONException e) {
onError(request, e);
return;
}
onSuccess(value);
}
}
示例8: getErrorCallback
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
private RestErrorCallback getErrorCallback() {
return new RestErrorCallback() {
@Override
public boolean error(Request request, Throwable throwable) {
autoMessageBox.hide();
String message = "";
int defaultCodeError = Response.SC_NOT_MODIFIED;
try {
throw throwable;
} catch (ResponseException e) {
Response response = e.getResponse();
message = response.getStatusText();
defaultCodeError = response.getStatusCode();
} catch (Throwable t) {
message = t.getMessage();
}
messageDialogBuilder.createError(
UIMessages.INSTANCE.warning() + " " + defaultCodeError,
message).show();
return false;
}
};
}
示例9: onError
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
@Override
public void onError(Response response) {
String message = "Error calling REST method with status (" + response.getStatusCode() + ": " + response.getStatusText() + ") and text (" +
response.getText() + ").";
ErrorPopup.show(message);
throw new IllegalStateException(message);
}
示例10: createResponseHandler
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
@Override
protected XhrResponseHandler createResponseHandler() {
return new XhrResponseHandler() {
protected int serverTimeOnClient;
@Override
public void onResponseReceived(Request request, Response response) {
int statusCode = response.getStatusCode();
if (statusCode == 200) {
serverTimeOnClient = (int) Util.round(Profiler.getRelativeTimeMillis() - requestStartTime, 0);
}
super.onResponseReceived(request, response);
}
@Override
protected void beforeHandlingMessage(ValueMap json) {
super.beforeHandlingMessage(json);
ScreenClientProfiler profiler = ScreenClientProfiler.getInstance();
String profilerMarker = ScreenClientProfiler.getProfilerMarkerFromJson(json);
if (profilerMarker != null) {
int serverTimeOnServer = ScreenClientProfiler.getServerTimeFromJson(json);
if (serverTimeOnServer > 0) {
profiler.registerServerTime(profilerMarker, serverTimeOnServer);
profiler.registerNetworkTime(profilerMarker, serverTimeOnClient - serverTimeOnServer);
} else {
profiler.registerServerTime(profilerMarker, serverTimeOnClient);
}
profiler.registerEventTs(profilerMarker, ScreenClientProfiler.getEventTsFromJson(json));
}
}
};
}
示例11: handleSuccess
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
private void handleSuccess(Response response) {
try {
if (unmarshaller != null) {
// It's needed for handling a situation when response DTO object is NULL
if (response.getStatusCode() != Response.SC_NO_CONTENT) {
unmarshaller.unmarshal(response);
}
payload = unmarshaller.getPayload();
}
onSuccess(payload);
} catch (Exception e) {
onFailure(e);
}
}
示例12: getError
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
/**
* Return error associated with response.
*
* @param response the response.
* @return the error if any, null otherwise.
*/
@Nullable
protected Throwable getError( @Nonnull final Response response )
{
final int statusCode = response.getStatusCode();
if ( Response.SC_OK == statusCode )
{
return null;
}
else
{
return new Exception( "Bad status code: " + statusCode );
}
}
示例13: onResponseReceived
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
@Override
public void onResponseReceived(Request request, Response response) {
if(response.getStatusCode() == 200) {
updateTimelineChart(ChartUtils.convertJSONToDataTable(response.getText()));
}
}
示例14: onResponseReceived
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
@Override
public void onResponseReceived(Request request, Response response) {
if(response.getStatusCode() == 200) {
updatePhysicalInterfaceList(NodeRestResponseMapper.createSnmpInterfaceData(response.getText()));
}else {
//updatePhysicalInterfaceList(NodeRestResponseMapper.createSnmpInterfaceData(DefaultNodeService.SNMP_INTERFACES_TEST_RESPONSE));
showErrorDialogBox("Error attempting to get SnmpInterfaces");
}
}
示例15: onResponseReceived
import com.google.gwt.http.client.Response; //导入方法依赖的package包/类
public void onResponseReceived(Request request, Response response) {
if (callback != null) {
if (response.getStatusCode() == 200) {
if (!uri.toLowerCase().contains("polling")) {
int lag = (int) (System.currentTimeMillis() - startTime);
totalLag += lag;
lastLag = lag;
requestsCount++;
}
AnswerData answerData = AnswerData.wrap(response.getText());
String type = answerData.getType();
if (type.equals(AnswerData.TYPE_SUCCESS)) {
callback.onSuccess(answerData);
} else if (type.equals(AnswerData.TYPE_ERROR)) {
callback.onFailure(answerData.getStringData());
} else if (type.equals(AnswerData.TYPE_CONFIRM_PASSWORD) ||
type.equals(AnswerData.TYPE_WRONG_PASSWORD)) {
FaultManager.showConfirmPasswordDialog(uri, params, callback,
type.equals(AnswerData.TYPE_WRONG_PASSWORD));
} else if (type.equals(AnswerData.TYPE_DISCONNECTED)) {
disconnected = true;
FaultManager.showDisconnectedDialog();
}
cleanUp();
} else {
retry(String.valueOf(response.getStatusCode()));
}
} else {
if (response.getStatusCode() != 200) {
retry(String.valueOf(response.getStatusCode()));
}
cleanUp();
}
}