1 23 24 package org.apache.webdav.lib; 25 26 import org.apache.webdav.lib.methods.DepthSupport; 27 28 33 public class Lock { 34 35 36 38 39 42 public static final String TAG_NAME = "activelock"; 43 44 45 48 public static final int TYPE_WRITE = 0; 49 50 53 public static final int TYPE_TRANSACTION = 1; 54 55 56 59 public static final int SCOPE_EXCLUSIVE = 0; 60 61 62 65 public static final int SCOPE_SHARED = 1; 66 67 68 70 71 74 public Lock(int lockScope, int lockType) { 75 this.lockScope = lockScope; 76 this.lockType = lockType; 77 } 78 79 80 83 public Lock(int lockScope, int lockType, int depth, String owner, 84 int timeout, String lockToken) { 85 this.lockScope = lockScope; 86 this.lockType = lockType; 87 this.depth = depth; 88 this.owner = owner; 89 this.timeout = timeout; 90 this.lockToken = lockToken; 91 } 92 93 public Lock(int lockScope, int lockType, int depth, String owner, 94 int timeout, String lockToken, String principalUrl) { 95 this.lockScope = lockScope; 96 this.lockType = lockType; 97 this.depth = depth; 98 this.owner = owner; 99 this.timeout = timeout; 100 this.lockToken = lockToken; 101 this.principalUrl = principalUrl; 102 } 103 104 108 public Lock(int lockScope, int lockType, int depth, String owner, 109 long timeout, String lockToken) { 110 this(lockScope, lockType, depth, owner, (int) timeout, lockToken); 111 } 112 113 114 116 117 protected int lockScope = -1; 118 119 120 protected int lockType = -1; 121 122 123 protected int depth = -1; 124 125 126 protected String owner = null; 127 128 129 protected int timeout = -1; 130 131 132 protected String lockToken = null; 133 134 protected String principalUrl = null; 135 136 137 139 140 145 public int getLockScope() { 146 return lockScope; 147 } 148 149 150 155 public int getLockType() { 156 return lockType; 157 } 158 159 160 165 public int getDepth() { 166 return depth; 167 } 168 169 170 175 public String getOwner() { 176 return owner; 177 } 178 179 183 public String getPrincipalUrl() { 184 return principalUrl; 185 } 186 187 188 193 public int getTimeout() { 194 return timeout; 195 } 196 197 198 203 public String getLockToken() { 204 return lockToken; 205 } 206 207 public String toString() { 208 StringBuffer tmp=new StringBuffer (); 209 210 if (lockScope==Lock.SCOPE_EXCLUSIVE) { 211 tmp.append("Exclusive"); 212 } 213 else if (lockScope==Lock.SCOPE_SHARED) { 214 tmp.append("Shared"); 215 } 216 217 if (lockType==Lock.TYPE_WRITE) { 218 tmp.append(" write lock"); 219 } 220 221 if (depth==DepthSupport.DEPTH_INFINITY) { 222 tmp.append(" depth:infinity"); 223 } 224 else if (depth==-1) { 225 } 227 else { 228 tmp.append(" depth:" + depth); 229 } 230 231 if (owner!=null) 232 tmp.append(" owner:" + owner); 233 234 if (timeout!=-1) 235 tmp.append(" timeout:" + timeout); 236 237 if (lockToken!=null) 238 tmp.append(" token:" + lockToken); 239 240 return tmp.toString(); 241 } 242 243 } 244 | Popular Tags |