1 package com.ibm.webdav; 2 3 15 import java.util.Hashtable ; 16 17 public class WebDAVStatus 18 { 19 private int statusCode = 200; 20 21 private static Hashtable messages = new Hashtable (); 22 23 26 27 29 35 public static final int SC_CONTINUE = 100; 36 37 41 public static final int SC_SWITCHING_PROTOCOLS = 101; 42 43 46 public static final int SC_PROCESSING = 102; 47 48 49 50 52 55 public static final int SC_OK = 200; 56 57 61 public static final int SC_CREATED = 201; 62 63 67 public static final int SC_ACCEPTED = 202; 68 69 73 public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203; 74 75 79 public static final int SC_NO_CONTENT = 204; 80 81 85 public static final int SC_RESET_CONTENT = 205; 86 87 91 public static final int SC_PARTIAL_CONTENT = 206; 92 93 97 public static final int SC_MULTI_STATUS = 207; 98 99 100 101 103 106 public static final int SC_MULTIPLE_CHOICES = 300; 107 108 113 public static final int SC_MOVED_PERMANENTLY = 301; 114 115 120 public static final int SC_MOVED_TEMPORARILY = 302; 121 122 126 public static final int SC_SEE_OTHER = 303; 127 128 132 public static final int SC_NOT_MODIFIED = 304; 133 134 138 public static final int SC_USE_PROXY = 305; 139 140 141 142 144 148 public static final int SC_BAD_REQUEST = 400; 149 150 154 public static final int SC_UNAUTHORIZED = 401; 155 156 159 public static final int SC_PAYMENT_REQUIRED = 402; 160 161 165 public static final int SC_FORBIDDEN = 403; 166 167 171 public static final int SC_NOT_FOUND = 404; 172 173 177 public static final int SC_METHOD_NOT_ALLOWED = 405; 178 179 185 public static final int SC_NOT_ACCEPTABLE = 406; 186 187 191 public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407; 192 193 197 public static final int SC_REQUEST_TIMEOUT = 408; 198 199 204 public static final int SC_CONFLICT = 409; 205 206 210 public static final int SC_GONE = 410; 211 212 216 public static final int SC_LENGTH_REQUIRED = 411; 217 218 223 public static final int SC_PRECONDITION_FAILED = 412; 224 225 230 public static final int SC_REQUEST_TOO_LONG = 413; 231 232 237 public static final int SC_REQUEST_URI_TOO_LONG = 414; 238 239 245 public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415; 246 247 251 public static final int SC_UNPROCESSABLE_ENTITY = 422; 252 253 257 public static final int SC_LOCKED = 423; 258 259 265 public static final int SC_FAILED_DEPENDENCY = 424; 266 267 271 public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 425; 272 273 274 275 279 public static final int SC_NO_SUCH_TARGET = 426; 280 281 282 283 285 289 public static final int SC_INTERNAL_SERVER_ERROR = 500; 290 291 295 public static final int SC_NOT_IMPLEMENTED = 501; 296 297 302 public static final int SC_BAD_GATEWAY = 502; 303 304 308 public static final int SC_SERVICE_UNAVAILABLE = 503; 309 310 315 public static final int SC_GATEWAY_TIMEOUT = 504; 316 317 322 public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505; 323 324 326 static { 327 messages.put(new Integer (SC_CONTINUE), "Continue"); 328 messages.put(new Integer (SC_SWITCHING_PROTOCOLS), "Switching Protocols"); 329 messages.put(new Integer (SC_PROCESSING), "Processing"); 330 messages.put(new Integer (SC_OK), "OK"); 331 messages.put(new Integer (SC_CREATED), "Created"); 332 messages.put(new Integer (SC_ACCEPTED), "Accepted"); 333 messages.put(new Integer (SC_NON_AUTHORITATIVE_INFORMATION), "Non-Authoritative Information"); 334 messages.put(new Integer (SC_NO_CONTENT), "No Content"); 335 messages.put(new Integer (SC_RESET_CONTENT), "Reset Content"); 336 messages.put(new Integer (SC_PARTIAL_CONTENT), "Partial Content"); 337 messages.put(new Integer (SC_MULTI_STATUS), "Multi-Status"); 338 messages.put(new Integer (SC_MULTIPLE_CHOICES), "Multiple Choices"); 339 messages.put(new Integer (SC_MOVED_PERMANENTLY), "Moved Permanently"); 340 messages.put(new Integer (SC_MOVED_TEMPORARILY), "Moved Temporarily"); 341 messages.put(new Integer (SC_SEE_OTHER), "See Other"); 342 messages.put(new Integer (SC_NOT_MODIFIED), "Not Modified"); 343 messages.put(new Integer (SC_USE_PROXY), "Use Proxy"); 344 messages.put(new Integer (SC_BAD_REQUEST), "Bad Request"); 345 messages.put(new Integer (SC_UNAUTHORIZED), "Unauthorized"); 346 messages.put(new Integer (SC_PAYMENT_REQUIRED), "Payment Required"); 347 messages.put(new Integer (SC_FORBIDDEN), "Forbidden"); 348 messages.put(new Integer (SC_NOT_FOUND), "Not Found"); 349 messages.put(new Integer (SC_METHOD_NOT_ALLOWED), "Method Not Allowed"); 350 messages.put(new Integer (SC_NOT_ACCEPTABLE), "Not Acceptable"); 351 messages.put(new Integer (SC_PROXY_AUTHENTICATION_REQUIRED), "Proxy Authentication Required"); 352 messages.put(new Integer (SC_REQUEST_TIMEOUT), "Request Time-out"); 353 messages.put(new Integer (SC_CONFLICT), "Conflict"); 354 messages.put(new Integer (SC_GONE), "Gone"); 355 messages.put(new Integer (SC_LENGTH_REQUIRED), "Length Required"); 356 messages.put(new Integer (SC_PRECONDITION_FAILED), "Precondition Failed"); 357 messages.put(new Integer (SC_REQUEST_TOO_LONG), "Request Entity Too Large"); 358 messages.put(new Integer (SC_REQUEST_URI_TOO_LONG), "Request-URI Too Large"); 359 messages.put(new Integer (SC_UNSUPPORTED_MEDIA_TYPE), "Unsupported Media Type"); 360 messages.put(new Integer (SC_UNPROCESSABLE_ENTITY), "Unprocessable Entity"); 361 messages.put(new Integer (SC_LOCKED), "Locked"); 362 messages.put(new Integer (SC_FAILED_DEPENDENCY), "Failed Dependency"); 363 messages.put(new Integer (SC_INSUFFICIENT_SPACE_ON_RESOURCE), "Inusfficient Space On Resource"); 364 messages.put(new Integer (SC_NO_SUCH_TARGET), "No Such Target"); 365 messages.put(new Integer (SC_INTERNAL_SERVER_ERROR), "Internal Server Error"); 366 messages.put(new Integer (SC_NOT_IMPLEMENTED), "Not Implemented"); 367 messages.put(new Integer (SC_BAD_GATEWAY), "Bad Gateway"); 368 messages.put(new Integer (SC_SERVICE_UNAVAILABLE), "Service Unavailable"); 369 messages.put(new Integer (SC_GATEWAY_TIMEOUT), "Gateway Time-out"); 370 messages.put(new Integer (SC_HTTP_VERSION_NOT_SUPPORTED), "HTTP Version not supported"); 371 } 372 373 374 378 public int getStatusCode() { 379 return statusCode; 380 } 381 385 public String getStatusMessage() { 386 return getStatusMessage(statusCode); 387 } 388 393 public static String getStatusMessage(int statusCode) { 394 String message = "Unknown"; 395 if (statusCode > 0) { 396 message = (String ) messages.get(new Integer (statusCode)); 397 } 398 return message; 399 } 400 404 public void setStatusCode(int newStatusCode) { 405 statusCode = newStatusCode; 406 } 407 411 public String toString() { 412 return new String (getStatusMessage()+'('+statusCode+')'); 413 } 414 } 415 | Popular Tags |