comparison errors.js @ 0:9ee956af41e3

Initial commit
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 27 Jun 2010 22:05:12 +0200
parents
children 5fc4ee90c1bc
comparison
equal deleted inserted replaced
-1:000000000000 0:9ee956af41e3
1 /*
2 * Copyright (C) 2010 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
3 *
4 * This file is part of PSĜS, a PubSub server written in JavaScript.
5 *
6 * PSĜS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License.
10 *
11 * PSĜS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with PSĜS. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 var errors = exports;
21
22 errors.success = true;
23 errors.feature_not_implemented = {n: 1, type: 'cancel', error: 'feature-not-implemented'};
24 errors.node_does_not_exist = {n: 2, type: 'cancel', error: 'item-not-found'};
25 errors.bad_request = {n: 3, type: 'modify', error: 'bad-request'};
26 errors.nodeid_required = {n: 4, type: 'modify', error: 'bad-request', reason: 'nodeid-required'};
27 errors.itemid_required = {n: 5, type: 'modify', error: 'bad-request', reason: 'item-required'},
28 errors.forbidden = {n: 6, type: 'auth', error: 'forbidden'};
29 errors.subscriptions_retrieval_not_supported = {n: 23, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'retrieve-subscriptions'};
30 errors.affiliations_retrieval_not_supported = {n: 29, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'retrieve-affiliations'};
31
32 errors.sub = {
33 subscribe: {
34 jids_do_not_match: {n: 34, type: 'modify', error: 'bad-request', reason: 'invalid-jid'},
35 presence_subscription_required: {n: 35, type: 'auth', error: 'not-authorized', reason: 'presence-subscription-required'},
36 not_in_roster_group: {n: 36, type: 'auth', error: 'not-authorized', reason: 'not-in-roster-group'},
37 not_on_whitelist: {n: 37, type: 'cancel', error: 'not-allowed', reason: 'closed-node'},
38 payment_required: {n: 38, type: 'auth', error: 'payment-required'},
39 anonymous_subscriptions_not_allowed: {n: 39, type: 'cancel', error: 'forbidden'},
40 subscription_pending: {n: 40, type: 'auth', error: 'not-authorized', reason: 'pending-subscription'},
41 blocked: {n: 41, type: 'auth', error: 'forbidden'},
42 too_many_subscriptions: {n: 42, type: 'wait', error: 'policy-violation', reason: 'too-many-subscriptions'},
43 not_supported: {n: 43, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'subscribe'},
44 node_has_moved: {n: 44, type: 'modify', error: 'gone', text: true},
45 node_does_not_exist: {n: 45, type: 'cancel', error: 'item-not-found'},
46 configuration_required: {n: 48, type: 'modify', error: 'not-acceptable', reason: 'configuration-required'},
47 },
48 unsubscribe: {
49 no_subscription_id: {n: 53, type: 'modify', error: 'bad-request', reason: 'subid-required'},
50 no_such_subscriber: {n: 54, type: 'cancel', error: 'unexpected-request', reason: 'not-subscribed'},
51 insufficient_privileges: {n: 55, type: 'auth', error: 'forbidden'},
52 node_does_not_exist: {n: 56, type: 'cancel', error: 'item-not-found'},
53 bad_subscription_id: {n: 57, type: 'modify', error: 'not-acceptable', reason: 'invalid-subid'},
54 },
55 configure: {
56 insufficient_privileges: {n: 61, type: 'auth', error: 'forbidden'},
57 no_such_subscriber: {n: 62, type: 'modify', error: 'unexpected-request', reason: 'not-subscribed'},
58 subscriber_jid_required: {n: 63, type: 'modify', error: 'bad-request', reason: 'jid-required'},
59 subscription_id_required: {n: 64, type: 'modify', error: 'bad-request', reason: 'subid-required'},
60 invalid_subscription_id: {n: 65, type: 'modify', error: 'not-acceptable', reason: 'invalid-subid'},
61 subscription_options_not_supported: {n: 66, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'subscription-options'},
62 node_does_not_exist: {n: 67, type: 'cancel', error: 'item-not-found'},
63 form_processing_failure: {n: 70, type: 'modify', error: 'bad-request', reason: 'invalid-options'},
64 },
65 default_options: {
66 node_configuration_not_supported: {n: 76, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'subscription-options'},
67 default_subscription_configuration_retrieval_not_supported: {n: 77, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'retrieve-default-sub'},
68 },
69 retrieve: {
70 subscription_id_required: {n: 87, type: 'modify', error: 'bad-request', reason: 'subid-required'},
71 invalid_subscription_id: {n: 88, type: 'modify', error: 'not-acceptable', reason: 'invalid-subid xmlns'},
72 entity_not_subscribed: {n: 89, type: 'auth', error: 'not-authorized', reason: 'not-subscribed'},
73 persistent_items_not_supported: {n: 90, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'persistent-items'},
74 item_retrieval_not_supported: {n: 91, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'retrieve-items'},
75 presence_subscription_required: {n: 92, type: 'auth', error: 'not-authorized', reason: 'presence-subscription-required'},
76 not_in_roster_group: {n: 93, type: 'auth', error: 'not-authorized', reason: 'not-in-roster-group'},
77 not_on_whitelist: {n: 94, type: 'cancel', error: 'not-allowed', reason: 'closed-node'},
78 payment_required: {n: 95, type: 'auth', error: 'payment-required'},
79 blocked: {n: 96, type: 'auth', error: 'forbidden'},
80 node_does_not_exist: {n: 97, type: 'cancel', error: 'item-not-found'},
81 },
82 };
83
84 errors.pub = {
85 publish: {
86 insufficient_privileges: {n: 105, type: 'auth', error: 'forbidden'},
87 item_publication_not_supported: {n: 106, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'publish'},
88 node_does_not_exist: {n: 107, type: 'cancel', error: 'item-not-found'},
89 payload_too_big: {n: 108, type: 'modify', error: 'not-acceptable', reason: 'payload-too-big'},
90 bad_payload: {n: 109, type: 'modify', error: 'bad-request', reason: 'invalid-payload'},
91 },
92 configuration: {
93 no_item: {n: 110, type: 'modify', error: 'bad-request', reason: 'item-required'},
94 no_payload: {n: 111, type: 'modify', error: 'bad-request', reason: 'payload-required'},
95 transient_item: {n: 112, type: 'modify', error: 'bad-request', reason: 'item-forbidden'},
96 precondition: {n: 113, type: 'modify', error: 'conflict', reason: 'precondition-not-met'},
97
98 },
99 retract: {
100 insufficient_privileges: {n: 118, type: 'auth', error: 'forbidden'},
101 node_does_not_exist: {n: 119, type: 'cancel', error: 'item-not-found'},
102 nodeid_required: {n: 120, type: 'modify', error: 'bad-request', reason: 'nodeid-required'},
103 item_or_itemid_required: {n: 121, type: 'modify', error: 'bad-request', reason: 'item-required'},
104 persistent_items_not_supported: {n: 122, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'persistent-items'},
105 item_deletion_not_supported: {n: 123, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'delete-items'},
106 },
107 };
108
109 errors.owner = {
110 create: {
111 node_creation_not_supported: {n: 125, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'create-nodes'},
112 service_requires_registration: {n: 126, type: 'auth', error: 'registration-required'},
113 prohibited: {n: 127, type: 'auth', error: 'forbidden'},
114 nodeid_already_exists: {n: 128, type: 'cancel', error: 'conflict'},
115 instant_nodes_not_supported: {n: 129, type: 'modify', error: 'not-acceptable', reason: 'nodeid-required'},
116 specified_access_model_not_supported: {n: 135, type: 'modify', error: 'not-acceptable', reason: 'unsupported-access-model'},
117 },
118 configure: {
119 node_configuration_not_supported: {n: 140, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'config-node'},
120 insufficient_privileges: {n: 141, type: 'auth', error: 'forbidden'},
121 nodeid_required: {n: 142, type: 'modify', error: 'bad-request', reason: 'nodeid-required'},
122 no_configuration_options: {n: 143, type: 'cancel', error: 'not-allowed'},
123 node_does_not_exist: {n: 144, type: 'cancel', error: 'item-not-found'},
124 form_processing_failure: {n: 148, type: 'modify', error: 'not-acceptable'},
125 },
126 default_options: {
127 node_configuration_not_supported: {n: 153, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'config-node'},
128 default_node_configuration_retrieval_not_supported: {n: 154, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'retrieve-default'},
129 },
130 delete_node: {
131 insufficient_privileges: {n: 159, type: 'auth', error: 'forbidden'},
132 node_does_not_exist: {n: 160, type: 'cancel', error: 'item-not-found'},
133 },
134 purge: {
135 node_purging_not_supported: {n: 164, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'purge-nodes'},
136 insufficient_privileges: {n: 165, type: 'auth', error: 'forbidden'},
137 node_does_not_persist_items: {n: 166, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'persistent-items'},
138 node_does_not_exist: {n: 167, type: 'cancel', error: 'item-not-found'},
139 },
140 //manage_subscription_requests: {},
141 pending_subscription_requests: {
142 ad_hoc_commands_not_supported: {n: 176, type: 'cancel', error: 'service-unavailable'},
143 get_pending_not_supported: {n: 177, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'get-pending'},
144 insufficient_privileges: {n: 178, type: 'auth', error: 'forbidden'},
145 node_does_not_exist: {n: 179, type: 'cancel', error: 'item-not-found'},
146 },
147 manage_subscriptions: {
148 not_supported: {n: 184, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'manage-subscriptions'},
149 retrieve_list: {
150 entity_is_not_an_owner: {n: 185, type: 'auth', error: 'forbidden'},
151 node_does_not_exist: {n: 186, type: 'cancel', error: 'item-not-found'},
152 },
153 modify: {
154 entity_is_not_an_owner: {n: 190, type: 'auth', error: 'forbidden'},
155 node_does_not_exist: {n: 191, type: 'cancel', error: 'item-not-found'},
156 multiple_simultaneous_modifications: {n: 193, type: 'modify', error: 'not-acceptable'},
157 },
158 },
159 manage_affiliations: {
160 not_supported: {n: 197, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'modify-affiliations'},
161 retrieve_list: {
162 entity_is_not_an_owner: {n: 198, type: 'auth', error: 'forbidden'},
163 node_does_not_exist: {n: 199, type: 'cancel', error: 'item-not-found'},
164 },
165 modify: {
166 requested_affiliation_not_supported: {
167 publisher: {n: 203, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'publisher-affiliation'},
168 'publish-only': {n: 203, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'publish-only-affiliation'},
169 member: {n: 203, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'member-affiliation'},
170 outcast: {n: 203, type: 'cancel', error: 'feature-not-implemented', reason: 'unsupported', feature: 'outcast-affiliation'},
171 },
172 entity_is_not_an_owner: {n: 204, type: 'auth', error: 'forbidden'},
173 node_does_not_exist: {n: 205, type: 'cancel', error: 'item-not-found'},
174 multiple_simultaneous_modifications: {n: 207, type: 'modify', error: 'not-acceptable'},
175 },
176 },
177 };
178
179 errors.reverse = {};
180
181 function reverseError(o) {
182 for (var i in o) {
183 if (i == 'reverse' || typeof (o[i]) == 'number');
184 else if (!o[i].n)
185 reverseError(o[i]);
186 else {
187 var k = {};
188 //var k = {name: i};
189 for (var j in o[i]) {
190 if (j != 'n')
191 k[j] = o[i][j];
192 }
193 errors.reverse[o[i].n] = k;
194 }
195 }
196 }
197
198 reverseError(errors);