Subversion Repositories eFlore/Applications.del

Rev

Rev 1621 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1621 Rev 1638
Line 1... Line 1...
1
package org.tela_botanica.del.client.services.rest.async;
1
package org.tela_botanica.del.client.services.rest.async;
Line -... Line 2...
-
 
2
 
-
 
3
import java.util.Arrays;
-
 
4
import java.util.List;
2
 
5
 
Line -... Line 6...
-
 
6
import org.tela_botanica.del.client.utils.StringUtils;
3
import org.tela_botanica.del.client.utils.StringUtils;
7
 
4
 
8
import com.google.gwt.core.shared.GWT;
5
import com.google.gwt.http.client.Request;
9
import com.google.gwt.http.client.Request;
6
import com.google.gwt.http.client.RequestCallback;
10
import com.google.gwt.http.client.RequestCallback;
7
import com.google.gwt.http.client.Response;
11
import com.google.gwt.http.client.Response;
Line 32... Line 36...
32
	}
36
	}
Line 33... Line 37...
33
 
37
 
34
	@Override
38
	@Override
35
	public void onResponseReceived(Request request, Response response) {
39
	public void onResponseReceived(Request request, Response response) {
36
		int statusCode = response.getStatusCode();
40
		int statusCode = response.getStatusCode();
37
		int codeAttendu = 500;
41
		List<Integer> codeAttendu = null;
38
		switch (mode) {
42
		switch (mode) {
39
		case AJOUT:
43
		case AJOUT:
40
			codeAttendu = 201;
44
			codeAttendu = Arrays.asList(200, 201, 204);
41
			break;
45
			break;
42
		case MODIFICATION:
46
		case MODIFICATION:
43
			codeAttendu = 200;
47
			codeAttendu = Arrays.asList(200, 201, 204);
44
			break;
48
			break;
45
		case SUPPRESSION:
49
		case SUPPRESSION:
46
			codeAttendu = 200;
50
			codeAttendu = Arrays.asList(200);
47
			break;
51
			break;
48
		case LECTURE:
52
		case LECTURE:
49
			codeAttendu = 200;
53
			codeAttendu = Arrays.asList(200);
50
			break;
54
			break;
51
		default:
55
		default:
52
			codeAttendu = 500;
56
			codeAttendu = Arrays.asList(500);
53
			break;
57
			break;
54
		}
-
 
-
 
58
		}
-
 
59
		GWT.log("Codes attendus:"+codeAttendu.toString());
55
 
60
		GWT.log("Code:"+statusCode);
-
 
61
		if (codeAttendu.contains(statusCode)) {
56
		if (statusCode == codeAttendu) {
62
			GWT.log("Code: OK");
57
			try {
63
			try {
58
				T reponseParsee = parserJSON(response.getText());
64
				T reponseParsee = parserJSON(response.getText());
59
				surRetour(reponseParsee);
65
				surRetour(reponseParsee);
60
			} catch (JSONException e) {
66
			} catch (JSONException e) {
Line 80... Line 86...
80
	}
86
	}
Line 81... Line 87...
81
 
87
 
Line 82... Line 88...
82
	public abstract void surRetour(T objetRetour);
88
	public abstract void surRetour(T objetRetour);
-
 
89
 
83
 
90
	public void surErreur(String messageErreur) {
84
	public void surErreur(String messageErreur) {
91
		GWT.log("Erreur service : "+messageErreur);
85
		Window.alert(messageErreur);
92
		Window.alert(messageErreur);