1f71f3c9ee10bf77e4eeeda52350ae8cc6b3c769
[pithos-web-client] / src / gr / grnet / pithos / web / client / Invitations.java
1 package gr.grnet.pithos.web.client;
2
3 import java.util.Date;
4
5 import com.google.gwt.http.client.Response;
6 import com.google.gwt.json.client.JSONObject;
7 import com.google.gwt.json.client.JSONParser;
8 import com.google.gwt.json.client.JSONValue;
9
10 import gr.grnet.pithos.web.client.foldertree.Resource;
11
12 public class Invitations extends Resource {
13
14         private int invitationsLeft = 0;
15         
16         @Override
17         public Date getLastModified() {
18                 return null;
19         }
20
21         public int getInvitationsLeft() {
22                 return invitationsLeft;
23         }
24
25         public void setInvitationsLeft(int invitationsLeft) {
26                 this.invitationsLeft = invitationsLeft;
27         }
28
29         public static Invitations createFromResponse(Response response) {
30                 Invitations result = new Invitations();
31                 result.populate(response);
32                 return result;
33         }
34
35         private void populate(Response response) {
36         JSONValue json = JSONParser.parseStrict(response.getText());
37         JSONObject o = json.isObject();
38         if (o != null)
39                 invitationsLeft = unmarshallInt(o, "invitations");
40         }
41
42 }