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.webdav.ResourceAdapter;
16 import org.abstracthorizon.danube.webdav.lock.LockingMechanism;
17 import org.abstracthorizon.danube.webdav.xml.XMLParserHandler;
18 import org.abstracthorizon.danube.webdav.xml.dav.DAVFactory;
19 import org.abstracthorizon.danube.webdav.xml.dav.request.LockEntry;
20 import org.abstracthorizon.danube.webdav.xml.dav.response.properties.ResponseProperty;
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import org.xml.sax.Attributes;
26 import org.xml.sax.SAXException;
27
28
29
30
31
32
33 public class SupportedLock extends RequestProperty {
34
35
36 protected DAVFactory davFactory;
37
38
39 protected List<LockEntry> lockEntries = new ArrayList<LockEntry>();
40
41
42
43
44
45
46 public SupportedLock(XMLParserHandler parent, DAVFactory factory) {
47 super(parent);
48 this.davFactory = factory;
49 }
50
51 @Override
52 public Object start(Object current, String tag, Attributes attributes) throws SAXException {
53 if ("lockentry".equals(tag)) {
54 LockEntry lockEntry = davFactory.newLockEntry(this);
55 lockEntries.add(lockEntry);
56 return lockEntry;
57 } else {
58 return super.start(current, tag, attributes);
59 }
60 }
61
62
63
64
65
66
67
68 public ResponseProperty processResponse(ResourceAdapter adapter, Object resource) {
69 LockingMechanism lockingMechanism = adapter.getLockingMechanism();
70 int[] scopes = lockingMechanism.getSupportedLockScopes(resource);
71 return new org.abstracthorizon.danube.webdav.xml.dav.response.properties.SupportedLock(scopes);
72 }
73
74 @Override
75 public String toString() {
76 StringBuffer res = new StringBuffer("SupportedLock[");
77 for (LockEntry lockEntry : lockEntries) {
78 res.append(lockEntry.toString());
79 }
80 res.append(']');
81 return res.toString();
82 }
83 }