1 23 24 package org.apache.webdav.lib; 25 26 import java.util.ArrayList ; 27 import java.util.Enumeration ; 28 import java.util.HashMap ; 29 import java.util.Vector ; 30 import org.apache.commons.httpclient.HttpState; 31 32 36 public class WebdavState extends HttpState { 37 38 39 41 42 private static final String [] EMPTY_ARRAY = new String [0]; 43 44 45 47 48 51 protected HashMap locks = new HashMap (); 52 53 54 57 protected ArrayList lockTokens = new ArrayList (); 58 59 62 protected String transactionHandle = null; 63 64 66 67 73 public void addLock(String uri, String value) { 74 75 if (value == null) 76 return; 77 78 if (lockTokens.contains(value)) 79 return; 80 81 locks.put(uri, value); 82 lockTokens.add(value); 83 84 } 85 86 87 93 public void removeLock(String uri, String value) { 94 95 locks.remove(uri); 96 int i = lockTokens.indexOf(value); 97 if (i != -1) 98 lockTokens.remove(i); 99 100 } 101 102 103 108 public void removeLocks(String uri) { 109 110 String result = (String ) locks.remove(uri); 111 if (result != null) { 112 int i = lockTokens.indexOf(result); 113 if (i != -1) 114 lockTokens.remove(i); 115 } 116 117 } 118 119 120 125 public String getLock(String uri) { 126 127 return (String ) locks.get(uri); 128 129 } 130 131 132 139 public Enumeration getLocks(String uri) { 140 141 Vector result = new Vector (); 142 String lockToken = getLock(uri); 143 if (lockToken != null) 144 result.addElement(lockToken); 145 return result.elements(); 146 147 } 148 149 150 156 public String [] getAllLocks(String uri) { 157 158 return (String []) lockTokens.toArray(EMPTY_ARRAY); 159 160 } 161 162 public String getTransactionHandle() { 163 return transactionHandle; 164 } 165 166 public void setTransactionHandle(String transactionHandle) { 167 this.transactionHandle = transactionHandle; 168 } 169 } 170 | Popular Tags |