File indexing completed on 2025-03-02 05:29:27
0001 <?php 0002 0003 /** 0004 * Zend Framework 0005 * 0006 * LICENSE 0007 * 0008 * This source file is subject to the new BSD license that is bundled 0009 * with this package in the file LICENSE.txt. 0010 * It is also available through the world-wide-web at this URL: 0011 * http://framework.zend.com/license/new-bsd 0012 * If you did not receive a copy of the license and are unable to 0013 * obtain it through the world-wide-web, please send an email 0014 * to license@zend.com so we can send you a copy immediately. 0015 * 0016 * @category Zend 0017 * @package Zend_Gdata 0018 * @subpackage Gapps 0019 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 * @version $Id$ 0022 */ 0023 0024 0025 /** 0026 * Zend_Gdata_App_Base 0027 */ 0028 // require_once 'Zend/Gdata/App/Base.php'; 0029 0030 /** 0031 * Gdata Gapps Error class. This class is used to represent errors returned 0032 * within an AppsForYourDomainErrors message received from the Google Apps 0033 * servers. 0034 * 0035 * Several different errors may be represented by this class, determined by 0036 * the error code returned by the server. For a list of error codes 0037 * available at the time of this writing, see getErrorCode. 0038 * 0039 * @category Zend 0040 * @package Zend_Gdata 0041 * @subpackage Gapps 0042 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0043 * @license http://framework.zend.com/license/new-bsd New BSD License 0044 */ 0045 class Zend_Gdata_Gapps_Error extends Zend_Gdata_App_Base 0046 { 0047 0048 // Error codes as defined at 0049 // http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#appendix_d 0050 0051 const UNKNOWN_ERROR = 1000; 0052 const USER_DELETED_RECENTLY = 1100; 0053 const USER_SUSPENDED = 1101; 0054 const DOMAIN_USER_LIMIT_EXCEEDED = 1200; 0055 const DOMAIN_ALIAS_LIMIT_EXCEEDED = 1201; 0056 const DOMAIN_SUSPENDED = 1202; 0057 const DOMAIN_FEATURE_UNAVAILABLE = 1203; 0058 const ENTITY_EXISTS = 1300; 0059 const ENTITY_DOES_NOT_EXIST = 1301; 0060 const ENTITY_NAME_IS_RESERVED = 1302; 0061 const ENTITY_NAME_NOT_VALID = 1303; 0062 const INVALID_GIVEN_NAME = 1400; 0063 const INVALID_FAMILY_NAME = 1401; 0064 const INVALID_PASSWORD = 1402; 0065 const INVALID_USERNAME = 1403; 0066 const INVALID_HASH_FUNCTION_NAME = 1404; 0067 const INVALID_HASH_DIGEST_LENGTH = 1405; 0068 const INVALID_EMAIL_ADDRESS = 1406; 0069 const INVALID_QUERY_PARAMETER_VALUE = 1407; 0070 const TOO_MANY_RECIPIENTS_ON_EMAIL_LIST = 1500; 0071 0072 protected $_errorCode = null; 0073 protected $_reason = null; 0074 protected $_invalidInput = null; 0075 0076 public function __construct($errorCode = null, $reason = null, 0077 $invalidInput = null) { 0078 parent::__construct("Google Apps error received: $errorCode ($reason)"); 0079 $this->_errorCode = $errorCode; 0080 $this->_reason = $reason; 0081 $this->_invalidInput = $invalidInput; 0082 } 0083 0084 /** 0085 * Set the error code for this exception. For more information about 0086 * error codes, see getErrorCode. 0087 * 0088 * @see getErrorCode 0089 * @param integer $value The new value for the error code. 0090 */ 0091 public function setErrorCode($value) { 0092 $this->_errorCode = $value; 0093 } 0094 0095 /** 0096 * Get the error code for this exception. Currently valid values are 0097 * available as constants within this class. These values are: 0098 * 0099 * UNKNOWN_ERROR (1000) 0100 * USER_DELETED_RECENTLY (1100) 0101 * USER_SUSPENDED (1101) 0102 * DOMAIN_USER_LIMIT_EXCEEDED (1200) 0103 * DOMAIN_ALIAS_LIMIT_EXCEEDED (1201) 0104 * DOMAIN_SUSPENDED (1202) 0105 * DOMAIN_FEATURE_UNAVAILABLE (1203) 0106 * ENTITY_EXISTS (1300) 0107 * ENTITY_DOES_NOT_EXIST (1301) 0108 * ENTITY_NAME_IS_RESERVED (1302) 0109 * ENTITY_NAME_NOT_VALID (1303) 0110 * INVALID_GIVEN_NAME (1400) 0111 * INVALID_FAMILY_NAME (1401) 0112 * INVALID_PASSWORD (1402) 0113 * INVALID_USERNAME (1403) 0114 * INVALID_HASH_FUNCTION_NAME (1404) 0115 * INVALID_HASH_DIGEST_LENGTH (1405) 0116 * INVALID_EMAIL_ADDRESS (1406) 0117 * INVALID_QUERY_PARAMETER_VALUE (1407) 0118 * TOO_MANY_RECIPIENTS_ON_EMAIL_LIST (1500) 0119 * 0120 * Numbers in parenthesis indicate the actual integer value of the 0121 * constant. This list should not be treated as exhaustive, as additional 0122 * error codes may be added at any time. 0123 * 0124 * For more information about these codes and their meaning, please 0125 * see Appendix D of the Google Apps Provisioning API Reference. 0126 * 0127 * @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 0128 * @see setErrorCode 0129 * @return integer The error code returned by the Google Apps server. 0130 */ 0131 public function getErrorCode() { 0132 return $this->_errorCode; 0133 } 0134 0135 /** 0136 * Set human-readable text describing the reason this exception occurred. 0137 * 0138 * @see getReason 0139 * @param string $value The reason this exception occurred. 0140 */ 0141 public function setReason($value) { 0142 $this->_reason = $value; 0143 } 0144 0145 /** 0146 * Get human-readable text describing the reason this exception occurred. 0147 * 0148 * @see setReason 0149 * @return string The reason this exception occurred. 0150 */ 0151 public function getReason() { 0152 return $this->_reason; 0153 } 0154 0155 /** 0156 * Set the invalid input which caused this exception. 0157 * 0158 * @see getInvalidInput 0159 * @param string $value The invalid input that triggered this exception. 0160 */ 0161 public function setInvalidInput($value) { 0162 $this->_invalidInput = $value; 0163 } 0164 0165 /** 0166 * Set the invalid input which caused this exception. 0167 * 0168 * @see setInvalidInput 0169 * @return string The reason this exception occurred. 0170 */ 0171 public function getInvalidInput() { 0172 return $this->_invalidInput; 0173 } 0174 0175 /** 0176 * Retrieves a DOMElement which corresponds to this element and all 0177 * child properties. This is used to build an entry back into a DOM 0178 * and eventually XML text for application storage/persistence. 0179 * 0180 * @param DOMDocument $doc The DOMDocument used to construct DOMElements 0181 * @return DOMElement The DOMElement representing this element and all 0182 * child properties. 0183 */ 0184 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) 0185 { 0186 $element = parent::getDOM($doc, $majorVersion, $minorVersion); 0187 if ($this->_errorCode !== null) { 0188 $element->setAttribute('errorCode', $this->_errorCode); 0189 } 0190 if ($this->_reason !== null) { 0191 $element->setAttribute('reason', $this->_reason); 0192 } 0193 if ($this->_invalidInput !== null) { 0194 $element->setAttribute('invalidInput', $this->_invalidInput); 0195 } 0196 return $element; 0197 } 0198 0199 /** 0200 * Given a DOMNode representing an attribute, tries to map the data into 0201 * instance members. If no mapping is defined, the name and value are 0202 * stored in an array. 0203 * 0204 * @param DOMNode $attribute The DOMNode attribute needed to be handled 0205 */ 0206 protected function takeAttributeFromDOM($attribute) 0207 { 0208 switch ($attribute->localName) { 0209 case 'errorCode': 0210 $this->_errorCode = $attribute->nodeValue; 0211 break; 0212 case 'reason': 0213 $this->_reason = $attribute->nodeValue; 0214 break; 0215 case 'invalidInput': 0216 $this->_invalidInput = $attribute->nodeValue; 0217 break; 0218 default: 0219 parent::takeAttributeFromDOM($attribute); 0220 } 0221 } 0222 0223 /** 0224 * Get a human readable version of this exception. 0225 * 0226 * @return string 0227 */ 0228 public function __toString() { 0229 return "Error " . $this->getErrorCode() . ": " . $this->getReason() . 0230 "\n\tInvalid Input: \"" . $this->getInvalidInput() . "\""; 0231 } 0232 0233 }