forked from heyrocker/services
-
Notifications
You must be signed in to change notification settings - Fork 2
/
services.install
244 lines (231 loc) · 7.18 KB
/
services.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
// $Id: services.install,v 1.3.2.21 2009/05/26 02:55:14 heyrocker Exp $
/**
* @file
* Install, uninstall and update the Services module.
*/
/**
* Implementation of hook_schema().
*/
function services_schema() {
$schema = array();
$schema['services_endpoint'] = array(
'description' => 'Stores endpoint information for services',
'fields' => array(
'eid' => array(
'type' => 'serial',
'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
'unsigned' => TRUE,
'not null' => TRUE,
'no export' => TRUE,
),
'name' => array(
'description' => 'The name of the endpoint.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'title' => array(
'description' => 'The title of the endpoint.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'server' => array(
'description' => 'The name of the server used in this endpoint.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'path' => array(
'description' => 'The path to the endpoint for this server.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'authentication' => array(
'description' => 'The authentication settings for the endpoint.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
'object default' => array(),
),
'resources' => array(
'description' => 'Information about the resources exposed in this endpoint.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
'object default' => array(),
),
),
'primary key' => array('eid'),
'unique keys' => array(
'name' => array('name'),
),
'export' => array(
'key' => 'name',
'identifier' => 'endpoint',
'api' => array(
'owner' => 'services',
'api' => 'services',
'minimum_version' => 3,
'current_version' => 3,
),
),
);
return $schema;
}
/**
* Implementation of hook_install().
*/
function services_install() {
drupal_install_schema('services');
}
/**
* Implementation of hook_uninstall().
*/
function services_uninstall() {
drupal_uninstall_schema('services');
$ret = array();
// Drop legacy tables
$legacy_tables = array('services_keys', 'services_timestamp_nonce');
foreach ($legacy_tables as $table) {
if (db_table_exists($table)) {
db_drop_table($ret, $table);
}
}
variable_del('services_use_key');
variable_del('services_use_sessid');
variable_del('services_debug');
variable_del('services_auth_module');
}
/**
* Implementation of hook_update().
*
* Create the nonce table
*/
function services_update_6001() {
$schema['services_timestamp_nonce'] = array(
'description' => 'Stores timestamp against nonce for repeat attacks.',
'fields' => array(
'timestamp' => array(
'description' => 'The timestamp used with the Nonce.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => ''
),
'nonce' => array(
'description' => 'The random string used on the request.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => ''
),
'domain' => array(
'description' => 'The domain that submitted the request.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''
),
),
'indexes' => array(
'timestamp' => array('timestamp'),
),
'primary key' => array('nonce'),
);
$update = array();
db_create_table($update, 'services_timestamp_nonce', $schema['services_timestamp_nonce']);
return $update;
}
function services_update_6002() {
$ret = array();
menu_rebuild();
return $ret;
}
/**
* Update 6300 adds the concept of endpoints which is a way to expose a
* specific server using a specific authentication method, with the full set
* or a subset of the installed services.
*
* This is a major change from the way services worked before: then all
* installed servers exposed all installed services and only one
* authentication method could be used for all servers. The endpoint was also
* non-configurable and was always 'services/[server path]'.
*
* As with most major changes, this is a _breaking_ update, in the sense that
* you will need to reconfigure services. If you have clients that expect the
* endpoint to remain the same you can easily set up a endpoint that exposes
* your server/authentication method/services set on the old
* 'services/[server path]' path.
*/
function services_update_6300() {
$ret = array();
db_create_table($ret, 'services_endpoint', array(
'description' => 'Stores endpoint information for services',
'export' => array(
'identifier' => 'endpoint',
'export callback' => 'services_endpoint_export',
'list callback' => 'services_endpoint_list',
),
'fields' => array(
'eid' => array(
'type' => 'serial',
'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
'unsigned' => TRUE,
'not null' => TRUE,
'no export' => TRUE,
),
'name' => array(
'description' => 'The name of the endpoint.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'title' => array(
'description' => 'The title of the endpoint.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'server' => array(
'description' => 'The name of the server used in this endpoint.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
),
'path' => array(
'description' => 'The path to the endpoint for this server.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'authentication' => array(
'description' => 'The authentication modules used in this endpoint.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
'object default' => array(),
),
'resources' => array(
'description' => 'Information about the resources exposed in this endpoint.',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
'serialize' => TRUE,
'object default' => array(),
),
),
'primary key' => array('eid'),
'unique keys' => array(
'name' => array('name'),
),
));
// Remove the auth_module variable as this won't be handled on a global basis anymore
variable_del('services_auth_module');
return $ret;
}