1 23 24 package org.apache.webdav.lib.util; 25 26 import java.util.Hashtable ; 27 28 public class WebdavStatus { 29 30 31 33 34 private static Hashtable mapStatusCodes = new Hashtable (); 35 36 37 39 40 public static String getStatusText(int nHttpStatusCode) { 41 Integer intKey = new Integer (nHttpStatusCode); 42 43 if (!mapStatusCodes.containsKey(intKey)) { 44 return null; 46 47 } else { 48 return (String ) mapStatusCodes.get(intKey); 49 } 50 } 51 52 53 55 56 private static void addStatusCodeMap(int nKey, String strVal) { 57 mapStatusCodes.put(new Integer (nKey), strVal); 58 } 59 60 61 63 64 public static final int SC_CONTINUE = 100; 65 public static final int SC_SWITCHING_PROTOCOLS = 101; 66 public static final int SC_PROCESSING = 102; 67 68 public static final int SC_OK = 200; 69 public static final int SC_CREATED = 201; 70 public static final int SC_ACCEPTED = 202; 71 public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203; 72 public static final int SC_NO_CONTENT = 204; 73 public static final int SC_RESET_CONTENT = 205; 74 public static final int SC_PARTIAL_CONTENT = 206; 75 public static final int SC_MULTI_STATUS = 207; 76 public static final int SC_ALREADY_REPORTED = 208; 79 80 public static final int SC_MULTIPLE_CHOICES = 300; 81 public static final int SC_MOVED_PERMANENTLY = 301; 82 public static final int SC_MOVED_TEMPORARILY = 302; 83 public static final int SC_SEE_OTHER = 303; 84 public static final int SC_NOT_MODIFIED = 304; 85 public static final int SC_USE_PROXY = 305; 86 87 public static final int SC_BAD_REQUEST = 400; 88 public static final int SC_UNAUTHORIZED = 401; 89 public static final int SC_PAYMENT_REQUIRED = 402; 90 public static final int SC_FORBIDDEN = 403; 91 public static final int SC_NOT_FOUND = 404; 92 public static final int SC_METHOD_NOT_ALLOWED = 405; 93 public static final int SC_NOT_ACCEPTABLE = 406; 94 public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407; 95 public static final int SC_REQUEST_TIMEOUT = 408; 96 public static final int SC_CONFLICT = 409; 97 public static final int SC_GONE = 410; 98 public static final int SC_LENGTH_REQUIRED = 411; 99 public static final int SC_PRECONDITION_FAILED = 412; 100 public static final int SC_REQUEST_TOO_LONG = 413; 101 public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415; 102 public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416; 103 public static final int SC_EXPECTATION_FAILED = 417; 104 public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419; 108 public static final int SC_METHOD_FAILURE = 420; 111 public static final int SC_UNPROCESSABLE_ENTITY = 422; 112 public static final int SC_LOCKED = 423; 113 public static final int SC_FAILED_DEPENDENCY = 424; 114 115 public static final int SC_INTERNAL_SERVER_ERROR = 500; 116 public static final int SC_NOT_IMPLEMENTED = 501; 117 public static final int SC_BAD_GATEWAY = 502; 118 public static final int SC_SERVICE_UNAVAILABLE = 503; 119 public static final int SC_GATEWAY_TIMEOUT = 504; 120 public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505; 121 public static final int SC_LOOP_DETECTED = 506; 122 public static final int SC_INSUFFICIENT_STORAGE = 507; 123 124 125 127 128 static { 129 addStatusCodeMap(SC_OK, "OK"); 131 addStatusCodeMap(SC_CREATED, "Created"); 132 addStatusCodeMap(SC_ACCEPTED, "Accepted"); 133 addStatusCodeMap(SC_NO_CONTENT, "No Content"); 134 addStatusCodeMap(SC_MOVED_PERMANENTLY, "Moved Permanently"); 135 addStatusCodeMap(SC_MOVED_TEMPORARILY, "Moved Temporarily"); 136 addStatusCodeMap(SC_NOT_MODIFIED, "Not Modified"); 137 addStatusCodeMap(SC_BAD_REQUEST, "Bad Request"); 138 addStatusCodeMap(SC_UNAUTHORIZED, "Unauthorized"); 139 addStatusCodeMap(SC_FORBIDDEN, "Forbidden"); 140 addStatusCodeMap(SC_NOT_FOUND, "Not Found"); 141 addStatusCodeMap(SC_INTERNAL_SERVER_ERROR, "Internal Server Error"); 142 addStatusCodeMap(SC_NOT_IMPLEMENTED, "Not Implemented"); 143 addStatusCodeMap(SC_BAD_GATEWAY, "Bad Gateway"); 144 addStatusCodeMap(SC_SERVICE_UNAVAILABLE, "Service Unavailable"); 145 146 addStatusCodeMap(SC_CONTINUE, "Continue"); 148 addStatusCodeMap(SC_METHOD_NOT_ALLOWED, "Method Not Allowed"); 149 addStatusCodeMap(SC_CONFLICT, "Conflict"); 150 addStatusCodeMap(SC_PRECONDITION_FAILED, "Precondition Failed"); 151 addStatusCodeMap(SC_REQUEST_TOO_LONG, "Request Too Long"); 152 addStatusCodeMap(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type"); 153 154 addStatusCodeMap(SC_SWITCHING_PROTOCOLS, "Switching Protocols"); 155 addStatusCodeMap(SC_NON_AUTHORITATIVE_INFORMATION, 156 "Non Authoritative Information"); 157 addStatusCodeMap(SC_RESET_CONTENT, "Reset Content"); 158 addStatusCodeMap(SC_GATEWAY_TIMEOUT, "Gateway Timeout"); 159 addStatusCodeMap(SC_HTTP_VERSION_NOT_SUPPORTED, 160 "Http Version Not Supported"); 161 162 addStatusCodeMap(SC_PROCESSING, "Processing"); 164 addStatusCodeMap(SC_MULTI_STATUS, "Multi-Status"); 165 addStatusCodeMap(SC_UNPROCESSABLE_ENTITY, "Unprocessable Entity"); 166 addStatusCodeMap(SC_INSUFFICIENT_SPACE_ON_RESOURCE, 167 "Insufficient Space On Resource"); 168 addStatusCodeMap(SC_METHOD_FAILURE, "Method Failure"); 169 addStatusCodeMap(SC_LOCKED, "Locked"); 170 addStatusCodeMap(SC_LOOP_DETECTED, "Loop Detected"); 171 addStatusCodeMap(SC_INSUFFICIENT_STORAGE , "Insufficient Storage"); 172 addStatusCodeMap(SC_FAILED_DEPENDENCY, "Failed Dependency"); 173 } 174 175 176 } 177 | Popular Tags |