2 * Copyright 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.client.rest.resource;
21 import java.util.Date;
23 import com.google.gwt.json.client.JSONObject;
24 import com.google.gwt.json.client.JSONParser;
29 public class UserResource extends RestResource {
31 public UserResource(String aUri) {
37 private String username;
41 private Date creationDate;
43 private Date modificationDate;
45 private String filesPath;
47 private String trashPath;
49 private String sharedPath;
51 private String othersPath;
53 private String tagsPath;
55 private String groupsPath;
57 private QuotaHolder quota;
59 private String announcement;
61 private Date lastLogin;
68 public String getName() {
75 * @param aName the name to set
77 public void setName(String aName) {
82 * Retrieve the username.
84 * @return the username
86 public String getUsername() {
91 * Modify the username.
93 * @param aUsername the username to set
95 public void setUsername(String aUsername) {
100 * Retrieve the email.
104 public String getEmail() {
111 * @param anEmail the email to set
113 public void setEmail(String anEmail) {
118 * Retrieve the creationDate.
120 * @return the creationDate
122 public Date getCreationDate() {
127 * Modify the creationDate.
129 * @param aCreationDate the creationDate to set
131 public void setCreationDate(Date aCreationDate) {
132 creationDate = aCreationDate;
136 * Retrieve the modificationDate.
138 * @return the modificationDate
140 public Date getModificationDate() {
141 return modificationDate;
145 * Modify the modificationDate.
147 * @param aModificationDate the modificationDate to set
149 public void setModificationDate(Date aModificationDate) {
150 modificationDate = aModificationDate;
154 * Retrieve the filesPath.
156 * @return the filesPath
158 public String getFilesPath() {
163 * Modify the filesPath.
165 * @param aFilesPath the filesPath to set
167 public void setFilesPath(String aFilesPath) {
168 filesPath = aFilesPath;
172 * Retrieve the trashPath.
174 * @return the trashPath
176 public String getTrashPath() {
181 * Modify the trashPath.
183 * @param aTrashPath the trashPath to set
185 public void setTrashPath(String aTrashPath) {
186 trashPath = aTrashPath;
190 * Retrieve the sharedPath.
192 * @return the sharedPath
194 public String getSharedPath() {
199 * Modify the sharedPath.
201 * @param aSharedPath the sharedPath to set
203 public void setSharedPath(String aSharedPath) {
204 sharedPath = aSharedPath;
208 * Retrieve the othersPath.
210 * @return the othersPath
212 public String getOthersPath() {
217 * Modify the othersPath.
219 * @param anOthersPath the othersPath to set
221 public void setOthersPath(String anOthersPath) {
222 othersPath = anOthersPath;
226 * Retrieve the tagsPath.
228 * @return the tagsPath
230 public String getTagsPath() {
235 * Modify the tagsPath.
237 * @param aTagsPath the tagsPath to set
239 public void setTagsPath(String aTagsPath) {
240 tagsPath = aTagsPath;
244 * Retrieve the groupsPath.
246 * @return the groupsPath
248 public String getGroupsPath() {
253 * Modify the groupsPath.
255 * @param aGroupsPath the groupsPath to set
257 public void setGroupsPath(String aGroupsPath) {
258 groupsPath = aGroupsPath;
262 * Retrieve the quota.
266 public QuotaHolder getQuota() {
273 * @param aQuota the quota to set
275 public void setQuota(QuotaHolder aQuota) {
281 * Retrieve the announcement.
283 * @return the announcement
285 public String getAnnouncement() {
290 * Modify the announcement.
292 * @param anAnnouncement the announcement to set
294 public void setAnnouncement(String anAnnouncement) {
295 announcement = anAnnouncement;
299 * Retrieve the lastLogin.
301 * @return the lastLogin
303 public Date getLastLogin() {
308 public void createFromJSON(String text) {
309 JSONObject json = (JSONObject) JSONParser.parse(text);
310 email = unmarshallString(json, "email");
311 name = unmarshallString(json, "name");
312 username = unmarshallString(json, "username");
313 filesPath = unmarshallString(json, "fileroot");
314 groupsPath = unmarshallString(json, "groups");
315 othersPath = unmarshallString(json, "others");
316 sharedPath = unmarshallString(json, "shared");
317 tagsPath = unmarshallString(json, "tags");
318 trashPath = unmarshallString(json, "trash");
319 announcement = unmarshallString(json, "announcement");
320 if (json.get("lastLogin") != null)
321 lastLogin = new Date(new Long(json.get("lastLogin").toString()));
322 if (json.get("creationDate") != null)
323 creationDate = new Date(new Long(json.get("creationDate").toString()));
324 if (json.get("modificationDate") != null)
325 modificationDate = new Date(new Long(json.get("modificationDate").toString()));
326 if (json.get("quota") != null) {
327 JSONObject qj = (JSONObject) json.get("quota");
329 quota = new QuotaHolder();
330 if(qj.get("totalFiles") != null)
331 quota.setFileCount(new Long(qj.get("totalFiles").toString()));
332 if(qj.get("totalBytes") != null)
333 quota.setFileSize(new Long(qj.get("totalBytes").toString()));
334 if(qj.get("bytesRemaining") != null)
335 quota.setQuotaLeftSize(new Long(qj.get("bytesRemaining").toString()));
341 public String toString() {
342 String res = email + "\n" + name + "\n" + username + "\n" + filesPath + "\n" + groupsPath;
347 public String getLastModifiedSince() {