-
Notifications
You must be signed in to change notification settings - Fork 9
/
datasource.remote.php
663 lines (547 loc) · 22.5 KB
/
datasource.remote.php
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
<?php
require_once TOOLKIT . '/class.datasource.php';
require_once FACE . '/interface.datasource.php';
Class RemoteDatasource extends DataSource implements iDatasource {
private static $url_result = null;
public static function getName() {
return __('Remote Datasource');
}
public static function getClass() {
return __CLASS__;
}
public function getSource() {
return self::getClass();
}
public static function getTemplate(){
return EXTENSIONS . '/remote_datasource/templates/blueprints.datasource.tpl';
}
public function settings() {
$settings = array();
$settings[self::getClass()]['namespaces'] = $this->dsParamNAMESPACES;
$settings[self::getClass()]['url'] = $this->dsParamURL;
$settings[self::getClass()]['xpath'] = isset($this->dsParamXPATH) ? $this->dsParamXPATH : '/';
$settings[self::getClass()]['cache'] = isset($this->dsParamCACHE) ? $this->dsParamCACHE : 30;
$settings[self::getClass()]['format'] = $this->dsParamFORMAT;
$settings[self::getClass()]['timeout'] = isset($this->dsParamTIMEOUT) ? $this->dsParamTIMEOUT : 6;
return $settings;
}
/*-------------------------------------------------------------------------
Utilities
-------------------------------------------------------------------------*/
/**
* Returns the source value for display in the Datasources index
*
* @param string $file
* The path to the Datasource file
* @return string
*/
public function getSourceColumn($handle) {
$datasource = DatasourceManager::create($handle, array(), false);
if(isset($datasource->dsParamURL)) {
return Widget::Anchor(str_replace('http://www.', '', $datasource->dsParamURL), $datasource->dsParamURL);
}
else {
return 'Remote Datasource';
}
}
/**
* Given a `$url` and `$timeout`, this function will use the `Gateway`
* class to determine that it is a valid URL and returns successfully
* before the `$timeout`. If it does not, an error message will be
* returned, otherwise true.
*
* @todo This function is a bit messy, could be revisited.
* @param string $url
* @param integer $timeout
* If not provided, this will default to 6 seconds
* @param boolean $fetch_URL
* Defaults to false, but when set to true, this function will use the
* `Gateway` class to attempt to validate the URL's existence and it
* returns before the `$timeout`
* @param string $format
* The format that the URL will return, either JSON or XML. Defaults
* to 'xml' which will send the appropriate ACCEPTs header.
* @return string|array
* Returns an array with the 'data' if it is a valid URL, otherwise a string
* containing an error message.
*/
public static function isValidURL($url, $timeout = 6, $format = 'xml', $fetch_URL = false) {
// Check that URL was provided
if(trim($url) == '') {
return __('This is a required field');
}
// Check to see the URL works.
else if ($fetch_URL === true) {
$gateway = new Gateway;
$gateway->init($url);
$gateway->setopt('TIMEOUT', $timeout);
// Set the approtiate Accept: headers depending on the format of the URL.
if($format == 'xml') {
$gateway->setopt('HTTPHEADER', array('Accept: text/xml, */*'));
}
else if($format == 'json') {
$gateway->setopt('HTTPHEADER', array('Accept: application/json, */*'));
}
$data = $gateway->exec();
$info = $gateway->getInfoLast();
// 28 is CURLE_OPERATION_TIMEOUTED
if($info['curl_error'] == 28) {
return __('Request timed out. %d second limit reached.', array($timeout));
}
else if($data === false || $info['http_code'] != 200) {
return __('Failed to load URL, status code %d was returned.', array($info['http_code']));
}
}
return array('data' => $data);
}
/**
* Builds the namespaces out to be saved in the Datasource file
*
* @param array $namespaces
* An associative array of where the key is the namespace prefix
* and the value is the namespace URL.
* @param string $template
* The template file, as defined by `getTemplate()`
* @return string
* The template injected with the Namespaces (if any).
*/
public static function injectNamespaces(array $namespaces, &$template) {
if(empty($namespaces)) return;
$placeholder = '<!-- NAMESPACES -->';
$string = 'public $dsParamNAMESPACES = array(' . PHP_EOL;
foreach($namespaces as $key => $val){
if(trim($val) == '') continue;
$string .= "\t\t\t'$key' => '" . addslashes($val) . "'," . PHP_EOL;
}
$string .= "\t\t);" . PHP_EOL . "\t\t" . $placeholder;
$template = str_replace($placeholder, trim($string), $template);
}
/**
* Helper function to build Cache information block
*
* @param XMLElement $wrapper
* @param Cacheable $cache
* @param string $cache_id
*/
public static function buildCacheInformation(XMLElement $wrapper, Cacheable $cache, $cache_id) {
$cachedData = $cache->check($cache_id);
if(is_array($cachedData) && !empty($cachedData) && (time() < $cachedData['expiry'])) {
$a = Widget::Anchor(__('Clear now'), SYMPHONY_URL . getCurrentPage() . 'clear_cache/');
$wrapper->appendChild(
new XMLElement('p', __('Cache expires in %d minutes. %s', array(
($cachedData['expiry'] - time()) / 60,
$a->generate(false)
)), array('class' => 'help'))
);
}
else {
$wrapper->appendChild(
new XMLElement('p', __('Cache has expired or does not exist.'), array('class' => 'help'))
);
}
}
/*-------------------------------------------------------------------------
Editor
-------------------------------------------------------------------------*/
public static function buildEditor(XMLElement $wrapper, array &$errors = array(), array $settings = null, $handle = null) {
if(!is_null($handle)) {
$cache = new Cacheable(Symphony::Database());
$cache_id = md5(
$settings[self::getClass()]['url'] .
serialize($settings[self::getClass()]['namespaces']) .
$settings[self::getClass()]['xpath'] .
$settings[self::getClass()]['format']
);
}
// If `clear_cache` is set, clear it..
if(isset($cache_id) && in_array('clear_cache', Administration::instance()->Page->getContext())) {
$cache->forceExpiry($cache_id);
Administration::instance()->Page->pageAlert(
__('Data source cache cleared at %s.', array(DateTimeObj::getTimeAgo()))
. '<a href="' . SYMPHONY_URL . '/blueprints/datasources/" accesskey="a">'
. __('View all Data sources')
. '</a>'
, Alert::SUCCESS);
}
$fieldset = new XMLElement('fieldset');
$fieldset->setAttribute('class', 'settings contextual ' . __CLASS__);
$fieldset->appendChild(new XMLElement('legend', self::getName()));
// URL
$group = new XMLElement('div');
$group->setAttribute('class', 'two columns');
$primary = new XMLElement('div', null, array('class' => 'primary column'));
$label = Widget::Label(__('URL'));
$label->appendChild(Widget::Input('fields[' . self::getClass() . '][url]', General::sanitize($settings[self::getClass()]['url']), 'text', array('placeholder' => 'http://')));
$p = new XMLElement('p',
__('Use %s syntax to specify dynamic portions of the URL.', array(
'<code>{' . __('$param') . '}</code>'
))
);
$p->setAttribute('class', 'help');
$label->appendChild($p);
if(isset($errors[self::getClass()]['url'])) {
$primary->appendChild(Widget::Error($label, $errors[self::getClass()]['url']));
}
else {
$primary->appendChild($label);
}
$group->appendChild($primary);
$secondary = new XMLElement('div', null, array('class' => 'secondary column'));
$label = Widget::Label(__('Format'));
$label->appendChild(
Widget::Select('fields[' . self::getClass() . '][format]', array(
array('xml', $settings[self::getClass()]['format'] == 'xml', 'XML'),
array('json', $settings[self::getClass()]['format'] == 'json', 'JSON')
))
);
if(isset($errors[self::getClass()]['format'])) {
$secondary->appendChild(Widget::Error($label, $errors[self::getClass()]['format']));
}
else {
$secondary->appendChild($label);
}
$group->appendChild($secondary);
$fieldset->appendChild($group);
// Namespaces
$div = new XMLElement('div');
$p = new XMLElement('p', __('Namespace Declarations'));
$p->appendChild(new XMLElement('i', __('Optional')));
$p->setAttribute('class', 'label');
$div->appendChild($p);
$ol = new XMLElement('ol');
$ol->setAttribute('class', 'filters-duplicator');
$ol->setAttribute('data-add', __('Add namespace'));
$ol->setAttribute('data-remove', __('Remove namespace'));
if(is_array($settings[self::getClass()]['namespace']) && !empty($settings[self::getClass()]['namespace'])){
$ii = 0;
foreach($settings[self::getClass()]['namespace'] as $name => $uri) {
// Namespaces get saved to the file as $name => $uri, however in
// the $_POST they are represented as $index => array. This loop
// patches the difference.
if(is_array($uri)) {
$name = $uri['name'];
$uri = $uri['uri'];
}
$li = new XMLElement('li');
$li->setAttribute('class', 'instance');
$header = new XMLElement('header');
$header->appendChild(
new XMLElement('h4', __('Namespace'))
);
$li->appendChild($header);
$group = new XMLElement('div');
$group->setAttribute('class', 'two columns');
$label = Widget::Label(__('Name'));
$label->setAttribute('class', 'column');
$label->appendChild(Widget::Input("fields[" . self::getClass() . "][namespace][$ii][name]", General::sanitize($name)));
$group->appendChild($label);
$label = Widget::Label(__('URI'));
$label->setAttribute('class', 'column');
$label->appendChild(Widget::Input("fields[" . self::getClass() . "][namespace][$ii][uri]", General::sanitize($uri)));
$group->appendChild($label);
$li->appendChild($group);
$ol->appendChild($li);
$ii++;
}
}
$li = new XMLElement('li');
$li->setAttribute('class', 'template');
$li->setAttribute('data-type', 'namespace');
$header = new XMLElement('header');
$header->appendChild(
new XMLElement('h4', __('Namespace'))
);
$li->appendChild($header);
$group = new XMLElement('div');
$group->setAttribute('class', 'two columns');
$label = Widget::Label(__('Name'));
$label->setAttribute('class', 'column');
$label->appendChild(Widget::Input('fields[' . self::getClass() . '][namespace][-1][name]'));
$group->appendChild($label);
$label = Widget::Label(__('URI'));
$label->setAttribute('class', 'column');
$label->appendChild(Widget::Input('fields[' . self::getClass() . '][namespace][-1][uri]'));
$group->appendChild($label);
$li->appendChild($group);
$ol->appendChild($li);
$div->appendChild($ol);
$div->appendChild(
new XMLElement('p', __('Namespaces will automatically be discovered when saving this datasource if it does not include any dynamic portions.'), array('class' => 'help'))
);
$fieldset->appendChild($div);
// Included Elements
$label = Widget::Label(__('Included Elements'));
$label->appendChild(Widget::Input('fields[' . self::getClass() . '][xpath]', General::sanitize($settings[self::getClass()]['xpath'])));
if(isset($errors[self::getClass()]['xpath'])) $fieldset->appendChild(Widget::Error($label, $errors[self::getClass()]['xpath']));
else $fieldset->appendChild($label);
$p = new XMLElement('p', __('Use an XPath expression to select which elements from the source XML to include.'));
$p->setAttribute('class', 'help');
$fieldset->appendChild($p);
// Caching
$label = Widget::Label();
$input = Widget::Input('fields[' . self::getClass() . '][cache]', (string)max(1, intval($settings[self::getClass()]['cache'])), NULL, array('size' => '6'));
$label->setValue(__('Update cached result every %s minutes', array($input->generate(false))));
if(isset($errors[self::getClass()]['cache'])) $fieldset->appendChild(Widget::Error($label, $errors[self::getClass()]['cache']));
else $fieldset->appendChild($label);
// Check for existing Cache objects
if(isset($cache_id)) {
self::buildCacheInformation($fieldset, $cache, $cache_id);
}
// Timeout
$label = Widget::Label();
$input = Widget::Input('fields[' . self::getClass() . '][timeout]', (string)max(1, intval($settings[self::getClass()]['timeout'])), NULL, array('type' => 'hidden'));
$label->appendChild($input);
$fieldset->appendChild($label);
$wrapper->appendChild($fieldset);
}
public static function validate(array &$settings, array &$errors) {
// Use the TIMEOUT that was specified by the user for a real world indication
$timeout = isset($settings[self::getClass()]['timeout'])
? (int)$settings[self::getClass()]['timeout']
: 6;
if(trim($settings[self::getClass()]['url']) == '') {
$errors[self::getClass()]['url'] = __('This is a required field');
}
// If there is a parameter in the URL, we can't validate the existence of the URL
// as we don't have the environment details of where this datasource is going
// to be executed.
else if(!preg_match('@{([^}]+)}@i', $settings[self::getClass()]['url'])) {
$valid_url = self::isValidURL($settings[self::getClass()]['url'], $timeout, $settings[self::getClass()]['format'], true);
// If url was valid, `isValidURL` will return an array of data
if(is_array($valid_url)) {
self::$url_result = $valid_url['data'];
}
// Otherwise it'll return a string, which is an error
else {
$errors[self::getClass()]['url'] = $valid_url;
}
}
if(trim($settings[self::getClass()]['xpath']) == '') {
$errors[self::getClass()]['xpath'] = __('This is a required field');
}
if(!is_numeric($settings[self::getClass()]['cache'])) {
$errors[self::getClass()]['cache'] = __('Must be a valid number');
}
else if($settings[self::getClass()]['cache'] < 1) {
$errors[self::getClass()]['cache'] = __('Must be greater than zero');
}
return empty($errors[self::getClass()]);
}
public static function prepare(array $settings, array $params, $template) {
$settings = $settings[self::getClass()];
// Automatically detect namespaces
if(!is_null(self::$url_result)) {
preg_match_all('/xmlns:([a-z][a-z-0-9\-]*)="([^\"]+)"/i', self::$url_result, $matches);
if(!is_array($settings['namespace'])) {
$settings['namespace'] = array();
}
if (isset($matches[2][0])) {
$detected_namespaces = array();
foreach ($settings['namespace'] as $index => $namespace) {
$detected_namespaces[] = $namespace['name'];
$detected_namespaces[] = $namespace['uri'];
}
foreach ($matches[2] as $index => $uri) {
$name = $matches[1][$index];
if (in_array($name, $detected_namespaces) or in_array($uri, $detected_namespaces)) continue;
$detected_namespaces[] = $name;
$detected_namespaces[] = $uri;
$settings['namespace'][] = array(
'name' => $name,
'uri' => $uri
);
}
}
}
$namespaces = array();
if(is_array($settings['namespace'])) {
foreach($settings['namespace'] as $index => $data) {
$namespaces[$data['name']] = $data['uri'];
}
}
self::injectNamespaces($namespaces, $template);
$timeout = isset($settings['timeout'])
? (int)$settings['timeout']
: 6;
return sprintf($template,
$params['rootelement'], // rootelement
$settings['url'], // url
$settings['format'], // format
$settings['xpath'], // xpath
$settings['cache'], // cache
$timeout// timeout
);
}
/*-------------------------------------------------------------------------
Execution
-------------------------------------------------------------------------*/
public function grab(array &$param_pool = null) {
$result = new XMLElement($this->dsParamROOTELEMENT);
try {
require_once(TOOLKIT . '/class.gateway.php');
require_once(TOOLKIT . '/class.xsltprocess.php');
require_once(CORE . '/class.cacheable.php');
$this->dsParamURL = $this->parseParamURL($this->dsParamURL);
if(isset($this->dsParamXPATH)) $this->dsParamXPATH = $this->__processParametersInString($this->dsParamXPATH, $this->_env);
if(!isset($this->dsParamFORMAT)) $this->dsParamFORMAT = 'xml';
// Builds a Default Stylesheet to transform the resulting XML with
$stylesheet = new XMLElement('xsl:stylesheet');
$stylesheet->setAttributeArray(array('version' => '1.0', 'xmlns:xsl' => 'http://www.w3.org/1999/XSL/Transform'));
$output = new XMLElement('xsl:output');
$output->setAttributeArray(array('method' => 'xml', 'version' => '1.0', 'encoding' => 'utf-8', 'indent' => 'yes', 'omit-xml-declaration' => 'yes'));
$stylesheet->appendChild($output);
$template = new XMLElement('xsl:template');
$template->setAttribute('match', '/');
$instruction = new XMLElement('xsl:copy-of');
// Namespaces
if(isset($this->dsParamNAMESPACES) && is_array($this->dsParamNAMESPACES)){
foreach($this->dsParamNAMESPACES as $name => $uri) {
$instruction->setAttribute('xmlns' . ($name ? ":{$name}" : NULL), $uri);
}
}
// XPath
$instruction->setAttribute('select', $this->dsParamXPATH);
$template->appendChild($instruction);
$stylesheet->appendChild($template);
$stylesheet->setIncludeHeader(true);
$xsl = $stylesheet->generate(true);
// Check for an existing Cache for this Datasource
$cache_id = md5($this->dsParamURL . serialize($this->dsParamNAMESPACES) . $this->dsParamXPATH . $this->dsParamFORMAT);
$cache = new Cacheable(Symphony::Database());
$cachedData = $cache->check($cache_id);
$writeToCache = false;
$valid = true;
$creation = DateTimeObj::get('c');
// Execute if the cache doesn't exist, or if it is old.
if(
(!is_array($cachedData) || empty($cachedData)) // There's no cache.
|| (time() - $cachedData['creation']) > ($this->dsParamCACHE * 60) // The cache is old.
){
if(Mutex::acquire($cache_id, $this->dsParamTIMEOUT, TMP)) {
$ch = new Gateway;
$ch->init($this->dsParamURL);
$ch->setopt('TIMEOUT', $this->dsParamTIMEOUT);
// Set the approtiate Accept: headers depending on the format of the URL.
if($this->dsParamFORMAT == 'xml') {
$ch->setopt('HTTPHEADER', array('Accept: text/xml, */*'));
}
else {
$ch->setopt('HTTPHEADER', array('Accept: application/json, */*'));
}
$data = $ch->exec();
$info = $ch->getInfoLast();
Mutex::release($cache_id, TMP);
$data = trim($data);
$writeToCache = true;
// Handle any response that is not a 200, or the content type does not include XML, JSON, plain or text
if((int)$info['http_code'] != 200 || !preg_match('/(xml|json|plain|text)/i', $info['content_type'])){
$writeToCache = false;
$result->setAttribute('valid', 'false');
// 28 is CURLE_OPERATION_TIMEOUTED
if($info['curl_error'] == 28) {
$result->appendChild(
new XMLElement('error',
sprintf('Request timed out. %d second limit reached.', $timeout)
)
);
}
else{
$result->appendChild(
new XMLElement('error',
sprintf('Status code %d was returned. Content-type: %s', $info['http_code'], $info['content_type'])
)
);
}
return $result;
}
// Handle where there is `$data`
else if(strlen($data) > 0) {
// If it's JSON, convert it to XML
if($this->dsParamFORMAT == 'json') {
try {
require_once TOOLKIT . '/class.json.php';
$data = JSON::convertToXML($data);
}
catch (Exception $ex) {
$writeToCache = false;
$errors = array(
array('message' => $ex->getMessage())
);
}
}
// If the XML doesn't validate..
else if(!General::validateXML($data, $errors, false, new XsltProcess)) {
$writeToCache = false;
}
// If the `$data` is invalid, return a result explaining why
if($writeToCache === false) {
$result = new XMLElement('errors');
$result->setAttribute('valid', 'false');
$result->appendChild(new XMLElement('error', __('Data returned is invalid.')));
foreach($errors as $e) {
if(strlen(trim($e['message'])) == 0) continue;
$result->appendChild(new XMLElement('item', General::sanitize($e['message'])));
}
$result->appendChild($result);
return $result;
}
}
// If `$data` is empty, set the `force_empty_result` to true.
else if(strlen($data) == 0){
$this->_force_empty_result = true;
}
}
// Failed to acquire a lock
else {
$result->appendChild(
new XMLElement('error', __('The %s class failed to acquire a lock.', array('<code>Mutex</code>')))
);
}
}
// The cache is good, use it!
else {
$data = trim($cachedData['data']);
$creation = DateTimeObj::get('c', $cachedData['creation']);
}
// If `$writeToCache` is set to false, invalidate the old cache if it existed.
if(is_array($cachedData) && !empty($cachedData) && $writeToCache === false) {
$data = trim($cachedData['data']);
$valid = false;
$creation = DateTimeObj::get('c', $cachedData['creation']);
if(empty($data)) $this->_force_empty_result = true;
}
// If `force_empty_result` is false and `$result` is an instance of
// XMLElement, build the `$result`.
if(!$this->_force_empty_result && is_object($result)) {
$proc = new XsltProcess;
$ret = $proc->process($data, $xsl);
if($proc->isErrors()) {
$result->setAttribute('valid', 'false');
$error = new XMLElement('error', __('Transformed XML is invalid.'));
$result->appendChild($error);
$errors = new XMLElement('errors');
foreach($proc->getError() as $e) {
if(strlen(trim($e['message'])) == 0) continue;
$errors->appendChild(new XMLElement('item', General::sanitize($e['message'])));
}
$result->appendChild($errors);
}
else if(strlen(trim($ret)) == 0) {
$this->_force_empty_result = true;
}
else {
if($writeToCache) $cache->write($cache_id, $data, $this->dsParamCACHE);
$result->setValue(PHP_EOL . str_repeat("\t", 2) . preg_replace('/([\r\n]+)/', "$1\t", $ret));
$result->setAttribute('status', ($valid === true ? 'fresh' : 'stale'));
$result->setAttribute('creation', $creation);
}
}
}
catch(Exception $e){
$result->appendChild(new XMLElement('error', $e->getMessage()));
}
if($this->_force_empty_result) $result = $this->emptyXMLSet();
return $result;
}
}
return 'RemoteDatasource';