LibreOffice Module ucb (master) 1
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 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#pragma once
22
23#include <rtl/ustring.hxx>
24
25namespace http_dav_ucp
26{
27
28
29// HTTP/WebDAV status codes
30
31
32const sal_uInt16 SC_NONE = 0;
33
34// 1xx (Informational - no errors)
35const sal_uInt16 SC_CONTINUE = 100;
36const sal_uInt16 SC_SWITCHING_PROTOCOLS = 101;
37// DAV extensions
38const sal_uInt16 SC_PROCESSING = 102;
39
40//2xx (Successful - no errors)
41const sal_uInt16 SC_OK = 200;
42const sal_uInt16 SC_CREATED = 201;
43const sal_uInt16 SC_ACCEPTED = 202;
44const sal_uInt16 SC_NON_AUTHORITATIVE_INFORMATION = 203;
45const sal_uInt16 SC_NO_CONTENT = 204;
46const sal_uInt16 SC_RESET_CONTENT = 205;
47const sal_uInt16 SC_PARTIAL_CONTENT = 206;
48// DAV extensions
49const sal_uInt16 SC_MULTISTATUS = 207;
50
51//3xx (Redirection)
52const sal_uInt16 SC_MULTIPLE_CHOICES = 300;
53const sal_uInt16 SC_MOVED_PERMANENTLY = 301;
54const sal_uInt16 SC_MOVED_TEMPORARILY = 302;
55const sal_uInt16 SC_SEE_OTHER = 303;
56const sal_uInt16 SC_NOT_MODIFIED = 304;
57const sal_uInt16 SC_USE_PROXY = 305;
58const sal_uInt16 SC_TEMPORARY_REDIRECT = 307;
59
60//4xx (Client error)
61const sal_uInt16 SC_BAD_REQUEST = 400;
62const sal_uInt16 SC_UNAUTHORIZED = 401;
63const sal_uInt16 SC_PAYMENT_REQUIRED = 402;
64const sal_uInt16 SC_FORBIDDEN = 403;
65const sal_uInt16 SC_NOT_FOUND = 404;
66const sal_uInt16 SC_METHOD_NOT_ALLOWED = 405;
67const sal_uInt16 SC_NOT_ACCEPTABLE = 406;
68const sal_uInt16 SC_PROXY_AUTHENTICATION_REQUIRED = 407;
69const sal_uInt16 SC_REQUEST_TIMEOUT = 408;
70const sal_uInt16 SC_CONFLICT = 409;
71const sal_uInt16 SC_GONE = 410;
72const sal_uInt16 SC_LENGTH_REQUIRED = 411;
73const sal_uInt16 SC_PRECONDITION_FAILED = 412;
74const sal_uInt16 SC_REQUEST_ENTITY_TOO_LARGE = 413;
75const sal_uInt16 SC_REQUEST_URI_TOO_LONG = 414;
76const sal_uInt16 SC_UNSUPPORTED_MEDIA_TYPE = 415;
78const sal_uInt16 SC_EXPECTATION_FAILED = 417;
79// DAV extensions
80const sal_uInt16 SC_UNPROCESSABLE_ENTITY = 422;
81const sal_uInt16 SC_LOCKED = 423;
82const sal_uInt16 SC_FAILED_DEPENDENCY = 424;
83
84//5xx (Server error, general <https://tools.ietf.org/html/rfc7231#section-6.6>)
85const sal_uInt16 SC_INTERNAL_SERVER_ERROR = 500;
86const sal_uInt16 SC_NOT_IMPLEMENTED = 501;
87const sal_uInt16 SC_BAD_GATEWAY = 502;
88const sal_uInt16 SC_SERVICE_UNAVAILABLE = 503;
89const sal_uInt16 SC_GATEWAY_TIMEOUT = 504;
90const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED = 505;
91// DAV extensions (<https://tools.ietf.org/html/rfc4918#section-11>)
92const sal_uInt16 SC_INSUFFICIENT_STORAGE = 507;
93
94// unofficial status codes only used internally by LO
95// used to cache the connection time out event
96const sal_uInt16 USC_CONNECTION_TIMED_OUT = 908;
97 // name resolution failed
98const sal_uInt16 USC_LOOKUP_FAILED = 909;
99const sal_uInt16 USC_AUTH_FAILED = 910;
100const sal_uInt16 USC_AUTHPROXY_FAILED = 911;
101
102
103
104class DAVException : public std::exception
105{
106 public:
108 DAV_HTTP_ERROR = 0, // Generic error,
109 // mData = server error message,
110 // mStatusCode = HTTP status code
111 DAV_HTTP_LOOKUP, // Name lookup failed,
112 // mData = server[:port]
113 DAV_HTTP_NOAUTH, // No User authentication data provided - e.g., user aborts corresponding dialog
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:
144 OUString mData;
145 sal_uInt16 mStatusCode;
146
147 public:
148 explicit DAVException( ExceptionCode inExceptionCode )
149 : mExceptionCode( inExceptionCode )
150 , mData()
152 {};
153 DAVException( ExceptionCode inExceptionCode,
154 const OUString & rData )
155 : mExceptionCode( inExceptionCode )
156 , mData( rData )
158 {};
159 DAVException( ExceptionCode inExceptionCode,
160 const OUString & rData,
161 sal_uInt16 nStatusCode )
162 : mExceptionCode( inExceptionCode )
163 , mData( rData )
164 , mStatusCode( nStatusCode )
165 {};
166
167 const ExceptionCode & getError() const { return mExceptionCode; }
168 const OUString & getData() const { return mData; }
169 sal_uInt16 getStatus() const { return mStatusCode; }
170};
171
172} // namespace http_dav_ucp
173
174/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DAVException(ExceptionCode inExceptionCode, const OUString &rData, sal_uInt16 nStatusCode)
DAVException(ExceptionCode inExceptionCode)
DAVException(ExceptionCode inExceptionCode, const OUString &rData)
const OUString & getData() const
const ExceptionCode & getError() const
sal_uInt16 getStatus() const
const ContentProperties & rData
const sal_uInt16 SC_NOT_IMPLEMENTED
const sal_uInt16 SC_TEMPORARY_REDIRECT
const sal_uInt16 SC_FAILED_DEPENDENCY
const sal_uInt16 SC_PROCESSING
const sal_uInt16 USC_AUTHPROXY_FAILED
const sal_uInt16 SC_SEE_OTHER
const sal_uInt16 SC_MULTIPLE_CHOICES
const sal_uInt16 SC_BAD_GATEWAY
const sal_uInt16 SC_CONTINUE
const sal_uInt16 SC_LOCKED
const sal_uInt16 USC_LOOKUP_FAILED
const sal_uInt16 SC_USE_PROXY
const sal_uInt16 SC_MOVED_TEMPORARILY
const sal_uInt16 SC_NON_AUTHORITATIVE_INFORMATION
const sal_uInt16 SC_NOT_ACCEPTABLE
const sal_uInt16 SC_GONE
const sal_uInt16 SC_FORBIDDEN
const sal_uInt16 USC_CONNECTION_TIMED_OUT
const sal_uInt16 SC_GATEWAY_TIMEOUT
const sal_uInt16 SC_SERVICE_UNAVAILABLE
const sal_uInt16 SC_EXPECTATION_FAILED
const sal_uInt16 SC_UNPROCESSABLE_ENTITY
const sal_uInt16 SC_PRECONDITION_FAILED
const sal_uInt16 SC_NOT_MODIFIED
const sal_uInt16 SC_NONE
const sal_uInt16 SC_PROXY_AUTHENTICATION_REQUIRED
const sal_uInt16 SC_OK
const sal_uInt16 SC_NO_CONTENT
const sal_uInt16 SC_REQUEST_URI_TOO_LONG
const sal_uInt16 SC_CONFLICT
const sal_uInt16 SC_REQUESTED_RANGE_NOT_SATISFIABLE
const sal_uInt16 SC_UNSUPPORTED_MEDIA_TYPE
const sal_uInt16 SC_MOVED_PERMANENTLY
const sal_uInt16 SC_PARTIAL_CONTENT
const sal_uInt16 SC_SWITCHING_PROTOCOLS
const sal_uInt16 SC_INSUFFICIENT_STORAGE
const sal_uInt16 SC_UNAUTHORIZED
const sal_uInt16 SC_REQUEST_ENTITY_TOO_LARGE
const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED
const sal_uInt16 SC_BAD_REQUEST
const sal_uInt16 SC_MULTISTATUS
const sal_uInt16 SC_INTERNAL_SERVER_ERROR
const sal_uInt16 SC_LENGTH_REQUIRED
const sal_uInt16 SC_ACCEPTED
const sal_uInt16 SC_NOT_FOUND
const sal_uInt16 SC_METHOD_NOT_ALLOWED
const sal_uInt16 SC_PAYMENT_REQUIRED
const sal_uInt16 USC_AUTH_FAILED
const sal_uInt16 SC_RESET_CONTENT
const sal_uInt16 SC_CREATED
const sal_uInt16 SC_REQUEST_TIMEOUT