本文整理汇总了Java中com.google.gwt.http.client.Response.SC_OK属性的典型用法代码示例。如果您正苦于以下问题:Java Response.SC_OK属性的具体用法?Java Response.SC_OK怎么用?Java Response.SC_OK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.gwt.http.client.Response
的用法示例。
在下文中一共展示了Response.SC_OK属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: syncRequest
public XMLHttpRequest2 syncRequest(String aUrl, ResponseType aResponseType) throws Exception {
final XMLHttpRequest2 req = syncRequest(aUrl, aResponseType, null, RequestBuilder.GET);
if (req.getStatus() == Response.SC_OK)
return req;
else
throw new Exception(req.getStatus() + " " + req.getStatusText());
}
示例2: syncApiRequest
public XMLHttpRequest2 syncApiRequest(String aUrlPrefix, final String aUrlQuery, ResponseType aResponseType) throws Exception {
String url = apiUrl + (aUrlPrefix != null ? aUrlPrefix : "") + "?" + aUrlQuery;
final XMLHttpRequest2 req = syncRequest(url, aResponseType, null, RequestBuilder.GET);
if (req.getStatus() == Response.SC_OK)
return req;
else
throw new Exception(req.getStatus() + " " + req.getStatusText());
}
示例3: getError
/**
* 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 );
}
}
示例4: onSubmit
private void onSubmit(String result) {
switch (ServletConstants.getErrorCode(result)) {
case Response.SC_OK:
if (view.getAutomatedField().getValue()) {
doAutomatedImport(result);
} else {
loadImportResults(result);
}
break;
default:
N10N.error(I18N.CONSTANTS.createFormIncomplete(), I18N.MESSAGES.importFormIncompleteDetails(""));
break;
}
}
示例5: onReceiving
private void onReceiving(int statusCode, String responseText, boolean connected) {
if (statusCode != Response.SC_OK) {
if (!connected) {
super.disconnect();
listener.onError(new StatusCodeException(statusCode, responseText), connected);
}
}
else {
int index = responseText.lastIndexOf(SEPARATOR);
if (index > read) {
List<Serializable> messages = new ArrayList<Serializable>();
SplitResult data = separator.split(responseText.substring(read, index), index);
int length = data.length();
for (int i = 0; i < length; i++) {
if (disconnecting) {
return;
}
String message = data.get(i);
if (!message.isEmpty()) {
parse(message, messages);
}
}
read = index + 1;
if (!messages.isEmpty()) {
listener.onMessage(messages);
}
}
if (!connected) {
super.disconnected();
}
}
}
示例6: onResponseReceived
@Override
public void onResponseReceived(Request request, Response response) {
if (response != null && response.getStatusCode() == Response.SC_OK) {
dispatch(SERVER_AVAILABLE);
} else {
dispatch(RESPONSE_TIMEOUT);
}
}
示例7: onResponseReceived
@Override
public void onResponseReceived(Request nativeRequest, Response nativeResponse)
{
TransactionRequest request = this.getDispatchedRequest(nativeRequest);
m_reusedResponse.clear();
int statusCode = nativeResponse.getStatusCode();
if( statusCode != Response.SC_OK )
{
String statusText = nativeResponse.getStatusText();
m_reusedResponse.setError(E_ResponseError.HTTP_ERROR);
this.onError(nativeRequest, request, m_reusedResponse);
return;
}
I_JsonObject responseJson = m_jsonFactory.createJsonObject(nativeResponse.getText());
m_reusedResponse.readJson(m_jsonFactory, responseJson);
if( !(request instanceof TransactionRequestBatch) )
{
m_callbacks.onResponseReceived(request, m_reusedResponse);
}
else
{
if( m_reusedResponse.getError() != E_ResponseError.NO_ERROR )
{
this.onError(nativeRequest, request, m_reusedResponse);
return;
}
TransactionRequestBatch batch = (TransactionRequestBatch) request;
I_JsonArray responseList = m_jsonFactory.getHelper().getJsonArray(responseJson, E_JsonKey.responseList);
m_callbacks.onResponseReceived(batch, responseList);
}
this.m_nativeRequestMap.remove(nativeRequest);
}
示例8: getErrorCode
/**
* Parse the error message and return the embeded error code as an integer. If the message does not denote an error,
* 200 is returned.
*
* @param message
* Message returned by a servlet.
* @return The error code if available, 200 otherwise.
*/
public static int getErrorCode(String message) {
if (!isErrorResponse(message)) {
return Response.SC_OK;
} else {
return Integer.parseInt(message.substring(1));
}
}