Subversion Repositories eFlore/Applications.cel

Rev

Rev 2 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 5
Line 15... Line 15...
15
import com.google.gwt.user.client.HTTPRequest;
15
import com.google.gwt.user.client.HTTPRequest;
16
import com.google.gwt.user.client.ResponseTextHandler;
16
import com.google.gwt.user.client.ResponseTextHandler;
Line 17... Line 17...
17
 
17
 
Line 18... Line -...
18
public class UtilisateurAsynchroneDAO {
-
 
19
 
-
 
20
	
18
public class UtilisateurAsynchroneDAO {
21
	
19
 
22
	/**
20
	/**
23
	 * Constructeur 
21
	 * Constructeur
24
	 */
22
	 */
25
	
23
 
26
	public UtilisateurAsynchroneDAO() {		
-
 
27
	}
24
	public UtilisateurAsynchroneDAO() {
28
	
-
 
29
	
25
	}
30
	
26
 
-
 
27
	/**
-
 
28
	 * Methode de classe d'appel du service gestion identification
31
	/**
29
	 * 
-
 
30
	 * @param baseURL :
32
	 * Methode de classe d'appel du service gestion identification 
31
	 *            URL du service
33
	 * @param baseURL : URL du service
32
	 * @param retour :
34
	 * @param retour : methode appelle en retour d'appel
33
	 *            methode appelle en retour d'appel
35
	 */
34
	 */
Line 36... Line 35...
36
	
35
 
Line 37... Line 36...
37
	public void getUtilisateur(String baseURL, final iRetourUtilisateur retour) {
36
	public void getUtilisateur(String baseURL, final iRetourUtilisateur retour) {
Line 44... Line 43...
44
				JSONValue jsonValue = JSONParser.parse(str);
43
				JSONValue jsonValue = JSONParser.parse(str);
45
				JSONArray jsonArray;
44
				JSONArray jsonArray;
46
				if ((jsonArray = jsonValue.isArray()) != null) {
45
				if ((jsonArray = jsonValue.isArray()) != null) {
47
					String identifiant = ((JSONString) jsonArray.get(0))
46
					String identifiant = ((JSONString) jsonArray.get(0))
48
							.stringValue(); // Identifiant utilisateur ou
47
							.stringValue(); // Identifiant utilisateur ou
49
											// identifiant de session si non
48
					// identifiant de session si non
50
											// identifie
49
					// identifie
51
					boolean identifie = ((JSONBoolean) jsonArray.get(1))
50
					boolean identifie = ((JSONBoolean) jsonArray.get(1))
52
							.booleanValue(); // Drapeau leve si utilisateur
51
							.booleanValue(); // Drapeau leve si utilisateur
53
												// deja identifie
52
					// deja identifie
54
					retour.onRetour(new Utilisateur(identifiant, identifie));
53
					retour.onRetour(new Utilisateur(identifiant, identifie));
55
				}
54
				}
56
			}
55
			}
57
		});
56
		});
Line 58... Line 57...
58
 
57
 
Line -... Line 58...
-
 
58
	}
-
 
59
 
Line 59... Line -...
59
	}
-
 
60
 
-
 
61
 
-
 
62
 
60
	public void deconnecterUtilisateur(String baseURL,
63
	public void deconnecterUtilisateur(String baseURL, final iRetourUtilisateur retour, String user) {
61
			final iRetourUtilisateur retour, String user) {
Line 64... Line 62...
64
 
62
 
65
		HTTPRequest.asyncGet(baseURL + "/User/" + user    ,
-
 
66
				new ResponseTextHandler() {
-
 
67
 
-
 
68
					public void onCompletion(String str) {
-
 
69
						
-
 
70
							JSONValue jsonValue = JSONParser.parse(str);
-
 
71
							JSONArray jsonArray;
-
 
72
							if ((jsonArray = jsonValue.isArray()) != null) {
-
 
73
								String identifiant = ((JSONString) jsonArray.get(0))
-
 
74
								.stringValue(); // Identifiant utilisateur ou
-
 
75
												// identifiant de session si non
-
 
76
												// identifie
-
 
Line -... Line 63...
-
 
63
		HTTPRequest.asyncGet(baseURL + "/User/" + user,
-
 
64
				new ResponseTextHandler() {
-
 
65
 
-
 
66
					public void onCompletion(String str) {
-
 
67
 
-
 
68
						JSONValue jsonValue = JSONParser.parse(str);
-
 
69
						JSONArray jsonArray;
-
 
70
						if ((jsonArray = jsonValue.isArray()) != null) {
-
 
71
							String identifiant = ((JSONString) jsonArray.get(0))
-
 
72
									.stringValue(); // Identifiant utilisateur
-
 
73
													// ou
-
 
74
							// identifiant de session si non
-
 
75
							// identifie
77
								boolean identifie = ((JSONBoolean) jsonArray.get(1))
76
							boolean identifie = ((JSONBoolean) jsonArray.get(1))
-
 
77
									.booleanValue(); // Drapeau leve si
78
								.booleanValue(); // Drapeau leve si utilisateur
78
														// utilisateur
79
													// deja identifie
79
							// deja identifie
80
								
80
 
81
 
81
							retour.onRetour(new Utilisateur(identifiant,
Line -... Line 82...
-
 
82
									identifie));
-
 
83
						}
Line 82... Line -...
82
							retour.onRetour(new Utilisateur(identifiant, identifie));
-
 
83
							}
-
 
84
					}
-
 
85
		});
84
					}
86
	}
85
				});
Line 87... Line 86...
87
 
86
	}
88
 
87
 
89
 
88
	public void connecteUtilisateur(String baseURL,
90
	public void connecteUtilisateur(String baseURL,final iRetourUtilisateur retour, String login, String password) {
89
			final iRetourUtilisateur retour, String login, String password) {
91
 
90
 
92
		HTTPRequest.asyncGet(baseURL + "/User/" + login + "/" + password ,
91
		HTTPRequest.asyncGet(baseURL + "/User/" + login + "/" + password,
93
				new ResponseTextHandler() {
92
				new ResponseTextHandler() {
94
 
93
 
-
 
94
					public void onCompletion(String str) {
95
					public void onCompletion(String str) {
95
 
96
			
96
						JSONValue jsonValue = JSONParser.parse(str);
97
						JSONValue jsonValue = JSONParser.parse(str);
97
						JSONArray jsonArray;
98
						JSONArray jsonArray;
98
 
-
 
99
						if ((jsonArray = jsonValue.isArray()) != null) {
99
						
100
							String identifiant = ((JSONString) jsonArray.get(0))
100
						if ((jsonArray = jsonValue.isArray()) != null) {
-
 
Line 101... Line 101...
101
							String identifiant = ((JSONString) jsonArray.get(0))
101
									.stringValue(); // Identifiant utilisateur
-
 
102
													// ou
102
							.stringValue(); // Identifiant utilisateur ou
103
							// identifiant de session si non
103
											// identifiant de session si non
104
							// identifie
104
											// identifie
105
							boolean identifie = ((JSONBoolean) jsonArray.get(1))
Line 105... Line 106...
105
							boolean identifie = ((JSONBoolean) jsonArray.get(1))
106
									.booleanValue(); // Drapeau leve si