16df1ea1fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
36df1ea1fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
46df1ea1fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
56df1ea1fSAndrew Rist  * distributed with this work for additional information
66df1ea1fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
76df1ea1fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
86df1ea1fSAndrew Rist  * "License"); you may not use this file except in compliance
96df1ea1fSAndrew Rist  * with the License.  You may obtain a copy of the License at
106df1ea1fSAndrew Rist  *
116df1ea1fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
126df1ea1fSAndrew Rist  *
136df1ea1fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
146df1ea1fSAndrew Rist  * software distributed under the License is distributed on an
156df1ea1fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166df1ea1fSAndrew Rist  * KIND, either express or implied.  See the License for the
176df1ea1fSAndrew Rist  * specific language governing permissions and limitations
186df1ea1fSAndrew Rist  * under the License.
196df1ea1fSAndrew Rist  *
206df1ea1fSAndrew Rist  *************************************************************/
216df1ea1fSAndrew Rist 
226df1ea1fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DAVEXCEPTION_HXX_
25cdf0e10cSrcweir #define _DAVEXCEPTION_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir 
2959ddfc10SAndre Fischer namespace http_dav_ucp
30cdf0e10cSrcweir {
31cdf0e10cSrcweir 
32cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
33cdf0e10cSrcweir // HTTP/WebDAV status codes
34cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
35cdf0e10cSrcweir 
36cdf0e10cSrcweir const sal_uInt16 SC_NONE                             = 0;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir // 1xx (Informational - no errors)
39cdf0e10cSrcweir const sal_uInt16 SC_CONTINUE                         = 100;
40cdf0e10cSrcweir const sal_uInt16 SC_SWITCHING_PROTOCOLS              = 101;
41cdf0e10cSrcweir // DAV extensions
42cdf0e10cSrcweir const sal_uInt16 SC_PROCESSING                       = 102;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir //2xx (Successful - no errors)
45cdf0e10cSrcweir const sal_uInt16 SC_OK                               = 200;
46cdf0e10cSrcweir const sal_uInt16 SC_CREATED                          = 201;
47cdf0e10cSrcweir const sal_uInt16 SC_ACCEPTED                         = 202;
48cdf0e10cSrcweir const sal_uInt16 SC_NON_AUTHORITATIVE_INFORMATION    = 203;
49cdf0e10cSrcweir const sal_uInt16 SC_NO_CONTENT                       = 204;
50cdf0e10cSrcweir const sal_uInt16 SC_RESET_CONTENT                    = 205;
51cdf0e10cSrcweir const sal_uInt16 SC_PARTIAL_CONTENT                  = 206;
52cdf0e10cSrcweir // DAV extensions
53cdf0e10cSrcweir const sal_uInt16 SC_MULTISTATUS                      = 207;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir //3xx (Redirection)
56cdf0e10cSrcweir const sal_uInt16 SC_MULTIPLE_CHOICES                 = 300;
57cdf0e10cSrcweir const sal_uInt16 SC_MOVED_PERMANENTLY                = 301;
58cdf0e10cSrcweir const sal_uInt16 SC_MOVED_TEMPORARILY                = 302;
59cdf0e10cSrcweir const sal_uInt16 SC_SEE_OTHER                        = 303;
60cdf0e10cSrcweir const sal_uInt16 SC_NOT_MODIFIED                     = 304;
61cdf0e10cSrcweir const sal_uInt16 SC_USE_PROXY                        = 305;
62cdf0e10cSrcweir const sal_uInt16 SC_TEMPORARY_REDIRECT               = 307;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //4xx (Client error)
65cdf0e10cSrcweir const sal_uInt16 SC_BAD_REQUEST                      = 400;
66cdf0e10cSrcweir const sal_uInt16 SC_UNAUTHORIZED                     = 401;
67cdf0e10cSrcweir const sal_uInt16 SC_PAYMENT_REQUIRED                 = 402;
68cdf0e10cSrcweir const sal_uInt16 SC_FORBIDDEN                        = 403;
69cdf0e10cSrcweir const sal_uInt16 SC_NOT_FOUND                        = 404;
70cdf0e10cSrcweir const sal_uInt16 SC_METHOD_NOT_ALLOWED               = 405;
71cdf0e10cSrcweir const sal_uInt16 SC_NOT_ACCEPTABLE                   = 406;
72cdf0e10cSrcweir const sal_uInt16 SC_PROXY_AUTHENTICATION_REQUIRED    = 407;
73cdf0e10cSrcweir const sal_uInt16 SC_REQUEST_TIMEOUT                  = 408;
74cdf0e10cSrcweir const sal_uInt16 SC_CONFLICT                         = 409;
75cdf0e10cSrcweir const sal_uInt16 SC_GONE                             = 410;
76cdf0e10cSrcweir const sal_uInt16 SC_LENGTH_REQUIRED                  = 411;
77cdf0e10cSrcweir const sal_uInt16 SC_PRECONDITION_FAILED              = 412;
78cdf0e10cSrcweir const sal_uInt16 SC_REQUEST_ENTITY_TOO_LARGE         = 413;
79cdf0e10cSrcweir const sal_uInt16 SC_REQUEST_URI_TOO_LONG             = 414;
80cdf0e10cSrcweir const sal_uInt16 SC_UNSUPPORTED_MEDIA_TYPE           = 415;
81cdf0e10cSrcweir const sal_uInt16 SC_REQUESTED_RANGE_NOT_SATISFIABLE  = 416;
82cdf0e10cSrcweir const sal_uInt16 SC_EXPECTATION_FAILED               = 417;
83cdf0e10cSrcweir // DAV extensions
84cdf0e10cSrcweir const sal_uInt16 SC_UNPROCESSABLE_ENTITY             = 422;
85cdf0e10cSrcweir const sal_uInt16 SC_LOCKED                           = 423;
86cdf0e10cSrcweir const sal_uInt16 SC_FAILED_DEPENDENCY                = 424;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir //5xx (Server error)
89cdf0e10cSrcweir const sal_uInt16 SC_INTERNAL_SERVER_ERROR            = 500;
90cdf0e10cSrcweir const sal_uInt16 SC_NOT_IMPLEMENTED                  = 501;
91cdf0e10cSrcweir const sal_uInt16 SC_BAD_GATEWAY                      = 502;
92cdf0e10cSrcweir const sal_uInt16 SC_SERVICE_UNAVAILABLE              = 503;
93cdf0e10cSrcweir const sal_uInt16 SC_GATEWAY_TIMEOUT                  = 504;
94cdf0e10cSrcweir const sal_uInt16 SC_HTTP_VERSION_NOT_SUPPORTED       = 505;
95cdf0e10cSrcweir // DAV extensions
96cdf0e10cSrcweir const sal_uInt16 SC_INSUFFICIENT_STORAGE             = 507;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
99cdf0e10cSrcweir 
100cdf0e10cSrcweir class DAVException
101cdf0e10cSrcweir {
102cdf0e10cSrcweir     public:
103cdf0e10cSrcweir         enum ExceptionCode {
104cdf0e10cSrcweir             DAV_HTTP_ERROR = 0, // Generic error,
105cdf0e10cSrcweir                                 // mData = server error message,
106cdf0e10cSrcweir                                 // mStatusCode = HTTP status code
107cdf0e10cSrcweir             DAV_HTTP_LOOKUP,    // Name lookup failed,
108cdf0e10cSrcweir                                 // mData = server[:port]
109*fb7f54d2SOliver-Rainer Wittmann             DAV_HTTP_NOAUTH,    // No User authentication data provided - e.g., user aborts corresponding dialog
110*fb7f54d2SOliver-Rainer Wittmann                                 // mData = server[:port]
111cdf0e10cSrcweir             DAV_HTTP_AUTH,      // User authentication failed on server,
112cdf0e10cSrcweir                                 // mData = server[:port]
113cdf0e10cSrcweir             DAV_HTTP_AUTHPROXY, // User authentication failed on proxy,
114cdf0e10cSrcweir                                 // mData = proxy server[:port]
115cdf0e10cSrcweir             DAV_HTTP_CONNECT,   // Could not connect to server,
116cdf0e10cSrcweir                                 // mData = server[:port]
117cdf0e10cSrcweir             DAV_HTTP_TIMEOUT,   // Connection timed out
118cdf0e10cSrcweir                                 // mData = server[:port]
119cdf0e10cSrcweir             DAV_HTTP_FAILED,    // The precondition failed
120cdf0e10cSrcweir                                 // mData = server[:port]
121cdf0e10cSrcweir             DAV_HTTP_RETRY,     // Retry request
122cdf0e10cSrcweir                                 // mData = server[:port]
123cdf0e10cSrcweir             DAV_HTTP_REDIRECT,  // Request was redirected,
124cdf0e10cSrcweir                                 // mData = new URL
125cdf0e10cSrcweir             DAV_SESSION_CREATE, // session creation error,
126cdf0e10cSrcweir                                 // mData = server[:port]
127cdf0e10cSrcweir             DAV_INVALID_ARG,    // invalid argument
128cdf0e10cSrcweir 
129cdf0e10cSrcweir             DAV_LOCK_EXPIRED,   // DAV lock expired
130cdf0e10cSrcweir 
131cdf0e10cSrcweir             DAV_NOT_LOCKED,     // not locked
132cdf0e10cSrcweir 
133cdf0e10cSrcweir             DAV_LOCKED_SELF,    // locked by this OOo session
134cdf0e10cSrcweir 
135cdf0e10cSrcweir             DAV_LOCKED          // locked by third party
136cdf0e10cSrcweir         };
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     private:
139cdf0e10cSrcweir         ExceptionCode   mExceptionCode;
140cdf0e10cSrcweir         rtl::OUString   mData;
141cdf0e10cSrcweir         sal_uInt16      mStatusCode;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     public:
14459ddfc10SAndre Fischer          DAVException( ExceptionCode inExceptionCode )
14559ddfc10SAndre Fischer              : mExceptionCode( inExceptionCode )
14659ddfc10SAndre Fischer              , mData()
14759ddfc10SAndre Fischer              , mStatusCode( SC_NONE )
14859ddfc10SAndre Fischer          {};
149cdf0e10cSrcweir          DAVException( ExceptionCode inExceptionCode,
15059ddfc10SAndre Fischer                        const rtl::OUString & rData )
15159ddfc10SAndre Fischer              : mExceptionCode( inExceptionCode )
15259ddfc10SAndre Fischer              , mData( rData )
15359ddfc10SAndre Fischer              , mStatusCode( SC_NONE )
15459ddfc10SAndre Fischer          {};
155cdf0e10cSrcweir          DAVException( ExceptionCode inExceptionCode,
156cdf0e10cSrcweir                        const rtl::OUString & rData,
15759ddfc10SAndre Fischer                        sal_uInt16 nStatusCode )
15859ddfc10SAndre Fischer             : mExceptionCode( inExceptionCode )
15959ddfc10SAndre Fischer             , mData( rData )
16059ddfc10SAndre Fischer             , mStatusCode( nStatusCode )
16159ddfc10SAndre Fischer          {};
162cdf0e10cSrcweir         ~DAVException( ) {};
163cdf0e10cSrcweir 
164cdf0e10cSrcweir     const ExceptionCode & getError() const { return mExceptionCode; }
165cdf0e10cSrcweir     const rtl::OUString & getData() const  { return mData; }
166cdf0e10cSrcweir     sal_uInt16 getStatus() const { return mStatusCode; }
167cdf0e10cSrcweir };
168cdf0e10cSrcweir 
16959ddfc10SAndre Fischer } // namespace http_dav_ucp
170cdf0e10cSrcweir 
171cdf0e10cSrcweir #endif // _DAVEXCEPTION_HXX_
172