当前位置: 首页>>代码示例>>Java>>正文


Java Response.getStatusCode方法代码示例

本文整理汇总了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;
		}
	};
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:26,代码来源:AbstractGitHubGetListRequest.java

示例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;
		}
	};
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:26,代码来源:GitHubGetRepositoryListRequest.java

示例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());
        }
    }
}
 
开发者ID:nmorel,项目名称:gwt-jackson-rest,代码行数:26,代码来源:RestRequestCallback.java

示例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);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:AsyncRequestCallback.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:AsyncRequestCallback.java

示例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);
}
 
开发者ID:Unisay,项目名称:preferanser,代码行数:22,代码来源:ErrorHandlingRestyGwtRequestListener.java

示例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);
  }
}
 
开发者ID:tsuna,项目名称:droopy,代码行数:25,代码来源:Main.java

示例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;
		}
	};
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:28,代码来源:GitHubCreateFileExporter.java

示例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);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:8,代码来源:FailureShownRestCallback.java

示例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));
            }
        }
    };
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:33,代码来源:CubaXhrConnection.java

示例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);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:AsyncRequestCallback.java

示例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 );
  }
}
 
开发者ID:realityforge,项目名称:gwt-webpoller,代码行数:20,代码来源:AbstractHttpRequestFactory.java

示例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()));
    }

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:8,代码来源:Application.java

示例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");
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:10,代码来源:PageableNodeList.java

示例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();
	}
}
 
开发者ID:Orichievac,项目名称:FallenGalaxy,代码行数:38,代码来源:Action.java


注:本文中的com.google.gwt.http.client.Response.getStatusCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。