-
Notifications
You must be signed in to change notification settings - Fork 2
/
ValidatorWrapper.php
126 lines (93 loc) · 3.38 KB
/
ValidatorWrapper.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
<?php
class ValidatorWrapper
{
private $VALIDATION_INCOMPLETE = 2;
private $VALIDATION_COMPLETE_FAIL = 1;
private $VALIDATION_COMPLETE_PASS = 0;
private $uri;
private $state;
private $analyzer_error;
public function __construct($inURI)
{
global $wsi_install_path;
$this->uri = $inURI;
$this->state = -1;
$this->analyzer_error = '';
putenv('JAVA_HOME=/Library/Java/Home');
putenv('WSI_HOME=' . $wsi_install_path. '/wsi-test-tools');
putenv('XMLBEANS_HOME=' . $wsi_install_path . '/xmlbeans-2.4.0');
putenv('PATH=' . getenv('PATH') . ':' . getenv('XMLBEANS_HOME') . '/bin');
putenv('CLASSPATH=' . getenv('XMLBEANS_HOME') . '/lib/xbean.jar:' . getenv('XMLBEANS_HOME') . '/lib/samp');
}
public function execute()
{
global $wsi_install_path;
$validation_output;
exec('java -classpath '. $wsi_install_path . '/net/embraceregistry/wsianalyzer/ -jar ' . $wsi_install_path . '/net/embraceregistry/wsianalyzer/runanalyzer.jar ' . $this->uri, $validation_output);
if($validation_output[count($validation_output) - 1] == '1')
{
$this->state = $this->VALIDATION_COMPLETE_FAIL;
$this->analyzer_error = implode("\n", $validation_output);
return $this->state;
}
else
{
$this->state = $this->VALIDATION_COMPLETE_PASS;
return $this->state;
}
}
public function getMessages()
{
global $wsi_install_path;
$error_output;
exec('java -classpath '. $wsi_install_path . '/net/embraceregistry/wsianalyzer/ -jar ' . $wsi_install_path . '/net/embraceregistry/wsianalyzer/reportparser.jar', $error_output);
$result = trim($error_output[1]);
$returnData = array();
$returnData["result"] = $result;
$returnData["errors"] = "";
$returnData["warnings"] = "";
switch($result)
{
case 1:
$this->state = $this->VALIDATION_COMPLETE_FAIL;
$errorsec = false;
$warnsec = false;
for($i = 0; $i < count($error_output); $i++)
{
if(strstr($error_output[$i], 'ERROR'))
{
$errorsec = true;
$warnsec = false;
$i++;
}
if(strstr($error_output[$i], 'WARNING'))
{
$warnsec = true;
$errorsec = false;
$i++;
}
if($warnsec)
{
$returnData["warnings"] .= trim($error_output[$i]);
}
if($errorsec)
{
$returnData["errors"] .= trim($error_output[$i]);
}
}
break;
case 2:
$this->state = $this->VALIDATION_INCOMPLETE;
$returnData["errors"] .= $this->analyzer_error;
break;
default:
break;
}
return $returnData;
}
public function getReportPath()
{
return '';
}
}
?>