Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable31] refactor: moved version of JSignPdf to InstallService #4570

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Handler/JSignPdfHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Jeidison\JSignPDF\Sign\JSignParam;
use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Exception\LibresignException;
use OCA\Libresign\Service\Install\InstallService;
use OCP\IAppConfig;
use Psr\Log\LoggerInterface;

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

public function __construct(
private IAppConfig $appConfig,
Expand Down Expand Up @@ -53,7 +53,7 @@ public function getJSignParam(): JSignParam {
)
->setIsUseJavaInstalled(empty($javaPath))
->setjSignPdfJarPath(
$this->appConfig->getValueString(Application::APP_ID, 'jsignpdf_jar_path', '/opt/jsignpdf-' . self::VERSION . '/JSignPdf.jar')
$this->appConfig->getValueString(Application::APP_ID, 'jsignpdf_jar_path', '/opt/jsignpdf-' . InstallService::JSIGNPDF_VERSION . '/JSignPdf.jar')
);
if (!empty($javaPath)) {
if (!file_exists($javaPath)) {
Expand Down
10 changes: 5 additions & 5 deletions lib/Service/Install/ConfigureCheckService.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,20 @@ public function checkJSignPdf(): array {
$jsignPdf = $this->jSignPdfHandler->getJSignPdf();
$jsignPdf->setParam($this->jSignPdfHandler->getJSignParam());
$currentVersion = $jsignPdf->getVersion();
if ($currentVersion < JSignPdfHandler::VERSION) {
if ($currentVersion < InstallService::JSIGNPDF_VERSION) {
if (!$currentVersion) {
$message = 'Necessary install the version ' . JSignPdfHandler::VERSION;
$message = 'Necessary install the version ' . InstallService::JSIGNPDF_VERSION;
} else {
$message = 'Necessary bump JSignPdf versin from ' . $currentVersion . ' to ' . JSignPdfHandler::VERSION;
$message = 'Necessary bump JSignPdf versin from ' . $currentVersion . ' to ' . InstallService::JSIGNPDF_VERSION;
}
$return[] = (new ConfigureCheckHelper())
->setErrorMessage($message)
->setResource('jsignpdf')
->setTip('Run occ libresign:install --jsignpdf');
}
if ($currentVersion > JSignPdfHandler::VERSION) {
if ($currentVersion > InstallService::JSIGNPDF_VERSION) {
$return[] = (new ConfigureCheckHelper())
->setErrorMessage('Necessary downgrade JSignPdf versin from ' . $currentVersion . ' to ' . JSignPdfHandler::VERSION)
->setErrorMessage('Necessary downgrade JSignPdf versin from ' . $currentVersion . ' to ' . InstallService::JSIGNPDF_VERSION)
->setResource('jsignpdf')
->setTip('Run occ libresign:install --jsignpdf');
}
Expand Down
10 changes: 5 additions & 5 deletions lib/Service/Install/InstallService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use OCA\Libresign\Handler\CertificateEngine\CfsslHandler;
use OCA\Libresign\Handler\CertificateEngine\Handler as CertificateEngineHandler;
use OCA\Libresign\Handler\CertificateEngine\IEngineHandler;
use OCA\Libresign\Handler\JSignPdfHandler;
use OCP\Files\AppData\IAppDataFactory;
use OCP\Files\IAppData;
use OCP\Files\IRootFolder;
Expand All @@ -43,6 +42,7 @@ class InstallService {
public const JAVA_VERSION = 'openjdk version "21.0.6" 2025-01-21 LTS';
private const JAVA_URL_PATH_NAME = '21.0.6+7';
public const PDFTK_VERSION = '3.3.3';
public const JSIGNPDF_VERSION = '2.3.0';
/**
* When update, verify the hash of all architectures
*/
Expand Down Expand Up @@ -471,19 +471,19 @@ public function installJSignPdf(?bool $async = false): void {
if (!$this->appConfig->getValueString(Application::APP_ID, 'jsignpdf_jar_path')) {
$folder = $this->getFolder($this->resource);
$extractDir = $this->getInternalPathOfFolder($folder);
$fullPath = $extractDir . '/jsignpdf-' . JSignPdfHandler::VERSION . '/JSignPdf.jar';
$fullPath = $extractDir . '/jsignpdf-' . InstallService::JSIGNPDF_VERSION . '/JSignPdf.jar';
$this->appConfig->setValueString(Application::APP_ID, 'jsignpdf_jar_path', $fullPath);
}
} else {
$folder = $this->getFolder($this->resource);
$compressedFileName = 'jsignpdf-' . JSignPdfHandler::VERSION . '.zip';
$compressedFileName = 'jsignpdf-' . InstallService::JSIGNPDF_VERSION . '.zip';
try {
$compressedFile = $folder->getFile($compressedFileName);
} catch (\Throwable $th) {
$compressedFile = $folder->newFile($compressedFileName);
}
$comporessedInternalFileName = $this->getInternalPathOfFile($compressedFile);
$url = 'https://github.com/intoolswetrust/jsignpdf/releases/download/JSignPdf_' . str_replace('.', '_', JSignPdfHandler::VERSION) . '/jsignpdf-' . JSignPdfHandler::VERSION . '.zip';
$url = 'https://github.com/intoolswetrust/jsignpdf/releases/download/JSignPdf_' . str_replace('.', '_', InstallService::JSIGNPDF_VERSION) . '/jsignpdf-' . InstallService::JSIGNPDF_VERSION . '.zip';
/** WHEN UPDATE version: generate this hash handmade and update here */
$hash = 'd239658ea50a39eb35169d8392feaffb';

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