LibreOffice Module ucb (master)  1
neon/DAVException.hxx
Go to the documentation of this file.
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, general <https://tools.ietf.org/html/rfc7231#section-6.6>)
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 (<https://tools.ietf.org/html/rfc4918#section-11>)
102 const sal_uInt16 SC_INSUFFICIENT_STORAGE = 507;
103 
104 // unofficial status codes only used internally by LO
105 // used to cache the connection time out event
106 const sal_uInt16 USC_CONNECTION_TIMED_OUT = 908;
107  // name resolution failed
108 const sal_uInt16 USC_LOOKUP_FAILED = 909;
109 const sal_uInt16 USC_AUTH_FAILED = 910;
110 const sal_uInt16 USC_AUTHPROXY_FAILED = 911;
111 
112 
113 
114 class DAVException : public std::exception
115 {
116  public:
118  DAV_HTTP_ERROR = 0, // Generic error,
119  // mData = server error message,
120  // mStatusCode = HTTP status code
121  DAV_HTTP_LOOKUP, // Name lookup failed,
122  // mData = server[:port]
123  DAV_HTTP_AUTH, // User authentication failed on server,
124  // mData = server[:port]
125  DAV_HTTP_AUTHPROXY, // User authentication failed on proxy,
126  // mData = proxy server[:port]
127  DAV_HTTP_CONNECT, // Could not connect to server,
128  // mData = server[:port]
129  DAV_HTTP_TIMEOUT, // Connection timed out
130  // mData = server[:port]
131  DAV_HTTP_FAILED, // The precondition failed
132  // mData = server[:port]
133  DAV_HTTP_RETRY, // Retry request
134  // mData = server[:port]
135  DAV_HTTP_REDIRECT, // Request was redirected,
136  // mData = new URL
137  DAV_SESSION_CREATE, // session creation error,
138  // mData = server[:port]
139  DAV_INVALID_ARG, // invalid argument
140 
141  DAV_LOCK_EXPIRED, // DAV lock expired
142 
143  DAV_NOT_LOCKED, // not locked
144 
145  DAV_LOCKED_SELF, // locked by this OOo session
146 
147  DAV_LOCKED // locked by third party
148  };
149 
150  private:
152  OUString mData;
153  sal_uInt16 mStatusCode;
154 
155  public:
156  explicit DAVException( ExceptionCode inExceptionCode ) :
157  mExceptionCode( inExceptionCode ), mStatusCode( SC_NONE ) {};
158  DAVException( ExceptionCode inExceptionCode,
159  const OUString & rData ) :
160  mExceptionCode( inExceptionCode ), mData( rData ),
161  mStatusCode( SC_NONE ) {};
162  DAVException( ExceptionCode inExceptionCode,
163  const OUString & rData,
164  sal_uInt16 nStatusCode ) :
165  mExceptionCode( inExceptionCode ), mData( rData ),
166  mStatusCode( nStatusCode ) {};
167 
168  const ExceptionCode & getError() const { return mExceptionCode; }
169  const OUString & getData() const { return mData; }
170  sal_uInt16 getStatus() const { return mStatusCode; }
171 };
172 
173 } // namespace webdav_ucp
174 
175 #endif // INCLUDED_UCB_SOURCE_UCP_WEBDAV_NEON_DAVEXCEPTION_HXX
176 
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const sal_uInt16 SC_CREATED
const sal_uInt16 USC_AUTHPROXY_FAILED
DAVException(ExceptionCode inExceptionCode, const OUString &rData)
const sal_uInt16 SC_LOCKED
const sal_uInt16 SC_USE_PROXY
const sal_uInt16 SC_BAD_REQUEST
const sal_uInt16 SC_GATEWAY_TIMEOUT
const sal_uInt16 SC_ACCEPTED
const sal_uInt16 SC_PARTIAL_CONTENT
const sal_uInt16 SC_REQUEST_ENTITY_TOO_LARGE
const sal_uInt16 SC_MOVED_PERMANENTLY
const ExceptionCode & getError() const
const sal_uInt16 SC_INSUFFICIENT_STORAGE
const sal_uInt16 SC_SWITCHING_PROTOCOLS
const sal_uInt16 SC_MULTIPLE_CHOICES
const sal_uInt16 SC_FAILED_DEPENDENCY
const sal_uInt16 SC_REQUEST_TIMEOUT
const OUString & getData() const
const sal_uInt16 SC_CONTINUE
const sal_uInt16 SC_REQUEST_URI_TOO_LONG
const sal_uInt16 SC_NOT_ACCEPTABLE
const sal_uInt16 SC_PAYMENT_REQUIRED
const sal_uInt16 SC_METHOD_NOT_ALLOWED
const sal_uInt16 SC_SERVICE_UNAVAILABLE
const sal_uInt16 SC_NOT_IMPLEMENTED
sal_uInt16 getStatus() const
const sal_uInt16 SC_RESET_CONTENT
const sal_uInt16 SC_UNSUPPORTED_MEDIA_TYPE
const sal_uInt16 SC_OK
const sal_uInt16 SC_BAD_GATEWAY
const sal_uInt16 SC_GONE
const sal_uInt16 SC_FORBIDDEN
const sal_uInt16 SC_NONE
const sal_uInt16 SC_TEMPORARY_REDIRECT
const sal_uInt16 SC_REQUESTED_RANGE_NOT_SATISFIABLE
const sal_uInt16 USC_LOOKUP_FAILED
const sal_uInt16 SC_NO_CONTENT
const sal_uInt16 SC_MOVED_TEMPORARILY
const sal_uInt16 SC_LENGTH_REQUIRED
const sal_uInt16 SC_CONFLICT
const sal_uInt16 USC_CONNECTION_TIMED_OUT
const sal_uInt16 SC_NON_AUTHORITATIVE_INFORMATION
const sal_uInt16 SC_UNPROCESSABLE_ENTITY
DAVException(ExceptionCode inExceptionCode, const OUString &rData, sal_uInt16 nStatusCode)
const sal_uInt16 USC_AUTH_FAILED
const sal_uInt16 SC_NOT_FOUND
const sal_uInt16 SC_PROXY_AUTHENTICATION_REQUIRED
DAVException(ExceptionCode inExceptionCode)
const sal_uInt16 SC_PRECONDITION_FAILED
const sal_uInt16 SC_EXPECTATION_FAILED
const sal_uInt16 SC_NOT_MODIFIED
const sal_uInt16 SC_MULTISTATUS
const sal_uInt16 SC_UNAUTHORIZED
const sal_uInt16 SC_PROCESSING
const sal_uInt16 SC_INTERNAL_SERVER_ERROR
const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED
const sal_uInt16 SC_SEE_OTHER