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