1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package org.apache.xindice.webadmin.webdav.components.props; |
19 |
| |
20 |
| import org.apache.xindice.core.Collection; |
21 |
| import org.apache.xindice.core.DBException; |
22 |
| import org.apache.xindice.core.data.Entry; |
23 |
| import org.apache.xindice.core.meta.MetaData; |
24 |
| import org.apache.xindice.webadmin.PartialResponse; |
25 |
| import org.apache.commons.logging.Log; |
26 |
| import org.apache.commons.logging.LogFactory; |
27 |
| |
28 |
| import java.util.Date; |
29 |
| import java.util.Locale; |
30 |
| import java.util.TimeZone; |
31 |
| import java.text.SimpleDateFormat; |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| public class CreationDate implements DAVProperty { |
49 |
| private static final String CREATION_TIME = "creationdate"; |
50 |
| private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; |
51 |
| private static final Log log = LogFactory.getLog(CreationDate.class); |
52 |
| |
53 |
2
| public String getName() {
|
54 |
2
| return CREATION_TIME;
|
55 |
| } |
56 |
| |
57 |
0
| public PartialResponse.Content getRootProperty() {
|
58 |
0
| return null;
|
59 |
| } |
60 |
| |
61 |
8
| public PartialResponse.Content getProperty(Collection col) {
|
62 |
8
| try {
|
63 |
8
| MetaData meta = col.getCollectionMeta();
|
64 |
8
| long date = meta.getCreatedTime();
|
65 |
8
| if (date != 0) {
|
66 |
8
| SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US);
|
67 |
8
| sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
68 |
8
| return new PartialResponse.Content(CREATION_TIME, sdf.format(new Date(date)));
|
69 |
| } |
70 |
| } catch (DBException e) { |
71 |
0
| log.error("Getting creation time for collection " + col.getCanonicalName() + " failed", e);
|
72 |
0
| return null;
|
73 |
| } |
74 |
| |
75 |
0
| return null;
|
76 |
| } |
77 |
| |
78 |
5
| public PartialResponse.Content getProperty(Entry entry) {
|
79 |
5
| long date = entry.getCreationTime();
|
80 |
5
| if (date != 0) {
|
81 |
5
| SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US);
|
82 |
5
| sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
83 |
5
| return new PartialResponse.Content(CREATION_TIME, sdf.format(new Date(date)));
|
84 |
| } else { |
85 |
| |
86 |
0
| return null;
|
87 |
| } |
88 |
| } |
89 |
| |
90 |
| } |