package gr.grnet.pithos.web.client.rest;
-import gr.grnet.pithos.web.client.foldertree.Resource;
+import gr.grnet.pithos.web.client.Resource;
import java.util.HashMap;
import java.util.Map;
+import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
* Templates.
*/
public abstract class DeleteRequest implements ScheduledCommand {
- private String api;
+
+ protected static final int MAX_RETRIES = 3;
+
+ protected int retries = 0;
+
+ private String api;
protected String owner;
@Override
public void onError(Request request, Throwable throwable) {
- DeleteRequest.this.onError(throwable);
+ if (retries >= MAX_RETRIES)
+ DeleteRequest.this.onError(throwable);
+ else
+ Scheduler.get().scheduleDeferred(DeleteRequest.this);
}
@Override
public void onUnauthorized(Response response) {
- DeleteRequest.this.onUnauthorized(response);
+ if (retries >= MAX_RETRIES)
+ DeleteRequest.this.onUnauthorized(response);
+ else
+ Scheduler.get().scheduleDeferred(DeleteRequest.this);
}
});
+ retries++;
}
catch (RequestException e) {
}