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 {
34 public UserResource(String path) {
40 private String username;
44 private Date creationDate;
46 private Date modificationDate;
48 private String filesPath;
50 private String trashPath;
52 private String sharedPath;
54 private String othersPath;
56 private String tagsPath;
58 private String groupsPath;
60 private QuotaHolder quota;
67 public String getName() {
74 * @param name the name to set
76 public void setName(String name) {
81 * Retrieve the username.
83 * @return the username
85 public String getUsername() {
90 * Modify the username.
92 * @param username the username to set
94 public void setUsername(String username) {
95 this.username = username;
103 public String getEmail() {
110 * @param email the email to set
112 public void setEmail(String email) {
117 * Retrieve the creationDate.
119 * @return the creationDate
121 public Date getCreationDate() {
126 * Modify the creationDate.
128 * @param creationDate the creationDate to set
130 public void setCreationDate(Date creationDate) {
131 this.creationDate = creationDate;
135 * Retrieve the modificationDate.
137 * @return the modificationDate
139 public Date getModificationDate() {
140 return modificationDate;
144 * Modify the modificationDate.
146 * @param modificationDate the modificationDate to set
148 public void setModificationDate(Date modificationDate) {
149 this.modificationDate = modificationDate;
153 * Retrieve the filesPath.
155 * @return the filesPath
157 public String getFilesPath() {
162 * Modify the filesPath.
164 * @param filesPath the filesPath to set
166 public void setFilesPath(String filesPath) {
167 this.filesPath = filesPath;
171 * Retrieve the trashPath.
173 * @return the trashPath
175 public String getTrashPath() {
180 * Modify the trashPath.
182 * @param trashPath the trashPath to set
184 public void setTrashPath(String trashPath) {
185 this.trashPath = trashPath;
189 * Retrieve the sharedPath.
191 * @return the sharedPath
193 public String getSharedPath() {
198 * Modify the sharedPath.
200 * @param sharedPath the sharedPath to set
202 public void setSharedPath(String sharedPath) {
203 this.sharedPath = sharedPath;
207 * Retrieve the othersPath.
209 * @return the othersPath
211 public String getOthersPath() {
216 * Modify the othersPath.
218 * @param othersPath the othersPath to set
220 public void setOthersPath(String othersPath) {
221 this.othersPath = othersPath;
225 * Retrieve the tagsPath.
227 * @return the tagsPath
229 public String getTagsPath() {
234 * Modify the tagsPath.
236 * @param tagsPath the tagsPath to set
238 public void setTagsPath(String tagsPath) {
239 this.tagsPath = tagsPath;
243 * Retrieve the groupsPath.
245 * @return the groupsPath
247 public String getGroupsPath() {
252 * Modify the groupsPath.
254 * @param groupsPath the groupsPath to set
256 public void setGroupsPath(String groupsPath) {
257 this.groupsPath = groupsPath;
261 * Retrieve the quota.
265 public QuotaHolder getQuota() {
272 * @param quota the quota to set
274 public void setQuota(QuotaHolder quota) {
278 public void createFromJSON(String text) {
279 JSONObject json = (JSONObject) JSONParser.parse(text);
280 email = unmarshallString(json, "email");
281 name = unmarshallString(json, "name");
282 username = unmarshallString(json, "username");
283 filesPath = unmarshallString(json, "files");
284 groupsPath = unmarshallString(json, "groups");
285 othersPath = unmarshallString(json, "others");
286 sharedPath = unmarshallString(json, "shared");
287 tagsPath = unmarshallString(json, "tags");
288 trashPath = unmarshallString(json, "trash");
289 if (json.get("creationDate") != null)
290 creationDate = new Date(new Long(json.get("creationDate").toString()));
291 if (json.get("modificationDate") != null)
292 modificationDate = new Date(new Long(json.get("modificationDate").toString()));
293 if (json.get("quota") != null) {
294 JSONObject qj = (JSONObject) json.get("quota");
296 quota = new QuotaHolder();
297 if(qj.get("totalFiles") != null)
298 quota.setFileCount(new Long(qj.get("totalFiles").toString()));
299 if(qj.get("totalBytes") != null)
300 quota.setFileSize(new Long(qj.get("totalBytes").toString()));
301 if(qj.get("bytesRemaining") != null)
302 quota.setQuotaLeftSize(new Long(qj.get("bytesRemaining").toString()));
308 public String toString() {
309 String res = email + "\n" + name + "\n" + username + "\n" + filesPath + "\n" + groupsPath;