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.Status;
16 import org.abstracthorizon.danube.webdav.ResourceAdapter;
17 import org.abstracthorizon.danube.webdav.lock.Lock;
18 import org.abstracthorizon.danube.webdav.lock.LockingMechanism;
19 import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
20 import org.abstracthorizon.danube.webdav.xml.dav.response.properties.ResponseProperty;
21
22 import org.xml.sax.SAXException;
23
24
25
26
27
28
29 public class LockDiscovery extends RequestProperty {
30
31
32
33
34
35 public LockDiscovery(XMLParserHandler parent) {
36 super(parent);
37 }
38
39 @Override
40 public Object end(Object current, String tag, String value) throws SAXException {
41 return super.end(current, tag, value);
42 }
43
44 @Override
45 public String toString() {
46 return "LockDiscovery[]";
47 }
48
49
50
51
52
53
54
55 public ResponseProperty processResponse(ResourceAdapter adapter, Object resource) {
56 LockingMechanism lockingMechanism = adapter.getLockingMechanism();
57 if (lockingMechanism != null) {
58 Lock[] locks = lockingMechanism.getLocks(resource);
59 org.abstracthorizon.danube.webdav.xml.dav.response.properties.LockDiscovery lockDiscovery = new org.abstracthorizon.danube.webdav.xml.dav.response.properties.LockDiscovery(Status.OK);
60 if ((locks != null) && (locks.length > 0)) {
61 for (Lock l : locks) {
62 lockDiscovery.getLocks().add(l);
63 }
64 }
65 return lockDiscovery;
66 } else {
67 return super.processResponse(adapter, resource);
68 }
69 }
70 }