8,6 → 8,11 |
import org.tela_botanica.client.CarnetEnLigneModele; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
|
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.Response; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONBoolean; |
import com.google.gwt.json.client.JSONParser; |
49,10 → 54,21 |
|
// Recherche identifiant utilisateur identifie |
|
HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/", new ResponseTextHandler() { |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/") ; |
|
public void onCompletion(String str) { |
JSONValue jsonValue = JSONParser.parse(str); |
try { |
|
rb.sendRequest(null, new RequestCallback() { |
|
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
|
} |
|
public void onResponseReceived(Request request, |
Response response) { |
|
JSONValue jsonValue = JSONParser.parse(response.getText()); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
String identifiant = ((JSONString) jsonArray.get(0)) |
67,18 → 83,32 |
} |
}); |
|
|
} catch (RequestException e) { |
|
|
} |
} |
|
|
|
public void deconnecterUtilisateur(final Rafraichissable r, String user) { |
|
HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl()+ "/User/" + user , |
new ResponseTextHandler() { |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, carnetEnLigneModele.getConfig().getServiceBaseUrl()+ "/User/" + user) ; |
|
public void onCompletion(String str) { |
try { |
|
JSONValue jsonValue = JSONParser.parse(str); |
rb.sendRequest(null, new RequestCallback() { |
|
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
|
} |
|
public void onResponseReceived(Request request, |
Response response) { |
|
JSONValue jsonValue = JSONParser.parse(response.getText()); |
JSONArray jsonArray; |
if ((jsonArray = jsonValue.isArray()) != null) { |
String identifiant = ((JSONString) jsonArray.get(0)) |
92,19 → 122,34 |
r.rafraichir(new Utilisateur(identifiant, identifie),true); |
} |
} |
|
}); |
|
} catch (RequestException e) { |
|
|
} |
} |
|
|
|
public void connecteUtilisateur (final Rafraichissable r, String login, String password) { |
|
HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/" + login + "/" + password , |
new ResponseTextHandler() { |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/" + login + "/" + password) ; |
|
public void onCompletion(String str) { |
try { |
|
JSONValue jsonValue = JSONParser.parse(str); |
rb.sendRequest(null, new RequestCallback() { |
|
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
|
} |
|
public void onResponseReceived(Request request, |
Response response) { |
|
JSONValue jsonValue = JSONParser.parse(response.getText()); |
JSONArray jsonArray; |
|
if ((jsonArray = jsonValue.isArray()) != null) { |
120,9 → 165,15 |
r.rafraichir(new Utilisateur(identifiant, identifie),true); |
} |
} |
|
|
}); |
|
} catch (RequestException e) { |
|
e.printStackTrace() ; |
} |
} |
|
|
|