Rev 1732 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.http;
import org.tela_botanica.client.Mediateur;
import org.tela_botanica.client.util.Log;
import com.google.gwt.http.client.Request;
import org.tela_botanica.client.http.RequestBuilderWithCredentials;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.URL;
public class JsonRestRequestBuilder extends RequestBuilderWithCredentials {
// avec header "Authorization"
public JsonRestRequestBuilder(Method httpMethod, String url) {
super(httpMethod, url);
}
// ajoute le header "Authorization" si authorizationHeader vaut true
public JsonRestRequestBuilder(Method httpMethod, String url, boolean authorizationHeader) {
super(httpMethod, url, authorizationHeader);
}
public Request envoyerRequete(String donneesRequete, RequestCallback retour) {
Request requeteSortie = null;
try {
requeteSortie = sendRequest(donneesRequete, retour);
String m = this.getHTTPMethod()+" : "+this.getUrl();
m += ( donneesRequete != null ? "\n"+URL.decodeQueryString(donneesRequete) : "");
Log.trace(m);
} catch (RequestException e) {
Log.warn(Mediateur.i18nM.erreurJrest(), e);
}
return requeteSortie;
}
public Request envoyerRequeteSuppression(RequestCallback retour) {
Request requeteSortie = envoyerRequete("action=DELETE", retour);
return requeteSortie;
}
}