private T cached;
+ private T result;
+
private Map<String, String> headers = new HashMap<String, String>();
public abstract void onSuccess(T result);
public abstract void onError(Throwable t);
- public GetRequest(Class<T> aClass, String path, int okCode) {
+ public GetRequest(Class<T> aClass, String path, int okCode, T result) {
this.aClass = aClass;
this.path = path;
this.okCode = okCode;
+ this.result = result;
}
public GetRequest(Class<T> aClass, String path) {
- this(aClass, path, -1);
+ this(aClass, path, -1, null);
+ }
+
+ public GetRequest(Class<T> aClass, String path, T result) {
+ this(aClass, path, -1, result);
}
@Override
@Override
public T deserialize(Response response) {
- return Resource.createFromResponse(aClass, response);
+ return Resource.createFromResponse(aClass, response, result);
}
@Override
public void onError(Request request, Throwable throwable) {
if (throwable instanceof RestException) {
if (((RestException) throwable).getHttpStatusCode() == 304 && cached != null){
- GWT.log("Using cache: " + cached.getUri(), null);
+ GWT.log("Using cache: " + cached.toString(), null);
onSuccess(cached);
return;
}