TestGetObsDataTree_40.php
2.14 KB
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
<?php
require_once "Base/TestAbstract.php";
class TestGetObsDataTree_40 extends TestAbstract
{
public function getAPI() {
return "getObsDataTree";
}
public function getParams() {
return array();
}
public function getDescription() {
return "Provides the hierarchy of public access data in AMDA.";
}
protected function checkRESTResult($result) {
if (empty($result)) {
return array(
'success' => FALSE,
'message' => 'Empty result',
);
}
$doc = new DOMDocument();
if (!$doc->loadXML($result)) {
return array(
'success' => FALSE,
'message' => 'Result is not in XML format',
);
}
$nodes = $doc->getElementsByTagName('LocalDataBaseParameters');
if ($nodes->length == 0) {
return array(
'success' => FALSE,
'message' => 'Cannot retrieve LocalDataBaseParameters node',
);
}
$xml_url = $nodes->item(0)->nodeValue;
if (empty($xml_url)) {
return array(
'success' => FALSE,
'message' => 'Cannot retrieve XML file path',
);
}
return $this->checkObsDataTree($xml_url);
}
protected function checkSOAPResult($result) {
if (empty($result)) {
return array(
'success' => FALSE,
'message' => 'Empty result',
);
}
if (empty($result->success)) {
return array(
'success' => FALSE,
'message' => 'Error in request',
);
}
if (empty($result->WorkSpace) || empty($result->WorkSpace->LocalDataBaseParameters)) {
return array(
'success' => FALSE,
'message' => 'Cannot retrieve XML file path',
);
}
return $this->checkObsDataTree($result->WorkSpace->LocalDataBaseParameters);
}
private function checkObsDataTree($xml_path) {
$data = file_get_contents($xml_path);
if (!$data) {
return array(
'success' => FALSE,
'message' => 'Cannot load tree XML file',
);
}
$doc = new DOMDocument();
if (!@$doc->loadXML($data)) {
return array(
'success' => FALSE,
'message' => 'Local tree is not in XML format',
);
}
if ($doc->documentElement->nodeName != 'dataRoot') {
return array(
'success' => FALSE,
'message' => 'Cannot retrieve dataRoot node in tree file',
);
}
return array(
'success' => TRUE,
);
}
}
?>