1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Soluble\Jasper\Proxy\V6; |
6
|
|
|
|
7
|
|
|
use Soluble\Jasper\Exception; |
8
|
|
|
use Soluble\Jasper\Proxy\RemoteJavaObjectProxyInterface; |
9
|
|
|
use Soluble\Japha\Bridge\Adapter as BridgeAdapter; |
10
|
|
|
use Soluble\Japha\Interfaces\JavaObject; |
11
|
|
|
use Soluble\Japha\Bridge\Exception\JavaException; |
12
|
|
|
|
13
|
|
|
class JasperCompileManager implements RemoteJavaObjectProxyInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var BridgeAdapter |
17
|
|
|
*/ |
18
|
|
|
protected $ba; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var \Soluble\Japha\Interfaces\JavaClass |
22
|
|
|
*/ |
23
|
|
|
protected $compileManager; |
24
|
|
|
|
25
|
5 |
|
public function __construct(BridgeAdapter $bridgeAdapter) |
26
|
|
|
{ |
27
|
5 |
|
$this->ba = $bridgeAdapter; |
28
|
5 |
|
$this->compileManager = $this->ba->javaClass('net.sf.jasperreports.engine.JasperCompileManager'); |
29
|
5 |
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Compile the jrxml report file in a blazing fast representation. |
33
|
|
|
* |
34
|
|
|
* @param string $reportFile |
35
|
|
|
* |
36
|
|
|
* @return JavaObject Java('net.sf.jasperreports.engine.JasperReport') |
37
|
|
|
* |
38
|
|
|
* @throws Exception\BrokenXMLReportFileException |
39
|
|
|
* @throws Exception\ReportFileNotFoundException |
40
|
|
|
* @throws JavaException |
41
|
|
|
*/ |
42
|
5 |
|
public function compileReport(string $reportFile): JavaObject |
43
|
|
|
{ |
44
|
5 |
|
$compiledReport = null; |
45
|
|
|
|
46
|
|
|
try { |
47
|
5 |
|
$compiledReport = $this->compileManager->compileReport($reportFile); |
48
|
2 |
|
} catch (JavaException $e) { |
|
|
|
|
49
|
2 |
|
$className = $e->getJavaClassName(); |
50
|
|
|
switch ($className) { |
51
|
2 |
|
case 'net.sf.jasperreports.engine.JRException': |
52
|
2 |
|
$cause = $e->getCause(); |
53
|
2 |
|
if (strpos($cause, 'java.io.FileNotFoundException') !== false) { |
54
|
1 |
|
$msg = (file_exists($reportFile)) ? |
55
|
|
|
'Report file "%s" exists but cannot be located from the java (servlet) side.' |
56
|
|
|
: |
57
|
1 |
|
'Report file "%s" cannot be found'; |
58
|
1 |
|
throw new Exception\ReportFileNotFoundException(sprintf( |
59
|
1 |
|
$msg, |
60
|
1 |
|
$reportFile |
61
|
|
|
)); |
62
|
1 |
|
} elseif (strpos($cause, 'org.xml.sax.SAXParseException') !== false) { |
63
|
1 |
|
throw new Exception\BrokenXMLReportFileException(sprintf( |
64
|
1 |
|
'The report file "%s" cannot be parsed. (XML error cause: %s)', |
65
|
1 |
|
$reportFile, |
66
|
1 |
|
$cause |
67
|
|
|
)); |
68
|
|
|
} else { |
69
|
|
|
throw $e; |
70
|
|
|
} |
71
|
|
|
break; |
|
|
|
|
72
|
|
|
default: |
73
|
|
|
throw $e; |
74
|
|
|
} |
75
|
|
|
} catch (\Exception $e) { |
76
|
|
|
throw new Exception\RuntimeException($e->getMessage()); |
77
|
|
|
} |
78
|
|
|
|
79
|
3 |
|
return $compiledReport; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getJavaProxiedObject(): JavaObject |
83
|
|
|
{ |
84
|
|
|
return $this->compileManager; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.