source: trunk/www.guidonia.net/wp/wp-content/plugins/webtv/Drivers/Zend/Gdata/Gapps/Error.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 7.7 KB
Line 
1<?php
2
3/**
4 * Zend Framework
5 *
6 * LICENSE
7 *
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.
15 *
16 * @category Zend
17 * @package Zend_Gdata
18 * @subpackage Gapps
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
21 */
22
23
24/**
25 * Zend_Gdata_App_Base
26 */
27require_once 'Zend/Gdata/App/Base.php';
28
29/**
30 * Gdata Gapps Error class. This class is used to represent errors returned
31 * within an AppsForYourDomainErrors message received from the Google Apps
32 * servers.
33 *
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.
37 *
38 * @category Zend
39 * @package Zend_Gdata
40 * @subpackage Gapps
41 * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
42 * @license http://framework.zend.com/license/new-bsd New BSD License
43 */
44class Zend_Gdata_Gapps_Error extends Zend_Gdata_App_Base
45{
46
47 // Error codes as defined at
48 // http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#appendix_d
49
50 const UNKNOWN_ERROR = 1000;
51 const USER_DELETED_RECENTLY = 1100;
52 const USER_SUSPENDED = 1101;
53 const DOMAIN_USER_LIMIT_EXCEEDED = 1200;
54 const DOMAIN_ALIAS_LIMIT_EXCEEDED = 1201;
55 const DOMAIN_SUSPENDED = 1202;
56 const DOMAIN_FEATURE_UNAVAILABLE = 1203;
57 const ENTITY_EXISTS = 1300;
58 const ENTITY_DOES_NOT_EXIST = 1301;
59 const ENTITY_NAME_IS_RESERVED = 1302;
60 const ENTITY_NAME_NOT_VALID = 1303;
61 const INVALID_GIVEN_NAME = 1400;
62 const INVALID_FAMILY_NAME = 1401;
63 const INVALID_PASSWORD = 1402;
64 const INVALID_USERNAME = 1403;
65 const INVALID_HASH_FUNCTION_NAME = 1404;
66 const INVALID_HASH_DIGEST_LENGTH = 1405;
67 const INVALID_EMAIL_ADDRESS = 1406;
68 const INVALID_QUERY_PARAMETER_VALUE = 1407;
69 const TOO_MANY_RECIPIENTS_ON_EMAIL_LIST = 1500;
70
71 protected $_errorCode = null;
72 protected $_reason = null;
73 protected $_invalidInput = null;
74
75 public function __construct($errorCode = null, $reason = null,
76 $invalidInput = null) {
77 parent::__construct("Google Apps error received: $errorCode ($reason)");
78 $this->_errorCode = $errorCode;
79 $this->_reason = $reason;
80 $this->_invalidInput = $invalidInput;
81 }
82
83 /**
84 * Set the error code for this exception. For more information about
85 * error codes, see getErrorCode.
86 *
87 * @see getErrorCode
88 * @param integer $value The new value for the error code.
89 */
90 public function setErrorCode($value) {
91 $this->_errorCode = $value;
92 }
93
94 /**
95 * Get the error code for this exception. Currently valid values are
96 * available as constants within this class. These values are:
97 *
98 * UNKNOWN_ERROR (1000)
99 * USER_DELETED_RECENTLY (1100)
100 * USER_SUSPENDED (1101)
101 * DOMAIN_USER_LIMIT_EXCEEDED (1200)
102 * DOMAIN_ALIAS_LIMIT_EXCEEDED (1201)
103 * DOMAIN_SUSPENDED (1202)
104 * DOMAIN_FEATURE_UNAVAILABLE (1203)
105 * ENTITY_EXISTS (1300)
106 * ENTITY_DOES_NOT_EXIST (1301)
107 * ENTITY_NAME_IS_RESERVED (1302)
108 * ENTITY_NAME_NOT_VALID (1303)
109 * INVALID_GIVEN_NAME (1400)
110 * INVALID_FAMILY_NAME (1401)
111 * INVALID_PASSWORD (1402)
112 * INVALID_USERNAME (1403)
113 * INVALID_HASH_FUNCTION_NAME (1404)
114 * INVALID_HASH_DIGEST_LENGTH (1405)
115 * INVALID_EMAIL_ADDRESS (1406)
116 * INVALID_QUERY_PARAMETER_VALUE (1407)
117 * TOO_MANY_RECIPIENTS_ON_EMAIL_LIST (1500)
118 *
119 * Numbers in parenthesis indicate the actual integer value of the
120 * constant. This list should not be treated as exhaustive, as additional
121 * error codes may be added at any time.
122 *
123 * For more information about these codes and their meaning, please
124 * see Appendix D of the Google Apps Provisioning API Reference.
125 *
126 * @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 * @see setErrorCode
128 * @return integer The error code returned by the Google Apps server.
129 */
130 public function getErrorCode() {
131 return $this->_errorCode;
132 }
133
134 /**
135 * Set human-readable text describing the reason this exception occurred.
136 *
137 * @see getReason
138 * @param string $value The reason this exception occurred.
139 */
140 public function setReason($value) {
141 $this->_reason = $value;
142 }
143
144 /**
145 * Get human-readable text describing the reason this exception occurred.
146 *
147 * @see setReason
148 * @return string The reason this exception occurred.
149 */
150 public function getReason() {
151 return $this->_reason;
152 }
153
154 /**
155 * Set the invalid input which caused this exception.
156 *
157 * @see getInvalidInput
158 * @param string $value The invalid input that triggered this exception.
159 */
160 public function setInvalidInput($value) {
161 $this->_invalidInput = $value;
162 }
163
164 /**
165 * Set the invalid input which caused this exception.
166 *
167 * @see setInvalidInput
168 * @return string The reason this exception occurred.
169 */
170 public function getInvalidInput() {
171 return $this->_invalidInput;
172 }
173
174 /**
175 * Retrieves a DOMElement which corresponds to this element and all
176 * child properties. This is used to build an entry back into a DOM
177 * and eventually XML text for application storage/persistence.
178 *
179 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
180 * @return DOMElement The DOMElement representing this element and all
181 * child properties.
182 */
183 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
184 {
185 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
186 if ($this->_errorCode !== null) {
187 $element->setAttribute('errorCode', $this->_errorCode);
188 }
189 if ($this->_reason !== null) {
190 $element->setAttribute('reason', $this->_reason);
191 }
192 if ($this->_invalidInput !== null) {
193 $element->setAttribute('invalidInput', $this->_invalidInput);
194 }
195 return $element;
196 }
197
198 /**
199 * Given a DOMNode representing an attribute, tries to map the data into
200 * instance members. If no mapping is defined, the name and value are
201 * stored in an array.
202 *
203 * @param DOMNode $attribute The DOMNode attribute needed to be handled
204 */
205 protected function takeAttributeFromDOM($attribute)
206 {
207 switch ($attribute->localName) {
208 case 'errorCode':
209 $this->_errorCode = $attribute->nodeValue;
210 break;
211 case 'reason':
212 $this->_reason = $attribute->nodeValue;
213 break;
214 case 'invalidInput':
215 $this->_invalidInput = $attribute->nodeValue;
216 break;
217 default:
218 parent::takeAttributeFromDOM($attribute);
219 }
220 }
221
222 /**
223 * Get a human readable version of this exception.
224 *
225 * @return string
226 */
227 public function __toString() {
228 return "Error " . $this->getErrorCode() . ": " . $this->getReason() .
229 "\n\tInvalid Input: \"" . $this->getInvalidInput() . "\"";
230 }
231
232}
Note: See TracBrowser for help on using the repository browser.