~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/Gapps/Error.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
27
require_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
 * @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
 
42
 */
 
43
class Zend_Gdata_Gapps_Error extends Zend_Gdata_App_Base
 
44
{
 
45
    
 
46
    // Error codes as defined at 
 
47
    // http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html#appendix_d
 
48
    
 
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;
 
69
    
 
70
    protected $_errorCode = null;
 
71
    protected $_reason = null;
 
72
    protected $_invalidInput = null;
 
73
    
 
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;
 
80
    }
 
81
    
 
82
    /**
 
83
     * Set the error code for this exception. For more information about 
 
84
     * error codes, see getErrorCode.
 
85
     * 
 
86
     * @see getErrorCode
 
87
     * @param integer $value The new value for the error code.
 
88
     */
 
89
    public function setErrorCode($value) {
 
90
       $this->_errorCode = $value;
 
91
    }
 
92
    
 
93
    /** 
 
94
     * Get the error code for this exception. Currently valid values are 
 
95
     * available as constants within this class. These values are:
 
96
     * 
 
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)
 
117
     * 
 
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.
 
121
     * 
 
122
     * For more information about these codes and their meaning, please 
 
123
     * see Appendix D of the Google Apps Provisioning API Reference.
 
124
     * 
 
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
 
126
     * @see setErrorCode
 
127
     * @return integer The error code returned by the Google Apps server.
 
128
     */
 
129
    public function getErrorCode() {
 
130
        return $this->_errorCode;
 
131
    }
 
132
    
 
133
    /**
 
134
     * Set human-readable text describing the reason this exception occurred.
 
135
     * 
 
136
     * @see getReason
 
137
     * @param string $value The reason this exception occurred.
 
138
     */
 
139
    public function setReason($value) {
 
140
       $this->_reason = $value;
 
141
    }
 
142
    
 
143
    /**
 
144
     * Get human-readable text describing the reason this exception occurred.
 
145
     * 
 
146
     * @see setReason
 
147
     * @return string The reason this exception occurred.
 
148
     */
 
149
    public function getReason() {
 
150
       return $this->_reason;
 
151
    }
 
152
 
 
153
    /**
 
154
     * Set the invalid input which caused this exception.
 
155
     * 
 
156
     * @see getInvalidInput
 
157
     * @param string $value The invalid input that triggered this exception.
 
158
     */
 
159
    public function setInvalidInput($value) {
 
160
       $this->_invalidInput = $value;
 
161
    }
 
162
    
 
163
    /**
 
164
     * Set the invalid input which caused this exception.
 
165
     * 
 
166
     * @see setInvalidInput
 
167
     * @return string The reason this exception occurred.
 
168
     */
 
169
    public function getInvalidInput() {
 
170
       return $this->_invalidInput;
 
171
    }
 
172
    
 
173
    /**
 
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.
 
177
     *
 
178
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
 
179
     * @return DOMElement The DOMElement representing this element and all
 
180
     *          child properties.
 
181
     */
 
182
    public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
 
183
    {
 
184
        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
 
185
        if ($this->_errorCode !== null) {
 
186
            $element->setAttribute('errorCode', $this->_errorCode);
 
187
        }
 
188
        if ($this->_reason !== null) {
 
189
            $element->setAttribute('reason', $this->_reason);
 
190
        }
 
191
        if ($this->_invalidInput !== null) {
 
192
            $element->setAttribute('invalidInput', $this->_invalidInput);
 
193
        }
 
194
        return $element;
 
195
    }
 
196
    
 
197
    /**
 
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.
 
201
     *
 
202
     * @param DOMNode $attribute The DOMNode attribute needed to be handled
 
203
     */
 
204
    protected function takeAttributeFromDOM($attribute)
 
205
    {
 
206
        switch ($attribute->localName) {
 
207
        case 'errorCode':
 
208
            $this->_errorCode = $attribute->nodeValue;
 
209
            break;
 
210
        case 'reason':
 
211
            $this->_reason = $attribute->nodeValue;
 
212
            break;
 
213
        case 'invalidInput':
 
214
            $this->_invalidInput = $attribute->nodeValue;
 
215
            break;
 
216
        default:
 
217
            parent::takeAttributeFromDOM($attribute);
 
218
        }
 
219
    }
 
220
    
 
221
    /**
 
222
     * Get a human readable version of this exception.
 
223
     * 
 
224
     * @return string
 
225
     */
 
226
    public function __toString() {
 
227
        return "Error " . $this->getErrorCode() . ": " . $this->getReason() .
 
228
            "\n\tInvalid Input: \"" . $this->getInvalidInput() . "\"";
 
229
    }
 
230
 
 
231
}