Skip to content

Commit caf78eb

Browse files
authored
Merge pull request #4567 from LibreSign/refactor/moved-version-to-install-service
refactor: moved version of JSignPdf to InstallService
2 parents ce38f29 + 9aaa2c3 commit caf78eb

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

lib/Handler/JSignPdfHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Jeidison\JSignPDF\Sign\JSignParam;
1313
use OCA\Libresign\AppInfo\Application;
1414
use OCA\Libresign\Exception\LibresignException;
15+
use OCA\Libresign\Service\Install\InstallService;
1516
use OCP\IAppConfig;
1617
use Psr\Log\LoggerInterface;
1718

@@ -20,7 +21,6 @@ class JSignPdfHandler extends SignEngineHandler {
2021
private $jSignPdf;
2122
/** @var JSignParam */
2223
private $jSignParam;
23-
public const VERSION = '2.3.0';
2424

2525
public function __construct(
2626
private IAppConfig $appConfig,
@@ -53,7 +53,7 @@ public function getJSignParam(): JSignParam {
5353
)
5454
->setIsUseJavaInstalled(empty($javaPath))
5555
->setjSignPdfJarPath(
56-
$this->appConfig->getValueString(Application::APP_ID, 'jsignpdf_jar_path', '/opt/jsignpdf-' . self::VERSION . '/JSignPdf.jar')
56+
$this->appConfig->getValueString(Application::APP_ID, 'jsignpdf_jar_path', '/opt/jsignpdf-' . InstallService::JSIGNPDF_VERSION . '/JSignPdf.jar')
5757
);
5858
if (!empty($javaPath)) {
5959
if (!file_exists($javaPath)) {

lib/Service/Install/ConfigureCheckService.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,20 @@ public function checkJSignPdf(): array {
171171
$jsignPdf = $this->jSignPdfHandler->getJSignPdf();
172172
$jsignPdf->setParam($this->jSignPdfHandler->getJSignParam());
173173
$currentVersion = $jsignPdf->getVersion();
174-
if ($currentVersion < JSignPdfHandler::VERSION) {
174+
if ($currentVersion < InstallService::JSIGNPDF_VERSION) {
175175
if (!$currentVersion) {
176-
$message = 'Necessary install the version ' . JSignPdfHandler::VERSION;
176+
$message = 'Necessary install the version ' . InstallService::JSIGNPDF_VERSION;
177177
} else {
178-
$message = 'Necessary bump JSignPdf versin from ' . $currentVersion . ' to ' . JSignPdfHandler::VERSION;
178+
$message = 'Necessary bump JSignPdf versin from ' . $currentVersion . ' to ' . InstallService::JSIGNPDF_VERSION;
179179
}
180180
$return[] = (new ConfigureCheckHelper())
181181
->setErrorMessage($message)
182182
->setResource('jsignpdf')
183183
->setTip('Run occ libresign:install --jsignpdf');
184184
}
185-
if ($currentVersion > JSignPdfHandler::VERSION) {
185+
if ($currentVersion > InstallService::JSIGNPDF_VERSION) {
186186
$return[] = (new ConfigureCheckHelper())
187-
->setErrorMessage('Necessary downgrade JSignPdf versin from ' . $currentVersion . ' to ' . JSignPdfHandler::VERSION)
187+
->setErrorMessage('Necessary downgrade JSignPdf versin from ' . $currentVersion . ' to ' . InstallService::JSIGNPDF_VERSION)
188188
->setResource('jsignpdf')
189189
->setTip('Run occ libresign:install --jsignpdf');
190190
}

lib/Service/Install/InstallService.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use OCA\Libresign\Handler\CertificateEngine\CfsslHandler;
2121
use OCA\Libresign\Handler\CertificateEngine\Handler as CertificateEngineHandler;
2222
use OCA\Libresign\Handler\CertificateEngine\IEngineHandler;
23-
use OCA\Libresign\Handler\JSignPdfHandler;
2423
use OCP\Files\AppData\IAppDataFactory;
2524
use OCP\Files\IAppData;
2625
use OCP\Files\IRootFolder;
@@ -43,6 +42,7 @@ class InstallService {
4342
public const JAVA_VERSION = 'openjdk version "21.0.6" 2025-01-21 LTS';
4443
private const JAVA_URL_PATH_NAME = '21.0.6+7';
4544
public const PDFTK_VERSION = '3.3.3';
45+
public const JSIGNPDF_VERSION = '2.3.0';
4646
/**
4747
* When update, verify the hash of all architectures
4848
*/
@@ -471,19 +471,19 @@ public function installJSignPdf(?bool $async = false): void {
471471
if (!$this->appConfig->getValueString(Application::APP_ID, 'jsignpdf_jar_path')) {
472472
$folder = $this->getFolder($this->resource);
473473
$extractDir = $this->getInternalPathOfFolder($folder);
474-
$fullPath = $extractDir . '/jsignpdf-' . JSignPdfHandler::VERSION . '/JSignPdf.jar';
474+
$fullPath = $extractDir . '/jsignpdf-' . InstallService::JSIGNPDF_VERSION . '/JSignPdf.jar';
475475
$this->appConfig->setValueString(Application::APP_ID, 'jsignpdf_jar_path', $fullPath);
476476
}
477477
} else {
478478
$folder = $this->getFolder($this->resource);
479-
$compressedFileName = 'jsignpdf-' . JSignPdfHandler::VERSION . '.zip';
479+
$compressedFileName = 'jsignpdf-' . InstallService::JSIGNPDF_VERSION . '.zip';
480480
try {
481481
$compressedFile = $folder->getFile($compressedFileName);
482482
} catch (\Throwable $th) {
483483
$compressedFile = $folder->newFile($compressedFileName);
484484
}
485485
$comporessedInternalFileName = $this->getInternalPathOfFile($compressedFile);
486-
$url = 'https://github.com/intoolswetrust/jsignpdf/releases/download/JSignPdf_' . str_replace('.', '_', JSignPdfHandler::VERSION) . '/jsignpdf-' . JSignPdfHandler::VERSION . '.zip';
486+
$url = 'https://github.com/intoolswetrust/jsignpdf/releases/download/JSignPdf_' . str_replace('.', '_', InstallService::JSIGNPDF_VERSION) . '/jsignpdf-' . InstallService::JSIGNPDF_VERSION . '.zip';
487487
/** WHEN UPDATE version: generate this hash handmade and update here */
488488
$hash = 'd239658ea50a39eb35169d8392feaffb';
489489

@@ -493,7 +493,7 @@ public function installJSignPdf(?bool $async = false): void {
493493
$zip = new ZIP($extractDir . '/' . $compressedFileName);
494494
$zip->extract($extractDir);
495495
unlink($extractDir . '/' . $compressedFileName);
496-
$fullPath = $extractDir . '/jsignpdf-' . JSignPdfHandler::VERSION . '/JSignPdf.jar';
496+
$fullPath = $extractDir . '/jsignpdf-' . InstallService::JSIGNPDF_VERSION . '/JSignPdf.jar';
497497
$this->appConfig->setValueString(Application::APP_ID, 'jsignpdf_jar_path', $fullPath);
498498
$this->writeAppSignature();
499499
}

0 commit comments

Comments
 (0)