Skip to content

Commit

Permalink
Merge pull request #38 from horstoeko/kositvalidator
Browse files Browse the repository at this point in the history
KositValidator -> Cache downloaded versions
  • Loading branch information
horstoeko authored Apr 12, 2024
2 parents 504a43b + 30c593c commit da94b22
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/ZugferdKositValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ public function validate(): ZugferdKositValidator
*/
private function resolveBaseDirectory(): string
{
$baseDirectory = PathUtils::combinePathWithPath($this->baseDirectory, "kositvalidator");
$baseDirectorySuffix = md5($this->validatorDownloadUrl . $this->validatorScenarioDownloadUrl);

$baseDirectory = PathUtils::combinePathWithPath($this->baseDirectory, sprintf("kositvalidator-%s", $baseDirectorySuffix));

if (!is_dir($baseDirectory)) {
@mkdir($baseDirectory);
Expand Down Expand Up @@ -666,24 +668,20 @@ private function unpackRequiredFile(string $filename): bool
*/
private function performValidation(): bool
{
$jarFilename = $this->resolveAppJarFilename();
$scenarioFilename = $this->resolveAppScenarioFilename();
$fileToValidateFilename = $this->resolveFileToValidateFilename();

if (file_put_contents($fileToValidateFilename, $this->document->serializeAsXml()) === false) {
if (file_put_contents($this->resolveFileToValidateFilename(), $this->document->serializeAsXml()) === false) {
$this->addToMessageBag("Cannot create temporary file which contains the XML to validate");
return false;
}

$applicationOptions = [
'java',
'-jar',
$jarFilename,
$this->resolveAppJarFilename(),
'-r',
$this->resolveBaseDirectory(),
'-s',
$scenarioFilename,
$fileToValidateFilename
$this->resolveAppScenarioFilename(),
$this->resolveFileToValidateFilename()
];

if (!$this->runValidationApplication($applicationOptions, $this->resolveBaseDirectory())) {
Expand Down Expand Up @@ -805,6 +803,8 @@ private function runValidationApplication(array $command, string $workingdirecto
$process->run();

if (!$process->isSuccessful()) {
echo "Dir " . $this->resolveBaseDirectory();
echo "Exitcode " . $process->getExitCode();
if ($process->getExitCode() == -1) {
$this->addToMessageBag("Parsing error. The commandline arguments specified are incorrect", static::MSG_TYPE_VALIDATIONERROR);
}
Expand Down

0 comments on commit da94b22

Please sign in to comment.