Subversion Repositories eFlore/Applications.cel

Rev

Rev 676 | Rev 965 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 676 Rev 937
Line 13... Line 13...
13
import com.google.gwt.http.client.RequestCallback;
13
import com.google.gwt.http.client.RequestCallback;
14
import com.google.gwt.http.client.RequestException;
14
import com.google.gwt.http.client.RequestException;
15
import com.google.gwt.http.client.Response;
15
import com.google.gwt.http.client.Response;
16
import com.google.gwt.json.client.JSONArray;
16
import com.google.gwt.json.client.JSONArray;
17
import com.google.gwt.json.client.JSONBoolean;
17
import com.google.gwt.json.client.JSONBoolean;
-
 
18
import com.google.gwt.json.client.JSONObject;
18
import com.google.gwt.json.client.JSONParser;
19
import com.google.gwt.json.client.JSONParser;
19
import com.google.gwt.json.client.JSONString;
20
import com.google.gwt.json.client.JSONString;
20
import com.google.gwt.json.client.JSONValue;
21
import com.google.gwt.json.client.JSONValue;
21
import com.google.gwt.user.client.Window;
22
import com.google.gwt.user.client.Window;
Line 22... Line 23...
22
 
23
 
Line 23... Line -...
23
public class UtilisateurAsynchroneDAO {
-
 
24
 
-
 
25
	
-
 
26
	
24
public class UtilisateurAsynchroneDAO {
27
	
25
 
28
	/**
26
	/**
29
	 * Le modèle associé au DAO
27
	 * Le modèle associé au DAO
Line 30... Line 28...
30
	 */
28
	 */
31
	private CarnetEnLigneModele carnetEnLigneModele = null ;
29
	private CarnetEnLigneModele carnetEnLigneModele = null ;
32
	
30
	
Line 33... Line 31...
33
	/**
31
	/**
34
	 * Constructeur 
-
 
35
	 */
32
	 * Constructeur 
36
	
-
 
37
	public UtilisateurAsynchroneDAO(CarnetEnLigneModele carnetEnLigneModele) {
33
	 */
38
		
-
 
39
		this.carnetEnLigneModele=carnetEnLigneModele;
-
 
40
		
-
 
41
	}
-
 
42
	
34
	
43
	
35
	public UtilisateurAsynchroneDAO(CarnetEnLigneModele carnetEnLigneModele) {		
44
	
36
		this.carnetEnLigneModele=carnetEnLigneModele;
45
	
37
	}
46
	/**
38
	/**
Line 69... Line 61...
69
					if(response.getText().isEmpty()) {
61
					if(response.getText().isEmpty()) {
70
						Window.alert("Impossible de contacter le serveur, veuillez vérifier la configuration du cel ou contacter un administrateur");
62
						Window.alert("Impossible de contacter le serveur, veuillez vérifier la configuration du cel ou contacter un administrateur");
71
					} else {
63
					} else {
Line 72... Line 64...
72
										
64
										
73
						JSONValue jsonValue = JSONParser.parse(response.getText());
65
						JSONValue jsonValue = JSONParser.parse(response.getText());
74
						JSONArray jsonArray;
-
 
75
						
-
 
76
						if ((jsonArray = jsonValue.isArray()) != null) {
-
 
77
							String identifiant = ((JSONString) jsonArray.get(0))
-
 
78
									.stringValue(); // Identifiant utilisateur ou
-
 
79
													// identifiant de session si non
-
 
80
													// identifie
-
 
81
							boolean identifie = ((JSONBoolean) jsonArray.get(1))
-
 
82
									.booleanValue(); // Drapeau leve si utilisateur
-
 
83
														// deja identifie
-
 
84
							boolean isAdmin = ((JSONBoolean) jsonArray.get(2))
-
 
85
							.booleanValue(); // Drapeau leve si utilisateur
-
 
86
												// est admin
-
 
87
							
-
 
88
							boolean licenceAcceptee = ((JSONBoolean) jsonArray.get(3))
-
 
89
							.booleanValue(); // Drapeau leve si utilisateur
-
 
Line 90... Line 66...
90
												// a accepte licence
66
						JSONObject objetJsonUtilisateur;
91
							
-
 
Line -... Line 67...
-
 
67
						
92
							Utilisateur utilisateur = new Utilisateur(identifiant, identifie, isAdmin);
68
						if ((objetJsonUtilisateur = jsonValue.isObject()) != null) {
93
							utilisateur.setLicenceAcceptee(licenceAcceptee);
69
							
94
							
70
							Utilisateur utilisateur = Utilisateur.InitialiserInstance(objetJsonUtilisateur);
95
							r.rafraichir(utilisateur,true);
71
							r.rafraichir(utilisateur,true);
96
						}
72
						}
Line 97... Line -...
97
					}
-
 
98
				}			
73
					}
Line 99... Line -...
99
			}) ;
-
 
100
			
74
				}			
101
			
75
			}) ;
Line 122... Line 96...
122
 
96
 
123
				public void onResponseReceived(Request request,
97
				public void onResponseReceived(Request request,
Line 124... Line 98...
124
						Response response) {
98
						Response response) {
125
					
99
					
126
					JSONValue jsonValue = JSONParser.parse(response.getText());
-
 
127
					JSONArray jsonArray;
-
 
128
					if ((jsonArray = jsonValue.isArray()) != null) {
-
 
129
						String identifiant = ((JSONString) jsonArray.get(0))
-
 
130
						.stringValue(); // Identifiant utilisateur ou
-
 
131
										// identifiant de session si non
-
 
132
										// identifie
-
 
133
						boolean identifie = ((JSONBoolean) jsonArray.get(1))
-
 
134
						.booleanValue(); // Drapeau leve si utilisateur
-
 
Line 135... Line 100...
135
						
100
					JSONValue jsonValue = JSONParser.parse(response.getText());
136
											// deja identifie
-
 
Line -... Line 101...
-
 
101
					JSONObject objetJsonUtilisateur;
137
						
102
					
138
						Utilisateur utilisateur = new Utilisateur(identifiant, identifie);
103
					if ((objetJsonUtilisateur = jsonValue.isObject()) != null) {
139
						utilisateur.setLicenceAcceptee(false);
104
						
140
						
-
 
141
					r.rafraichir(utilisateur,true);
105
						Utilisateur utilisateur = Utilisateur.InitialiserInstance(objetJsonUtilisateur);
Line 142... Line 106...
142
					}				
106
						r.rafraichir(utilisateur,true);
Line 143... Line -...
143
				}			
-
 
144
				
107
					}		
145
			}) ;
108
				}			
Line 146... Line -...
146
			
-
 
147
		} catch (RequestException e) {
-
 
148
			
109
			}) ;
Line 149... Line 110...
149
			
110
			
Line 150... Line 111...
150
		}
111
		} catch (RequestException e) {
Line 167... Line 128...
167
 
128
 
168
				public void onResponseReceived(Request request,
129
				public void onResponseReceived(Request request,
Line 169... Line 130...
169
						Response response) {
130
						Response response) {
170
					
131
					
171
					JSONValue jsonValue = JSONParser.parse(response.getText());
-
 
172
					JSONArray jsonArray;
-
 
173
					
-
 
174
					if ((jsonArray = jsonValue.isArray()) != null) {
-
 
175
						String identifiant = ((JSONString) jsonArray.get(0))
-
 
176
						.stringValue(); // Identifiant utilisateur ou
-
 
177
										// identifiant de session si non
-
 
178
										// identifie
-
 
179
						boolean identifie = ((JSONBoolean) jsonArray.get(1))
-
 
180
						.booleanValue(); // Drapeau leve si utilisateur
-
 
181
											// deja identifie
-
 
182
						boolean isAdmin = ((JSONBoolean) jsonArray.get(2))
-
 
183
						.booleanValue(); // Drapeau leve si utilisateur
-
 
184
											// est admin
-
 
185
						
-
 
186
						boolean licenceAcceptee = ((JSONBoolean) jsonArray.get(3))
-
 
187
						.booleanValue(); // Drapeau leve si utilisateur
-
 
188
											// a accepte licence
-
 
189
						
-
 
Line -... Line 132...
-
 
132
					JSONValue jsonValue = JSONParser.parse(response.getText());
Line -... Line 133...
-
 
133
					JSONObject objetJsonUtilisateur;
190
						Utilisateur utilisateur = new Utilisateur(identifiant, identifie, isAdmin);
134
					
191
						utilisateur.setLicenceAcceptee(licenceAcceptee);
135
					if ((objetJsonUtilisateur = jsonValue.isObject()) != null) {
192
						
136
						
Line 221... Line 165...
221
 
165
 
222
				public void onResponseReceived(Request request,
166
				public void onResponseReceived(Request request,
Line 223... Line 167...
223
						Response response) {
167
						Response response) {
224
			
-
 
225
				}
-
 
226
				
168
			
Line 227... Line 169...
227
				
169
				}	
Line 228... Line 170...
228
			}) ;
170
			}) ;
229
			
171
			
230
		} catch (RequestException e) {
-
 
231
			
172
		} catch (RequestException e) {
232
			e.printStackTrace() ;
-
 
233
		}
-
 
234
		
-
 
235
	}
-
 
236
 
173