Subversion Repositories eFlore/Applications.coel

Rev

Rev 1563 | 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 {

        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;
        }

}