KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/WebdavStatus.java,v 1.1 2004/08/02 16:36:06 unico Exp $
3  * $Revision: 1.1 $
4  * $Date: 2004/08/02 16:36:06 $
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.slide.webdav.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

79     public static final int SC_MULTIPLE_CHOICES = 300;
80     public static final int SC_MOVED_PERMANENTLY = 301;
81     public static final int SC_MOVED_TEMPORARILY = 302;
82     public static final int SC_SEE_OTHER = 303;
83     public static final int SC_NOT_MODIFIED = 304;
84     public static final int SC_USE_PROXY = 305;
85     
86     public static final int SC_BAD_REQUEST = 400;
87     public static final int SC_UNAUTHORIZED = 401;
88     public static final int SC_PAYMENT_REQUIRED = 402;
89     public static final int SC_FORBIDDEN = 403;
90     public static final int SC_NOT_FOUND = 404;
91     public static final int SC_METHOD_NOT_ALLOWED = 405;
92     public static final int SC_NOT_ACCEPTABLE = 406;
93     public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
94     public static final int SC_REQUEST_TIMEOUT = 408;
95     public static final int SC_CONFLICT = 409;
96     public static final int SC_GONE = 410;
97     public static final int SC_LENGTH_REQUIRED = 411;
98     public static final int SC_PRECONDITION_FAILED = 412;
99     public static final int SC_REQUEST_TOO_LONG = 413;
100     public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415;
101     public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
102     public static final int SC_EXPECTATION_FAILED = 417;
103     //public static final int SC_UNPROCESSABLE_ENTITY = 418;
104
// This one colides with HTTP 1.1
105
// "418 Reauthentication Required"
106
public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419;
107     // This one colides with HTTP 1.1
108
// "419 Proxy Reauthentication Required"
109
public static final int SC_METHOD_FAILURE = 420;
110     public static final int SC_UNPROCESSABLE_ENTITY = 422;
111     public static final int SC_LOCKED = 423;
112     public static final int SC_FAILED_DEPENDENCY = 424;
113     
114     public static final int SC_INTERNAL_SERVER_ERROR = 500;
115     public static final int SC_NOT_IMPLEMENTED = 501;
116     public static final int SC_BAD_GATEWAY = 502;
117     public static final int SC_SERVICE_UNAVAILABLE = 503;
118     public static final int SC_GATEWAY_TIMEOUT = 504;
119     public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505;
120     public static final int SC_INSUFFICIENT_STORAGE = 507;
121     
122     
123     // ----------------------------------------------------- Static Initializer
124

125     
126     static {
127         // HTTP 1.0 Server status codes -- see RFC 1945
128
addStatusCodeMap(SC_OK, "OK");
129         addStatusCodeMap(SC_CREATED, "Created");
130         addStatusCodeMap(SC_ACCEPTED, "Accepted");
131         addStatusCodeMap(SC_NO_CONTENT, "No Content");
132         addStatusCodeMap(SC_MOVED_PERMANENTLY, "Moved Permanently");
133         addStatusCodeMap(SC_MOVED_TEMPORARILY, "Moved Temporarily");
134         addStatusCodeMap(SC_NOT_MODIFIED, "Not Modified");
135         addStatusCodeMap(SC_BAD_REQUEST, "Bad Request");
136         addStatusCodeMap(SC_UNAUTHORIZED, "Unauthorized");
137         addStatusCodeMap(SC_FORBIDDEN, "Forbidden");
138         addStatusCodeMap(SC_NOT_FOUND, "Not Found");
139         addStatusCodeMap(SC_INTERNAL_SERVER_ERROR, "Internal Server Error");
140         addStatusCodeMap(SC_NOT_IMPLEMENTED, "Not Implemented");
141         addStatusCodeMap(SC_BAD_GATEWAY, "Bad Gateway");
142         addStatusCodeMap(SC_SERVICE_UNAVAILABLE, "Service Unavailable");
143         
144         // HTTP 1.1 Server status codes -- see RFC 2048
145
addStatusCodeMap(SC_CONTINUE, "Continue");
146         addStatusCodeMap(SC_METHOD_NOT_ALLOWED, "Method Not Allowed");
147         addStatusCodeMap(SC_NOT_ACCEPTABLE, "Not Acceptable");
148         addStatusCodeMap(SC_CONFLICT, "Conflict");
149         addStatusCodeMap(SC_PRECONDITION_FAILED, "Precondition Failed");
150         addStatusCodeMap(SC_REQUEST_TOO_LONG, "Request Too Long");
151         addStatusCodeMap(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type");
152         addStatusCodeMap(SC_REQUESTED_RANGE_NOT_SATISFIABLE, "Requested Range Not Satisfiable");
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_INSUFFICIENT_STORAGE , "Insufficient Storage");
171         addStatusCodeMap(SC_FAILED_DEPENDENCY, "Failed Dependency");
172     }
173     
174     
175 }
176
Popular Tags