|
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.text.SimpleDateFormat; |
|
29 |
| import java.util.Locale; |
|
30 |
| import java.util.Date; |
|
31 |
| import java.util.TimeZone; |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| public class LastModified implements DAVProperty { |
|
49 |
| private static final String MODIFICATION_TIME = "getlastmodified"; |
|
50 |
| private static final String DATE_FORMAT = "EEE, dd MMM yyyy HH:mm:ss zzz"; |
|
51 |
| private static final Log log = LogFactory.getLog(LastModified.class); |
|
52 |
| |
|
53 |
2
| public String getName() {
|
|
54 |
2
| return MODIFICATION_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
| if (meta == null) {
|
|
65 |
0
| return null;
|
|
66 |
| } |
|
67 |
| |
|
68 |
8
| long date = meta.getLastModifiedTime();
|
|
69 |
8
| if (date != 0) {
|
|
70 |
8
| SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US);
|
|
71 |
8
| sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
|
72 |
8
| return new PartialResponse.Content(MODIFICATION_TIME, sdf.format(new Date(date)));
|
|
73 |
| } |
|
74 |
| |
|
75 |
| } catch (DBException e) { |
|
76 |
0
| log.error("Getting last modified time for collection " + col.getCanonicalName() + " failed", e);
|
|
77 |
0
| return null;
|
|
78 |
| } |
|
79 |
| |
|
80 |
0
| return null;
|
|
81 |
| } |
|
82 |
| |
|
83 |
5
| public PartialResponse.Content getProperty(Entry entry) {
|
|
84 |
5
| long date = entry.getModificationTime();
|
|
85 |
5
| if (date != 0) {
|
|
86 |
5
| SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT, Locale.US);
|
|
87 |
5
| sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
|
88 |
5
| return new PartialResponse.Content(MODIFICATION_TIME, sdf.format(new Date(date)));
|
|
89 |
| } else { |
|
90 |
0
| return null;
|
|
91 |
| } |
|
92 |
| } |
|
93 |
| |
|
94 |
| } |