1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.danube.webdav.spring.properties;
14
15 import org.abstracthorizon.danube.http.Status;
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.io.File;
21 import java.io.IOException;
22
23 import org.springframework.core.io.Resource;
24
25
26
27
28
29
30 public class GetLastModified extends org.abstracthorizon.danube.webdav.xml.dav.request.properties.GetLastModified {
31
32
33
34
35
36 public GetLastModified(XMLParserHandler parent) {
37 super(parent);
38 }
39
40
41
42
43
44
45
46 public ResponseProperty processSetProperty(ResourceAdapter adapter, Object resource) {
47 long newTimestamp = getLastModified();
48 Resource res = (Resource)resource;
49 try {
50 File file = res.getFile();
51 long oldTimestamp = file.lastModified();
52 if (newTimestamp != oldTimestamp) {
53 file.setLastModified(newTimestamp);
54 File f = new File(file.getParentFile(), file.getName());
55 if (newTimestamp != f.lastModified()) {
56 return processResponse(adapter, file);
57 }
58 }
59 } catch (IOException ignore) {
60 }
61 return constructResponse(Status.FORBIDDEN);
62 }
63 }
64