root / src / gr / ebs / gss / server / domain / dto / FileHeaderDTO.java @ 16b54aa8
History | View | Annotate | Download (7.7 kB)
1 |
/*
|
---|---|
2 |
* Copyright 2007, 2008, 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.server.domain.dto; |
20 |
|
21 |
import java.io.Serializable; |
22 |
import java.util.List; |
23 |
import java.util.Set; |
24 |
|
25 |
import javax.persistence.Column; |
26 |
|
27 |
import com.google.gwt.i18n.client.NumberFormat; |
28 |
|
29 |
/**
|
30 |
* @author chstath
|
31 |
*/
|
32 |
public class FileHeaderDTO implements Serializable { |
33 |
|
34 |
/**
|
35 |
* The path for the resource manipulation subsystem.
|
36 |
*/
|
37 |
public static final String PATH_FILES = "/files"; |
38 |
|
39 |
/**
|
40 |
* The serial version UID.
|
41 |
*/
|
42 |
private static final long serialVersionUID = 1L; |
43 |
|
44 |
/**
|
45 |
* The persistence ID of the object.
|
46 |
*/
|
47 |
private Long id; |
48 |
|
49 |
/**
|
50 |
* The file name.
|
51 |
*/
|
52 |
private String name; |
53 |
|
54 |
/**
|
55 |
* The file path.
|
56 |
*/
|
57 |
private String path; |
58 |
|
59 |
/**
|
60 |
* Is this a versioned file?
|
61 |
*/
|
62 |
private boolean versioned; |
63 |
|
64 |
/**
|
65 |
* The current version
|
66 |
*/
|
67 |
private int version = 0; |
68 |
|
69 |
/**
|
70 |
* The owner of this file.
|
71 |
*/
|
72 |
private UserDTO owner;
|
73 |
|
74 |
/**
|
75 |
* The folder that contains this file.
|
76 |
*/
|
77 |
private FolderDTO folder;
|
78 |
|
79 |
/**
|
80 |
* The size of the file
|
81 |
*/
|
82 |
private long fileSize; |
83 |
|
84 |
/**
|
85 |
* The MIME type of this file.
|
86 |
*/
|
87 |
private String mimeType; |
88 |
|
89 |
/**
|
90 |
* The original filename (with which file was uploaded).
|
91 |
*/
|
92 |
private String originalFilename; |
93 |
|
94 |
/**
|
95 |
* The original filename URL-encoded.
|
96 |
*/
|
97 |
private String originalFilenameEncoded; |
98 |
|
99 |
/**
|
100 |
* The audit information for this object.
|
101 |
*/
|
102 |
private AuditInfoDTO auditInfo;
|
103 |
|
104 |
/**
|
105 |
* A list of tags (Strings).
|
106 |
*
|
107 |
*
|
108 |
*/
|
109 |
private List<String> tags; |
110 |
|
111 |
private Set<PermissionDTO> permissions; |
112 |
/**
|
113 |
* is this file deleted?
|
114 |
*/
|
115 |
private boolean deleted=false; |
116 |
/**
|
117 |
* Anyone can read this file?
|
118 |
*/
|
119 |
private boolean readForAll=false; |
120 |
|
121 |
|
122 |
private Boolean shared=false; |
123 |
/**
|
124 |
* @return the id
|
125 |
*/
|
126 |
public Long getId() { |
127 |
return id;
|
128 |
} |
129 |
|
130 |
/**
|
131 |
* @param newId the id to set
|
132 |
*/
|
133 |
public void setId(final Long newId) { |
134 |
id = newId; |
135 |
} |
136 |
|
137 |
/**
|
138 |
* @return the name
|
139 |
*/
|
140 |
public String getName() { |
141 |
return name;
|
142 |
} |
143 |
|
144 |
/**
|
145 |
* @param newName the name to set
|
146 |
*/
|
147 |
public void setName(final String newName) { |
148 |
name = newName; |
149 |
} |
150 |
|
151 |
/**
|
152 |
* @return the versioned
|
153 |
*/
|
154 |
public boolean isVersioned() { |
155 |
return versioned;
|
156 |
} |
157 |
|
158 |
/**
|
159 |
* @param newVersioned the versioned to set
|
160 |
*/
|
161 |
public void setVersioned(final boolean newVersioned) { |
162 |
versioned = newVersioned; |
163 |
} |
164 |
|
165 |
/**
|
166 |
* @return the owner
|
167 |
*/
|
168 |
public UserDTO getOwner() {
|
169 |
return owner;
|
170 |
} |
171 |
|
172 |
/**
|
173 |
* @param newOwner the owner to set
|
174 |
*/
|
175 |
public void setOwner(final UserDTO newOwner) { |
176 |
owner = newOwner; |
177 |
} |
178 |
|
179 |
/**
|
180 |
* @return the version
|
181 |
*/
|
182 |
public int getVersion() { |
183 |
return version;
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* @param newVersion the version to set
|
188 |
*/
|
189 |
public void setVersion(final int newVersion) { |
190 |
version = newVersion; |
191 |
} |
192 |
|
193 |
/**
|
194 |
* @return the fileSize
|
195 |
*/
|
196 |
public long getFileSize() { |
197 |
return fileSize;
|
198 |
} |
199 |
|
200 |
/**
|
201 |
* @param newFileSize the fileSize to set
|
202 |
*/
|
203 |
public void setFileSize(final long newFileSize) { |
204 |
fileSize = newFileSize; |
205 |
} |
206 |
|
207 |
/**
|
208 |
* Return the file size in a humanly readable form, using SI units to denote
|
209 |
* size information, e.g. 1 KB = 1000 B (bytes).
|
210 |
*
|
211 |
* @return the fileSize
|
212 |
*/
|
213 |
public String getFileSizeAsString() { |
214 |
if (fileSize < 1024) |
215 |
return String.valueOf(fileSize) + " B"; |
216 |
else if (fileSize <= 1024*1024) |
217 |
return getSize(fileSize, 1024D) + " KB"; |
218 |
else if (fileSize <= 1024*1024*1024) |
219 |
return getSize(fileSize,(1024D*1024D)) + " MB"; |
220 |
return getSize(fileSize , (1024D*1024D*1024D)) + " GB"; |
221 |
} |
222 |
|
223 |
private String getSize(Long size, Double division){ |
224 |
Double res = Double.valueOf(size.toString())/division; |
225 |
NumberFormat nf = NumberFormat.getFormat("######.###"); |
226 |
return nf.format(res);
|
227 |
} |
228 |
|
229 |
/**
|
230 |
* Retrieve the auditInfo.
|
231 |
*
|
232 |
* @return the auditInfo
|
233 |
*/
|
234 |
public AuditInfoDTO getAuditInfo() {
|
235 |
return auditInfo;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* Modify the auditInfo.
|
240 |
*
|
241 |
* @param newAuditInfo the auditInfo to set
|
242 |
*/
|
243 |
public void setAuditInfo(final AuditInfoDTO newAuditInfo) { |
244 |
auditInfo = newAuditInfo; |
245 |
} |
246 |
|
247 |
/**
|
248 |
* Retrieve the tags.
|
249 |
*
|
250 |
* @return the tags
|
251 |
*/
|
252 |
public List<String> getTags() { |
253 |
return tags;
|
254 |
} |
255 |
|
256 |
/**
|
257 |
* Modify the tags.
|
258 |
*
|
259 |
* @param newTags the tags to set
|
260 |
*/
|
261 |
public void setTags(List<String> newTags) { |
262 |
tags = newTags; |
263 |
} |
264 |
|
265 |
/**
|
266 |
* Retrieve the mimeType.
|
267 |
*
|
268 |
* @return the mimeType
|
269 |
*/
|
270 |
public String getMimeType() { |
271 |
return mimeType;
|
272 |
} |
273 |
|
274 |
/**
|
275 |
* Modify the mimeType.
|
276 |
*
|
277 |
* @param newMimeType the mimeType to set
|
278 |
*/
|
279 |
public void setMimeType(String newMimeType) { |
280 |
mimeType = newMimeType; |
281 |
} |
282 |
|
283 |
/**
|
284 |
* Retrieve the originalFilename.
|
285 |
*
|
286 |
* @return the originalFilename
|
287 |
*/
|
288 |
public String getOriginalFilename() { |
289 |
return originalFilename;
|
290 |
} |
291 |
|
292 |
/**
|
293 |
* Modify the originalFilename.
|
294 |
*
|
295 |
* @param newOriginalFilename the originalFilename to set
|
296 |
*/
|
297 |
public void setOriginalFilename(String newOriginalFilename) { |
298 |
originalFilename = newOriginalFilename; |
299 |
} |
300 |
|
301 |
/**
|
302 |
* Retrieve the originalFilenameEncoded.
|
303 |
*
|
304 |
* @return the originalFilenameEncoded
|
305 |
*/
|
306 |
public String getOriginalFilenameEncoded() { |
307 |
return originalFilenameEncoded;
|
308 |
} |
309 |
|
310 |
/**
|
311 |
* Modify the originalFilenameEncoded.
|
312 |
*
|
313 |
* @param newOriginalFilenameEncoded the originalFilenameEncoded to set
|
314 |
*/
|
315 |
public void setOriginalFilenameEncoded(String newOriginalFilenameEncoded) { |
316 |
originalFilenameEncoded = newOriginalFilenameEncoded; |
317 |
} |
318 |
|
319 |
/**
|
320 |
* Retrieve the deleted.
|
321 |
*
|
322 |
* @return the deleted
|
323 |
*/
|
324 |
public boolean isDeleted() { |
325 |
return deleted;
|
326 |
} |
327 |
|
328 |
/**
|
329 |
* Modify the deleted.
|
330 |
*
|
331 |
* @param newDeleted the deleted to set
|
332 |
*/
|
333 |
public void setDeleted(boolean newDeleted) { |
334 |
deleted = newDeleted; |
335 |
} |
336 |
|
337 |
/**
|
338 |
* Retrieve the readForAll.
|
339 |
*
|
340 |
* @return the readForAll
|
341 |
*/
|
342 |
public boolean isReadForAll() { |
343 |
return readForAll;
|
344 |
} |
345 |
|
346 |
/**
|
347 |
* Modify the readForAll.
|
348 |
*
|
349 |
* @param aReadForAll the readForAll to set
|
350 |
*/
|
351 |
public void setReadForAll(boolean aReadForAll) { |
352 |
readForAll = aReadForAll; |
353 |
} |
354 |
|
355 |
/**
|
356 |
* Retrieve the path.
|
357 |
*
|
358 |
* @return the path
|
359 |
*/
|
360 |
public String getPath() { |
361 |
return path;
|
362 |
} |
363 |
|
364 |
/**
|
365 |
* Modify the path.
|
366 |
*
|
367 |
* @param aPath the path to set
|
368 |
*/
|
369 |
public void setPath(String aPath) { |
370 |
path = aPath; |
371 |
} |
372 |
|
373 |
/**
|
374 |
* Retrieve the URI for this resource, relative to the REST API root URI.
|
375 |
* This unique identifier can be used to refer to the resource from
|
376 |
* various GSS clients.
|
377 |
*
|
378 |
* @return the URI
|
379 |
*/
|
380 |
public String getURI() { |
381 |
return owner.getUsername() + PATH_FILES + getPath();
|
382 |
} |
383 |
|
384 |
/**
|
385 |
* Retrieve the folder.
|
386 |
*
|
387 |
* @return the folder
|
388 |
*/
|
389 |
public FolderDTO getFolder() {
|
390 |
return folder;
|
391 |
} |
392 |
|
393 |
/**
|
394 |
* Modify the folder.
|
395 |
*
|
396 |
* @param aFolder the folder to set
|
397 |
*/
|
398 |
public void setFolder(FolderDTO aFolder) { |
399 |
folder = aFolder; |
400 |
} |
401 |
|
402 |
/**
|
403 |
* Modify the permissions.
|
404 |
*
|
405 |
* @param newPermissions the permissions to set
|
406 |
*/
|
407 |
public void setPermissions(Set<PermissionDTO> newPermissions) { |
408 |
permissions = newPermissions; |
409 |
} |
410 |
|
411 |
/**
|
412 |
* Retrieve the permissions.
|
413 |
*
|
414 |
* @return the permissions
|
415 |
*/
|
416 |
public Set<PermissionDTO> getPermissions() { |
417 |
return permissions;
|
418 |
} |
419 |
|
420 |
/**
|
421 |
* Retrieve the shared.
|
422 |
*
|
423 |
* @return the shared
|
424 |
*/
|
425 |
public Boolean getShared() { |
426 |
return shared;
|
427 |
} |
428 |
|
429 |
|
430 |
/**
|
431 |
* Modify the shared.
|
432 |
*
|
433 |
* @param shared the shared to set
|
434 |
*/
|
435 |
public void setShared(Boolean shared) { |
436 |
this.shared = shared;
|
437 |
} |
438 |
} |