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