Example usage for com.google.gwt.http.client Response SC_MULTIPLE_CHOICES

List of usage examples for com.google.gwt.http.client Response SC_MULTIPLE_CHOICES

Introduction

In this page you can find the example usage for com.google.gwt.http.client Response SC_MULTIPLE_CHOICES.

Prototype

int SC_MULTIPLE_CHOICES

To view the source code for com.google.gwt.http.client Response SC_MULTIPLE_CHOICES.

Click Source Link

Usage

From source file:org.fusesource.restygwt.client.callback.CachingCallbackFilter.java

License:Apache License

protected boolean isCachingStatusCode(final int code) {
    return code < Response.SC_MULTIPLE_CHOICES // code < 300
            && code >= Response.SC_OK; // code >= 200
}

From source file:org.fusesource.restygwt.client.callback.ModelChangeCallbackFilter.java

License:Apache License

/**
 * the real filter method, called independent of the response code
 *
 * TODO method.getResponse() is not equal to response. unfortunately
 *///from  w w  w  . j av  a 2  s  .  c o m
@Override
public RequestCallback filter(final Method method, final Response response, RequestCallback callback) {
    final int code = response.getStatusCode();

    if (code < Response.SC_MULTIPLE_CHOICES // code < 300
            && code >= Response.SC_OK) { // code >= 200
        String modelChangeIdentifier = method.getData().get(ModelChange.MODEL_CHANGED_DOMAIN_KEY);

        if (modelChangeIdentifier != null) {
            if (getLogger() != null) {
                getLogger()
                        .fine("found modelChangeIdentifier \"" + modelChangeIdentifier + "\" in " + response);
            }
            JSONValue jsonValue = JSONParser.parseStrict(modelChangeIdentifier);
            JSONArray jsonArray = jsonValue.isArray();

            if (jsonArray != null) {
                for (int i = 0; i < jsonArray.size(); ++i) {
                    ModelChangeEvent e = new ModelChangeEvent(jsonArray.get(i).isString().stringValue());

                    if (getLogger() != null) {
                        getLogger().info("fire event \"" + e + "\" ...");
                    }
                    eventBus.fireEvent(e);
                }
            } else {
                if (getLogger() != null) {
                    getLogger().info("found null array for model-change events");
                }
            }
        }
        return callback;
    }

    if (getLogger() != null) {
        getLogger().fine("no event processing due to invalid response code: " + code);
    }
    return callback;
}