001/* 002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.webengine.servlet; 023 024import javax.servlet.http.HttpServletResponse; 025 026/** 027 * HTTP constants. 028 * 029 * @author <a href="mailto:[email protected]">Thierry Delprat</a> 030 */ 031// TODO: is this needed? Only one constant is actually used (MULTIPART) 032public class WebConst { 033 034 /** 035 * Part of HTTP content type header. 036 */ 037 public static final String MULTIPART = "multipart/"; 038 039 public static final String ACTION_SEPARATOR = "@@"; 040 041 public static final String MODE_KEY = "render_mode"; 042 043 public static final String ENGINE_KEY = "render_engine"; 044 045 public static final String VIEW_MODE = "VIEW"; 046 047 public static final String EDIT_MODE = "EDIT"; 048 049 public static final String CREATE_MODE = "CREATE"; 050 051 public static final String METHOD_HEAD = "HEAD"; 052 053 public static final String METHOD_COPY = "COPY"; 054 055 public static final String METHOD_MOVE = "MOVE"; 056 057 public static final String METHOD_LOCK = "LOCK"; 058 059 public static final String METHOD_UNLOCK = "UNLOCK"; 060 061 public static final String METHOD_PUT = "PUT"; 062 063 public static final String METHOD_POST = "POST"; 064 065 public static final String METHOD_GET = "GET"; 066 067 public static final String METHOD_DELETE = "DELETE"; 068 069 public static final String METHOD_OPTIONS = "OPTIONS"; 070 071 /** 072 * Status code (200) indicating the request succeeded normally. 073 */ 074 public static final int SC_OK = HttpServletResponse.SC_OK; 075 076 /** 077 * Status code (201) indicating the request succeeded and created a new resource on the server. 078 */ 079 public static final int SC_CREATED = HttpServletResponse.SC_CREATED; 080 081 /** 082 * Status code (202) indicating that a request was accepted for processing, but was not completed. 083 */ 084 public static final int SC_ACCEPTED = HttpServletResponse.SC_ACCEPTED; 085 086 /** 087 * Status code (204) indicating that the request succeeded but that there was no new information to return. 088 */ 089 public static final int SC_NO_CONTENT = HttpServletResponse.SC_NO_CONTENT; 090 091 /** 092 * Status code (301) indicating that the resource has permanently moved to a new location, and that future 093 * references should use a new URI with their requests. 094 */ 095 public static final int SC_MOVED_PERMANENTLY = HttpServletResponse.SC_MOVED_PERMANENTLY; 096 097 /** 098 * Status code (302) indicating that the resource has temporarily moved to another location, but that future 099 * references should still use the original URI to access the resource. 100 */ 101 public static final int SC_MOVED_TEMPORARILY = HttpServletResponse.SC_MOVED_TEMPORARILY; 102 103 /** 104 * Status code (304) indicating that a conditional GET operation found that the resource was available and not 105 * modified. 106 */ 107 public static final int SC_NOT_MODIFIED = HttpServletResponse.SC_NOT_MODIFIED; 108 109 /** 110 * Status code (400) indicating the request sent by the client was syntactically incorrect. 111 */ 112 public static final int SC_BAD_REQUEST = HttpServletResponse.SC_BAD_REQUEST; 113 114 /** 115 * Status code (401) indicating that the request requires HTTP authentication. 116 */ 117 public static final int SC_UNAUTHORIZED = HttpServletResponse.SC_UNAUTHORIZED; 118 119 /** 120 * Status code (403) indicating the server understood the request but refused to fulfill it. 121 */ 122 public static final int SC_FORBIDDEN = HttpServletResponse.SC_FORBIDDEN; 123 124 /** 125 * Status code (404) indicating that the requested resource is not available. 126 */ 127 public static final int SC_NOT_FOUND = HttpServletResponse.SC_NOT_FOUND; 128 129 /** 130 * Status code (500) indicating an error inside the HTTP service which prevented it from fulfilling the request. 131 */ 132 public static final int SC_INTERNAL_SERVER_ERROR = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; 133 134 /** 135 * Status code (501) indicating the HTTP service does not support the functionality needed to fulfill the request. 136 */ 137 public static final int SC_NOT_IMPLEMENTED = HttpServletResponse.SC_NOT_IMPLEMENTED; 138 139 /** 140 * Status code (502) indicating that the HTTP server received an invalid response from a server it consulted when 141 * acting as a proxy or gateway. 142 */ 143 public static final int SC_BAD_GATEWAY = HttpServletResponse.SC_BAD_GATEWAY; 144 145 /** 146 * Status code (503) indicating that the HTTP service is temporarily overloaded, and unable to handle the request. 147 */ 148 public static final int SC_SERVICE_UNAVAILABLE = HttpServletResponse.SC_SERVICE_UNAVAILABLE; 149 150 /** 151 * Status code (100) indicating the client may continue with its request. This interim response is used to inform 152 * the client that the initial part of the request has been received and has not yet been rejected by the server. 153 */ 154 public static final int SC_CONTINUE = 100; 155 156 /** 157 * Status code (405) indicating the method specified is not allowed for the resource. 158 */ 159 public static final int SC_METHOD_NOT_ALLOWED = 405; 160 161 /** 162 * Status code (409) indicating that the request could not be completed due to a conflict with the current state of 163 * the resource. 164 */ 165 public static final int SC_CONFLICT = 409; 166 167 /** 168 * Status code (412) indicating the precondition given in one or more of the request-header fields evaluated to 169 * false when it was tested on the server. 170 */ 171 public static final int SC_PRECONDITION_FAILED = 412; 172 173 /** 174 * Status code (413) indicating the server is refusing to process a request because the request entity is larger 175 * than the server is willing or able to process. 176 */ 177 public static final int SC_REQUEST_TOO_LONG = 413; 178 179 /** 180 * Status code (415) indicating the server is refusing to service the request because the entity of the request is 181 * in a format not supported by the requested resource for the requested method. 182 */ 183 public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415; 184 185 // Extended WebDav status code -------------------------------------------- 186 187 /** 188 * Status code (207) indicating that the response requires providing status for multiple independent operations. 189 */ 190 public static final int SC_MULTI_STATUS = 207; 191 192 // This one collides with HTTP 1.1 193 // "207 Parital Update OK" 194 195 /** 196 * Status code (418) indicating the entity body submitted with the PATCH method was not understood by the resource. 197 */ 198 public static final int SC_UNPROCESSABLE_ENTITY = 418; 199 200 // This one collides with HTTP 1.1 201 // "418 Reauthentication Required" 202 203 /** 204 * Status code (419) indicating that the resource does not have sufficient space to record the state of the resource 205 * after the execution of this method. 206 */ 207 public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419; 208 209 // This one collides with HTTP 1.1 210 // "419 Proxy Reauthentication Required" 211 212 /** 213 * Status code (420) indicating the method was not executed on a particular resource within its scope because some 214 * part of the method's execution failed causing the entire method to be aborted. 215 */ 216 public static final int SC_METHOD_FAILURE = 420; 217 218 /** 219 * Status code (423) indicating the destination resource of a method is locked, and either the request did not 220 * contain a valid Lock-Info header, or the Lock-Info header identifies a lock held by another principal. 221 */ 222 public static final int SC_LOCKED = 423; 223 224 /* 225 * VirtualHosting header provided by reverse-proxies 226 */ 227 public static final String X_FORWARDED_HOST = "x-forwarded-host"; 228 229 /* 230 * VirtualHosting header specific to Nuxeo 5 EP 231 */ 232 public static final String VH_HEADER = "nuxeo-virtual-host"; 233 234 // Constant utility class 235 private WebConst() { 236 } 237 238}