Subversion Repositories eFlore/Applications.coel

Rev

Rev 1415 | Rev 1714 | 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 com.google.gwt.http.client.RequestBuilder;
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 RequestBuilder {

        public JsonRestRequestBuilder(Method httpMethod, String url) {
                super(httpMethod, url);
        }
        
        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;
        }

}