Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 12 Rev 33
Line 6... Line 6...
6
 */
6
 */
Line 7... Line 7...
7
 
7
 
8
import org.tela_botanica.client.CarnetEnLigneModele;
8
import org.tela_botanica.client.CarnetEnLigneModele;
Line -... Line 9...
-
 
9
import org.tela_botanica.client.interfaces.Rafraichissable;
-
 
10
 
-
 
11
import com.google.gwt.http.client.Request;
-
 
12
import com.google.gwt.http.client.RequestBuilder;
-
 
13
import com.google.gwt.http.client.RequestCallback;
9
import org.tela_botanica.client.interfaces.Rafraichissable;
14
import com.google.gwt.http.client.RequestException;
10
 
15
import com.google.gwt.http.client.Response;
11
import com.google.gwt.json.client.JSONArray;
16
import com.google.gwt.json.client.JSONArray;
12
import com.google.gwt.json.client.JSONBoolean;
17
import com.google.gwt.json.client.JSONBoolean;
13
import com.google.gwt.json.client.JSONParser;
18
import com.google.gwt.json.client.JSONParser;
Line 47... Line 52...
47
	
52
	
Line 48... Line 53...
48
	public void getEtatUtilisateur(final Rafraichissable r) {
53
	public void getEtatUtilisateur(final Rafraichissable r) {
Line 49... Line 54...
49
 
54
 
Line -... Line 55...
-
 
55
		// Recherche identifiant utilisateur identifie
-
 
56
 
-
 
57
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/") ;
-
 
58
		
-
 
59
		try {
-
 
60
			
-
 
61
			rb.sendRequest(null, new RequestCallback() {
-
 
62
 
-
 
63
				public void onError(Request request, Throwable exception) {
50
		// Recherche identifiant utilisateur identifie
64
					// TODO Auto-generated method stub
-
 
65
					
-
 
66
				}
51
 
67
 
52
		HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/", new ResponseTextHandler() {
68
				public void onResponseReceived(Request request,
53
 
69
						Response response) {
54
			public void onCompletion(String str) {
70
					
55
				JSONValue jsonValue = JSONParser.parse(str);
71
					JSONValue jsonValue = JSONParser.parse(response.getText());
56
				JSONArray jsonArray;
72
					JSONArray jsonArray;
Line 65... Line 81...
65
					r.rafraichir(new Utilisateur(identifiant, identifie),true);
81
						r.rafraichir(new Utilisateur(identifiant, identifie),true);
66
				}
82
					}			
67
			}
83
				}			
68
		});
84
			}) ;
Line -... Line 85...
-
 
85
			
-
 
86
			
-
 
87
		} catch (RequestException e) {
-
 
88
			
-
 
89
			
69
 
90
		}
Line 70... Line 91...
70
	}
91
	}
Line 71... Line 92...
71
 
92
 
-
 
93
 
-
 
94
 
-
 
95
	public void deconnecterUtilisateur(final Rafraichissable r, String user) {
72
 
96
 
-
 
97
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, carnetEnLigneModele.getConfig().getServiceBaseUrl()+ "/User/" + user) ;
-
 
98
		
-
 
99
		try {
-
 
100
			
-
 
101
			rb.sendRequest(null, new RequestCallback() {
Line 73... Line 102...
73
 
102
 
-
 
103
				public void onError(Request request, Throwable exception) {
Line 74... Line 104...
74
	public void deconnecterUtilisateur(final Rafraichissable r, String user) {
104
					// TODO Auto-generated method stub
75
 
105
					
76
		HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl()+ "/User/" + user    ,
106
				}
77
				new ResponseTextHandler() {
107
 
78
 
108
				public void onResponseReceived(Request request,
79
					public void onCompletion(String str) {
109
						Response response) {
Line 90... Line 120...
90
													// deja identifie
120
											// deja identifie
Line 91... Line 121...
91
								
121
						
92
							r.rafraichir(new Utilisateur(identifiant, identifie),true);
122
					r.rafraichir(new Utilisateur(identifiant, identifie),true);
93
							}
123
					}				
-
 
124
				}			
94
					}
125
				
-
 
126
			}) ;
-
 
127
			
-
 
128
		} catch (RequestException e) {
-
 
129
			
-
 
130
			
95
		});
131
		}
Line 96... Line 132...
96
	}
132
	}
Line 97... Line 133...
97
 
133
 
-
 
134
 
-
 
135
 
-
 
136
	public void connecteUtilisateur (final Rafraichissable r, String login, String password) {
98
 
137
		
Line 99... Line 138...
99
 
138
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/" + login + "/" + password) ;
-
 
139
		
Line -... Line 140...
-
 
140
		try {
-
 
141
			
-
 
142
			rb.sendRequest(null, new RequestCallback() {
-
 
143
 
-
 
144
				public void onError(Request request, Throwable exception) {
100
	public void connecteUtilisateur (final Rafraichissable r, String login, String password) {
145
					// TODO Auto-generated method stub
101
 
146
					
Line 102... Line 147...
102
		HTTPRequest.asyncGet(carnetEnLigneModele.getConfig().getServiceBaseUrl() + "/User/" + login + "/" + password ,
147
				}
103
				new ResponseTextHandler() {
148
 
104
 
149
				public void onResponseReceived(Request request,
Line 118... Line 163...
118
							
163
						
119
 
164
 
120
							r.rafraichir(new Utilisateur(identifiant, identifie),true);
165
						r.rafraichir(new Utilisateur(identifiant, identifie),true);
-
 
166
					}				
-
 
167
				}
121
						}
168
				
Line -... Line 169...
-
 
169
				
-
 
170
			}) ;
-
 
171
			
-
 
172
		} catch (RequestException e) {
122
					}
173