From 3141251d387fb896817745f6a0e78c7c9dda529e Mon Sep 17 00:00:00 2001 From: rsteffen Date: Thu, 3 Dec 2020 15:22:57 +0100 Subject: [PATCH 1/3] fixes malformed urls in metadata when journal context is null --- filter/DNBXmlFilter.inc.php | 9 +++++---- scheduledTasks.xml | 4 +--- templates/settingsForm.tpl | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/filter/DNBXmlFilter.inc.php b/filter/DNBXmlFilter.inc.php index e550830..9309b7a 100644 --- a/filter/DNBXmlFilter.inc.php +++ b/filter/DNBXmlFilter.inc.php @@ -17,6 +17,7 @@ import('lib.pkp.plugins.importexport.native.filter.NativeExportFilter'); define('XML_NON_VALID_CHARCTERS', 100); define('URN_SET', 101); +define('MESSAGE_URN_SET','An URN has been set.'); // @RS refine class DNBXmlFilter extends NativeExportFilter { /** @@ -79,7 +80,7 @@ function &process(&$pubObject) { } // abort export in case any URN is set, this is a special case that has to be discussed with DNB and implmented differently in each case - $articleURN = $article->getStoredPubId('other::urnDNB'); + $articleURN = $article->getStoredPubId('other::urnDNB'); if (empty($articleURN)) $articleURN = $article->getStoredPubId('other::urn'); if (!empty($articleURN)) { throw new ErrorException(MESSAGE_URN_SET, URN_SET); @@ -217,7 +218,7 @@ function &process(&$pubObject) { $abstract = mb_substr($abstract, 0, 996,"UTF-8"); $abstract .= '...'; } - $abstractURL = $request->url(null, 'article', 'view', array($article->getId())); + $abstractURL = $request->url($journal->getPath(), 'article', 'view', array($article->getId())); $datafield520 = $this->createDatafieldNode($doc, $recordNode, '520', '3', ' '); $this->createSubfieldNode($doc, $datafield520, 'a', $abstract); $this->createSubfieldNode($doc, $datafield520, 'u', $abstractURL); @@ -230,7 +231,7 @@ function &process(&$pubObject) { if (empty($copyrightNotice)) $copyrightNotice = $journal->getSetting('copyrightNotice', $journal->getPrimaryLocale()); if (!empty($copyrightNotice)) { // link to the article view page where the copyright notice can be found - $licenseURL = $request->url(null, 'article', 'view', array($article->getId())); + $licenseURL = $request->url($journal->getPath(), 'article', 'view', array($article->getId())); } } if (!empty($licenseURL)) { @@ -279,7 +280,7 @@ function &process(&$pubObject) { $journalDatafield773 = $this->createDatafieldNode($doc, $recordNode, '773', '1', '8'); $this->createSubfieldNode($doc, $journalDatafield773, 'x', $issn); // file data - $galleyURL = $request->url(null, 'article', 'view', array($article->getId(), $galley->getId())); + $galleyURL = $request->url($journal->getPath(), 'article', 'view', array($article->getId(), $galley->getId())); $datafield856 = $this->createDatafieldNode($doc, $recordNode, '856', '4', ' '); $this->createSubfieldNode($doc, $datafield856, 'u', $galleyURL); $this->createSubfieldNode($doc, $datafield856, 'q', $this->_getGalleyFileType($galley)); diff --git a/scheduledTasks.xml b/scheduledTasks.xml index 5a6e8c1..ff1dc2f 100644 --- a/scheduledTasks.xml +++ b/scheduledTasks.xml @@ -17,10 +17,8 @@ - ---> diff --git a/templates/settingsForm.tpl b/templates/settingsForm.tpl index da8c435..365898f 100644 --- a/templates/settingsForm.tpl +++ b/templates/settingsForm.tpl @@ -36,10 +36,10 @@ {fbvElement type="text" id="folderId" value=$folderId label="plugins.importexport.dnb.settings.form.folderId" maxlength="50" size=$fbvStyles.size.MEDIUM} {translate key="plugins.importexport.dnb.settings.form.folderId.description"}
{/fbvFormSection} -{** {fbvFormSection list="true"} -* {fbvElement type="checkbox" id="automaticDeposit" label="plugins.importexport.dnb.settings.form.automaticDeposit.description" checked=$automaticDeposit|compare:true} -* {/fbvFormSection} - *} + {fbvFormSection list="true"} + {fbvElement type="checkbox" id="automaticDeposit" label="plugins.importexport.dnb.settings.form.automaticDeposit.description" checked=$automaticDeposit|compare:true} + {/fbvFormSection} + {/fbvFormArea} {fbvFormButtons submitText="common.save"} From 01f4ca6621baf3f46d930aeb4d2698283a618171 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 3 Dec 2020 13:54:25 +0000 Subject: [PATCH 2/3] - added missing locales - added sftp debug mode --- DNBExportPlugin.inc.php | 21 ++++++++++++++++----- locale/de_DE/locale.xml | 7 +++++-- locale/en_US/locale.xml | 4 +++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/DNBExportPlugin.inc.php b/DNBExportPlugin.inc.php index 78a9209..9794e90 100644 --- a/DNBExportPlugin.inc.php +++ b/DNBExportPlugin.inc.php @@ -17,12 +17,22 @@ import('classes.plugins.PubObjectsExportPlugin'); import('lib.pkp.classes.file.FileManager'); +define('DEBUG', true); + define('DNB_STATUS_DEPOSITED', 'deposited'); # determines whether to export remote galleys (experimental feature) define('EXPORT_REMOTE_GALLEYS', false); define('ALLOWED_REMOTE_IP_PATTERN','/160.45./');//@RS implement IP pattern as setting define('ADDITIONAL_PACKAGE_OPTIONS','');//use --format=gnu with tar to avoid PAX-Headers +if (!DEBUG) { + define('SFTP_SERVER','sftp://@hotfolder.dnb.de/'); + define('SFTP_PORT', 22122); +} else { + define('SFTP_SERVER','sftp://ojs@sftp/'); + define('SFTP_PORT', 22); +} + class DNBExportPlugin extends PubObjectsExportPlugin { /** * Constructor @@ -179,8 +189,8 @@ function depositXML($object, $context, $filename) { $folderId = ltrim($folderId, '/'); $folderId = rtrim($folderId, '/'); - curl_setopt($curlCh, CURLOPT_URL, 'sftp://@hotfolder.dnb.de/'.$folderId.'/'.basename($filename)); - curl_setopt($curlCh, CURLOPT_PORT, 22122); + curl_setopt($curlCh, CURLOPT_URL, SFTP_SERVER.$folderId.'/'.basename($filename)); + curl_setopt($curlCh, CURLOPT_PORT, SFTP_PORT); curl_setopt($curlCh, CURLOPT_USERPWD, "$username:$password"); curl_setopt($curlCh, CURLOPT_INFILESIZE, filesize($filename)); curl_setopt($curlCh, CURLOPT_INFILE, $fh); @@ -466,14 +476,15 @@ function copyGalleyFile($galley, $exportPath) { $submissionFile = $galley->getFile(); $sourceGalleyFilePath = $submissionFile->getFilePath(); $targetGalleyFilePath = $exportPath . 'content' . '/' . $submissionFile->getServerFileName(); - } + } if (!file_exists($sourceGalleyFilePath)) { - return array('plugins.importexport.dnb.export.error.galleyFileNotFound', $sourceGalleyFilePath); + return array('plugins.importexport.dnb.export.error.galleyFileNotFound',$sourceGalleyFilePath); } $fileManager = new FileManager(); if (!$fileManager->copyFile($sourceGalleyFilePath, $targetGalleyFilePath)) { - return array('plugins.importexport.dnb.export.error.galleyFileNoCopy'); + $param = __('plugins.importexport.dnb.export.error.galleyFileNoCopy', array('sourceGalleyFilePath' => $sourceGalleyFilePath, 'targetGalleyFilePath' => $targetGalleyFilePath)); + return array('plugins.importexport.dnb.export.error.galleyFileNoCopy', $param); } //remove temporary file if (!empty($temporaryFilename)) $fileManager->rmtree($temporaryFilename); diff --git a/locale/de_DE/locale.xml b/locale/de_DE/locale.xml index 2f971f5..bd2d780 100644 --- a/locale/de_DE/locale.xml +++ b/locale/de_DE/locale.xml @@ -56,13 +56,16 @@ Die XML-Datei mit der Einreichungs-ID {$param} Es wurden keine Artikel exportiert! {$submissionId} konnte nicht erstellt werden. Ein Feld enthält enhält Zeichen die in der XML 1.0 Spezifikation nicht erlaubt sind: "{$node}". Die Ausgabedatei {$param} ist nicht schreibbar. - You have to select at least one object for export. + Sie müssen mindestens ein Objekt für den Export auswählen. Das Hochladen per SFTP ist fehlgeschlagen: {$param}. - für die Paketdatei {$package} des Artikels {$articleId}: {$error} + Die Paketdatei {$package} des Artikels {$articleId} konnte nicht hochgeladen werden. Fehler: {$error} Bei der Ausführung von curl ist ein Fehler aufgetreten: {$param}. Export abgebrochen! Der entfernte Server meldet den nicht akzeptierten Inhaltstyp: {$param}. Export aller Artikel abgebrochen! Mime type der Galley mit der ID {$param} nicht akzeptiert. Export abgebrochen! Das DNB Export Plugin exportiert keine Artikel mit URNs auf Artikelebene. Bitte wenden Sie sich an die Deutsche Nationalbibliothek für mehr Informaitonen. + Die Fahnendatei {$param} konnte nicht gefunden werden. + Die Fahnendatei {$param} kopiert werden. + {$sourceGalleyFilePath} konnte nicht nach {$targetGalleyFilePath} DNB automatic deposit task diff --git a/locale/en_US/locale.xml b/locale/en_US/locale.xml index 83766fd..b769b36 100644 --- a/locale/en_US/locale.xml +++ b/locale/en_US/locale.xml @@ -63,7 +63,9 @@ Remote server reported invalid content type: {$param}. No articles exported! Mime type of remote galley file with ID {$param} not valid. No articles exported! The DNB Export Plugin does not export articles with URNs for article objects. Please contact the Deutsche Nationalbibliothek for more information. - + The galley file {$param} could not be found. + The galley file {$param}. + {$sourceGalleyFilePath} could not be copied to {$targetGalleyFilePath} DNB automatic deposit task From 51042eab98a3009c378b211ae451f17c20f090f4 Mon Sep 17 00:00:00 2001 From: ronste Date: Fri, 15 Jan 2021 14:09:26 +0000 Subject: [PATCH 3/3] Readme and version updated for release of plugin version 1.3.2 for OJS 3.1.2 --- DNBExportPlugin.inc.php | 24 +++++++++++++----------- README | 6 ++---- README_DE | 10 ++++------ scheduledTasks.xml | 2 +- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/DNBExportPlugin.inc.php b/DNBExportPlugin.inc.php index 9794e90..321aa44 100644 --- a/DNBExportPlugin.inc.php +++ b/DNBExportPlugin.inc.php @@ -17,12 +17,12 @@ import('classes.plugins.PubObjectsExportPlugin'); import('lib.pkp.classes.file.FileManager'); -define('DEBUG', true); +define('DEBUG', false); define('DNB_STATUS_DEPOSITED', 'deposited'); # determines whether to export remote galleys (experimental feature) define('EXPORT_REMOTE_GALLEYS', false); -define('ALLOWED_REMOTE_IP_PATTERN','/160.45./');//@RS implement IP pattern as setting +define('ALLOWED_REMOTE_IP_PATTERN','/160.45./');//TODO @RS implement IP pattern as setting define('ADDITIONAL_PACKAGE_OPTIONS','');//use --format=gnu with tar to avoid PAX-Headers if (!DEBUG) { @@ -66,15 +66,17 @@ function getDescription() { * @copydoc ImportExportPlugin::display() */ function display($args, $request) { - - if (($args[0] == 'exportSubmissions') & empty((array) $request->getUserVar('selectedSubmissions'))) { - //show error - $this->errorNotification($request, array(array('plugins.importexport.dnb.deposit.error.noObjectsSelected'))); - // redirect back to exportSubmissions-tab - $path = array('plugin', $this->getName()); - $request->redirect(null, null, null, $path, null, 'exportSubmissions-tab'); - return; - } + + if (!empty($args)) { + if (($args[0] == 'exportSubmissions') & empty((array) $request->getUserVar('selectedSubmissions'))) { + //show error + $this->errorNotification($request, array(array('plugins.importexport.dnb.deposit.error.noObjectsSelected'))); + // redirect back to exportSubmissions-tab + $path = array('plugin', $this->getName()); + $request->redirect(null, null, null, $path, null, 'exportSubmissions-tab'); + return; + } + } parent::display($args, $request); diff --git a/README b/README index 82bea1f..c673216 100644 --- a/README +++ b/README @@ -1,12 +1,10 @@ ============================================================= === OJS DNB Export Plugin -=== Version: 1.3.1.1 +=== Version: 1.3.2 === Author: Bozana Bokan, Ronald Steffen -=== Last update: September 14, 2020 +=== Last update: January 15, 2021 ============================================================= -Attention: Please do not use automatic deposit until next official release. - About ----- This plugin provides the export of article metadata and full texts (in PDF and EPUB format) for their transfer to the German National Library (DNB) diff --git a/README_DE b/README_DE index 6c40d27..eb8872a 100644 --- a/README_DE +++ b/README_DE @@ -1,13 +1,11 @@ ============================================================= === OJS DNB-Export-Plug-In -=== Version: 1.3.1.1 +=== Version: 1.3.2 === Autor: Bozana Bokan, Ronald Steffen -=== Letzte Ãnderung: 14. September 2020 +=== Letzte Änderung: 15. Januar 2021 ============================================================= -Achtung: Bitte benutzen Sie bis zur Veröffentlichung einer neuen Plugin-Version nicht die automatische Ablieferung an die DNB. - -Über +Ãœber ----- Dieses Plug-In ermöglicht den Export von Artikel-Metadaten und -Volltexten (im PDF- und EPUB-Format) zwecks ihrer Pflichtablieferung an die Deutsche Nationalbibliothek (DNB) mittels DNB-Hotfolder-Verfahren. Das Plug-In bietet auch die Option, das Transferpaket direkt in den DNB-Hotfolder abzuliefern. @@ -21,7 +19,7 @@ Das Plug-In ist unter GNU General Public License v2 lizenziert. Sehen Sie die Da Systemanforderungen ------------------- Dieses Plug-In ist kompatibel mit... - - OJS 3.1.1 + - OJS 3.1.1, 3.1.2 TAR-Programm wird benötigt und es muss in der Datei config.inc.php konfiguriert werden. diff --git a/scheduledTasks.xml b/scheduledTasks.xml index ff1dc2f..068d577 100644 --- a/scheduledTasks.xml +++ b/scheduledTasks.xml @@ -19,6 +19,6 @@ Deposit article packages to DNB Hotfolder. - +