Fixed various compilation warnings
[pithos-web-client] / src / gr / grnet / pithos / web / client / SharingUsers.java
1 package gr.grnet.pithos.web.client;
2
3 import gr.grnet.pithos.web.client.foldertree.Resource;
4
5 import java.util.ArrayList;
6 import java.util.List;
7
8 import com.google.gwt.http.client.Response;
9 import com.google.gwt.json.client.JSONArray;
10 import com.google.gwt.json.client.JSONObject;
11 import com.google.gwt.json.client.JSONParser;
12 import com.google.gwt.json.client.JSONValue;
13
14 public class SharingUsers extends Resource {
15         private List<String> users;
16
17         public static SharingUsers createFromResponse(Response response, SharingUsers result) {
18                 SharingUsers u;
19                 if (result == null)
20                         u = new SharingUsers();
21                 else
22                         u = result;
23                 u.populate(response);
24                 return u;
25         }
26
27         private void populate(Response response) {
28                 users = new ArrayList<String>();
29         JSONValue json = JSONParser.parseStrict(response.getText());
30         JSONArray array = json.isArray();
31         if (array != null) {
32             for (int i=0; i<array.size(); i++) {
33                 JSONObject o = array.get(i).isObject();
34                 if (o != null) {
35                         users.add(unmarshallString(o, "name"));
36                 }
37             }
38         }
39         }
40
41         public List<String> getUsers() {
42                 return users;
43         }
44 }