1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.danube.webdav.xml.dav.request.properties;
14
15 import org.abstracthorizon.danube.http.HTTPServerConnectionHandler;
16 import org.abstracthorizon.danube.webdav.ResourceAdapter;
17 import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
18 import org.abstracthorizon.danube.webdav.xml.dav.response.properties.ResponseProperty;
19
20 import java.text.ParseException;
21 import java.util.Date;
22
23 import org.xml.sax.SAXException;
24
25
26
27
28
29
30 public class GetLastModified extends RequestProperty {
31
32
33 protected long lastModified;
34
35
36
37
38
39 public GetLastModified(XMLParserHandler parent) {
40 super(parent);
41 }
42
43 @Override
44 public Object end(Object current, String tag, String value) throws SAXException {
45 if ((value != null) && (value.length() >0)) {
46 try {
47 lastModified = HTTPServerConnectionHandler.DATE_FORMAT.parse(value).getTime();
48 } catch (ParseException e) {
49
50 e.printStackTrace();
51 }
52 }
53 return super.end(current, tag, value);
54 }
55
56
57
58
59
60 public long getLastModified() {
61 return lastModified;
62 }
63
64
65
66
67
68
69
70 public ResponseProperty processResponse(ResourceAdapter adapter, Object resource) {
71 return new org.abstracthorizon.danube.webdav.xml.dav.response.properties.GetLastModified(adapter.resourceLastModified(resource));
72 }
73
74
75
76
77
78 public String asString() {
79 return HTTPServerConnectionHandler.DATE_FORMAT.format(new Date(lastModified));
80 }
81
82 @Override
83 public String toString() {
84 if (lastModified != 0) {
85 return "GetLastModified[" + asString() + "]";
86 } else {
87 return "GetLastModified[]";
88 }
89 }
90 }