/*
- * Copyright 2011 GRNET S.A. All rights reserved.
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
package gr.grnet.pithos.web.client.rest;
-import gr.grnet.pithos.web.client.foldertree.Resource;
+import gr.grnet.pithos.web.client.Pithos;
+import gr.grnet.pithos.web.client.Resource;
import java.util.HashMap;
import java.util.Map;
public abstract class HeadRequest<T extends Resource> implements ScheduledCommand {
+ protected static final int MAX_RETRIES = 3;
+
+ private final Pithos app;
+
+ protected int retries = 0;
+
protected Class<T> aClass;
private String api;
public abstract void onError(Throwable t);
- public HeadRequest(Class<T> aClass, String api, String owner, String path, int okCode, T result) {
+ public HeadRequest(Pithos app, Class<T> aClass, String api, String owner, String path, int okCode, T result) {
+ this.app = app;
this.aClass = aClass;
this.api = api;
this.owner = owner;
this.result = result;
}
- public HeadRequest(Class<T> aClass, String api, String owner, String path) {
- this(aClass, api, owner, path, Response.SC_NO_CONTENT, null);
+ public HeadRequest(Pithos app, Class<T> aClass, String api, String owner, String path) {
+ this(app, aClass, api, owner, path, Response.SC_NO_CONTENT, null);
}
- public HeadRequest(Class<T> aClass, String api, String owner, String path, T result) {
- this(aClass, api, owner, path, Response.SC_NO_CONTENT, result);
+ public HeadRequest(Pithos app, Class<T> aClass, String api, String owner, String path, T result) {
+ this(app, aClass, api, owner, path, Response.SC_NO_CONTENT, result);
}
@Override
@Override
public T deserialize(Response response) {
- return Resource.createFromResponse(aClass, owner, response, result);
+ return Resource.createFromResponse(app, aClass, owner, response, result);
}
@Override
HeadRequest.this.onUnauthorized(response);
}
});
+ retries++;
}
catch (RequestException e) {
}