You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@apache.org on 2001/02/06 06:54:53 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib WebdavStatus.java
remm 01/02/05 21:54:53
Modified: src/webdav/client/src/org/apache/webdav/lib
WebdavStatus.java
Log:
- Cleanup of WebdavStatus code.
Patch submitted by Sung-Gu Park.
Revision Changes Path
1.2 +122 -251 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavStatus.java
Index: WebdavStatus.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavStatus.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WebdavStatus.java 2000/11/22 06:19:08 1.1
+++ WebdavStatus.java 2001/02/06 05:54:52 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavStatus.java,v 1.1 2000/11/22 06:19:08 remm Exp $
- * $Revision: 1.1 $
- * $Date: 2000/11/22 06:19:08 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavStatus.java,v 1.2 2001/02/06 05:54:52 remm Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/02/06 05:54:52 $
*
* ====================================================================
*
@@ -72,278 +72,149 @@
import java.util.Enumeration;
import java.util.NoSuchElementException;
-/**
- * Wraps the HttpServletResponse class to abstract the
- * specific protocol used. To support other protocols
- * we would only need to modify this class and the
- * WebDavRetCode classes.
- *
- * @see WebDavRetCode
- * @author Marc Eaddy
- * @version 1.0, 16 Nov 1997
- */
public class WebdavStatus {
- /**
- * This Hashtable contains the mapping of HTTP and WebDAV
- * status codes to descriptive text. This is a static
- * variable.
- */
+
+ // -------------------------------------------------------------- Variables
+
+
private static Hashtable mapStatusCodes = new Hashtable();
- /**
- * Adds a new status code -> status text mapping. This is a static
- * method because the mapping is a static variable.
- *
- * @param nKey [IN] HTTP or WebDAV status code
- * @param strVal [IN] HTTP status text
- */
- private static void addStatusCodeMap(int nKey, String strVal) {
- mapStatusCodes.put(new Integer(nKey), strVal);
- }
+
+ // --------------------------------------------------------- Public Methods
- /**
- * Returns the HTTP status text for the HTTP or WebDav status code
- * specified by looking it up in the static mapping. This is a
- * static function.
- *
- * @param nHttpStatusCode [IN] HTTP or WebDAV status code
- * @return A string with a short descriptive phrase for the
- * HTTP status code (e.g., "OK").
- */
+
public static String getStatusText(int nHttpStatusCode) {
- Integer intKey = new Integer(nHttpStatusCode);
-
- if (!mapStatusCodes.containsKey(intKey)) {
- // DANGER!!! - RECURSIVE!!!
- return getStatusText(SC_INTERNAL_SERVER_ERROR);
- } else {
- return (String) mapStatusCodes.get(intKey);
- }
+ Integer intKey = new Integer(nHttpStatusCode);
+
+ if (!mapStatusCodes.containsKey(intKey)) {
+ // No information
+ return null;
+
+ } else {
+ return (String) mapStatusCodes.get(intKey);
+ }
}
- /*
- * HTTP 1.0 Server status codes; see RFC 1945.
- */
-
- /**
- * Status code (200) indicating the request succeeded normally.
- */
- public static final int SC_OK = HttpServletResponse.SC_OK;
-
- /**
- * Status code (201) indicating the request succeeded and created
- * a new resource on the server.
- */
- public static final int SC_CREATED = HttpServletResponse.SC_CREATED;
-
- /**
- * Status code (202) indicating that a request was accepted for
- * processing, but was not completed.
- */
- public static final int SC_ACCEPTED = HttpServletResponse.SC_ACCEPTED;
-
- /**
- * Status code (204) indicating that the request succeeded but that
- * there was no new information to return.
- */
- public static final int SC_NO_CONTENT = HttpServletResponse.SC_NO_CONTENT;
-
- /**
- * Status code (301) indicating that the resource has permanently
- * moved to a new location, and that future references should use a
- * new URI with their requests.
- */
- public static final int SC_MOVED_PERMANENTLY = HttpServletResponse.SC_MOVED_PERMANENTLY;
-
- /**
- * Status code (302) indicating that the resource has temporarily
- * moved to another location, but that future references should
- * still use the original URI to access the resource.
- */
- public static final int SC_MOVED_TEMPORARILY = HttpServletResponse.SC_MOVED_TEMPORARILY;
-
- /**
- * Status code (304) indicating that a conditional GET operation
- * found that the resource was available and not modified.
- */
- public static final int SC_NOT_MODIFIED = HttpServletResponse.SC_NOT_MODIFIED;
-
- /**
- * Status code (400) indicating the request sent by the client was
- * syntactically incorrect.
- */
- public static final int SC_BAD_REQUEST = HttpServletResponse.SC_BAD_REQUEST;
-
- /**
- * Status code (401) indicating that the request requires HTTP
- * authentication.
- */
- public static final int SC_UNAUTHORIZED = HttpServletResponse.SC_UNAUTHORIZED;
-
- /**
- * Status code (403) indicating the server understood the request
- * but refused to fulfill it.
- */
- public static final int SC_FORBIDDEN = HttpServletResponse.SC_FORBIDDEN;
-
- /**
- * Status code (404) indicating that the requested resource is not
- * available.
- */
- public static final int SC_NOT_FOUND = HttpServletResponse.SC_NOT_FOUND;
-
- /**
- * Status code (500) indicating an error inside the HTTP service
- * which prevented it from fulfilling the request.
- */
- public static final int SC_INTERNAL_SERVER_ERROR = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
-
- /**
- * Status code (501) indicating the HTTP service does not support
- * the functionality needed to fulfill the request.
- */
- public static final int SC_NOT_IMPLEMENTED = HttpServletResponse.SC_NOT_IMPLEMENTED;
-
- /**
- * Status code (502) indicating that the HTTP server received an
- * invalid response from a server it consulted when acting as a
- * proxy or gateway.
- */
- public static final int SC_BAD_GATEWAY = HttpServletResponse.SC_BAD_GATEWAY;
-
- /**
- * Status code (503) indicating that the HTTP service is
- * temporarily overloaded, and unable to handle the request.
- */
- public static final int SC_SERVICE_UNAVAILABLE = HttpServletResponse.SC_SERVICE_UNAVAILABLE;
-
- /*
- * HTTP 1.1 Server status codes; see RFC 2048. When JWS supports HTTP 1.1 we
- * will use the appropriate HttpServletRespones status codes.
- */
-
- /**
- * Status code (100) indicating the client may continue with
- * its request. This interim response is used to inform the
- * client that the initial part of the request has been
- * received and has not yet been rejected by the server.
- */
- public static final int SC_CONTINUE = 100;
-
- /**
- * Status code (405) indicating the method specified is not
- * allowed for the resource.
- */
- public static final int SC_METHOD_NOT_ALLOWED = 405;
- /**
- * Status code (409) indicating that the request could not be
- * completed due to a conflict with the current state of the
- * resource.
- */
- public static final int SC_CONFLICT = 409;
-
- /**
- * Status code (412) indicating the precondition given in one
- * or more of the request-header fields evaluated to false
- * when it was tested on the server.
- */
- public static final int SC_PRECONDITION_FAILED = 412;
-
- /**
- * Status code (413) indicating the server is refusing to
- * process a request because the request entity is larger
- * than the server is willing or able to process.
- */
- public static final int SC_REQUEST_TOO_LONG = 413;
-
- /**
- * Status code (415) indicating the server is refusing to service
- * the request because the entity of the request is in a format
- * not supported by the requested resource for the requested
- * method.
- */
- public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415;
+ // -------------------------------------------------------- Private Methods
+
+
+ private static void addStatusCodeMap(int nKey, String strVal) {
+ mapStatusCodes.put(new Integer(nKey), strVal);
+ }
+
+
+ // -------------------------------------------------------------- Constants
+
+ public static final int SC_CONTINUE = 100;
+ public static final int SC_SWITCHING_PROTOCOLS = 101;
+ public static final int SC_PROCESSING = 102;
- /*
- * Extended WebDAV HTTP status codes; see <draft-ietf-webdav-protocol-05>.
- */
-
- /**
- * Status code (207) indicating that the response requires
- * providing status for multiple independent operations.
- */
+ public static final int SC_OK = 200;
+ public static final int SC_CREATED = 201;
+ public static final int SC_ACCEPTED = 202;
+ public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203;
+ public static final int SC_NO_CONTENT = 204;
+ public static final int SC_RESET_CONTENT = 205;
+ public static final int SC_PARTIAL_CONTENT = 206;
public static final int SC_MULTI_STATUS = 207;
// This one colides with HTTP 1.1
// "207 Parital Update OK"
- /**
- * Status code (418) indicating the entity body submitted with
- * the PATCH method was not understood by the resource.
- */
- public static final int SC_UNPROCESSABLE_ENTITY = 418;
+ public static final int SC_MULTIPLE_CHOICES = 300;
+ public static final int SC_MOVED_PERMANENTLY = 301;
+ public static final int SC_MOVED_TEMPORARILY = 302;
+ public static final int SC_SEE_OTHER = 303;
+ public static final int SC_NOT_MODIFIED = 304;
+ public static final int SC_USE_PROXY = 305;
+
+ public static final int SC_BAD_REQUEST = 400;
+ public static final int SC_UNAUTHORIZED = 401;
+ public static final int SC_PAYMENT_REQUIRED = 402;
+ public static final int SC_FORBIDDEN = 403;
+ public static final int SC_NOT_FOUND = 404;
+ public static final int SC_METHOD_NOT_ALLOWED = 405;
+ public static final int SC_NOT_ACCEPTABLE = 406;
+ public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
+ public static final int SC_REQUEST_TIMEOUT = 408;
+ public static final int SC_CONFLICT = 409;
+ public static final int SC_GONE = 410;
+ public static final int SC_LENGTH_REQUIRED = 411;
+ public static final int SC_PRECONDITION_FAILED = 412;
+ public static final int SC_REQUEST_TOO_LONG = 413;
+ public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415;
+ public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
+ public static final int SC_EXPECTATION_FAILED = 417;
+ //public static final int SC_UNPROCESSABLE_ENTITY = 418;
// This one colides with HTTP 1.1
// "418 Reauthentication Required"
-
- /**
- * Status code (419) indicating that the resource does not have
- * sufficient space to record the state of the resource after the
- * execution of this method.
- */
public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419;
// This one colides with HTTP 1.1
// "419 Proxy Reauthentication Required"
-
- /**
- * Status code (420) indicating the method was not executed on
- * a particular resource within its scope because some part of
- * the method's execution failed causing the entire method to be
- * aborted.
- */
public static final int SC_METHOD_FAILURE = 420;
-
- /**
- * Status code (423) indicating the destination resource of a
- * method is locked, and either the request did not contain a
- * valid Lock-Info header, or the Lock-Info header identifies
- * a lock held by another principal.
- */
+ public static final int SC_UNPROCESSABLE_ENTITY = 422;
public static final int SC_LOCKED = 423;
+ public static final int SC_FAILED_DEPENDENCY = 424;
+
+ public static final int SC_INTERNAL_SERVER_ERROR = 500;
+ public static final int SC_NOT_IMPLEMENTED = 501;
+ public static final int SC_BAD_GATEWAY = 502;
+ public static final int SC_SERVICE_UNAVAILABLE = 503;
+ public static final int SC_GATEWAY_TIMEOUT = 504;
+ public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505;
+ public static final int SC_INSUFFICIENT_STORAGE = 507;
+
+ // ----------------------------------------------------- Static Initializer
+
+
static {
- // HTTP 1.0 Server status codes -- see RFC 1945
- addStatusCodeMap(SC_OK, "OK");
- addStatusCodeMap(SC_CREATED, "Created");
- addStatusCodeMap(SC_ACCEPTED, "Accepted");
- addStatusCodeMap(SC_NO_CONTENT, "No Content");
- addStatusCodeMap(SC_MOVED_PERMANENTLY, "Moved Permanently");
- addStatusCodeMap(SC_MOVED_TEMPORARILY, "Moved Temporarily");
- addStatusCodeMap(SC_NOT_MODIFIED, "Not Modified");
- addStatusCodeMap(SC_BAD_REQUEST, "Bad Request");
- addStatusCodeMap(SC_UNAUTHORIZED, "Unauthorized");
- addStatusCodeMap(SC_FORBIDDEN, "Forbidden");
- addStatusCodeMap(SC_NOT_FOUND, "Not Found");
- addStatusCodeMap(SC_INTERNAL_SERVER_ERROR, "Internal Server Error");
- addStatusCodeMap(SC_NOT_IMPLEMENTED, "Not Implemented");
- addStatusCodeMap(SC_BAD_GATEWAY, "Bad Gateway");
- addStatusCodeMap(SC_SERVICE_UNAVAILABLE, "Service Unavailable");
-
- // HTTP 1.1 Server status codes -- see RFC 2048
- addStatusCodeMap(SC_CONTINUE, "Continue");
- addStatusCodeMap(SC_METHOD_NOT_ALLOWED, "Method Not Allowed");
- addStatusCodeMap(SC_CONFLICT, "Conflict");
- addStatusCodeMap(SC_PRECONDITION_FAILED, "Precondition Failed");
- addStatusCodeMap(SC_REQUEST_TOO_LONG, "Request Too Long");
- addStatusCodeMap(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type");
-
- // WebDav Server-specific status codes
- addStatusCodeMap(SC_MULTI_STATUS, "Multi-Status");
- addStatusCodeMap(SC_UNPROCESSABLE_ENTITY, "Unprocessable Entity");
- addStatusCodeMap(SC_INSUFFICIENT_SPACE_ON_RESOURCE, "Insufficient Space On Resource");
- addStatusCodeMap(SC_METHOD_FAILURE, "Method Failure");
- addStatusCodeMap(SC_LOCKED, "Locked");
+ // HTTP 1.0 Server status codes -- see RFC 1945
+ addStatusCodeMap(SC_OK, "OK");
+ addStatusCodeMap(SC_CREATED, "Created");
+ addStatusCodeMap(SC_ACCEPTED, "Accepted");
+ addStatusCodeMap(SC_NO_CONTENT, "No Content");
+ addStatusCodeMap(SC_MOVED_PERMANENTLY, "Moved Permanently");
+ addStatusCodeMap(SC_MOVED_TEMPORARILY, "Moved Temporarily");
+ addStatusCodeMap(SC_NOT_MODIFIED, "Not Modified");
+ addStatusCodeMap(SC_BAD_REQUEST, "Bad Request");
+ addStatusCodeMap(SC_UNAUTHORIZED, "Unauthorized");
+ addStatusCodeMap(SC_FORBIDDEN, "Forbidden");
+ addStatusCodeMap(SC_NOT_FOUND, "Not Found");
+ addStatusCodeMap(SC_INTERNAL_SERVER_ERROR, "Internal Server Error");
+ addStatusCodeMap(SC_NOT_IMPLEMENTED, "Not Implemented");
+ addStatusCodeMap(SC_BAD_GATEWAY, "Bad Gateway");
+ addStatusCodeMap(SC_SERVICE_UNAVAILABLE, "Service Unavailable");
+
+ // HTTP 1.1 Server status codes -- see RFC 2048
+ addStatusCodeMap(SC_CONTINUE, "Continue");
+ addStatusCodeMap(SC_METHOD_NOT_ALLOWED, "Method Not Allowed");
+ addStatusCodeMap(SC_CONFLICT, "Conflict");
+ addStatusCodeMap(SC_PRECONDITION_FAILED, "Precondition Failed");
+ addStatusCodeMap(SC_REQUEST_TOO_LONG, "Request Too Long");
+ addStatusCodeMap(SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported Media Type");
+
+ addStatusCodeMap(SC_SWITCHING_PROTOCOLS, "Switching Protocols");
+ addStatusCodeMap(SC_NON_AUTHORITATIVE_INFORMATION,
+ "Non Authoritative Information");
+ addStatusCodeMap(SC_RESET_CONTENT, "Reset Content");
+ addStatusCodeMap(SC_GATEWAY_TIMEOUT, "Gateway Timeout");
+ addStatusCodeMap(SC_HTTP_VERSION_NOT_SUPPORTED,
+ "Http Version Not Supported");
+
+ // WebDAV Server-specific status codes
+ addStatusCodeMap(SC_PROCESSING, "Processing");
+ addStatusCodeMap(SC_MULTI_STATUS, "Multi-Status");
+ addStatusCodeMap(SC_UNPROCESSABLE_ENTITY, "Unprocessable Entity");
+ addStatusCodeMap(SC_INSUFFICIENT_SPACE_ON_RESOURCE,
+ "Insufficient Space On Resource");
+ addStatusCodeMap(SC_METHOD_FAILURE, "Method Failure");
+ addStatusCodeMap(SC_LOCKED, "Locked");
+ addStatusCodeMap(SC_INSUFFICIENT_STORAGE , "Insufficient Storage");
+ addStatusCodeMap(SC_FAILED_DEPENDENCY, "Failed Dependency");
}
+
-};
+}