Project

General

Profile

Download (18.5 KB) Statistics
| Branch: | Tag: | Revision:
1 32a96ee6 Andreas Kohlbecker
<?php
2 1e687365 Andreas Kohlbecker
// $Id$
3 32a96ee6 Andreas Kohlbecker
4
/**
5
 * @file
6
 * Functions which are required or useful when accessing and processing CDM Data Store Webservices
7
 * 
8
 * Naming conventions:
9
 * ----------------------
10
 * 
11
 *  - all webservice access methods are prefixed with cdm_ws
12 e5ac8efc Andreas Kohlbecker
 * 
13 32a96ee6 Andreas Kohlbecker
 *
14
 * Copyright (C) 2007 EDIT
15
 * European Distributed Institute of Taxonomy 
16
 * http://www.e-taxonomy.eu
17
 */
18
require_once ('xml2json.php');
19 6ee322a7 Andreas Kohlbecker
require_once ('uuids.php');
20 ee780c57 Andreas Kohlbecker
21
22 d96a6e06 Andreas Kohlbecker
23 32a96ee6 Andreas Kohlbecker
/**
24 d96a6e06 Andreas Kohlbecker
 * Implementation of hook_requirements()
25 32a96ee6 Andreas Kohlbecker
 */
26 d96a6e06 Andreas Kohlbecker
function cdm_api_requirements() {
27
28
  $requirements['cdm_api'] = array(
29
    'title' => t('CDM API')
30
  );
31
32
  if( function_exists('curl_init') ){
33
    $requirements['cdm_api']['description'] = ''; // description below title is not jet in use 
34
    $requirements['cdm_api']['value'] =  'CURL php extension is available.';
35
  } else {
36
    $requirements['cdm_api']['value'] =  'CURL php extension is missing.';
37
  }
38
 
39
  //FIXME: once _get_content_fsockopen is implemented change  severity to  REQUIREMENT_WARNING,
40
  $requirements['cdm_api']['severity'] =  (function_exists('curl_init') ? REQUIREMENT_OK : REQUIREMENT_ERROR);
41
  
42
  return $requirements;
43 32a96ee6 Andreas Kohlbecker
}
44
45 d96a6e06 Andreas Kohlbecker
46 bd6b2769 Andreas Kohlbecker
/**
47 d96a6e06 Andreas Kohlbecker
 * Implementation of hook_menu()
48 bd6b2769 Andreas Kohlbecker
 */
49 d96a6e06 Andreas Kohlbecker
function cdm_api_menu($may_cache) {
50
  $items = array();
51
  if ($may_cache) {
52
    
53
   $items[] = array(
54 5a688ffe Andreas Kohlbecker
      // usage: url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
55 d96a6e06 Andreas Kohlbecker
      'path' => 'cdm_api/proxy',
56
      'callback' => 'proxy_content',
57
      'access' => true,
58
      'type' => MENU_CALLBACK,
59
      );
60
    
61 bd6b2769 Andreas Kohlbecker
  }
62 d96a6e06 Andreas Kohlbecker
  
63
  return $items;
64 bd6b2769 Andreas Kohlbecker
}
65
66 2e748209 Andreas Kohlbecker
function cdm_api_settings_form(){
67
  
68
   $form['cdm_webservice'] = array(
69
      '#type' => 'fieldset',
70
      '#title' => t('CDM Web Service'),
71
      '#collapsible' => FALSE,
72
      '#collapsed' => FALSE,
73
  );
74
75
  $form['cdm_webservice']['cdm_webservice_url'] =  array(
76
    '#type' => 'textfield',
77
    '#title'         => t('CDM Web Service URL'),
78
    '#description'   => t('The URL of CDM Webservice which delivers the data to be published.'),
79
    '#default_value' => variable_get('cdm_webservice_url', 'http://dev.e-taxonomy.eu/svn/trunk/drupal/modules/cdm_dataportal/cdm_api/ws_stub/'),
80
  );
81
82
  $form['cdm_webservice']['cdm_webservice_isStub'] =  array(
83
    '#type' => 'checkbox',
84
    '#title'         => t('Use Web Service Stub'),
85
    '#default_value' => variable_get('cdm_webservice_isStub', 1),
86
    '#description'   => t('Use a static web service stub. Only for development. For further information please refer to the ')
87
  .l('ws_stub/README.txt', 'http://dev.e-taxonomy.eu/svn/trunk/drupal/modules/cdm_dataportal/cdm/ws_stub/README.txt', array('target'=>'_blank')),
88
  );
89 d96a6e06 Andreas Kohlbecker
  
90 2e748209 Andreas Kohlbecker
91
  $form['cdm_webservice']['cdm_webservice_type'] =  array(
92 812a9c04 Andreas Kohlbecker
    '#type'          => 'select',
93 2e748209 Andreas Kohlbecker
    '#title'         => t('Web Service Type'),
94
    '#default_value' => variable_get('cdm_webservice_type', 'json'),
95 812a9c04 Andreas Kohlbecker
    '#options'       => array(
96
            'xml'  => t('XML'),
97
            'json' => t('JSON'),
98 2e748209 Andreas Kohlbecker
        ),
99
    '#description'   => t('The response data type of the web service.'),
100
  );
101 d96a6e06 Andreas Kohlbecker
102
  $form['cdm_webservice']['cdm_webservice_cache'] =  array(
103
    '#type' => 'checkbox',
104
    '#title'         => t('Enable Caching'),
105
    '#default_value' => variable_get('cdm_webservice_cache', 1),
106 21604cea Andreas Kohlbecker
    '#description'   => t('Enable caching of webservice responses on simple requests, '
107
      .'that is requests which only have one parameter generally a UUID or a concatenation of UUIDs')
108 d96a6e06 Andreas Kohlbecker
  );
109 2e748209 Andreas Kohlbecker
  
110
  $form['cdm_webservice']['proxy'] = array(
111
      '#type' => 'fieldset',
112
      '#title' => t('Proxy'),
113
      '#collapsible' => TRUE,
114
      '#collapsed' => TRUE
115
  );
116
  
117
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_url'] =  array(
118
    '#type' => 'textfield',
119
    '#title'         => t('Proxy URL'),
120
    '#description'   => t('If this proxy url is set the cdm api tries 
121
    to connect the web service over the given proxy server. 
122
    Otherwise proxy usage is deactivated.'),
123
    '#default_value' => variable_get('cdm_webservice_proxy_url', false),
124
  );
125
  
126
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_port'] =  array(
127
    '#type' => 'textfield',
128
    '#title'         => t('Proxy Port'),
129
    '#default_value' => variable_get('cdm_webservice_proxy_port', '80'),
130
  );
131
  
132
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_usr'] =  array(
133
    '#type' => 'textfield',
134
    '#title'         => t('Login'),
135
    '#default_value' => variable_get('cdm_webservice_proxy_usr', false),
136
  );
137
  
138
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_pwd'] =  array(
139
    '#type' => 'textfield',
140
    '#title'         => t('Password'),
141
    '#default_value' => variable_get('cdm_webservice_proxy_pwd', false),
142
  );
143
  
144
  $form['cdm_webservice']['cdm_webservice_debug'] =  array(
145
    '#type' => 'checkbox',
146
    '#title'         => t('Debug CDM Web Service'),
147
    '#default_value' => variable_get('cdm_webservice_debug', 1),
148
    '#description'   => t('Enable CDM Web Service debugging messages')
149
  );
150
  return $form;
151
}
152
153 d96a6e06 Andreas Kohlbecker
/**
154
 * Implementation of hook_cron().
155
 *
156
 * Expire outdated cache entries
157
 */
158
function cdm_api_cron() {
159
  cache_clear_all(NULL, 'cache_cdm_ws');
160
}
161
162
163
// ----------------------------------------------------------- //
164
165
166
/**
167
 * Converts an array of TagedText items into a sequence of corresponding html tags whereas 
168
 * each item will provided with a class attribute which set to the key of the TaggedText item.
169
 * 
170
 * @param array $taggedtxt
171
 * @param String $tag
172
 * @param String $glue the string by which the chained text tokens are concatenated together. 
173
 *       Default is a blak character
174
 * @return String of HTML 
175
 */
176 5a688ffe Andreas Kohlbecker
function cdm_taggedtext2html(array &$taggedtxt, $tag = 'span', $glue = ' ', $skiptags = array()){
177 81df545f Andreas Kohlbecker
   $out = '';
178
   $i = 0;
179 d96a6e06 Andreas Kohlbecker
   foreach($taggedtxt as $tt){
180 81df545f Andreas Kohlbecker
     if(!in_array($tt->type, $skiptags) && strlen($tt->text) > 0){
181
      $out .= (strlen($out) > 0 && ++$i < count($taggedtxt)? $glue : '').'<'.$tag.' class="'.$tt->type.'">'.$tt->text.'</'.$tag.'>';
182 5a688ffe Andreas Kohlbecker
     }
183 d96a6e06 Andreas Kohlbecker
   }
184
   return $out;
185
}
186
187
/**
188
 * Finds the text tagged with $$tag_type in an array of taggedText instances
189
 *
190
 * @param array $taggedtxt
191
 * @param string $tag_type
192
 * @return the text mapped by $tag_type or an empty string
193
 */
194
function cdm_taggedtext_value(array &$taggedtxt = array(), $tag_type){
195
  foreach($taggedtxt as $tagtxt){
196
    if($tagtxt->type == $tag_type)
197
    return $tagtxt->text;
198
  }
199
  return '';
200
}
201
202
203 fa97cd20 Andreas Kohlbecker
/**
204
 * Produces a path to a static web service stub out of a cdm web service path. 
205
 * These stubs are object serialisations stored in files whereas the filename
206
 * consists of the service name and of a 
207
 * encoded version of the request query parameters
208
 *
209
 * @param string $path
210 6ee322a7 Andreas Kohlbecker
 * @param string $fileExtension
211 fa97cd20 Andreas Kohlbecker
 * @return string
212
 */
213 ee99abea Andreas Kohlbecker
function cdm_encode_stub($path, $fileExtension, $hasParams = false){
214 6ee322a7 Andreas Kohlbecker
  $path =  str_replace('/',',',$path);
215 ee99abea Andreas Kohlbecker
  if($hasParams){
216 cacc1bbf Andreas Kohlbecker
    $path =  str_replace('?',',',$path);
217 ee99abea Andreas Kohlbecker
    $path =  str_replace('&',',',$path);
218
  }
219 6ee322a7 Andreas Kohlbecker
  return variable_get('cdm_webservice_type', 'xml').'/'.$path.'.'.$fileExtension;
220 32a96ee6 Andreas Kohlbecker
}
221
222 6ee322a7 Andreas Kohlbecker
223 cacc1bbf Andreas Kohlbecker
function cdm_compose_url($ws_name, $parameters = array()){
224 6ee322a7 Andreas Kohlbecker
  
225 cacc1bbf Andreas Kohlbecker
  $request_params = '';
226
  $path_params = '';
227
  if(!is_array($parameters)){
228
     // add to path
229
     $path_params .= '/'.( is_string($parameters) ? urlencode($parameters) : $parameters);
230
  }else{
231
    foreach($parameters as $key=>$value){
232
      if(is_numeric($key)){
233
        // add to path
234
        $path_params .= '/'.( is_string($value) ? urlencode($value) : $value);
235
      } else {
236
        // add to parameters
237
        $request_params .= ( strlen($request_params) == 0 ? '?' : '&').$key.'='.( is_string($value) ? urlencode($value) : $value);
238
      }
239
    }
240 32a96ee6 Andreas Kohlbecker
  }
241 cacc1bbf Andreas Kohlbecker
  $path = $ws_name.$path_params.$request_params;
242 32a96ee6 Andreas Kohlbecker
  
243
  if(variable_get('cdm_webservice_isStub', 0)){
244 cacc1bbf Andreas Kohlbecker
    $path = cdm_encode_stub($path, variable_get('cdm_webservice_type', 'json'), strlen($request_params) > 0);
245 32a96ee6 Andreas Kohlbecker
  }
246
  
247 cacc1bbf Andreas Kohlbecker
  $url = variable_get('cdm_webservice_url', '').$path; 
248 32a96ee6 Andreas Kohlbecker
  return $url;
249
}
250
251 6ee322a7 Andreas Kohlbecker
252 d96a6e06 Andreas Kohlbecker
function proxy_content($url, $theme = null){
253
  $args = func_get_args();
254 2e748209 Andreas Kohlbecker
  
255 d96a6e06 Andreas Kohlbecker
  $url = array_shift($args);
256
  $theme = array_shift($args);
257 2e748209 Andreas Kohlbecker
  
258 4712b4bb Andreas Kohlbecker
  //TODO reconsider caching logic in this function
259 d96a6e06 Andreas Kohlbecker
  if(!$theme){
260 5a688ffe Andreas Kohlbecker
    // print out JSON, the cache cannot be used since it contains objetcs
261 4712b4bb Andreas Kohlbecker
    $data = get_content(urldecode($url));
262 d96a6e06 Andreas Kohlbecker
    print $data;
263 32a96ee6 Andreas Kohlbecker
  } else {
264 4712b4bb Andreas Kohlbecker
    $obj = cdm_ws_load(urldecode($url), false);
265
    array_unshift($args, $theme, $obj);
266 d96a6e06 Andreas Kohlbecker
    print call_user_func_array('theme', $args);
267 32a96ee6 Andreas Kohlbecker
  }
268
}
269
270
271
/**
272 d96a6e06 Andreas Kohlbecker
 * Enter description here...
273
 *
274
 * @param unknown_type $method
275
 * @param $parameters may be an array or a single variable
276
 * @return unknown
277 32a96ee6 Andreas Kohlbecker
 */
278 d96a6e06 Andreas Kohlbecker
function cdm_ws_get($method, $parameters = array()){
279
  /*$args = func_get_args();
280
  $method = array_shift($args);
281
  */  
282
  /*if(isset($args[0]) && is_array($args[0])){
283
    $url = cdm_compose_url_parametrised($method, $args[0]);
284
  } else {
285
 */    
286
  $url = cdm_compose_url($method, $parameters);
287
  //}
288
  return cdm_ws_load($url, (is_array($parameters)));
289 32a96ee6 Andreas Kohlbecker
}
290
291 4f462b79 Andreas Kohlbecker
/**
292 d96a6e06 Andreas Kohlbecker
 * Loads the XML or JSON response for the given url from the CDM Data Store Webservice.
293
 * The XML is turned into a object which is returned.
294
 * 
295
 * @param String $url the relative url of the web service call. 
296
 *        Relative means relative to the web service base url which is stored in cdm_webservice_url
297
 * @return An object or false
298 4f462b79 Andreas Kohlbecker
 */
299 d96a6e06 Andreas Kohlbecker
function cdm_ws_load($url, $is_multi_paramater_query){
300 4f462b79 Andreas Kohlbecker
  
301 d96a6e06 Andreas Kohlbecker
  $do_cache = !$is_multi_paramater_query && variable_get('cdm_webservice_cache', 0);
302
  $cache_entry = false;
303 231984cc Andreas Kohlbecker
  
304 d96a6e06 Andreas Kohlbecker
  if($do_cache){
305
    // try to get object from cache 
306
    $cache_entry = cache_get($url, 'cache_cdm_ws');
307
  }
308 32a96ee6 Andreas Kohlbecker
  
309 d96a6e06 Andreas Kohlbecker
  if(!$cache_entry){
310
    // load fresh data from webservice
311 6e1ec3a4 Andreas Kohlbecker
    $time_get_start = microtime(true);
312 d96a6e06 Andreas Kohlbecker
    $datastr = get_content($url);
313 6e1ec3a4 Andreas Kohlbecker
    $time_get = microtime(true) - $time_get_start;
314 e46927b4 Andreas Kohlbecker
    /*if(TRUE){
315
      $storef =  urlencode($url);
316
      drupal_set_message($storef);
317
      file_save_data($datastr, $storef, FILE_EXISTS_REPLACE);
318
    }*/
319 6e1ec3a4 Andreas Kohlbecker
    
320
    $time_parse_start = microtime(true);
321 d96a6e06 Andreas Kohlbecker
    $obj = cdm_load_obj($datastr);
322 6e1ec3a4 Andreas Kohlbecker
    $time_parse = microtime(true) - $time_parse_start;
323 e46927b4 Andreas Kohlbecker
    if(variable_get('cdm_webservice_debug', 1)){
324 5a688ffe Andreas Kohlbecker
      drupal_set_message($url.' [fetched in: '.sprintf('%3.3f', $time_get).'s; parsed in '.sprintf('%3.3f', $time_parse).' s; size:'.sprintf('%3.1f', (strlen($datastr) / 1024)).' kb of '.($obj ?  l('valid data', 'cdm_api/proxy/'.urlencode($url), array('target'=>'json-data')):'invalid data').'] '.$json_data_link, 'debug');
325 e46927b4 Andreas Kohlbecker
    }
326 d96a6e06 Andreas Kohlbecker
    if( !$obj || !$datastr){
327
      watchdog('CDM', 'cdm_ws_load() - URL: '.$url, WATCHDOG_ERROR);
328
    } else if($do_cache) {
329
      // store fresh data in cache
330
      cache_set($url, 'cache_cdm_ws', serialize($obj), CACHE_TEMPORARY);
331
    }
332 32a96ee6 Andreas Kohlbecker
  } else {
333 d96a6e06 Andreas Kohlbecker
    $obj = unserialize($cache_entry->data);
334 e46927b4 Andreas Kohlbecker
    if(variable_get('cdm_webservice_debug', 1)){
335 d96a6e06 Andreas Kohlbecker
      drupal_set_message('Using cache for: '.$url, 'debug');
336 e46927b4 Andreas Kohlbecker
    }
337 32a96ee6 Andreas Kohlbecker
  }
338 d96a6e06 Andreas Kohlbecker
  return $obj;
339 32a96ee6 Andreas Kohlbecker
}
340
341 d96a6e06 Andreas Kohlbecker
342 32a96ee6 Andreas Kohlbecker
function cdm_load_obj($datastr){
343 8c19e1a5 Andreas Kohlbecker
     
344 c0ac3382 Andreas Kohlbecker
  // if the web service delivers XML convert it into json
345 32a96ee6 Andreas Kohlbecker
  if(variable_get('cdm_webservice_type', 'xml') == 'xml'){
346
    $datastr = xml2json::transformXmlStringToJson($datastr);  
347
  }
348 812a9c04 Andreas Kohlbecker
  $use_stub = variable_get('cdm_webservice_isStub', 0); 
349
  if($use_stub){
350 8c19e1a5 Andreas Kohlbecker
    // --- for STUBS use the more syntax tolerant PEAR json lib --- //
351
    $json_pear = new Services_JSON();
352
    $obj = $json_pear->decode($datastr);
353
  } else {
354
    // --- generally use the fast php json lib --- //
355
    $obj = json_decode($datastr);
356
  }
357 6ee322a7 Andreas Kohlbecker
  
358 812a9c04 Andreas Kohlbecker
  if(!(is_object($obj) || is_array($obj)) || ($use_stub && !isset($obj->root)) ){
359 6ee322a7 Andreas Kohlbecker
    ob_start();
360
    var_dump($obj);
361
    $obj_dump = ob_get_contents();
362
    ob_clean();
363
    watchdog('CDM', 'cdm_load_obj() - invalid object: '.$obj_dump, WATCHDOG_ERROR);
364
    return false;
365
  }
366
367 812a9c04 Andreas Kohlbecker
  if($use_stub){
368
    $arr = (array)$obj;
369
    $obj = array_pop($arr);
370
  }
371
  return $obj;
372 32a96ee6 Andreas Kohlbecker
}
373
374 d96a6e06 Andreas Kohlbecker
function get_content($url){
375
  global $locale;  // drupal variable containing the current locale i.e. language
376
  static $header;
377 32a96ee6 Andreas Kohlbecker
  
378 d96a6e06 Andreas Kohlbecker
  if(!$header){
379
    $header = array();
380
    $header[] = 'Accept: '.(variable_get('cdm_webservice_type', 'json') == 'json' ? 'application/json' : 'text/xml');    
381
    $header[] = 'Accept-Language: '.$locale;
382
    $header[] = 'Accept-Encoding: UTF8';
383
  }
384
  
385
  if(function_exists('curl_init')){
386
387
    // use the CURL lib if installed it is supposed to be 20x faster
388
    return _get_content_curl($url, $header);
389
  } else {
390
    return _get_content_fsockopen($url, $header);
391 32a96ee6 Andreas Kohlbecker
  }
392 d96a6e06 Andreas Kohlbecker
}
393
394
395
function _get_content_fsockopen($url, $header = array()){
396
  //FIXME implement get_content_fsockopen($url);
397
   watchdog('CDM_API', '_get_content_fsockopen - UNIMPLEMENTED', WATCHDOG_ERROR);
398
   return false;
399 32a96ee6 Andreas Kohlbecker
}
400
401
402 cacc1bbf Andreas Kohlbecker
/**
403 d96a6e06 Andreas Kohlbecker
 * Return string content from a remote file
404
 * 
405
 * @param string $url
406
 * @return string
407
 * 
408
 * @author Luiz Miguel Axcar (lmaxcar@yahoo.com.br)
409
*/
410
function _get_content_curl($url, $header = array())
411
{
412
    $ch = curl_init();
413
414
    curl_setopt ($ch, CURLOPT_URL, $url);
415
    // set proxy settings
416
    if(variable_get('cdm_webservice_proxy_url', false)){
417
      curl_setopt($ch, CURLOPT_PROXY, variable_get('cdm_webservice_proxy_url', ''));
418
      curl_setopt($ch, CURLOPT_PROXYPORT, variable_get('cdm_webservice_proxy_port', '80'));
419
      if(variable_get('cdm_webservice_proxy_usr', false)){
420
        curl_setopt ($ch, CURLOPT_PROXYUSERPWD, variable_get('cdm_webservice_proxy_usr', '').':'.variable_get('cdm_webservice_proxy_pwd', '')); 
421
      }
422
    }
423
    // set headers
424
    curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
425
426
    ob_start();
427
    curl_exec ($ch);
428
    if(curl_errno($ch)){
429
      watchdog('CDM_API', '_get_content_curl() - '.curl_error($ch).' URL: '.$url, WATCHDOG_ERROR);
430
        if(variable_get('cdm_webservice_debug', 1)){
431
          drupal_set_message('_get_content_curl() - '.curl_error($ch).' URL: '.$url, 'error');
432
        }
433
    }
434
    curl_close ($ch);
435
    $string = ob_get_contents();
436
    ob_end_clean();
437
 
438
    return $string;    
439 32a96ee6 Andreas Kohlbecker
}
440
441 6e1ec3a4 Andreas Kohlbecker
function cdm_api_secref_cache_prefetch(&$secUuids){
442
  global $secref_cache;
443
  if(!is_array($secref_cache)){
444
    $secref_cache = array();
445
  }
446
  $uniqueUuids = array_unique($secUuids);
447
  $i = 0;
448
  $param = '';
449
  while($i++ < count($uniqueUuids)){
450
    $param .= $secUuids[$i].',';
451
    if(strlen($param) + 37 > 2000){
452
     _cdm_api_secref_cache_add($param);
453
      $param = '';
454
    }
455
  }
456
  if($param){
457
     _cdm_api_secref_cache_add($param);
458
  }
459
}
460
461
function cdm_api_secref_cache_get($secUuid){
462
  global $secref_cache;
463
  if(!is_array($secref_cache)){
464
    $secref_cache = array();
465
  }
466
  if(!array_key_exists($secUuid, $secref_cache)){
467
    _cdm_api_secref_cache_add($secUuid);
468
  }
469
  return $secref_cache[$secUuid]; 
470
}
471
472
function cdm_api_secref_cache_clear(){
473
  global $secref_cache;
474
  $secref_cache = array();
475
}
476
477
function _cdm_api_secref_cache_add($secUuidsStr){
478
  global $secref_cache;
479
  $refSTOs = cdm_ws_get(CDM_WS_SIMPLE_REFERENCE, $secUuidsStr);
480
  $assocRefSTOs = array();
481 ba530d73 Andreas Kohlbecker
  if($refSTOs) {
482
    foreach($refSTOs as $ref){
483
      $assocRefSTOs[$ref->uuid] = $ref;
484
    }
485
    $secref_cache = array_merge($secref_cache, $assocRefSTOs);
486 6e1ec3a4 Andreas Kohlbecker
  }
487
}
488 d96a6e06 Andreas Kohlbecker
489 6ee322a7 Andreas Kohlbecker
/**
490
 * Web Service Arguments: {Uuid}
491
 * 
492 32a96ee6 Andreas Kohlbecker
 * The whatis service returns the type 
493
 * i.e. DTO class name and simplename & cdm class name and simplename of the instance referenced by the $uuid parameter. 
494
 * 
495 1e687365 Andreas Kohlbecker
 * return: false if the cdm store contains no matching instance. 
496 32a96ee6 Andreas Kohlbecker
 * An associative array with the following key-value pairs:
497
 *   - 'cdmName':       name of the cdm class as returned by Class.getName(), e.g. eu.etaxonomy.cdm.model.taxon.Taxon
498
 *   - 'cdmSimpleName': simple name of the cdm class as returned by Class.getSimpleName(), e.g. Taxon
499
 *   - 'dtoName':       name of the DTO class as returned by Class.getName(), e.g. eu.etaxonomy.cdm.dto.TaxonTO
500
 *   - 'dtoSimpleName': simple name of the TDO class as returned by Class.getSimpleName(), e.g. TaxonTO
501
 */
502 6ee322a7 Andreas Kohlbecker
define('CDM_WS_WHATIS', 'whatis');
503 32a96ee6 Andreas Kohlbecker
504
505
/**
506 6ee322a7 Andreas Kohlbecker
 * Web Service Arguments: {NameUuid}
507 32a96ee6 Andreas Kohlbecker
 */
508 6ee322a7 Andreas Kohlbecker
define('CDM_WS_NAME', 'name');
509 32a96ee6 Andreas Kohlbecker
510
/**
511 ee99abea Andreas Kohlbecker
 * Web Service url parameters:
512 1e687365 Andreas Kohlbecker
 * -  [last path element]: querystring
513
 * -  sec : the uuid of the concept reference
514
 * -  higherTaxa : list of taxon uuid, if higherTaxa are defined only taxa which are includet in one these taxa are taken in to account 
515
 * -  matchAnywhere : false (default) match the querystring to the beginning of names, if set to true any matching substring is taken as a hit.
516
 * -  onlyAccepted : return only taxa which are accepted in the sence of the concept reference as given by parameter sec
517
 * -  pagesize : maximum number of iteme per result page
518
 * -  page: the number of page to be returned
519
 * 
520
 * returns ResultPageSTO
521 32a96ee6 Andreas Kohlbecker
 */
522 5a688ffe Andreas Kohlbecker
define('CDM_WS_FIND_TAXA', 'find/taxon');
523 32a96ee6 Andreas Kohlbecker
524 bd6b2769 Andreas Kohlbecker
/**
525 6ee322a7 Andreas Kohlbecker
 * Web Service Arguments: {referenceUuid}
526 1e687365 Andreas Kohlbecker
 * 
527 bd6b2769 Andreas Kohlbecker
 */
528 3c088755 Andreas Kohlbecker
define('CDM_WS_REFERENCE', 'ref');
529 32a96ee6 Andreas Kohlbecker
530 8c19e1a5 Andreas Kohlbecker
/**
531 44e02685 Andreas Kohlbecker
 * Web Service Arguments: {referenceUuid} or array of {referenceUuid}
532 8c19e1a5 Andreas Kohlbecker
 * 
533 44e02685 Andreas Kohlbecker
 * returns a list of ReferenceSTO
534 8c19e1a5 Andreas Kohlbecker
 */
535 3c088755 Andreas Kohlbecker
define('CDM_WS_SIMPLE_REFERENCE', 'simple/ref');
536 8c19e1a5 Andreas Kohlbecker
537 6ee322a7 Andreas Kohlbecker
/**
538
 * Web Service Arguments: {taxonUuid}
539
 */
540
define('CDM_WS_TAXON', 'taxon');
541 32a96ee6 Andreas Kohlbecker
542 8c19e1a5 Andreas Kohlbecker
543
/**
544 44e02685 Andreas Kohlbecker
 * Web Service Arguments: {taxonUuid} or array of {referenceUuid}
545
 * 
546
 * returns a list of TaxonSTO
547 8c19e1a5 Andreas Kohlbecker
 */
548
define('CDM_WS_SIMPLE_TAXON', 'simple/taxon');
549
550 6ee322a7 Andreas Kohlbecker
/**
551
 * Web Service Arguments: {nameUuid}
552 bbf2df83 Andreas Kohlbecker
 * 
553
 * returns a set of type designation which are assigned to the name given
554
 * as parameter. The Set may contain {@link NameTypeDesignationSTO}
555
 * and {@link SpecimenTypeDesignationSTO}
556 6ee322a7 Andreas Kohlbecker
 */
557 1e687365 Andreas Kohlbecker
define('CDM_WS_TYPE_DESIGNATIONS', 'types');
558 32a96ee6 Andreas Kohlbecker
559 6ee322a7 Andreas Kohlbecker
/**
560
 * Web Service Arguments: {taxonUuid}
561 bbf2df83 Andreas Kohlbecker
 * 
562
 * returns the taxon which is the accepted synonym for the taxon given as
563
 * parameter taxonUuid. If the taxon specified by taxonUuid is itself the
564
 * accepted taxon, this one will be returned.
565 6ee322a7 Andreas Kohlbecker
 */
566 81df545f Andreas Kohlbecker
define('CDM_WS_ACCEPTED_TAXON', 'simple/taxon/acceptedfor');
567 bd6b2769 Andreas Kohlbecker
568 6ee322a7 Andreas Kohlbecker
/**
569 bbf2df83 Andreas Kohlbecker
 * Web Service Arguments: {secUuid}
570
 * 
571
 * Gets the root nodes of the taxonomic concept tree for the concept
572
 * reference specified by the secUuid parameter.
573 a22e3f38 Andreas Kohlbecker
 * 
574
 * stub: treenode_root
575 6ee322a7 Andreas Kohlbecker
 */
576 a22e3f38 Andreas Kohlbecker
define('CDM_WS_TREENODE_ROOT', 'taxonomy/root');
577 bd6b2769 Andreas Kohlbecker
578
/**
579 6ee322a7 Andreas Kohlbecker
 * Web Service Arguments: {taxonUuid}
580
 * 
581 bbf2df83 Andreas Kohlbecker
 * Searches the concept taxon tree for all parent taxa by walking the tree
582
 * from the taxon which is referenced by the parameter taxonUuid down to its
583
 * root. The reference taxon will also be included into the returned set of
584
 * TreeNode instances.
585 a22e3f38 Andreas Kohlbecker
 * 
586
 * stub: treenode_parents
587 bd6b2769 Andreas Kohlbecker
 */
588 a22e3f38 Andreas Kohlbecker
define('CDM_WS_TREENODE_PARENTS', 'taxonomy/parents');
589 7ae0186f Andreas Kohlbecker
590 6ee322a7 Andreas Kohlbecker
/**
591
 * Web Service Arguments: {taxonUuid}
592 bbf2df83 Andreas Kohlbecker
 * 
593
 * returns the children of the taxon referenced by the parameter
594
 * taxonUuid.
595 a22e3f38 Andreas Kohlbecker
 * 
596
 * stub: treenode_children
597 6ee322a7 Andreas Kohlbecker
 */
598 a22e3f38 Andreas Kohlbecker
define('CDM_WS_TREENODE_CHILDREN', 'taxonomy/children');
599 ee99abea Andreas Kohlbecker