Subversion Repositories eFlore/Applications.del

Rev

Rev 1496 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.del.client.services.rest;

import org.tela_botanica.del.client.config.Config;
import org.tela_botanica.del.client.services.rest.async.UtilisateurCallback;
import org.tela_botanica.del.client.services.rest.async.PHPCallback.ModeRequete;

import org.tela_botanica.del.client.services.RequestBuilderWithCredentials;

public class UtilisateurServiceConcret implements UtilisateurService {
        
        private String baseUrl;
        
        public UtilisateurServiceConcret() {
                this(new Config());
        }
        
        public UtilisateurServiceConcret(Config config) {
                this.baseUrl = config.getUrl("serviceUtilisateursBaseUrl");
        }
        
        @Override
        public void connecterUtilisateur(String login, String motDePasse, UtilisateurCallback callback) {
                RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.GET, baseUrl + "utilisateurs/" + login + "/" + motDePasse);
                callback.setMode(ModeRequete.LECTURE);
                try {
                        rb.sendRequest(null, callback);
                } catch (Exception e) {
                        // TODO: handle exception
                }
        }

        @Override
        public void deconnecterUtilisateur(UtilisateurCallback callback) {
                RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.GET, baseUrl + "utilisateurs/deconnecter");
                callback.setMode(ModeRequete.LECTURE);
                try {
                        rb.sendRequest(null, callback);
                } catch (Exception e) {
                        // TODO: handle exception
                }
        }

        @Override
        public void obtenirUtilisateur(UtilisateurCallback callback) {
                RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.GET, baseUrl + "utilisateurs/");
                callback.setMode(ModeRequete.LECTURE);
                try {
                        rb.sendRequest(null, callback);
                } catch (Exception e) {
                        // TODO: handle exception
                }
        }

}