Statistics
| Branch: | Tag: | Revision:

root / src / org / gss_project / gss / web / client / rest / resource / UserResource.java @ 83c3bc8e

History | View | Annotate | Download (7 kB)

1
/*
2
 * Copyright 2009 Electronic Business Systems Ltd.
3
 *
4
 * This file is part of GSS.
5
 *
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.
10
 *
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.
15
 *
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/>.
18
 */
19
package org.gss_project.gss.web.client.rest.resource;
20

    
21
import java.util.Date;
22

    
23
import com.google.gwt.json.client.JSONObject;
24
import com.google.gwt.json.client.JSONParser;
25

    
26
/**
27
 * @author kman
28
 */
29
public class UserResource extends RestResource {
30

    
31
        public UserResource(String aUri) {
32
                super(aUri);
33
        }
34

    
35
        private String name;
36

    
37
        private String username;
38

    
39
        private String email;
40

    
41
        private Date creationDate;
42

    
43
        private Date modificationDate;
44

    
45
        private String filesPath;
46

    
47
        private String trashPath;
48

    
49
        private String sharedPath;
50

    
51
        private String othersPath;
52

    
53
        private String tagsPath;
54

    
55
        private String groupsPath;
56

    
57
        private QuotaHolder quota;
58

    
59
        private String announcement;
60

    
61
        private Date lastLogin;
62
        
63
        private Date currentLogin;
64

    
65
        /**
66
         * Retrieve the name.
67
         *
68
         * @return the name
69
         */
70
        @Override
71
        public String getName() {
72
                return name;
73
        }
74

    
75
        /**
76
         * Modify the name.
77
         *
78
         * @param aName the name to set
79
         */
80
        public void setName(String aName) {
81
                name = aName;
82
        }
83

    
84
        /**
85
         * Retrieve the username.
86
         *
87
         * @return the username
88
         */
89
        public String getUsername() {
90
                return username;
91
        }
92

    
93
        /**
94
         * Modify the username.
95
         *
96
         * @param aUsername the username to set
97
         */
98
        public void setUsername(String aUsername) {
99
                username = aUsername;
100
        }
101

    
102
        /**
103
         * Retrieve the email.
104
         *
105
         * @return the email
106
         */
107
        public String getEmail() {
108
                return email;
109
        }
110

    
111
        /**
112
         * Modify the email.
113
         *
114
         * @param anEmail the email to set
115
         */
116
        public void setEmail(String anEmail) {
117
                email = anEmail;
118
        }
119

    
120
        /**
121
         * Retrieve the creationDate.
122
         *
123
         * @return the creationDate
124
         */
125
        public Date getCreationDate() {
126
                return creationDate;
127
        }
128

    
129
        /**
130
         * Modify the creationDate.
131
         *
132
         * @param aCreationDate the creationDate to set
133
         */
134
        public void setCreationDate(Date aCreationDate) {
135
                creationDate = aCreationDate;
136
        }
137

    
138
        /**
139
         * Retrieve the modificationDate.
140
         *
141
         * @return the modificationDate
142
         */
143
        public Date getModificationDate() {
144
                return modificationDate;
145
        }
146

    
147
        /**
148
         * Modify the modificationDate.
149
         *
150
         * @param aModificationDate the modificationDate to set
151
         */
152
        public void setModificationDate(Date aModificationDate) {
153
                modificationDate = aModificationDate;
154
        }
155

    
156
        /**
157
         * Retrieve the filesPath.
158
         *
159
         * @return the filesPath
160
         */
161
        public String getFilesPath() {
162
                return filesPath;
163
        }
164

    
165
        /**
166
         * Modify the filesPath.
167
         *
168
         * @param aFilesPath the filesPath to set
169
         */
170
        public void setFilesPath(String aFilesPath) {
171
                filesPath = aFilesPath;
172
        }
173

    
174
        /**
175
         * Retrieve the trashPath.
176
         *
177
         * @return the trashPath
178
         */
179
        public String getTrashPath() {
180
                return trashPath;
181
        }
182

    
183
        /**
184
         * Modify the trashPath.
185
         *
186
         * @param aTrashPath the trashPath to set
187
         */
188
        public void setTrashPath(String aTrashPath) {
189
                trashPath = aTrashPath;
190
        }
191

    
192
        /**
193
         * Retrieve the sharedPath.
194
         *
195
         * @return the sharedPath
196
         */
197
        public String getSharedPath() {
198
                return sharedPath;
199
        }
200

    
201
        /**
202
         * Modify the sharedPath.
203
         *
204
         * @param aSharedPath the sharedPath to set
205
         */
206
        public void setSharedPath(String aSharedPath) {
207
                sharedPath = aSharedPath;
208
        }
209

    
210
        /**
211
         * Retrieve the othersPath.
212
         *
213
         * @return the othersPath
214
         */
215
        public String getOthersPath() {
216
                return othersPath;
217
        }
218

    
219
        /**
220
         * Modify the othersPath.
221
         *
222
         * @param anOthersPath the othersPath to set
223
         */
224
        public void setOthersPath(String anOthersPath) {
225
                othersPath = anOthersPath;
226
        }
227

    
228
        /**
229
         * Retrieve the tagsPath.
230
         *
231
         * @return the tagsPath
232
         */
233
        public String getTagsPath() {
234
                return tagsPath;
235
        }
236

    
237
        /**
238
         * Modify the tagsPath.
239
         *
240
         * @param aTagsPath the tagsPath to set
241
         */
242
        public void setTagsPath(String aTagsPath) {
243
                tagsPath = aTagsPath;
244
        }
245

    
246
        /**
247
         * Retrieve the groupsPath.
248
         *
249
         * @return the groupsPath
250
         */
251
        public String getGroupsPath() {
252
                return groupsPath;
253
        }
254

    
255
        /**
256
         * Modify the groupsPath.
257
         *
258
         * @param aGroupsPath the groupsPath to set
259
         */
260
        public void setGroupsPath(String aGroupsPath) {
261
                groupsPath = aGroupsPath;
262
        }
263

    
264
        /**
265
         * Retrieve the quota.
266
         *
267
         * @return the quota
268
         */
269
        public QuotaHolder getQuota() {
270
                return quota;
271
        }
272

    
273
        /**
274
         * Modify the quota.
275
         *
276
         * @param aQuota the quota to set
277
         */
278
        public void setQuota(QuotaHolder aQuota) {
279
                quota = aQuota;
280
        }
281

    
282

    
283
        /**
284
         * Retrieve the announcement.
285
         *
286
         * @return the announcement
287
         */
288
        public String getAnnouncement() {
289
                return announcement;
290
        }
291

    
292
        /**
293
         * Modify the announcement.
294
         *
295
         * @param anAnnouncement the announcement to set
296
         */
297
        public void setAnnouncement(String anAnnouncement) {
298
                announcement = anAnnouncement;
299
        }
300

    
301
        /**
302
         * Retrieve the lastLogin.
303
         *
304
         * @return the lastLogin
305
         */
306
        public Date getLastLogin() {
307
                return lastLogin;
308
        }
309

    
310
        /**
311
         * Retrieve the currentLogin.
312
         *
313
         * @return the currentLogin
314
         */
315
        public Date getCurrentLogin() {
316
                return currentLogin;
317
        }
318

    
319
        @Override
320
        public void createFromJSON(String text) {
321
                JSONObject json = (JSONObject) JSONParser.parse(text);
322
                email = unmarshallString(json, "email");
323
                name = unmarshallString(json, "name");
324
                username = unmarshallString(json, "username");
325
                filesPath = unmarshallString(json, "fileroot");
326
                groupsPath = unmarshallString(json, "groups");
327
                othersPath = unmarshallString(json, "others");
328
                sharedPath = unmarshallString(json, "shared");
329
                tagsPath = unmarshallString(json, "tags");
330
                trashPath = unmarshallString(json, "trash");
331
                announcement = unmarshallString(json, "announcement");
332
                if (json.get("lastLogin") != null)
333
                        lastLogin = new Date(new Long(json.get("lastLogin").toString()));
334
                if (json.get("currentLogin") != null)
335
                        currentLogin = new Date(new Long(json.get("currentLogin").toString()));                        
336
                if (json.get("creationDate") != null)
337
                        creationDate = new Date(new Long(json.get("creationDate").toString()));
338
                if (json.get("modificationDate") != null)
339
                        modificationDate = new Date(new Long(json.get("modificationDate").toString()));
340
                if (json.get("quota") != null) {
341
                        JSONObject qj = (JSONObject) json.get("quota");
342
                        if (qj != null) {
343
                                quota = new QuotaHolder();
344
                                if(qj.get("totalFiles") != null)
345
                                        quota.setFileCount(new Long(qj.get("totalFiles").toString()));
346
                                if(qj.get("totalBytes") != null)
347
                                        quota.setFileSize(new Long(qj.get("totalBytes").toString()));
348
                                if(qj.get("bytesRemaining") != null)
349
                                        quota.setQuotaLeftSize(new Long(qj.get("bytesRemaining").toString()));
350
                        }
351
                }
352
        }
353

    
354
        @Override
355
        public String toString() {
356
                String res = email + "\n" + name + "\n" + username + "\n" + filesPath + "\n" + groupsPath;
357
                return res;
358
        }
359

    
360
        @Override
361
        public String getLastModifiedSince() {
362
                return null;
363
        }
364
}