Subversion Repositories eFlore/Applications.coel

Rev

Go to most recent revision | Details | 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;
7
import com.google.gwt.http.client.RequestBuilder;
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
 
12
public class JsonRestRequestBuilder extends RequestBuilder {
13
 
14
	public JsonRestRequestBuilder(Method httpMethod, String url) {
15
		super(httpMethod, url);
16
	}
17
 
18
	public Request envoyerRequete(String donneesRequete, RequestCallback retour) {
19
		Request requeteSortie = null;
20
		try {
21
			requeteSortie = sendRequest(donneesRequete, retour);
1563 jpm 22
			String m = this.getHTTPMethod()+" : "+this.getUrl();
23
			m += ( donneesRequete != null ? "\n"+URL.decodeQueryString(donneesRequete) : "");
24
			Log.trace(m);
463 jp_milcent 25
		} catch (RequestException e) {
1563 jpm 26
			Log.warn(Mediateur.i18nM.erreurJrest(), e);
463 jp_milcent 27
		}
28
		return requeteSortie;
29
	}
748 jpm 30
 
31
	public Request envoyerRequeteSuppression(RequestCallback retour) {
32
		Request requeteSortie = envoyerRequete("action=DELETE", retour);
33
		return requeteSortie;
34
	}
463 jp_milcent 35
 
36
}