KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webdav > lib > util > WebdavStatus


1 /*
2  * $Header: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/util/WebdavStatus.java,v 1.1 2004/08/02 15:45:49 unico Exp $
3  * $Revision: 1.1 $
4  * $Date: 2004/08/02 15:45:49 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.webdav.lib.util;
25
26 import java.util.Hashtable JavaDoc;
27
28 public class WebdavStatus {
29
30
31     // -------------------------------------------------------------- Variables
32

33
34     private static Hashtable JavaDoc mapStatusCodes = new Hashtable JavaDoc();
35
36
37     // --------------------------------------------------------- Public Methods
38

39
40     public static String JavaDoc getStatusText(int nHttpStatusCode) {
41         Integer JavaDoc intKey = new Integer JavaDoc(nHttpStatusCode);
42
43         if (!mapStatusCodes.containsKey(intKey)) {
44             // No information
45
return null;
46
47         } else {
48             return (String JavaDoc) mapStatusCodes.get(intKey);
49         }
50     }
51
52
53     // -------------------------------------------------------- Private Methods
54

55
56     private static void addStatusCodeMap(int nKey, String JavaDoc strVal) {
57         mapStatusCodes.put(new Integer JavaDoc(nKey), strVal);
58     }
59
60
61     // -------------------------------------------------------------- Constants
62

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     // This one colides with HTTP 1.1
77
// "207 Parital Update OK"
78
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_UNPROCESSABLE_ENTITY = 418;
105
// This one colides with HTTP 1.1
106
// "418 Reauthentication Required"
107
public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419;
108     // This one colides with HTTP 1.1
109
// "419 Proxy Reauthentication Required"
110
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     // ----------------------------------------------------- Static Initializer
126

127
128     static {
129         // HTTP 1.0 Server status codes -- see RFC 1945
130
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         // HTTP 1.1 Server status codes -- see RFC 2048
147
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         // WebDAV Server-specific status codes
163
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