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 INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVEXCEPTION_HXX
30 : #define INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVEXCEPTION_HXX
31 :
32 : #include <config_lgpl.h>
33 : #include <rtl/ustring.hxx>
34 :
35 : namespace webdav_ucp
36 : {
37 :
38 :
39 : // HTTP/WebDAV status codes
40 :
41 :
42 : const sal_uInt16 SC_NONE = 0;
43 :
44 : // 1xx (Informational - no errors)
45 : const sal_uInt16 SC_CONTINUE = 100;
46 : const sal_uInt16 SC_SWITCHING_PROTOCOLS = 101;
47 : // DAV extensions
48 : const sal_uInt16 SC_PROCESSING = 102;
49 :
50 : //2xx (Successful - no errors)
51 : const sal_uInt16 SC_OK = 200;
52 : const sal_uInt16 SC_CREATED = 201;
53 : const sal_uInt16 SC_ACCEPTED = 202;
54 : const sal_uInt16 SC_NON_AUTHORITATIVE_INFORMATION = 203;
55 : const sal_uInt16 SC_NO_CONTENT = 204;
56 : const sal_uInt16 SC_RESET_CONTENT = 205;
57 : const sal_uInt16 SC_PARTIAL_CONTENT = 206;
58 : // DAV extensions
59 : const sal_uInt16 SC_MULTISTATUS = 207;
60 :
61 : //3xx (Redirection)
62 : const sal_uInt16 SC_MULTIPLE_CHOICES = 300;
63 : const sal_uInt16 SC_MOVED_PERMANENTLY = 301;
64 : const sal_uInt16 SC_MOVED_TEMPORARILY = 302;
65 : const sal_uInt16 SC_SEE_OTHER = 303;
66 : const sal_uInt16 SC_NOT_MODIFIED = 304;
67 : const sal_uInt16 SC_USE_PROXY = 305;
68 : const sal_uInt16 SC_TEMPORARY_REDIRECT = 307;
69 :
70 : //4xx (Client error)
71 : const sal_uInt16 SC_BAD_REQUEST = 400;
72 : const sal_uInt16 SC_UNAUTHORIZED = 401;
73 : const sal_uInt16 SC_PAYMENT_REQUIRED = 402;
74 : const sal_uInt16 SC_FORBIDDEN = 403;
75 : const sal_uInt16 SC_NOT_FOUND = 404;
76 : const sal_uInt16 SC_METHOD_NOT_ALLOWED = 405;
77 : const sal_uInt16 SC_NOT_ACCEPTABLE = 406;
78 : const sal_uInt16 SC_PROXY_AUTHENTICATION_REQUIRED = 407;
79 : const sal_uInt16 SC_REQUEST_TIMEOUT = 408;
80 : const sal_uInt16 SC_CONFLICT = 409;
81 : const sal_uInt16 SC_GONE = 410;
82 : const sal_uInt16 SC_LENGTH_REQUIRED = 411;
83 : const sal_uInt16 SC_PRECONDITION_FAILED = 412;
84 : const sal_uInt16 SC_REQUEST_ENTITY_TOO_LARGE = 413;
85 : const sal_uInt16 SC_REQUEST_URI_TOO_LONG = 414;
86 : const sal_uInt16 SC_UNSUPPORTED_MEDIA_TYPE = 415;
87 : const sal_uInt16 SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
88 : const sal_uInt16 SC_EXPECTATION_FAILED = 417;
89 : // DAV extensions
90 : const sal_uInt16 SC_UNPROCESSABLE_ENTITY = 422;
91 : const sal_uInt16 SC_LOCKED = 423;
92 : const sal_uInt16 SC_FAILED_DEPENDENCY = 424;
93 :
94 : //5xx (Server error)
95 : const sal_uInt16 SC_INTERNAL_SERVER_ERROR = 500;
96 : const sal_uInt16 SC_NOT_IMPLEMENTED = 501;
97 : const sal_uInt16 SC_BAD_GATEWAY = 502;
98 : const sal_uInt16 SC_SERVICE_UNAVAILABLE = 503;
99 : const sal_uInt16 SC_GATEWAY_TIMEOUT = 504;
100 : const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED = 505;
101 : // DAV extensions
102 : const sal_uInt16 SC_INSUFFICIENT_STORAGE = 507;
103 :
104 :
105 :
106 : class DAVException : public std::exception
107 : {
108 : public:
109 : enum ExceptionCode {
110 : DAV_HTTP_ERROR = 0, // Generic error,
111 : // mData = server error message,
112 : // mStatusCode = HTTP status code
113 : DAV_HTTP_LOOKUP, // Name lookup failed,
114 : // mData = server[:port]
115 : DAV_HTTP_AUTH, // User authentication failed on server,
116 : // mData = server[:port]
117 : DAV_HTTP_AUTHPROXY, // User authentication failed on proxy,
118 : // mData = proxy server[:port]
119 : DAV_HTTP_CONNECT, // Could not connect to server,
120 : // mData = server[:port]
121 : DAV_HTTP_TIMEOUT, // Connection timed out
122 : // mData = server[:port]
123 : DAV_HTTP_FAILED, // The precondition failed
124 : // mData = server[:port]
125 : DAV_HTTP_RETRY, // Retry request
126 : // mData = server[:port]
127 : DAV_HTTP_REDIRECT, // Request was redirected,
128 : // mData = new URL
129 : DAV_SESSION_CREATE, // session creation error,
130 : // mData = server[:port]
131 : DAV_INVALID_ARG, // invalid argument
132 :
133 : DAV_LOCK_EXPIRED, // DAV lock expired
134 :
135 : DAV_NOT_LOCKED, // not locked
136 :
137 : DAV_LOCKED_SELF, // locked by this OOo session
138 :
139 : DAV_LOCKED // locked by third party
140 : };
141 :
142 : private:
143 : ExceptionCode mExceptionCode;
144 : OUString mData;
145 : sal_uInt16 mStatusCode;
146 :
147 : public:
148 0 : explicit DAVException( ExceptionCode inExceptionCode ) :
149 0 : mExceptionCode( inExceptionCode ), mStatusCode( SC_NONE ) {};
150 0 : DAVException( ExceptionCode inExceptionCode,
151 : const OUString & rData ) :
152 : mExceptionCode( inExceptionCode ), mData( rData ),
153 0 : mStatusCode( SC_NONE ) {};
154 0 : DAVException( ExceptionCode inExceptionCode,
155 : const OUString & rData,
156 : sal_uInt16 nStatusCode ) :
157 : mExceptionCode( inExceptionCode ), mData( rData ),
158 0 : mStatusCode( nStatusCode ) {};
159 0 : virtual ~DAVException() throw() {};
160 :
161 0 : const ExceptionCode & getError() const { return mExceptionCode; }
162 0 : const OUString & getData() const { return mData; }
163 0 : sal_uInt16 getStatus() const { return mStatusCode; }
164 : };
165 :
166 : } // namespace webdav_ucp
167 :
168 : #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVEXCEPTION_HXX
169 :
170 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|