Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
4
 
5
// LICENSE AGREEMENT. If folded, press za here to unfold and read license {{{
6
 
7
/**
8
* +-----------------------------------------------------------------------------+
9
* | Copyright (c) 2004-2006 Sergio Goncalves Carvalho                                |
10
* +-----------------------------------------------------------------------------+
11
* | This file is part of XML_RPC2.                                              |
12
* |                                                                             |
13
* | XML_RPC2 is free software; you can redistribute it and/or modify            |
14
* | it under the terms of the GNU Lesser General Public License as published by |
15
* | the Free Software Foundation; either version 2.1 of the License, or         |
16
* | (at your option) any later version.                                         |
17
* |                                                                             |
18
* | XML_RPC2 is distributed in the hope that it will be useful,                 |
19
* | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
20
* | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
21
* | GNU Lesser General Public License for more details.                         |
22
* |                                                                             |
23
* | You should have received a copy of the GNU Lesser General Public License    |
24
* | along with XML_RPC2; if not, write to the Free Software                     |
25
* | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA                    |
26
* | 02111-1307 USA                                                              |
27
* +-----------------------------------------------------------------------------+
28
* | Author: Sergio Carvalho <sergio.carvalho@portugalmail.com>                  |
29
* +-----------------------------------------------------------------------------+
30
*
31
* @category   XML
32
* @package    XML_RPC2
33
* @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
34
* @copyright  2004-2006 Sergio Carvalho
35
* @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
36
* @version    CVS: $Id: Exception.php 308615 2011-02-23 21:44:05Z sergiosgc $
37
* @link       http://pear.php.net/package/XML_RPC2
38
*/
39
 
40
// }}}
41
 
42
/**
43
 * XML_RPC2 base exception class. All XML_RPC2 originated exceptions inherit from XML_RPC2_Exception
44
 *
45
 * @category   XML
46
 * @package    XML_RPC2
47
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
48
 * @copyright  2004-2006 Sergio Carvalho
49
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
50
 * @link       http://pear.php.net/package/XML_RPC2
51
 */
52
class XML_RPC2_Exception extends Exception
53
{
54
}
55
 
56
/* Encoding and decoding values exceptions {{{
57
/**
58
 * XML_RPC2_InvalidTypeException is thrown whenever an invalid XML_RPC type is used in an operation
59
 *
60
 * @category   XML
61
 * @package    XML_RPC2
62
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
63
 * @copyright  2004-2006 Sergio Carvalho
64
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
65
 * @link       http://pear.php.net/package/XML_RPC2
66
 */
67
class XML_RPC2_InvalidTypeException extends XML_RPC2_Exception
68
{
69
}
70
 
71
/**
72
 * XML_RPC2_InvalidTypeException is thrown when creating DateTime value objects from invalid string datetime representations
73
 *
74
 * @category   XML
75
 * @package    XML_RPC2
76
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
77
 * @copyright  2004-2006 Sergio Carvalho
78
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
79
 * @link       http://pear.php.net/package/XML_RPC2
80
 */
81
class XML_RPC2_InvalidDateFormatException extends XML_RPC2_Exception
82
{
83
}
84
 
85
/**
86
 * XML_RPC2_EncodeException is thrown whenever a class is asked to encode itself in XML with invalid or not enough data.
87
 *
88
 * @category   XML
89
 * @package    XML_RPC2
90
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
91
 * @copyright  2004-2006 Sergio Carvalho
92
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
93
 * @link       http://pear.php.net/package/XML_RPC2
94
 */
95
class XML_RPC2_EncodeException extends XML_RPC2_Exception
96
{
97
}
98
 
99
/**
100
 * XML_RPC2_DecodeException is thrown whenever there is a problem decoding transport XML
101
 *
102
 * @category   XML
103
 * @package    XML_RPC2
104
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
105
 * @copyright  2004-2006 Sergio Carvalho
106
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
107
 * @link       http://pear.php.net/package/XML_RPC2
108
 */
109
class XML_RPC2_DecodeException extends XML_RPC2_Exception
110
{
111
}
112
 
113
/**
114
 * XML_RPC2_InvalidTypeEncodeException is thrown whenever a class is asked to encode itself and provided a PHP type
115
 * that can't be translated to XML_RPC
116
 *
117
 * @category   XML
118
 * @package    XML_RPC2
119
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
120
 * @copyright  2004-2006 Sergio Carvalho
121
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
122
 * @link       http://pear.php.net/package/XML_RPC2
123
 */
124
class XML_RPC2_InvalidTypeEncodeException extends XML_RPC2_Exception
125
{
126
}
127
/* }}} */
128
 
129
/**
130
 * XML_RPC2_InvalidUriException is thrown whenever the XML_RPC2 client is asked to use an invalid uri
131
 *
132
 * @category   XML
133
 * @package    XML_RPC2
134
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
135
 * @copyright  2004-2006 Sergio Carvalho
136
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
137
 * @link       http://pear.php.net/package/XML_RPC2
138
 */
139
class XML_RPC2_InvalidUriException extends XML_RPC2_Exception
140
{
141
}
142
 
143
/**
144
 * XML_RPC2_InvalidPrefixException is thrown whenever the XML_RPC2 client is asked to use an invalid XML/RPC prefix
145
 *
146
 * @category   XML
147
 * @package    XML_RPC2
148
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
149
 * @copyright  2004-2006 Sergio Carvalho
150
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
151
 * @link       http://pear.php.net/package/XML_RPC2
152
 */
153
class XML_RPC2_InvalidPrefixException extends XML_RPC2_Exception
154
{
155
}
156
 
157
/**
158
 * XML_RPC2_InvalidPrefixException is thrown whenever the XML_RPC2 client is asked to use an invalid XML/RPC debug flag
159
 *
160
 * @category   XML
161
 * @package    XML_RPC2
162
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
163
 * @copyright  2004-2006 Sergio Carvalho
164
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
165
 * @link       http://pear.php.net/package/XML_RPC2
166
 */
167
class XML_RPC2_InvalidDebugException extends XML_RPC2_Exception
168
{
169
}
170
 
171
/**
172
 * XML_RPC2_InvalidSslverifyException is thrown whenever the XML_RPC2 client is asked to use an invalid XML/RPC SSL verify flag
173
 *
174
 * @category   XML
175
 * @package    XML_RPC2
176
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
177
 * @copyright  2004-2006 Sergio Carvalho
178
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
179
 * @link       http://pear.php.net/package/XML_RPC2
180
 */
181
class XML_RPC2_InvalidSslverifyException extends XML_RPC2_Exception
182
{
183
}
184
 
185
/**
186
 * XML_RPC2_InvalidConnectionTimeoutException is thrown whenever the XML_RPC2
187
 * client is asked to use an invalid XML/RPC connection timeout value
188
 *
189
 * @category   XML
190
 * @package    XML_RPC2
191
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
192
 * @copyright  2004-2006 Sergio Carvalho
193
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
194
 * @link       http://pear.php.net/package/XML_RPC2
195
 */
196
class XML_RPC2_InvalidConnectionTimeoutException extends XML_RPC2_Exception
197
{
198
}
199
 
200
/**
201
 * XML_RPC2_FaultException signals a XML-RPC response that contains a fault element instead of a regular params element.
202
 *
203
 * @category   XML
204
 * @package    XML_RPC2
205
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
206
 * @copyright  2004-2006 Sergio Carvalho
207
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
208
 * @link       http://pear.php.net/package/XML_RPC2
209
 */
210
class XML_RPC2_FaultException extends XML_RPC2_Exception
211
{
212
 
213
    // {{{ properties
214
 
215
    /**
216
    * Fault code (in the response body)
217
    *
218
    * @var string
219
    */
220
    protected $faultCode = null;
221
 
222
    // }}}
223
    // {{{ constructor
224
 
225
    /** Construct a new XML_RPC2_FaultException with a given message string and fault code
226
     *
227
     * @param string        The message string, corresponding to the faultString present in the response body
228
     * @param string        The fault code, corresponding to the faultCode in the response body
229
     */
230
    function __construct($messageString, $faultCode)
231
    {
232
        parent::__construct($messageString);
233
        $this->faultCode = $faultCode;
234
    }
235
 
236
    // }}}
237
    // {{{ getFaultCode()
238
 
239
    /**
240
     * FaultCode getter
241
     *
242
     * @return string fault code
243
     */
244
    public function getFaultCode()
245
    {
246
        return $this->faultCode;
247
    }
248
 
249
    // }}}
250
    // {{{ getFaultString()
251
 
252
    /**
253
     * FaultString getter
254
     *
255
     * This is an alias to getMessage() in order to respect XML-RPC nomenclature for faults
256
     *
257
     * @return string fault code
258
     */
259
    public function getFaultString()
260
    {
261
        return $this->getMessage();
262
    }
263
 
264
    // }}}
265
    // {{{ createFromDecode()
266
 
267
    /**
268
    * Create a XML_RPC2_FaultException by decoding the corresponding xml string
269
    *
270
    * @param string $xml
271
    * @return object a XML_RPC2_FaultException
272
    */
273
    public static function createFromDecode($xml) {
274
        require_once 'XML/RPC2/Backend/Php/Value.php';
275
 
276
        // This is the only way I know of creating a new Document rooted in the provided simpleXMLFragment (needed for the xpath expressions that does not segfault sometimes
277
        $xml = simplexml_load_string($xml->asXML());
278
        $struct = XML_RPC2_Backend_Php_Value::createFromDecode($xml->value)->getNativeValue();
279
        if (!(is_array($struct) &&
280
              array_key_exists('faultString', $struct) &&
281
              array_key_exists('faultCode', $struct))) throw new XML_RPC2_DecodeException('Unable to decode XML-RPC fault payload');
282
 
283
        return new XML_RPC2_FaultException( $struct['faultString'], $struct['faultCode'] );
284
    }
285
 
286
    // }}}
287
 
288
}
289
 
290
/**
291
 * XML_RPC2_UnknownMethodException is thrown when a non-existent method is remote-called
292
 *
293
 * @category   XML
294
 * @package    XML_RPC2
295
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
296
 * @copyright  2004-2006 Sergio Carvalho
297
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
298
 * @link       http://pear.php.net/package/XML_RPC2
299
 */
300
class XML_RPC2_UnknownMethodException extends XML_RPC2_Exception
301
{
302
}
303
 
304
/**
305
 * XML_RPC2_TransportException signal transport level exceptions that stop requests from reaching the server
306
 *
307
 * @category   XML
308
 * @package    XML_RPC2
309
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
310
 * @copyright  2004-2006 Sergio Carvalho
311
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
312
 * @link       http://pear.php.net/package/XML_RPC2
313
 */
314
class XML_RPC2_TransportException extends XML_RPC2_Exception
315
{
316
}
317
 
318
/**
319
 * XML_RPC2_ReceivedInvalidStatusCodeExceptionextends is thrown whenever the XML_RPC2 response to a request does not return a 200 http status code.
320
 *
321
 * @category   XML
322
 * @package    XML_RPC2
323
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
324
 * @copyright  2004-2006 Sergio Carvalho
325
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
326
 * @link       http://pear.php.net/package/XML_RPC2
327
 */
328
class XML_RPC2_ReceivedInvalidStatusCodeException extends XML_RPC2_TransportException
329
{
330
}
331
 
332
/**
333
 * XML_RPC2_CurlException is thrown whenever an error is reported by the low level HTTP cURL library
334
 *
335
 * @category   XML
336
 * @package    XML_RPC2
337
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
338
 * @copyright  2004-2006 Sergio Carvalho
339
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
340
 * @link       http://pear.php.net/package/XML_RPC2
341
 */
342
class XML_RPC2_CurlException extends XML_RPC2_TransportException
343
{
344
}
345
 
346
/**
347
 * XML_RPC2_ConfigException is thrown whenever PHP config clashes with XML_RPC2 requirements or config
348
 *
349
 * @category   XML
350
 * @package    XML_RPC2
351
 * @author     Sergio Carvalho <sergio.carvalho@portugalmail.com>
352
 * @copyright  2004-2006 Sergio Carvalho
353
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
354
 * @link       http://pear.php.net/package/XML_RPC2
355
 */
356
class XML_RPC2_ConfigException extends XML_RPC2_Exception
357
{
358
}
359
 
360
?>