/** Callback for GWT's request builder upon receiving a response. */
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() != expectedResponseCode) {
onError(request, null);
} else {
Resource resource = factory.create();
resource.populateFromRepresentation(response.getText());
callback.onSuccess(resource);
}
}