Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / client / rest / resource / UserResource.java @ 0e64bec2

History | View | Annotate | Download (6.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 gr.ebs.gss.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
        /**
64
         * Retrieve the name.
65
         *
66
         * @return the name
67
         */
68
        public String getName() {
69
                return name;
70
        }
71

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

    
81
        /**
82
         * Retrieve the username.
83
         *
84
         * @return the username
85
         */
86
        public String getUsername() {
87
                return username;
88
        }
89

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

    
99
        /**
100
         * Retrieve the email.
101
         *
102
         * @return the email
103
         */
104
        public String getEmail() {
105
                return email;
106
        }
107

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

    
117
        /**
118
         * Retrieve the creationDate.
119
         *
120
         * @return the creationDate
121
         */
122
        public Date getCreationDate() {
123
                return creationDate;
124
        }
125

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

    
135
        /**
136
         * Retrieve the modificationDate.
137
         *
138
         * @return the modificationDate
139
         */
140
        public Date getModificationDate() {
141
                return modificationDate;
142
        }
143

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

    
153
        /**
154
         * Retrieve the filesPath.
155
         *
156
         * @return the filesPath
157
         */
158
        public String getFilesPath() {
159
                return filesPath;
160
        }
161

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

    
171
        /**
172
         * Retrieve the trashPath.
173
         *
174
         * @return the trashPath
175
         */
176
        public String getTrashPath() {
177
                return trashPath;
178
        }
179

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

    
189
        /**
190
         * Retrieve the sharedPath.
191
         *
192
         * @return the sharedPath
193
         */
194
        public String getSharedPath() {
195
                return sharedPath;
196
        }
197

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

    
207
        /**
208
         * Retrieve the othersPath.
209
         *
210
         * @return the othersPath
211
         */
212
        public String getOthersPath() {
213
                return othersPath;
214
        }
215

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

    
225
        /**
226
         * Retrieve the tagsPath.
227
         *
228
         * @return the tagsPath
229
         */
230
        public String getTagsPath() {
231
                return tagsPath;
232
        }
233

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

    
243
        /**
244
         * Retrieve the groupsPath.
245
         *
246
         * @return the groupsPath
247
         */
248
        public String getGroupsPath() {
249
                return groupsPath;
250
        }
251

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

    
261
        /**
262
         * Retrieve the quota.
263
         *
264
         * @return the quota
265
         */
266
        public QuotaHolder getQuota() {
267
                return quota;
268
        }
269

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

    
279

    
280
        /**
281
         * Retrieve the announcement.
282
         *
283
         * @return the announcement
284
         */
285
        public String getAnnouncement() {
286
                return announcement;
287
        }
288

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

    
298
        /**
299
         * Retrieve the lastLogin.
300
         *
301
         * @return the lastLogin
302
         */
303
        public Date getLastLogin() {
304
                return lastLogin;
305
        }
306

    
307
        @Override
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");
328
                        if (qj != null) {
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()));
336
                        }
337
                }
338
        }
339

    
340
        @Override
341
        public String toString() {
342
                String res = email + "\n" + name + "\n" + username + "\n" + filesPath + "\n" + groupsPath;
343
                return res;
344
        }
345

    
346
        @Override
347
        public String getLastModifiedSince() {
348
                return null;
349
        }
350
}