root / web_client / src / gr / grnet / pithos / web / client / rest / resource / UserSearchResource.java @ 9e8e14e4
History | View | Annotate | Download (1.4 kB)
1 |
/*
|
---|---|
2 |
* Copyright (c) 2011 Greek Research and Technology Network
|
3 |
*/
|
4 |
package gr.grnet.pithos.web.client.rest.resource; |
5 |
|
6 |
import java.util.ArrayList; |
7 |
import java.util.List; |
8 |
|
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 |
|
13 |
/**
|
14 |
* A container for the results of a search query for users.
|
15 |
*
|
16 |
*/
|
17 |
public class UserSearchResource extends RestResource { |
18 |
|
19 |
public UserSearchResource(String aUri) { |
20 |
super(aUri);
|
21 |
} |
22 |
|
23 |
List<UserResource> users = new ArrayList<UserResource>(); |
24 |
|
25 |
@Override
|
26 |
public void createFromJSON(String text) { |
27 |
JSONArray json = JSONParser.parse(text).isArray(); |
28 |
if (json != null) |
29 |
for (int i = 0; i < json.size(); i++) { |
30 |
JSONObject j = json.get(i).isObject(); |
31 |
if (j != null) { |
32 |
String username = unmarshallString(j, "username"); |
33 |
String name = unmarshallString(j, "name"); |
34 |
String home = unmarshallString(j, "home"); |
35 |
UserResource user = new UserResource(home);
|
36 |
user.setName(name); |
37 |
user.setUsername(username); |
38 |
users.add(user); |
39 |
} |
40 |
} |
41 |
} |
42 |
|
43 |
/**
|
44 |
* Retrieve the users.
|
45 |
*
|
46 |
* @return the users
|
47 |
*/
|
48 |
public List<UserResource> getUsers() { |
49 |
return users;
|
50 |
} |
51 |
|
52 |
/**
|
53 |
* Modify the users.
|
54 |
*
|
55 |
* @param newUsers the users to set
|
56 |
*/
|
57 |
public void setUsers(List<UserResource> newUsers) { |
58 |
users = newUsers; |
59 |
} |
60 |
|
61 |
@Override
|
62 |
public String getLastModifiedSince() { |
63 |
return null; |
64 |
} |
65 |
} |