8
* This source file is subject to the new BSD license that is bundled
9
* with this package in the file LICENSE.txt.
10
* It is also available through the world-wide-web at this URL:
11
* http://framework.zend.com/license/new-bsd
12
* If you did not receive a copy of the license and are unable to
13
* obtain it through the world-wide-web, please send an email
14
* to license@zend.com so we can send you a copy immediately.
19
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
20
* @license http://framework.zend.com/license/new-bsd New BSD License
27
require_once 'Zend/Gdata/App/Base.php';
30
* Gdata Gapps Error class. This class is used to represent errors returned
31
* within an AppsForYourDomainErrors message received from the Google Apps
34
* Several different errors may be represented by this class, determined by
35
* the error code returned by the server. For a list of error codes
36
* available at the time of this writing, see getErrorCode.
40
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
41
* @license http://framework.zend.com/license/new-bsd New BSD License
43
class Zend_Gdata_Gapps_Error extends Zend_Gdata_App_Base
46
// Error codes as defined at
47
// http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#appendix_d
49
const UNKNOWN_ERROR = 1000;
50
const USER_DELETED_RECENTLY = 1100;
51
const USER_SUSPENDED = 1101;
52
const DOMAIN_USER_LIMIT_EXCEEDED = 1200;
53
const DOMAIN_ALIAS_LIMIT_EXCEEDED = 1201;
54
const DOMAIN_SUSPENDED = 1202;
55
const DOMAIN_FEATURE_UNAVAILABLE = 1203;
56
const ENTITY_EXISTS = 1300;
57
const ENTITY_DOES_NOT_EXIST = 1301;
58
const ENTITY_NAME_IS_RESERVED = 1302;
59
const ENTITY_NAME_NOT_VALID = 1303;
60
const INVALID_GIVEN_NAME = 1400;
61
const INVALID_FAMILY_NAME = 1401;
62
const INVALID_PASSWORD = 1402;
63
const INVALID_USERNAME = 1403;
64
const INVALID_HASH_FUNCTION_NAME = 1404;
65
const INVALID_HASH_DIGEST_LENGTH = 1405;
66
const INVALID_EMAIL_ADDRESS = 1406;
67
const INVALID_QUERY_PARAMETER_VALUE = 1407;
68
const TOO_MANY_RECIPIENTS_ON_EMAIL_LIST = 1500;
70
protected $_errorCode = null;
71
protected $_reason = null;
72
protected $_invalidInput = null;
74
public function __construct($errorCode = null, $reason = null,
75
$invalidInput = null) {
76
parent::__construct("Google Apps error received: $errorCode ($reason)");
77
$this->_errorCode = $errorCode;
78
$this->_reason = $reason;
79
$this->_invalidInput = $invalidInput;
83
* Set the error code for this exception. For more information about
84
* error codes, see getErrorCode.
87
* @param integer $value The new value for the error code.
89
public function setErrorCode($value) {
90
$this->_errorCode = $value;
94
* Get the error code for this exception. Currently valid values are
95
* available as constants within this class. These values are:
97
* UNKNOWN_ERROR (1000)
98
* USER_DELETED_RECENTLY (1100)
99
* USER_SUSPENDED (1101)
100
* DOMAIN_USER_LIMIT_EXCEEDED (1200)
101
* DOMAIN_ALIAS_LIMIT_EXCEEDED (1201)
102
* DOMAIN_SUSPENDED (1202)
103
* DOMAIN_FEATURE_UNAVAILABLE (1203)
104
* ENTITY_EXISTS (1300)
105
* ENTITY_DOES_NOT_EXIST (1301)
106
* ENTITY_NAME_IS_RESERVED (1302)
107
* ENTITY_NAME_NOT_VALID (1303)
108
* INVALID_GIVEN_NAME (1400)
109
* INVALID_FAMILY_NAME (1401)
110
* INVALID_PASSWORD (1402)
111
* INVALID_USERNAME (1403)
112
* INVALID_HASH_FUNCTION_NAME (1404)
113
* INVALID_HASH_DIGEST_LENGTH (1405)
114
* INVALID_EMAIL_ADDRESS (1406)
115
* INVALID_QUERY_PARAMETER_VALUE (1407)
116
* TOO_MANY_RECIPIENTS_ON_EMAIL_LIST (1500)
118
* Numbers in parenthesis indicate the actual integer value of the
119
* constant. This list should not be treated as exhaustive, as additional
120
* error codes may be added at any time.
122
* For more information about these codes and their meaning, please
123
* see Appendix D of the Google Apps Provisioning API Reference.
125
* @link http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#appendix_d Google Apps Provisioning API Reference: Appendix D - Gdata Error Codes
127
* @return integer The error code returned by the Google Apps server.
129
public function getErrorCode() {
130
return $this->_errorCode;
134
* Set human-readable text describing the reason this exception occurred.
137
* @param string $value The reason this exception occurred.
139
public function setReason($value) {
140
$this->_reason = $value;
144
* Get human-readable text describing the reason this exception occurred.
147
* @return string The reason this exception occurred.
149
public function getReason() {
150
return $this->_reason;
154
* Set the invalid input which caused this exception.
156
* @see getInvalidInput
157
* @param string $value The invalid input that triggered this exception.
159
public function setInvalidInput($value) {
160
$this->_invalidInput = $value;
164
* Set the invalid input which caused this exception.
166
* @see setInvalidInput
167
* @return string The reason this exception occurred.
169
public function getInvalidInput() {
170
return $this->_invalidInput;
174
* Retrieves a DOMElement which corresponds to this element and all
175
* child properties. This is used to build an entry back into a DOM
176
* and eventually XML text for application storage/persistence.
178
* @param DOMDocument $doc The DOMDocument used to construct DOMElements
179
* @return DOMElement The DOMElement representing this element and all
182
public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
184
$element = parent::getDOM($doc, $majorVersion, $minorVersion);
185
if ($this->_errorCode !== null) {
186
$element->setAttribute('errorCode', $this->_errorCode);
188
if ($this->_reason !== null) {
189
$element->setAttribute('reason', $this->_reason);
191
if ($this->_invalidInput !== null) {
192
$element->setAttribute('invalidInput', $this->_invalidInput);
198
* Given a DOMNode representing an attribute, tries to map the data into
199
* instance members. If no mapping is defined, the name and value are
200
* stored in an array.
202
* @param DOMNode $attribute The DOMNode attribute needed to be handled
204
protected function takeAttributeFromDOM($attribute)
206
switch ($attribute->localName) {
208
$this->_errorCode = $attribute->nodeValue;
211
$this->_reason = $attribute->nodeValue;
214
$this->_invalidInput = $attribute->nodeValue;
217
parent::takeAttributeFromDOM($attribute);
222
* Get a human readable version of this exception.
226
public function __toString() {
227
return "Error " . $this->getErrorCode() . ": " . $this->getReason() .
228
"\n\tInvalid Input: \"" . $this->getInvalidInput() . "\"";