Subversion Repositories eFlore/Applications.coel

Rev

Rev 1732 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
463 jp_milcent 1
package org.tela_botanica.client.http;
2
 
846 gduche 3
import org.tela_botanica.client.Mediateur;
1563 jpm 4
import org.tela_botanica.client.util.Log;
846 gduche 5
 
463 jp_milcent 6
import com.google.gwt.http.client.Request;
1732 mathias 7
import org.tela_botanica.client.http.RequestBuilderWithCredentials;
463 jp_milcent 8
import com.google.gwt.http.client.RequestCallback;
9
import com.google.gwt.http.client.RequestException;
1563 jpm 10
import com.google.gwt.http.client.URL;
463 jp_milcent 11
 
1732 mathias 12
public class JsonRestRequestBuilder extends RequestBuilderWithCredentials {
463 jp_milcent 13
 
1906 mathias 14
	// avec header "Authorization"
463 jp_milcent 15
	public JsonRestRequestBuilder(Method httpMethod, String url) {
16
		super(httpMethod, url);
17
	}
1906 mathias 18
 
19
	// ajoute le header "Authorization" si authorizationHeader vaut true
20
	public JsonRestRequestBuilder(Method httpMethod, String url, boolean authorizationHeader) {
21
		super(httpMethod, url, authorizationHeader);
22
	}
463 jp_milcent 23
 
24
	public Request envoyerRequete(String donneesRequete, RequestCallback retour) {
25
		Request requeteSortie = null;
26
		try {
27
			requeteSortie = sendRequest(donneesRequete, retour);
1563 jpm 28
			String m = this.getHTTPMethod()+" : "+this.getUrl();
29
			m += ( donneesRequete != null ? "\n"+URL.decodeQueryString(donneesRequete) : "");
30
			Log.trace(m);
463 jp_milcent 31
		} catch (RequestException e) {
1563 jpm 32
			Log.warn(Mediateur.i18nM.erreurJrest(), e);
463 jp_milcent 33
		}
34
		return requeteSortie;
35
	}
748 jpm 36
 
37
	public Request envoyerRequeteSuppression(RequestCallback retour) {
38
		Request requeteSortie = envoyerRequete("action=DELETE", retour);
39
		return requeteSortie;
40
	}
463 jp_milcent 41
 
42
}