| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
//////////////////////////////////////////////////////////////////////////////
|
| 5 |
// Services API hooks
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Implementation of hook_service().
|
| 9 |
*/
|
| 10 |
function bitcache_service() {
|
| 11 |
return array(
|
| 12 |
array(
|
| 13 |
'#method' => 'bitcache.exists',
|
| 14 |
'#callback' => 'bitcache_exists',
|
| 15 |
'#return' => 'boolean',
|
| 16 |
'#args' => array(
|
| 17 |
array('#name' => 'id', '#type' => 'string', '#optional' => FALSE, '#description' => t('The bitstream\'s identifier (SHA-1 fingerprint).')),
|
| 18 |
),
|
| 19 |
'#help' => t('Determines whether a given bitstream exists.'),
|
| 20 |
),
|
| 21 |
array(
|
| 22 |
'#method' => 'bitcache.get',
|
| 23 |
'#callback' => 'bitcache_get_contents',
|
| 24 |
'#return' => 'base64',
|
| 25 |
'#args' => array(
|
| 26 |
array('#name' => 'id', '#type' => 'string', '#optional' => FALSE, '#description' => t('The bitstream\'s identifier (SHA-1 fingerprint).')),
|
| 27 |
),
|
| 28 |
'#help' => t('Retrieves the contents of the given bitstream.'),
|
| 29 |
),
|
| 30 |
array(
|
| 31 |
'#method' => 'bitcache.put',
|
| 32 |
'#callback' => 'bitcache_service_put',
|
| 33 |
'#return' => 'boolean',
|
| 34 |
'#args' => array(
|
| 35 |
array('#name' => 'id', '#type' => 'string', '#optional' => FALSE, '#description' => t('The bitstream\'s identifier (SHA-1 fingerprint).')),
|
| 36 |
array('#name' => 'data', '#type' => 'base64', '#optional' => FALSE, '#description' => t('The bitstream\'s contents.')),
|
| 37 |
array('#name' => 'repo', '#type' => 'string', '#optional' => TRUE, '#description' => t('The Bitcache repository to store the bitstream in.')),
|
| 38 |
),
|
| 39 |
'#help' => t('Stores the contents of the given bitstream.'),
|
| 40 |
),
|
| 41 |
array(
|
| 42 |
'#method' => 'bitcache.delete',
|
| 43 |
'#callback' => 'bitcache_delete',
|
| 44 |
'#return' => 'boolean',
|
| 45 |
'#args' => array(
|
| 46 |
array('#name' => 'id', '#type' => 'string', '#optional' => FALSE, '#description' => t('The bitstream\'s identifier (SHA-1 fingerprint).')),
|
| 47 |
),
|
| 48 |
'#help' => t('Deletes the given bitstream.'),
|
| 49 |
),
|
| 50 |
);
|
| 51 |
}
|
| 52 |
|
| 53 |
function bitcache_service_put($id, $data, $repo = NULL) {
|
| 54 |
if (!empty($repo)) {
|
| 55 |
bitcache_use_repository($repo);
|
| 56 |
}
|
| 57 |
return bitcache_put($id, $data);
|
| 58 |
}
|