Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _DAVEXCEPTION_HXX_
30 : : #define _DAVEXCEPTION_HXX_
31 : :
32 : : #include <rtl/ustring.hxx>
33 : :
34 : : namespace webdav_ucp
35 : : {
36 : :
37 : : /////////////////////////////////////////////////////////////////////////////
38 : : // HTTP/WebDAV status codes
39 : : /////////////////////////////////////////////////////////////////////////////
40 : :
41 : : const sal_uInt16 SC_NONE = 0;
42 : :
43 : : // 1xx (Informational - no errors)
44 : : const sal_uInt16 SC_CONTINUE = 100;
45 : : const sal_uInt16 SC_SWITCHING_PROTOCOLS = 101;
46 : : // DAV extensions
47 : : const sal_uInt16 SC_PROCESSING = 102;
48 : :
49 : : //2xx (Successful - no errors)
50 : : const sal_uInt16 SC_OK = 200;
51 : : const sal_uInt16 SC_CREATED = 201;
52 : : const sal_uInt16 SC_ACCEPTED = 202;
53 : : const sal_uInt16 SC_NON_AUTHORITATIVE_INFORMATION = 203;
54 : : const sal_uInt16 SC_NO_CONTENT = 204;
55 : : const sal_uInt16 SC_RESET_CONTENT = 205;
56 : : const sal_uInt16 SC_PARTIAL_CONTENT = 206;
57 : : // DAV extensions
58 : : const sal_uInt16 SC_MULTISTATUS = 207;
59 : :
60 : : //3xx (Redirection)
61 : : const sal_uInt16 SC_MULTIPLE_CHOICES = 300;
62 : : const sal_uInt16 SC_MOVED_PERMANENTLY = 301;
63 : : const sal_uInt16 SC_MOVED_TEMPORARILY = 302;
64 : : const sal_uInt16 SC_SEE_OTHER = 303;
65 : : const sal_uInt16 SC_NOT_MODIFIED = 304;
66 : : const sal_uInt16 SC_USE_PROXY = 305;
67 : : const sal_uInt16 SC_TEMPORARY_REDIRECT = 307;
68 : :
69 : : //4xx (Client error)
70 : : const sal_uInt16 SC_BAD_REQUEST = 400;
71 : : const sal_uInt16 SC_UNAUTHORIZED = 401;
72 : : const sal_uInt16 SC_PAYMENT_REQUIRED = 402;
73 : : const sal_uInt16 SC_FORBIDDEN = 403;
74 : : const sal_uInt16 SC_NOT_FOUND = 404;
75 : : const sal_uInt16 SC_METHOD_NOT_ALLOWED = 405;
76 : : const sal_uInt16 SC_NOT_ACCEPTABLE = 406;
77 : : const sal_uInt16 SC_PROXY_AUTHENTICATION_REQUIRED = 407;
78 : : const sal_uInt16 SC_REQUEST_TIMEOUT = 408;
79 : : const sal_uInt16 SC_CONFLICT = 409;
80 : : const sal_uInt16 SC_GONE = 410;
81 : : const sal_uInt16 SC_LENGTH_REQUIRED = 411;
82 : : const sal_uInt16 SC_PRECONDITION_FAILED = 412;
83 : : const sal_uInt16 SC_REQUEST_ENTITY_TOO_LARGE = 413;
84 : : const sal_uInt16 SC_REQUEST_URI_TOO_LONG = 414;
85 : : const sal_uInt16 SC_UNSUPPORTED_MEDIA_TYPE = 415;
86 : : const sal_uInt16 SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
87 : : const sal_uInt16 SC_EXPECTATION_FAILED = 417;
88 : : // DAV extensions
89 : : const sal_uInt16 SC_UNPROCESSABLE_ENTITY = 422;
90 : : const sal_uInt16 SC_LOCKED = 423;
91 : : const sal_uInt16 SC_FAILED_DEPENDENCY = 424;
92 : :
93 : : //5xx (Server error)
94 : : const sal_uInt16 SC_INTERNAL_SERVER_ERROR = 500;
95 : : const sal_uInt16 SC_NOT_IMPLEMENTED = 501;
96 : : const sal_uInt16 SC_BAD_GATEWAY = 502;
97 : : const sal_uInt16 SC_SERVICE_UNAVAILABLE = 503;
98 : : const sal_uInt16 SC_GATEWAY_TIMEOUT = 504;
99 : : const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED = 505;
100 : : // DAV extensions
101 : : const sal_uInt16 SC_INSUFFICIENT_STORAGE = 507;
102 : :
103 : : /////////////////////////////////////////////////////////////////////////////
104 : :
105 : : class DAVException
106 : : {
107 : : public:
108 : : enum ExceptionCode {
109 : : DAV_HTTP_ERROR = 0, // Generic error,
110 : : // mData = server error message,
111 : : // mStatusCode = HTTP status code
112 : : DAV_HTTP_LOOKUP, // Name lookup failed,
113 : : // mData = server[:port]
114 : : DAV_HTTP_AUTH, // User authentication failed on server,
115 : : // mData = server[:port]
116 : : DAV_HTTP_AUTHPROXY, // User authentication failed on proxy,
117 : : // mData = proxy server[:port]
118 : : DAV_HTTP_CONNECT, // Could not connect to server,
119 : : // mData = server[:port]
120 : : DAV_HTTP_TIMEOUT, // Connection timed out
121 : : // mData = server[:port]
122 : : DAV_HTTP_FAILED, // The precondition failed
123 : : // mData = server[:port]
124 : : DAV_HTTP_RETRY, // Retry request
125 : : // mData = server[:port]
126 : : DAV_HTTP_REDIRECT, // Request was redirected,
127 : : // mData = new URL
128 : : DAV_SESSION_CREATE, // session creation error,
129 : : // mData = server[:port]
130 : : DAV_INVALID_ARG, // invalid argument
131 : :
132 : : DAV_LOCK_EXPIRED, // DAV lock expired
133 : :
134 : : DAV_NOT_LOCKED, // not locked
135 : :
136 : : DAV_LOCKED_SELF, // locked by this OOo session
137 : :
138 : : DAV_LOCKED // locked by third party
139 : : };
140 : :
141 : : private:
142 : : ExceptionCode mExceptionCode;
143 : : rtl::OUString mData;
144 : : sal_uInt16 mStatusCode;
145 : :
146 : : public:
147 : 0 : DAVException( ExceptionCode inExceptionCode ) :
148 : 0 : mExceptionCode( inExceptionCode ), mStatusCode( SC_NONE ) {};
149 : 0 : DAVException( ExceptionCode inExceptionCode,
150 : : const rtl::OUString & rData ) :
151 : : mExceptionCode( inExceptionCode ), mData( rData ),
152 : 0 : mStatusCode( SC_NONE ) {};
153 : 0 : DAVException( ExceptionCode inExceptionCode,
154 : : const rtl::OUString & rData,
155 : : sal_uInt16 nStatusCode ) :
156 : : mExceptionCode( inExceptionCode ), mData( rData ),
157 : 0 : mStatusCode( nStatusCode ) {};
158 : 0 : ~DAVException( ) {};
159 : :
160 : 0 : const ExceptionCode & getError() const { return mExceptionCode; }
161 : 0 : const rtl::OUString & getData() const { return mData; }
162 : 0 : sal_uInt16 getStatus() const { return mStatusCode; }
163 : : };
164 : :
165 : : } // namespace webdav_ucp
166 : :
167 : : #endif // _DAVEXCEPTION_HXX_
168 : :
169 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|